src/protocols/yahoo/yahoo.c

changeset 5583
823143bef3b0
parent 5521
fca5b7c1340d
child 5590
96f84b9aae41
equal deleted inserted replaced
5582:2e5da5db947b 5583:823143bef3b0
49 49
50 #ifdef _WIN32 50 #ifdef _WIN32
51 #include "win32dep.h" 51 #include "win32dep.h"
52 #endif 52 #endif
53 53
54 extern char *yahoo_crypt(char *, char *); 54 extern char *yahoo_crypt(const char *, const char *);
55 55
56 /* for win32 compatability */ 56 /* for win32 compatability */
57 G_MODULE_IMPORT GSList *connections; 57 G_MODULE_IMPORT GSList *connections;
58 58
59 /* #define YAHOO_DEBUG */ 59 /* #define YAHOO_DEBUG */
366 pkt->hash = g_slist_remove(pkt->hash, pair); 366 pkt->hash = g_slist_remove(pkt->hash, pair);
367 } 367 }
368 g_free(pkt); 368 g_free(pkt);
369 } 369 }
370 370
371 static void yahoo_process_status(struct gaim_connection *gc, struct yahoo_packet *pkt) 371 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt)
372 { 372 {
373 struct yahoo_data *yd = gc->proto_data; 373 struct yahoo_data *yd = gc->proto_data;
374 GSList *l = pkt->hash; 374 GSList *l = pkt->hash;
375 char *name = NULL; 375 char *name = NULL;
376 int state = 0; 376 int state = 0;
383 switch (pair->key) { 383 switch (pair->key) {
384 case 0: /* we won't actually do anything with this */ 384 case 0: /* we won't actually do anything with this */
385 break; 385 break;
386 case 1: /* we don't get the full buddy list here. */ 386 case 1: /* we don't get the full buddy list here. */
387 if (!yd->logged_in) { 387 if (!yd->logged_in) {
388 account_online(gc); 388 gaim_connection_set_state(gc, GAIM_CONNECTED);
389 serv_finish_login(gc); 389 serv_finish_login(gc);
390 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", pair->value); 390 gaim_connection_set_display_name(gc, pair->value);
391 yd->logged_in = TRUE; 391 yd->logged_in = TRUE;
392 392
393 /* this requests the list. i have a feeling that this is very evil 393 /* this requests the list. i have a feeling that this is very evil
394 * 394 *
395 * scs.yahoo.com sends you the list before this packet without it being 395 * scs.yahoo.com sends you the list before this packet without it being
456 456
457 l = l->next; 457 l = l->next;
458 } 458 }
459 } 459 }
460 460
461 static void yahoo_process_list(struct gaim_connection *gc, struct yahoo_packet *pkt) 461 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt)
462 { 462 {
463 GSList *l = pkt->hash; 463 GSList *l = pkt->hash;
464 gboolean export = FALSE; 464 gboolean export = FALSE;
465 struct buddy *b; 465 struct buddy *b;
466 struct group *g; 466 struct group *g;
505 505
506 if (export) 506 if (export)
507 gaim_blist_save(); 507 gaim_blist_save();
508 } 508 }
509 509
510 static void yahoo_process_notify(struct gaim_connection *gc, struct yahoo_packet *pkt) 510 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt)
511 { 511 {
512 char *msg = NULL; 512 char *msg = NULL;
513 char *from = NULL; 513 char *from = NULL;
514 char *stat = NULL; 514 char *stat = NULL;
515 char *game = NULL; 515 char *game = NULL;
563 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc & ~YAHOO_STATUS_GAME); 563 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc & ~YAHOO_STATUS_GAME);
564 } 564 }
565 } 565 }
566 } 566 }
567 567
568 static void yahoo_process_message(struct gaim_connection *gc, struct yahoo_packet *pkt) 568 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt)
569 { 569 {
570 char *msg = NULL; 570 char *msg = NULL;
571 char *from = NULL; 571 char *from = NULL;
572 time_t tm = time(NULL); 572 time_t tm = time(NULL);
573 GSList *l = pkt->hash; 573 GSList *l = pkt->hash;
605 _("Your Yahoo! message did not get sent."), NULL); 605 _("Your Yahoo! message did not get sent."), NULL);
606 } 606 }
607 } 607 }
608 608
609 609
610 static void yahoo_process_contact(struct gaim_connection *gc, struct yahoo_packet *pkt) 610 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt)
611 { 611 {
612 struct yahoo_data *yd = gc->proto_data; 612 struct yahoo_data *yd = gc->proto_data;
613 char *id = NULL; 613 char *id = NULL;
614 char *who = NULL; 614 char *who = NULL;
615 char *msg = NULL; 615 char *msg = NULL;
656 msg ? g_strdup(msg) : g_malloc0(1)); 656 msg ? g_strdup(msg) : g_malloc0(1));
657 } 657 }
658 } 658 }
659 } 659 }
660 660
661 static void yahoo_process_mail(struct gaim_connection *gc, struct yahoo_packet *pkt) 661 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
662 { 662 {
663 GaimAccount *account = gaim_connection_get_account(gc);
663 char *who = NULL; 664 char *who = NULL;
664 char *email = NULL; 665 char *email = NULL;
665 char *subj = NULL; 666 char *subj = NULL;
666 int count = 0; 667 int count = 0;
667 GSList *l = pkt->hash; 668 GSList *l = pkt->hash;
668 669
669 if (!GAIM_ACCOUNT_CHECK_MAIL(gc->account)) 670 if (!gaim_account_get_check_mail(account))
670 return; 671 return;
671 672
672 while (l) { 673 while (l) {
673 struct yahoo_pair *pair = l->data; 674 struct yahoo_pair *pair = l->data;
674 if (pair->key == 9) 675 if (pair->key == 9)
683 } 684 }
684 685
685 if (who && subj && email && *email) { 686 if (who && subj && email && *email) {
686 char *from = g_strdup_printf("%s (%s)", who, email); 687 char *from = g_strdup_printf("%s (%s)", who, email);
687 688
688 gaim_notify_email(gc, subj, from, gc->username, 689 gaim_notify_email(gc, subj, from, gaim_account_get_username(account),
689 "http://mail.yahoo.com/", NULL, NULL); 690 "http://mail.yahoo.com/", NULL, NULL);
690 691
691 g_free(from); 692 g_free(from);
692 } else if (count > 0) { 693 } else if (count > 0) {
693 const char *to = gc->username; 694 const char *to = gaim_account_get_username(account);
694 const char *url = "http://mail.yahoo.com/"; 695 const char *url = "http://mail.yahoo.com/";
695 696
696 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, 697 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url,
697 NULL, NULL); 698 NULL, NULL);
698 } 699 }
726 *out++ = '-'; 727 *out++ = '-';
727 } 728 }
728 *out = '\0'; 729 *out = '\0';
729 } 730 }
730 731
731 static void yahoo_process_auth(struct gaim_connection *gc, struct yahoo_packet *pkt) 732 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt)
732 { 733 {
733 char *seed = NULL; 734 char *seed = NULL;
734 char *sn = NULL; 735 char *sn = NULL;
735 GSList *l = pkt->hash; 736 GSList *l = pkt->hash;
736 struct yahoo_data *yd = gc->proto_data; 737 struct yahoo_data *yd = gc->proto_data;
744 l = l->next; 745 l = l->next;
745 } 746 }
746 747
747 if (seed) { 748 if (seed) {
748 struct yahoo_packet *pack; 749 struct yahoo_packet *pack;
749 750 GaimAccount *account = gaim_connection_get_account(gc);
751 const char *name = gaim_account_get_username(account);
752 const char *pass = gaim_account_get_password(account);
753
750 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly 754 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly
751 * will soon do so in the rest of the world. 755 * will soon do so in the rest of the world.
752 * 756 *
753 * The new clients use this authentication method. I warn you in advance, it's 757 * The new clients use this authentication method. I warn you in advance, it's
754 * bizzare, convoluted, inordinately complicated. It's also no more secure than 758 * bizzare, convoluted, inordinately complicated. It's also no more secure than
758 * Sorry, Yahoo. 762 * Sorry, Yahoo.
759 */ 763 */
760 764
761 md5_byte_t result[16]; 765 md5_byte_t result[16];
762 md5_state_t ctx; 766 md5_state_t ctx;
767
763 char *crypt_result; 768 char *crypt_result;
764 char *password_hash = g_malloc(25); 769 char password_hash[25];
765 char *crypt_hash = g_malloc(25); 770 char crypt_hash[25];
766 char *hash_string_p = g_malloc(50 + strlen(sn)); 771 char *hash_string_p = g_malloc(50 + strlen(sn));
767 char *hash_string_c = g_malloc(50 + strlen(sn)); 772 char *hash_string_c = g_malloc(50 + strlen(sn));
768 773
769 char checksum; 774 char checksum;
770 775
771 int sv; 776 int sv;
772 777
773 char *result6 = g_malloc(25); 778 char result6[25];
774 char *result96 = g_malloc(25); 779 char result96[25];
775 780
776 sv = seed[15]; 781 sv = seed[15];
777 sv = sv % 8; 782 sv = sv % 8;
778 783
779 md5_init(&ctx); 784 md5_init(&ctx);
780 md5_append(&ctx, gc->password, strlen(gc->password)); 785 md5_append(&ctx, pass, strlen(pass));
781 md5_finish(&ctx, result); 786 md5_finish(&ctx, result);
782 to_y64(password_hash, result, 16); 787 to_y64(password_hash, result, 16);
783 788
784 md5_init(&ctx); 789 md5_init(&ctx);
785 crypt_result = yahoo_crypt(gc->password, "$1$_2S43d5f$"); 790 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$");
786 md5_append(&ctx, crypt_result, strlen(crypt_result)); 791 md5_append(&ctx, crypt_result, strlen(crypt_result));
787 md5_finish(&ctx, result); 792 md5_finish(&ctx, result);
788 to_y64(crypt_hash, result, 16); 793 to_y64(crypt_hash, result, 16);
789 794
790 switch (sv) { 795 switch (sv) {
791 case 1: 796 case 1:
792 case 6: 797 case 6:
793 checksum = seed[seed[9] % 16]; 798 checksum = seed[seed[9] % 16];
794 g_snprintf(hash_string_p, strlen(sn) + 50, 799 g_snprintf(hash_string_p, strlen(sn) + 50,
795 "%c%s%s%s", checksum, gc->username, seed, password_hash); 800 "%c%s%s%s", checksum, name, seed, password_hash);
796 g_snprintf(hash_string_c, strlen(sn) + 50, 801 g_snprintf(hash_string_c, strlen(sn) + 50,
797 "%c%s%s%s", checksum, gc->username, seed, crypt_hash); 802 "%c%s%s%s", checksum, name, seed, crypt_hash);
798 break; 803 break;
799 case 2: 804 case 2:
800 case 7: 805 case 7:
801 checksum = seed[seed[15] % 16]; 806 checksum = seed[seed[15] % 16];
802 g_snprintf(hash_string_p, strlen(sn) + 50, 807 g_snprintf(hash_string_p, strlen(sn) + 50,
803 "%c%s%s%s", checksum, seed, password_hash, gc->username); 808 "%c%s%s%s", checksum, seed, password_hash, name);
804 g_snprintf(hash_string_c, strlen(sn) + 50, 809 g_snprintf(hash_string_c, strlen(sn) + 50,
805 "%c%s%s%s", checksum, seed, crypt_hash, gc->username); 810 "%c%s%s%s", checksum, seed, crypt_hash, name);
806 break; 811 break;
807 case 3: 812 case 3:
808 checksum = seed[seed[1] % 16]; 813 checksum = seed[seed[1] % 16];
809 g_snprintf(hash_string_p, strlen(sn) + 50, 814 g_snprintf(hash_string_p, strlen(sn) + 50,
810 "%c%s%s%s", checksum, gc->username, password_hash, seed); 815 "%c%s%s%s", checksum, name, password_hash, seed);
811 g_snprintf(hash_string_c, strlen(sn) + 50, 816 g_snprintf(hash_string_c, strlen(sn) + 50,
812 "%c%s%s%s", checksum, gc->username, crypt_hash, seed); 817 "%c%s%s%s", checksum, name, crypt_hash, seed);
813 break; 818 break;
814 case 4: 819 case 4:
815 checksum = seed[seed[3] % 16]; 820 checksum = seed[seed[3] % 16];
816 g_snprintf(hash_string_p, strlen(sn) + 50, 821 g_snprintf(hash_string_p, strlen(sn) + 50,
817 "%c%s%s%s", checksum, password_hash, seed, gc->username); 822 "%c%s%s%s", checksum, password_hash, seed, name);
818 g_snprintf(hash_string_c, strlen(sn) + 50, 823 g_snprintf(hash_string_c, strlen(sn) + 50,
819 "%c%s%s%s", checksum, crypt_hash, seed, gc->username); 824 "%c%s%s%s", checksum, crypt_hash, seed, name);
820 break; 825 break;
821 case 0: 826 case 0:
822 case 5: 827 case 5:
823 checksum = seed[seed[7] % 16]; 828 checksum = seed[seed[7] % 16];
824 g_snprintf(hash_string_p, strlen(sn) + 50, 829 g_snprintf(hash_string_p, strlen(sn) + 50,
825 "%c%s%s%s", checksum, password_hash, gc->username, seed); 830 "%c%s%s%s", checksum, password_hash, name, seed);
826 g_snprintf(hash_string_c, strlen(sn) + 50, 831 g_snprintf(hash_string_c, strlen(sn) + 50,
827 "%c%s%s%s", checksum, crypt_hash, gc->username, seed); 832 "%c%s%s%s", checksum, crypt_hash, name, seed);
828 break; 833 break;
829 } 834 }
830 835
831 md5_init(&ctx); 836 md5_init(&ctx);
832 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); 837 md5_append(&ctx, hash_string_p, strlen(hash_string_p));
837 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); 842 md5_append(&ctx, hash_string_c, strlen(hash_string_c));
838 md5_finish(&ctx, result); 843 md5_finish(&ctx, result);
839 to_y64(result96, result, 16); 844 to_y64(result96, result, 16);
840 845
841 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); 846 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0);
842 yahoo_packet_hash(pack, 0, gc->username); 847 yahoo_packet_hash(pack, 0, name);
843 yahoo_packet_hash(pack, 6, result6); 848 yahoo_packet_hash(pack, 6, result6);
844 yahoo_packet_hash(pack, 96, result96); 849 yahoo_packet_hash(pack, 96, result96);
845 yahoo_packet_hash(pack, 1, gc->username); 850 yahoo_packet_hash(pack, 1, name);
846 851
847 yahoo_send_packet(yd, pack); 852 yahoo_send_packet(yd, pack);
848 853
849 g_free(result6);
850 g_free(result96);
851 g_free(password_hash);
852 g_free(crypt_hash);
853 g_free(hash_string_p); 854 g_free(hash_string_p);
854 g_free(hash_string_c); 855 g_free(hash_string_c);
855 856
856 yahoo_packet_free(pack); 857 yahoo_packet_free(pack);
857 } 858 }
858 } 859 }
859 860
860 static void yahoo_packet_process(struct gaim_connection *gc, struct yahoo_packet *pkt) 861 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt)
861 { 862 {
862 switch (pkt->service) 863 switch (pkt->service)
863 { 864 {
864 case YAHOO_SERVICE_LOGON: 865 case YAHOO_SERVICE_LOGON:
865 case YAHOO_SERVICE_LOGOFF: 866 case YAHOO_SERVICE_LOGOFF:
895 } 896 }
896 } 897 }
897 898
898 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) 899 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond)
899 { 900 {
900 struct gaim_connection *gc = data; 901 GaimConnection *gc = data;
901 struct yahoo_data *yd = gc->proto_data; 902 struct yahoo_data *yd = gc->proto_data;
902 char buf[1024]; 903 char buf[1024];
903 int len; 904 int len;
904 905
905 len = read(yd->fd, buf, sizeof(buf)); 906 len = read(yd->fd, buf, sizeof(buf));
906 907
907 if (len <= 0) { 908 if (len <= 0) {
908 hide_login_progress_error(gc, "Unable to read"); 909 gaim_connection_error(gc, "Unable to read");
909 signoff(gc);
910 return; 910 return;
911 } 911 }
912 912
913 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); 913 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
914 memcpy(yd->rxqueue + yd->rxlen, buf, len); 914 memcpy(yd->rxqueue + yd->rxlen, buf, len);
962 } 962 }
963 } 963 }
964 964
965 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) 965 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond)
966 { 966 {
967 struct gaim_connection *gc = data; 967 GaimConnection *gc = data;
968 struct yahoo_data *yd; 968 struct yahoo_data *yd;
969 struct yahoo_packet *pkt; 969 struct yahoo_packet *pkt;
970 970
971 if (!g_slist_find(connections, gc)) { 971 if (!g_slist_find(connections, gc)) {
972 close(source); 972 close(source);
973 return; 973 return;
974 } 974 }
975 975
976 if (source < 0) { 976 if (source < 0) {
977 hide_login_progress(gc, "Unable to connect"); 977 gaim_connection_error(gc, "Unable to connect");
978 signoff(gc);
979 return; 978 return;
980 } 979 }
981 980
982 yd = gc->proto_data; 981 yd = gc->proto_data;
983 yd->fd = source; 982 yd->fd = source;
984 983
985 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); 984 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0);
986 985
987 yahoo_packet_hash(pkt, 1, gc->username); 986 yahoo_packet_hash(pkt, 1, gaim_account_get_username(gaim_connection_get_account(gc)));
988 yahoo_send_packet(yd, pkt); 987 yahoo_send_packet(yd, pkt);
989 988
990 yahoo_packet_free(pkt); 989 yahoo_packet_free(pkt);
991 990
992 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); 991 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc);
993 } 992 }
994 993
995 static void yahoo_login(struct gaim_account *account) { 994 static void yahoo_login(GaimAccount *account) {
996 struct gaim_connection *gc = new_gaim_conn(account); 995 GaimConnection *gc = gaim_account_get_connection(account);
997 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); 996 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
998 997
999 set_login_progress(gc, 1, _("Connecting")); 998 gaim_connection_update_progress(gc, _("Connecting"), 1, 2);
1000 999
1001 yd->fd = -1; 1000 yd->fd = -1;
1002 yd->hash = g_hash_table_new(g_str_hash, g_str_equal); 1001 yd->hash = g_hash_table_new(g_str_hash, g_str_equal);
1003 yd->games = g_hash_table_new(g_str_hash, g_str_equal); 1002 yd->games = g_hash_table_new(g_str_hash, g_str_equal);
1004 1003
1005 1004 if (proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST),
1006 if (!g_ascii_strncasecmp(account->proto_opt[USEROPT_PAGERHOST], "cs.yahoo.com", strlen("cs.yahoo.com"))) { 1005 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
1007 /* Figured out the new auth method -- cs.yahoo.com likes to disconnect on buddy remove and add now */ 1006 yahoo_got_connected, gc) != 0) {
1008 gaim_debug(GAIM_DEBUG_INFO, "yahoo", 1007 gaim_connection_error(gc, "Connection problem");
1009 "Setting new Yahoo! server.\n");
1010 g_snprintf(account->proto_opt[USEROPT_PAGERHOST],
1011 strlen("scs.yahoo.com") + 1, "scs.yahoo.com");
1012 save_prefs();
1013 }
1014
1015
1016 if (proxy_connect(account, account->proto_opt[USEROPT_PAGERHOST][0] ?
1017 account->proto_opt[USEROPT_PAGERHOST] : YAHOO_PAGER_HOST,
1018 account->proto_opt[USEROPT_PAGERPORT][0] ?
1019 atoi(account->proto_opt[USEROPT_PAGERPORT]) : YAHOO_PAGER_PORT,
1020 yahoo_got_connected, gc) != 0) {
1021 hide_login_progress(gc, "Connection problem");
1022 signoff(gc);
1023 return; 1008 return;
1024 } 1009 }
1025 1010
1026 } 1011 }
1027 1012
1030 g_free(key); 1015 g_free(key);
1031 g_free(val); 1016 g_free(val);
1032 return TRUE; 1017 return TRUE;
1033 } 1018 }
1034 1019
1035 static void yahoo_close(struct gaim_connection *gc) { 1020 static void yahoo_close(GaimConnection *gc) {
1036 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 1021 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
1037 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); 1022 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL);
1038 g_hash_table_destroy(yd->hash); 1023 g_hash_table_destroy(yd->hash);
1039 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL); 1024 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL);
1040 g_hash_table_destroy(yd->games); 1025 g_hash_table_destroy(yd->games);
1047 if (gc->inpa) 1032 if (gc->inpa)
1048 gaim_input_remove(gc->inpa); 1033 gaim_input_remove(gc->inpa);
1049 g_free(yd); 1034 g_free(yd);
1050 } 1035 }
1051 1036
1052 static const char *yahoo_list_icon(struct gaim_account *a, struct buddy *b) 1037 static const char *yahoo_list_icon(GaimAccount *a, struct buddy *b)
1053 { 1038 {
1054 return "yahoo"; 1039 return "yahoo";
1055 } 1040 }
1056 1041
1057 static void yahoo_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) 1042 static void yahoo_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne)
1101 default: 1086 default:
1102 return _("Online"); 1087 return _("Online");
1103 } 1088 }
1104 } 1089 }
1105 1090
1106 static void yahoo_game(struct gaim_connection *gc, const char *name) { 1091 static void yahoo_game(GaimConnection *gc, const char *name) {
1107 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 1092 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
1108 char *game = g_hash_table_lookup(yd->games, name); 1093 char *game = g_hash_table_lookup(yd->games, name);
1109 char *t; 1094 char *t;
1110 char url[256]; 1095 char url[256];
1111 1096
1157 } 1142 }
1158 } 1143 }
1159 return NULL; 1144 return NULL;
1160 } 1145 }
1161 1146
1162 static GList *yahoo_buddy_menu(struct gaim_connection *gc, const char *who) 1147 static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who)
1163 { 1148 {
1164 GList *m = NULL; 1149 GList *m = NULL;
1165 struct proto_buddy_menu *pbm; 1150 struct proto_buddy_menu *pbm;
1166 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 1151 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
1167 struct buddy *b = gaim_find_buddy(gc->account, who); /* this should never be null. if it is, 1152 struct buddy *b = gaim_find_buddy(gc->account, who); /* this should never be null. if it is,
1193 } 1178 }
1194 1179
1195 return m; 1180 return m;
1196 } 1181 }
1197 1182
1198 static void yahoo_act_id(struct gaim_connection *gc, const char *entry) 1183 static void yahoo_act_id(GaimConnection *gc, const char *entry)
1199 { 1184 {
1200 struct yahoo_data *yd = gc->proto_data; 1185 struct yahoo_data *yd = gc->proto_data;
1201 1186
1202 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); 1187 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0);
1203 yahoo_packet_hash(pkt, 3, entry); 1188 yahoo_packet_hash(pkt, 3, entry);
1204 yahoo_send_packet(yd, pkt); 1189 yahoo_send_packet(yd, pkt);
1205 yahoo_packet_free(pkt); 1190 yahoo_packet_free(pkt);
1206 1191
1207 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", entry); 1192 gaim_connection_set_display_name(gc, entry);
1208 } 1193 }
1209 1194
1210 static void yahoo_show_act_id(struct gaim_connection *gc) 1195 static void yahoo_show_act_id(GaimConnection *gc)
1211 { 1196 {
1212 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, 1197 gaim_request_input(gc, NULL, _("Active which ID?"), NULL,
1213 gc->displayname, FALSE, 1198 gaim_connection_get_display_name(gc), FALSE,
1214 _("OK"), G_CALLBACK(yahoo_act_id), 1199 _("OK"), G_CALLBACK(yahoo_act_id),
1215 _("Cancel"), NULL, gc); 1200 _("Cancel"), NULL, gc);
1216 } 1201 }
1217 1202
1218 static GList *yahoo_actions(struct gaim_connection *gc) { 1203 static GList *yahoo_actions(GaimConnection *gc) {
1219 GList *m = NULL; 1204 GList *m = NULL;
1220 struct proto_actions_menu *pam; 1205 struct proto_actions_menu *pam;
1221 1206
1222 pam = g_new0(struct proto_actions_menu, 1); 1207 pam = g_new0(struct proto_actions_menu, 1);
1223 pam->label = _("Activate ID"); 1208 pam->label = _("Activate ID");
1226 m = g_list_append(m, pam); 1211 m = g_list_append(m, pam);
1227 1212
1228 return m; 1213 return m;
1229 } 1214 }
1230 1215
1231 static int yahoo_send_im(struct gaim_connection *gc, const char *who, const char *what, int len, int flags) 1216 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, int len, int flags)
1232 { 1217 {
1233 struct yahoo_data *yd = gc->proto_data; 1218 struct yahoo_data *yd = gc->proto_data;
1234 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); 1219 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0);
1235 char *msg = g_strdup(what); 1220 char *msg = g_strdup(what);
1236 1221
1237 yahoo_packet_hash(pkt, 1, gc->displayname); 1222 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
1238 yahoo_packet_hash(pkt, 5, who); 1223 yahoo_packet_hash(pkt, 5, who);
1239 yahoo_packet_hash(pkt, 14, msg); 1224 yahoo_packet_hash(pkt, 14, msg);
1240 1225
1241 yahoo_send_packet(yd, pkt); 1226 yahoo_send_packet(yd, pkt);
1242 1227
1243 yahoo_packet_free(pkt); 1228 yahoo_packet_free(pkt);
1244 1229
1245 return 1; 1230 return 1;
1246 } 1231 }
1247 1232
1248 int yahoo_send_typing(struct gaim_connection *gc, char *who, int typ) 1233 int yahoo_send_typing(GaimConnection *gc, char *who, int typ)
1249 { 1234 {
1250 struct yahoo_data *yd = gc->proto_data; 1235 struct yahoo_data *yd = gc->proto_data;
1251 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); 1236 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0);
1252 yahoo_packet_hash(pkt, 49, "TYPING"); 1237 yahoo_packet_hash(pkt, 49, "TYPING");
1253 yahoo_packet_hash(pkt, 1, gc->displayname); 1238 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
1254 yahoo_packet_hash(pkt, 14, " "); 1239 yahoo_packet_hash(pkt, 14, " ");
1255 yahoo_packet_hash(pkt, 13, typ == TYPING ? "1" : "0"); 1240 yahoo_packet_hash(pkt, 13, typ == TYPING ? "1" : "0");
1256 yahoo_packet_hash(pkt, 5, who); 1241 yahoo_packet_hash(pkt, 5, who);
1257 yahoo_packet_hash(pkt, 1002, "1"); 1242 yahoo_packet_hash(pkt, 1002, "1");
1258 1243
1261 yahoo_packet_free(pkt); 1246 yahoo_packet_free(pkt);
1262 1247
1263 return 0; 1248 return 0;
1264 } 1249 }
1265 1250
1266 static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) 1251 static void yahoo_set_away(GaimConnection *gc, char *state, char *msg)
1267 { 1252 {
1268 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 1253 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
1269 struct yahoo_packet *pkt; 1254 struct yahoo_packet *pkt;
1270 int service; 1255 int service;
1271 char s[4]; 1256 char s[4];
1331 1316
1332 yahoo_send_packet(yd, pkt); 1317 yahoo_send_packet(yd, pkt);
1333 yahoo_packet_free(pkt); 1318 yahoo_packet_free(pkt);
1334 } 1319 }
1335 1320
1336 static void yahoo_set_idle(struct gaim_connection *gc, int idle) 1321 static void yahoo_set_idle(GaimConnection *gc, int idle)
1337 { 1322 {
1338 struct yahoo_data *yd = gc->proto_data; 1323 struct yahoo_data *yd = gc->proto_data;
1339 struct yahoo_packet *pkt = NULL; 1324 struct yahoo_packet *pkt = NULL;
1340 1325
1341 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { 1326 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) {
1353 yahoo_send_packet(yd, pkt); 1338 yahoo_send_packet(yd, pkt);
1354 yahoo_packet_free(pkt); 1339 yahoo_packet_free(pkt);
1355 } 1340 }
1356 } 1341 }
1357 1342
1358 static GList *yahoo_away_states(struct gaim_connection *gc) 1343 static GList *yahoo_away_states(GaimConnection *gc)
1359 { 1344 {
1360 GList *m = NULL; 1345 GList *m = NULL;
1361 1346
1362 m = g_list_append(m, _("Available")); 1347 m = g_list_append(m, _("Available"));
1363 m = g_list_append(m, _("Be Right Back")); 1348 m = g_list_append(m, _("Be Right Back"));
1373 m = g_list_append(m, GAIM_AWAY_CUSTOM); 1358 m = g_list_append(m, GAIM_AWAY_CUSTOM);
1374 1359
1375 return m; 1360 return m;
1376 } 1361 }
1377 1362
1378 static void yahoo_keepalive(struct gaim_connection *gc) 1363 static void yahoo_keepalive(GaimConnection *gc)
1379 { 1364 {
1380 struct yahoo_data *yd = gc->proto_data; 1365 struct yahoo_data *yd = gc->proto_data;
1381 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); 1366 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0);
1382 yahoo_send_packet(yd, pkt); 1367 yahoo_send_packet(yd, pkt);
1383 yahoo_packet_free(pkt); 1368 yahoo_packet_free(pkt);
1384 } 1369 }
1385 1370
1386 static void yahoo_add_buddy(struct gaim_connection *gc, const char *who) 1371 static void yahoo_add_buddy(GaimConnection *gc, const char *who)
1387 { 1372 {
1388 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 1373 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
1389 struct yahoo_packet *pkt; 1374 struct yahoo_packet *pkt;
1390 struct group *g; 1375 struct group *g;
1391 char *group = NULL; 1376 char *group = NULL;
1398 group = g->name; 1383 group = g->name;
1399 else 1384 else
1400 group = "Buddies"; 1385 group = "Buddies";
1401 1386
1402 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); 1387 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0);
1403 yahoo_packet_hash(pkt, 1, gc->displayname); 1388 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
1404 yahoo_packet_hash(pkt, 7, who); 1389 yahoo_packet_hash(pkt, 7, who);
1405 yahoo_packet_hash(pkt, 65, group); 1390 yahoo_packet_hash(pkt, 65, group);
1406 yahoo_send_packet(yd, pkt); 1391 yahoo_send_packet(yd, pkt);
1407 yahoo_packet_free(pkt); 1392 yahoo_packet_free(pkt);
1408 } 1393 }
1409 1394
1410 static void yahoo_remove_buddy(struct gaim_connection *gc, char *who, char *group) 1395 static void yahoo_remove_buddy(GaimConnection *gc, char *who, char *group)
1411 { 1396 {
1412 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 1397 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
1413 1398
1414 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); 1399 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0);
1415 yahoo_packet_hash(pkt, 1, gc->displayname); 1400 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
1416 yahoo_packet_hash(pkt, 7, who); 1401 yahoo_packet_hash(pkt, 7, who);
1417 yahoo_packet_hash(pkt, 65, group); 1402 yahoo_packet_hash(pkt, 65, group);
1418 yahoo_send_packet(yd, pkt); 1403 yahoo_send_packet(yd, pkt);
1419 yahoo_packet_free(pkt); 1404 yahoo_packet_free(pkt);
1420 } 1405 }

mercurial