comparison libpurple/protocols/yahoo/libymsg.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents f07501af8bae
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
157 char *fedname = NULL; 157 char *fedname = NULL;
158 158
159 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 159 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
160 if (!purple_account_get_remember_password(account)) 160 if (!purple_account_get_remember_password(account))
161 purple_account_set_password(account, NULL); 161 purple_account_set_password(account, NULL);
162 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE, 162 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE,
163 _("You have signed on from another location")); 163 _("You have signed on from another location"));
164 return; 164 return;
165 } 165 }
166 166
167 while (l) { 167 while (l) {
335 PurpleBuddy *b; 335 PurpleBuddy *b;
336 336
337 if (!name) 337 if (!name)
338 break; 338 break;
339 339
340 b = purple_find_buddy(gc->account, name); 340 b = purple_find_buddy(purple_connection_get_account(gc), name);
341 341
342 if (!cksum || (cksum == -1)) { 342 if (!cksum || (cksum == -1)) {
343 if (f) 343 if (f)
344 yahoo_friend_set_buddy_icon_need_request(f, TRUE); 344 yahoo_friend_set_buddy_icon_need_request(f, TRUE);
345 purple_buddy_icons_set_for_user(gc->account, name, NULL, 0, NULL); 345 purple_buddy_icons_set_for_user(purple_connection_get_account(gc), name, NULL, 0, NULL);
346 break; 346 break;
347 } 347 }
348 348
349 if (!f) 349 if (!f)
350 break; 350 break;
494 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt) 494 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt)
495 { 495 {
496 GSList *l = pkt->hash; 496 GSList *l = pkt->hash;
497 497
498 PurpleAccount *account = purple_connection_get_account(gc); 498 PurpleAccount *account = purple_connection_get_account(gc);
499 YahooData *yd = gc->proto_data; 499 YahooData *yd = purple_connection_get_protocol_data(gc);
500 GHashTable *ht; 500 GHashTable *ht;
501 char *norm_bud = NULL; 501 char *norm_bud = NULL;
502 char *temp = NULL; 502 char *temp = NULL;
503 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */ 503 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */
504 /* But what if you had no friends? */ 504 /* But what if you had no friends? */
571 f->p2p_packet_sent = 0; 571 f->p2p_packet_sent = 0;
572 } else 572 } else
573 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_DO_NOT_CONNECT); 573 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_DO_NOT_CONNECT);
574 } else { 574 } else {
575 /* This buddy is on the ignore list (and therefore in no group) */ 575 /* This buddy is on the ignore list (and therefore in no group) */
576 purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n",account->username, norm_bud); 576 purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n", purple_account_get_username(account), norm_bud);
577 purple_privacy_deny_add(account, norm_bud, 1); 577 purple_privacy_deny_add(account, norm_bud, 1);
578 } 578 }
579 579
580 g_free(norm_bud); 580 g_free(norm_bud);
581 norm_bud=NULL; 581 norm_bud=NULL;
632 } 632 }
633 633
634 static void yahoo_process_list(PurpleConnection *gc, struct yahoo_packet *pkt) 634 static void yahoo_process_list(PurpleConnection *gc, struct yahoo_packet *pkt)
635 { 635 {
636 GSList *l = pkt->hash; 636 GSList *l = pkt->hash;
637 gboolean export = FALSE;
638 gboolean got_serv_list = FALSE; 637 gboolean got_serv_list = FALSE;
639 YahooFriend *f = NULL; 638 YahooFriend *f = NULL;
640 PurpleAccount *account = purple_connection_get_account(gc); 639 PurpleAccount *account = purple_connection_get_account(gc);
641 YahooData *yd = gc->proto_data; 640 YahooData *yd = purple_connection_get_protocol_data(gc);
642 GHashTable *ht; 641 GHashTable *ht;
643 642
644 char **lines; 643 char **lines;
645 char **split; 644 char **split;
646 char **buddies; 645 char **buddies;
710 g = purple_group_new(grp); 709 g = purple_group_new(grp);
711 purple_blist_add_group(g, NULL); 710 purple_blist_add_group(g, NULL);
712 } 711 }
713 b = purple_buddy_new(account, norm_bud, NULL); 712 b = purple_buddy_new(account, norm_bud, NULL);
714 purple_blist_add_buddy(b, NULL, g, NULL); 713 purple_blist_add_buddy(b, NULL, g, NULL);
715 export = TRUE;
716 } 714 }
717 715
718 yahoo_do_group_check(account, ht, norm_bud, grp); 716 yahoo_do_group_check(account, ht, norm_bud, grp);
719 /* set p2p status not connected and no p2p packet sent */ 717 /* set p2p status not connected and no p2p packet sent */
720 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED); 718 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
746 g_string_free(yd->tmp_serv_ilist, TRUE); 744 g_string_free(yd->tmp_serv_ilist, TRUE);
747 yd->tmp_serv_ilist = NULL; 745 yd->tmp_serv_ilist = NULL;
748 } 746 }
749 747
750 if (got_serv_list && 748 if (got_serv_list &&
751 ((account->perm_deny != PURPLE_PRIVACY_ALLOW_BUDDYLIST) && 749 ((purple_account_get_privacy_type(account) != PURPLE_PRIVACY_ALLOW_BUDDYLIST) &&
752 (account->perm_deny != PURPLE_PRIVACY_DENY_ALL) && 750 (purple_account_get_privacy_type(account) != PURPLE_PRIVACY_DENY_ALL) &&
753 (account->perm_deny != PURPLE_PRIVACY_ALLOW_USERS))) 751 (purple_account_get_privacy_type(account) != PURPLE_PRIVACY_ALLOW_USERS)))
754 { 752 {
755 account->perm_deny = PURPLE_PRIVACY_DENY_USERS; 753 purple_account_set_privacy_type(account, PURPLE_PRIVACY_DENY_USERS);
756 purple_debug_info("yahoo", "%s privacy defaulting to PURPLE_PRIVACY_DENY_USERS.\n", 754 purple_debug_info("yahoo", "%s privacy defaulting to PURPLE_PRIVACY_DENY_USERS.\n",
757 account->username); 755 purple_account_get_username(account));
758 } 756 }
759 757
760 if (yd->tmp_serv_plist) { 758 if (yd->tmp_serv_plist) {
761 buddies = g_strsplit(yd->tmp_serv_plist->str, ",", -1); 759 buddies = g_strsplit(yd->tmp_serv_plist->str, ",", -1);
762 for (bud = buddies; bud && *bud; bud++) { 760 for (bud = buddies; bud && *bud; bud++) {
763 f = yahoo_friend_find(gc, *bud); 761 f = yahoo_friend_find(gc, *bud);
764 if (f) { 762 if (f) {
765 purple_debug_info("yahoo", "%s setting presence for %s to PERM_OFFLINE\n", 763 purple_debug_info("yahoo", "%s setting presence for %s to PERM_OFFLINE\n",
766 account->username, *bud); 764 purple_account_get_username(account), *bud);
767 f->presence = YAHOO_PRESENCE_PERM_OFFLINE; 765 f->presence = YAHOO_PRESENCE_PERM_OFFLINE;
768 } 766 }
769 } 767 }
770 g_strfreev(buddies); 768 g_strfreev(buddies);
771 g_string_free(yd->tmp_serv_plist, TRUE); 769 g_string_free(yd->tmp_serv_plist, TRUE);
785 char *stat = NULL; 783 char *stat = NULL;
786 char *game = NULL; 784 char *game = NULL;
787 YahooFriend *f = NULL; 785 YahooFriend *f = NULL;
788 GSList *l = pkt->hash; 786 GSList *l = pkt->hash;
789 gint val_11 = 0; 787 gint val_11 = 0;
790 YahooData *yd = gc->proto_data; 788 YahooData *yd = purple_connection_get_protocol_data(gc);
791 YahooFederation fed = YAHOO_FEDERATION_NONE; 789 YahooFederation fed = YAHOO_FEDERATION_NONE;
792 790
793 account = purple_connection_get_account(gc); 791 account = purple_connection_get_account(gc);
794 792
795 while (l) { 793 while (l) {
897 struct _yahoo_im *sms = NULL; 895 struct _yahoo_im *sms = NULL;
898 YahooData *yd; 896 YahooData *yd;
899 char *server_msg = NULL; 897 char *server_msg = NULL;
900 char *m; 898 char *m;
901 899
902 yd = gc->proto_data; 900 yd = purple_connection_get_protocol_data(gc);
903 account = purple_connection_get_account(gc); 901 account = purple_connection_get_account(gc);
904 902
905 while (l != NULL) { 903 while (l != NULL) {
906 struct yahoo_pair *pair = l->data; 904 struct yahoo_pair *pair = l->data;
907 if (pair->key == 4) { 905 if (pair->key == 4) {
958 956
959 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */ 957 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */
960 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type) 958 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type)
961 { 959 {
962 PurpleAccount *account; 960 PurpleAccount *account;
963 YahooData *yd = gc->proto_data; 961 YahooData *yd = purple_connection_get_protocol_data(gc);
964 GSList *l = pkt->hash; 962 GSList *l = pkt->hash;
965 GSList *list = NULL; 963 GSList *list = NULL;
966 struct _yahoo_im *im = NULL; 964 struct _yahoo_im *im = NULL;
967 965
968 account = purple_connection_get_account(gc); 966 account = purple_connection_get_account(gc);
1059 if(wb == NULL) 1057 if(wb == NULL)
1060 { 1058 {
1061 doodle_session *ds; 1059 doodle_session *ds;
1062 wb = purple_whiteboard_create(account, im->from, 1060 wb = purple_whiteboard_create(account, im->from,
1063 DOODLE_STATE_REQUESTED); 1061 DOODLE_STATE_REQUESTED);
1064 ds = wb->proto_data; 1062 ds = purple_whiteboard_get_protocol_data(wb);
1065 ds->imv_key = g_strdup(pair->value); 1063 ds->imv_key = g_strdup(pair->value);
1066 1064
1067 yahoo_doodle_command_send_request(gc, im->from, pair->value); 1065 yahoo_doodle_command_send_request(gc, im->from, pair->value);
1068 yahoo_doodle_command_send_ready(gc, im->from, pair->value); 1066 yahoo_doodle_command_send_ready(gc, im->from, pair->value);
1069 } 1067 }
1200 static void 1198 static void
1201 yahoo_buddy_add_authorize_cb(gpointer data) 1199 yahoo_buddy_add_authorize_cb(gpointer data)
1202 { 1200 {
1203 struct yahoo_add_request *add_req = data; 1201 struct yahoo_add_request *add_req = data;
1204 struct yahoo_packet *pkt; 1202 struct yahoo_packet *pkt;
1205 YahooData *yd = add_req->gc->proto_data; 1203 YahooData *yd = purple_connection_get_protocol_data(add_req->gc);
1206 const char *who = add_req->who; 1204 const char *who = add_req->who;
1207 1205
1208 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id); 1206 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id);
1209 if (add_req->fed) { 1207 if (add_req->fed) {
1210 who += 4; 1208 who += 4;
1231 } 1229 }
1232 1230
1233 static void 1231 static void
1234 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) 1232 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg)
1235 { 1233 {
1236 YahooData *yd = add_req->gc->proto_data; 1234 YahooData *yd = purple_connection_get_protocol_data(add_req->gc);
1237 struct yahoo_packet *pkt; 1235 struct yahoo_packet *pkt;
1238 char *encoded_msg = NULL; 1236 char *encoded_msg = NULL;
1239 const char *who = add_req->who; 1237 const char *who = add_req->who;
1240 1238
1241 if (msg && *msg) 1239 if (msg && *msg)
1293 } 1291 }
1294 1292
1295 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) 1293 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason)
1296 { 1294 {
1297 char *notify_msg; 1295 char *notify_msg;
1298 YahooData *yd = gc->proto_data; 1296 YahooData *yd = purple_connection_get_protocol_data(gc);
1299 1297
1300 if (who == NULL) 1298 if (who == NULL)
1301 return; 1299 return;
1302 1300
1303 if (reason != NULL) { 1301 if (reason != NULL) {
1623 } 1621 }
1624 1622
1625 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) 1623 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt)
1626 { 1624 {
1627 PurpleAccount *account = purple_connection_get_account(gc); 1625 PurpleAccount *account = purple_connection_get_account(gc);
1628 YahooData *yd = gc->proto_data; 1626 YahooData *yd = purple_connection_get_protocol_data(gc);
1629 const char *who = NULL; 1627 const char *who = NULL;
1630 const char *email = NULL; 1628 const char *email = NULL;
1631 const char *subj = NULL; 1629 const char *subj = NULL;
1632 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); 1630 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL);
1633 int count = 0; 1631 int count = 0;
1707 *out = '\0'; 1705 *out = '\0';
1708 } 1706 }
1709 1707
1710 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) 1708 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt)
1711 { 1709 {
1712 YahooData *yd = gc->proto_data; 1710 YahooData *yd = purple_connection_get_protocol_data(gc);
1713 PurpleAccount *account = purple_connection_get_account(gc); 1711 PurpleAccount *account = purple_connection_get_account(gc);
1714 const char *name = purple_normalize(account, purple_account_get_username(account)); 1712 const char *name = purple_normalize(account, purple_account_get_username(account));
1715 PurpleCipher *md5_cipher; 1713 PurpleCipher *md5_cipher;
1716 PurpleCipherContext *md5_ctx; 1714 PurpleCipherContext *md5_ctx;
1717 guchar md5_digest[16]; 1715 guchar md5_digest[16];
1801 1799
1802 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 1800 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
1803 1801
1804 if (error_message != NULL) { 1802 if (error_message != NULL) {
1805 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); 1803 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message);
1806 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1804 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1807 g_free(auth_data->seed); 1805 g_free(auth_data->seed);
1808 g_free(auth_data); 1806 g_free(auth_data);
1809 return; 1807 return;
1810 } 1808 }
1811 else if (len > 0 && ret_data && *ret_data) { 1809 else if (len > 0 && ret_data && *ret_data) {
1888 break; 1886 break;
1889 } 1887 }
1890 if(error_reason) { 1888 if(error_reason) {
1891 purple_debug_error("yahoo", "Authentication error: %s. " 1889 purple_debug_error("yahoo", "Authentication error: %s. "
1892 "Code %d\n", error_reason, response_no); 1890 "Code %d\n", error_reason, response_no);
1893 purple_connection_error_reason(gc, error, error_reason); 1891 purple_connection_error(gc, error, error_reason);
1894 g_free(error_reason); 1892 g_free(error_reason);
1895 g_free(auth_data->seed); 1893 g_free(auth_data->seed);
1896 g_free(auth_data); 1894 g_free(auth_data);
1897 return; 1895 return;
1898 } 1896 }
1917 1915
1918 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 1916 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
1919 1917
1920 if (error_message != NULL) { 1918 if (error_message != NULL) {
1921 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message); 1919 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message);
1922 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1920 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1923 g_free(auth_data->seed); 1921 g_free(auth_data->seed);
1924 g_free(auth_data); 1922 g_free(auth_data);
1925 return; 1923 return;
1926 } 1924 }
1927 else if (len > 0 && ret_data && *ret_data) { 1925 else if (len > 0 && ret_data && *ret_data) {
1998 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 1996 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
1999 break; 1997 break;
2000 } 1998 }
2001 purple_debug_error("yahoo", "Authentication error: %s. Code %d\n", 1999 purple_debug_error("yahoo", "Authentication error: %s. Code %d\n",
2002 error_reason, response_no); 2000 error_reason, response_no);
2003 purple_connection_error_reason(gc, error, error_reason); 2001 purple_connection_error(gc, error, error_reason);
2004 g_free(error_reason); 2002 g_free(error_reason);
2005 g_free(auth_data->seed); 2003 g_free(auth_data->seed);
2006 g_free(auth_data); 2004 g_free(auth_data);
2007 g_free(token); 2005 g_free(token);
2008 } 2006 }
2012 char *url = NULL; 2010 char *url = NULL;
2013 gboolean yahoojp = yahoo_is_japan(account); 2011 gboolean yahoojp = yahoo_is_japan(account);
2014 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); 2012 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE);
2015 2013
2016 url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token); 2014 url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token);
2017 url_data = purple_util_fetch_url_request_len_with_account( 2015 url_data = purple_util_fetch_url_request(
2018 proxy_ssl ? account : NULL, url, TRUE, YAHOO_CLIENT_USERAGENT, 2016 proxy_ssl ? account : NULL, url, TRUE, YAHOO_CLIENT_USERAGENT,
2019 TRUE, NULL, TRUE, -1, yahoo_auth16_stage2, auth_data); 2017 TRUE, NULL, TRUE, -1, yahoo_auth16_stage2, auth_data);
2020 if (url_data) 2018 if (url_data)
2021 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); 2019 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
2022 g_free(url); 2020 g_free(url);
2038 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); 2036 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE);
2039 2037
2040 purple_debug_info("yahoo", "Authentication: In yahoo_auth16_stage1\n"); 2038 purple_debug_info("yahoo", "Authentication: In yahoo_auth16_stage1\n");
2041 2039
2042 if(!purple_ssl_is_supported()) { 2040 if(!purple_ssl_is_supported()) {
2043 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable")); 2041 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable"));
2044 return; 2042 return;
2045 } 2043 }
2046 2044
2047 auth_data = g_new0(struct yahoo_auth_data, 1); 2045 auth_data = g_new0(struct yahoo_auth_data, 1);
2048 auth_data->gc = gc; 2046 auth_data->gc = gc;
2053 url = g_strdup_printf(yahoojp ? YAHOOJP_TOKEN_URL : YAHOO_TOKEN_URL, 2051 url = g_strdup_printf(yahoojp ? YAHOOJP_TOKEN_URL : YAHOO_TOKEN_URL,
2054 encoded_username, encoded_password, purple_url_encode(seed)); 2052 encoded_username, encoded_password, purple_url_encode(seed));
2055 g_free(encoded_password); 2053 g_free(encoded_password);
2056 g_free(encoded_username); 2054 g_free(encoded_username);
2057 2055
2058 url_data = purple_util_fetch_url_request_len_with_account( 2056 url_data = purple_util_fetch_url_request(
2059 proxy_ssl ? account : NULL, url, TRUE, 2057 proxy_ssl ? account : NULL, url, TRUE,
2060 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1, 2058 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1,
2061 yahoo_auth16_stage1_cb, auth_data); 2059 yahoo_auth16_stage1_cb, auth_data);
2062 if (url_data) 2060 if (url_data)
2063 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); 2061 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
2178 case 12: 2176 case 12:
2179 purple_debug_info("yahoo", "Server reported \"is a buddy\" for %s while %s", 2177 purple_debug_info("yahoo", "Server reported \"is a buddy\" for %s while %s",
2180 who, (ignore ? "ignoring" : "unignoring")); 2178 who, (ignore ? "ignoring" : "unignoring"));
2181 2179
2182 if (ignore) { 2180 if (ignore) {
2183 b = purple_find_buddy(gc->account, who); 2181 b = purple_find_buddy(purple_connection_get_account(gc), who);
2184 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " 2182 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the "
2185 "user is on your buddy list. Clicking \"Yes\" " 2183 "user is on your buddy list. Clicking \"Yes\" "
2186 "will remove and ignore the buddy."), who); 2184 "will remove and ignore the buddy."), who);
2187 purple_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, 2185 purple_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0,
2188 gc->account, who, NULL, 2186 purple_connection_get_account(gc), who, NULL,
2189 b, 2187 b,
2190 G_CALLBACK(ignore_buddy), 2188 G_CALLBACK(ignore_buddy),
2191 G_CALLBACK(keep_buddy)); 2189 G_CALLBACK(keep_buddy));
2192 break; 2190 break;
2193 } 2191 }
2205 } 2203 }
2206 2204
2207 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) 2205 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt)
2208 { 2206 {
2209 #ifdef TRY_WEBMESSENGER_LOGIN 2207 #ifdef TRY_WEBMESSENGER_LOGIN
2210 YahooData *yd = gc->proto_data; 2208 YahooData *yd = purple_connection_get_protocol_data(gc);
2211 #endif /* TRY_WEBMESSENGER_LOGIN */ 2209 #endif /* TRY_WEBMESSENGER_LOGIN */
2212 GSList *l = pkt->hash; 2210 GSList *l = pkt->hash;
2213 int err = 0; 2211 int err = 0;
2214 char *msg; 2212 char *msg;
2215 char *url = NULL; 2213 char *url = NULL;
2216 char *fullmsg; 2214 char *fullmsg;
2217 PurpleAccount *account = gc->account; 2215 PurpleAccount *account = purple_connection_get_account(gc);
2218 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 2216 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
2219 2217
2220 while (l) { 2218 while (l) {
2221 struct yahoo_pair *pair = l->data; 2219 struct yahoo_pair *pair = l->data;
2222 2220
2242 if (!yd->wm) { 2240 if (!yd->wm) {
2243 PurpleUtilFetchUrlData *url_data; 2241 PurpleUtilFetchUrlData *url_data;
2244 yd->wm = TRUE; 2242 yd->wm = TRUE;
2245 if (yd->fd >= 0) 2243 if (yd->fd >= 0)
2246 close(yd->fd); 2244 close(yd->fd);
2247 if (gc->inpa) 2245 if (yd->inpa) {
2248 purple_input_remove(gc->inpa); 2246 purple_input_remove(yd->inpa);
2247 yd->inpa = 0;
2248 }
2249 url_data = purple_util_fetch_url(WEBMESSENGER_URL, TRUE, 2249 url_data = purple_util_fetch_url(WEBMESSENGER_URL, TRUE,
2250 "Purple/" VERSION, FALSE, yahoo_login_page_cb, gc); 2250 "Purple/" VERSION, FALSE, -1, yahoo_login_page_cb, gc);
2251 if (url_data != NULL) 2251 if (url_data != NULL)
2252 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); 2252 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
2253 return; 2253 return;
2254 } 2254 }
2255 #endif /* TRY_WEBMESSENGER_LOGIN */ 2255 #endif /* TRY_WEBMESSENGER_LOGIN */
2283 if (url) 2283 if (url)
2284 fullmsg = g_strdup_printf("%s\n%s", msg, url); 2284 fullmsg = g_strdup_printf("%s\n%s", msg, url);
2285 else 2285 else
2286 fullmsg = g_strdup(msg); 2286 fullmsg = g_strdup(msg);
2287 2287
2288 purple_connection_error_reason(gc, reason, fullmsg); 2288 purple_connection_error(gc, reason, fullmsg);
2289 g_free(msg); 2289 g_free(msg);
2290 g_free(fullmsg); 2290 g_free(fullmsg);
2291 } 2291 }
2292 2292
2293 static void yahoo_process_addbuddy(PurpleConnection *gc, struct yahoo_packet *pkt) 2293 static void yahoo_process_addbuddy(PurpleConnection *gc, struct yahoo_packet *pkt)
2298 char *group = NULL; 2298 char *group = NULL;
2299 char *decoded_group; 2299 char *decoded_group;
2300 char *buf; 2300 char *buf;
2301 YahooFriend *f; 2301 YahooFriend *f;
2302 GSList *l = pkt->hash; 2302 GSList *l = pkt->hash;
2303 YahooData *yd = gc->proto_data; 2303 YahooData *yd = purple_connection_get_protocol_data(gc);
2304 YahooFederation fed = YAHOO_FEDERATION_NONE; 2304 YahooFederation fed = YAHOO_FEDERATION_NONE;
2305 2305
2306 while (l) { 2306 while (l) {
2307 struct yahoo_pair *pair = l->data; 2307 struct yahoo_pair *pair = l->data;
2308 2308
2392 { 2392 {
2393 struct yahoo_p2p_data *p2p_data = value; 2393 struct yahoo_p2p_data *p2p_data = value;
2394 PurpleConnection *gc = user_data; 2394 PurpleConnection *gc = user_data;
2395 struct yahoo_packet *pkt_to_send; 2395 struct yahoo_packet *pkt_to_send;
2396 PurpleAccount *account; 2396 PurpleAccount *account;
2397 YahooData *yd = gc->proto_data; 2397 YahooData *yd = purple_connection_get_protocol_data(gc);
2398 2398
2399 account = purple_connection_get_account(gc); 2399 account = purple_connection_get_account(gc);
2400 2400
2401 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); 2401 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
2402 yahoo_packet_hash(pkt_to_send, "ssisi", 2402 yahoo_packet_hash(pkt_to_send, "ssisi",
2411 } 2411 }
2412 2412
2413 static gboolean yahoo_p2p_keepalive(gpointer data) 2413 static gboolean yahoo_p2p_keepalive(gpointer data)
2414 { 2414 {
2415 PurpleConnection *gc = data; 2415 PurpleConnection *gc = data;
2416 YahooData *yd = gc->proto_data; 2416 YahooData *yd = purple_connection_get_protocol_data(gc);
2417 2417
2418 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); 2418 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc);
2419 2419
2420 return TRUE; 2420 return TRUE;
2421 } 2421 }
2458 YahooFriend *f; 2458 YahooFriend *f;
2459 2459
2460 if(!(p2p_data = data)) 2460 if(!(p2p_data = data))
2461 return ; 2461 return ;
2462 2462
2463 yd = p2p_data->gc->proto_data; 2463 yd = purple_connection_get_protocol_data(p2p_data->gc);
2464 2464
2465 /* lets see whats in the packet */ 2465 /* lets see whats in the packet */
2466 while (l) { 2466 while (l) {
2467 struct yahoo_pair *pair = l->data; 2467 struct yahoo_pair *pair = l->data;
2468 2468
2543 struct yahoo_p2p_data *p2p_data; 2543 struct yahoo_p2p_data *p2p_data;
2544 YahooData *yd; 2544 YahooData *yd;
2545 2545
2546 if(!(p2p_data = data)) 2546 if(!(p2p_data = data))
2547 return ; 2547 return ;
2548 yd = p2p_data->gc->proto_data; 2548 yd = purple_connection_get_protocol_data(p2p_data->gc);
2549 2549
2550 len = read(source, buf, sizeof(buf)); 2550 len = read(source, buf, sizeof(buf));
2551 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) 2551 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
2552 return ; /* No Worries*/ 2552 return ; /* No Worries*/
2553 else if (len <= 0) 2553 else if (len <= 0)
2615 struct yahoo_p2p_data *p2p_data; 2615 struct yahoo_p2p_data *p2p_data;
2616 YahooData *yd; 2616 YahooData *yd;
2617 2617
2618 if(!(p2p_data = data)) 2618 if(!(p2p_data = data))
2619 return ; 2619 return ;
2620 yd = p2p_data->gc->proto_data; 2620 yd = purple_connection_get_protocol_data(p2p_data->gc);
2621 2621
2622 acceptfd = accept(source, NULL, 0); 2622 acceptfd = accept(source, NULL, 0);
2623 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) 2623 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
2624 return; 2624 return;
2625 else if(acceptfd == -1) { 2625 else if(acceptfd == -1) {
2655 YahooData *yd; 2655 YahooData *yd;
2656 2656
2657 if(!(p2p_data = data)) 2657 if(!(p2p_data = data))
2658 return FALSE; 2658 return FALSE;
2659 2659
2660 yd = p2p_data->gc->proto_data; 2660 yd = purple_connection_get_protocol_data(p2p_data->gc);
2661 2661
2662 purple_debug_warning("yahoo","yahoo p2p server timeout, peer failed to connect\n"); 2662 purple_debug_warning("yahoo","yahoo p2p server timeout, peer failed to connect\n");
2663 yahoo_p2p_disconnect_destroy_data(data); 2663 yahoo_p2p_disconnect_destroy_data(data);
2664 purple_input_remove(yd->yahoo_p2p_server_watcher); 2664 purple_input_remove(yd->yahoo_p2p_server_watcher);
2665 yd->yahoo_p2p_server_watcher = 0; 2665 yd->yahoo_p2p_server_watcher = 0;
2676 YahooData *yd; 2676 YahooData *yd;
2677 2677
2678 if(!(p2p_data = data)) 2678 if(!(p2p_data = data))
2679 return ; 2679 return ;
2680 2680
2681 yd = p2p_data->gc->proto_data; 2681 yd = purple_connection_get_protocol_data(p2p_data->gc);
2682 yd->listen_data = NULL; 2682 yd->listen_data = NULL;
2683 2683
2684 if(listenfd == -1) { 2684 if(listenfd == -1) {
2685 purple_debug_warning("yahoo","p2p: error starting p2p server\n"); 2685 purple_debug_warning("yahoo","p2p: error starting p2p server\n");
2686 yahoo_p2p_disconnect_destroy_data(data); 2686 yahoo_p2p_disconnect_destroy_data(data);
2704 char temp_str[100]; 2704 char temp_str[100];
2705 gchar *base64_ip = NULL; 2705 gchar *base64_ip = NULL;
2706 YahooFriend *f; 2706 YahooFriend *f;
2707 struct yahoo_packet *pkt; 2707 struct yahoo_packet *pkt;
2708 PurpleAccount *account; 2708 PurpleAccount *account;
2709 YahooData *yd = gc->proto_data; 2709 YahooData *yd = purple_connection_get_protocol_data(gc);
2710 struct yahoo_p2p_data *p2p_data; 2710 struct yahoo_p2p_data *p2p_data;
2711 const char *norm_username; 2711 const char *norm_username;
2712 2712
2713 f = yahoo_friend_find(gc, who); 2713 f = yahoo_friend_find(gc, who);
2714 account = purple_connection_get_account(gc); 2714 account = purple_connection_get_account(gc);
2768 /* FIXME: If the port is already used, purple_network_listener returns NULL and old listener won't be canceled 2768 /* FIXME: If the port is already used, purple_network_listener returns NULL and old listener won't be canceled
2769 * in yahoo_close function. */ 2769 * in yahoo_close function. */
2770 if (yd->listen_data) 2770 if (yd->listen_data)
2771 purple_debug_warning("yahoo","p2p: Failed to create p2p server - server already exists\n"); 2771 purple_debug_warning("yahoo","p2p: Failed to create p2p server - server already exists\n");
2772 else { 2772 else {
2773 yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data); 2773 yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_server_listen_cb, p2p_data);
2774 if (yd->listen_data == NULL) 2774 if (yd->listen_data == NULL)
2775 purple_debug_warning("yahoo","p2p: Failed to created p2p server\n"); 2775 purple_debug_warning("yahoo","p2p: Failed to created p2p server\n");
2776 } 2776 }
2777 2777
2778 g_free(base64_ip); 2778 g_free(base64_ip);
2785 struct yahoo_packet *pkt_to_send; 2785 struct yahoo_packet *pkt_to_send;
2786 PurpleAccount *account; 2786 PurpleAccount *account;
2787 YahooData *yd; 2787 YahooData *yd;
2788 2788
2789 p2p_data = data; 2789 p2p_data = data;
2790 yd = p2p_data->gc->proto_data; 2790 yd = purple_connection_get_protocol_data(p2p_data->gc);
2791 2791
2792 if(error_message != NULL) { 2792 if(error_message != NULL) {
2793 purple_debug_warning("yahoo","p2p: %s\n",error_message); 2793 purple_debug_warning("yahoo","p2p: %s\n",error_message);
2794 yahoo_send_p2p_pkt(p2p_data->gc, p2p_data->host_username, 2);/* send p2p init packet with val_13=2 */ 2794 yahoo_send_p2p_pkt(p2p_data->gc, p2p_data->host_username, 2);/* send p2p init packet with val_13=2 */
2795 2795
3130 } 3130 }
3131 3131
3132 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) 3132 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond)
3133 { 3133 {
3134 PurpleConnection *gc = data; 3134 PurpleConnection *gc = data;
3135 YahooData *yd = gc->proto_data; 3135 YahooData *yd = purple_connection_get_protocol_data(gc);
3136 char buf[1024]; 3136 char buf[1024];
3137 int len; 3137 int len;
3138 3138
3139 len = read(yd->fd, buf, sizeof(buf)); 3139 len = read(yd->fd, buf, sizeof(buf));
3140 3140
3145 /* No worries */ 3145 /* No worries */
3146 return; 3146 return;
3147 3147
3148 tmp = g_strdup_printf(_("Lost connection with server: %s"), 3148 tmp = g_strdup_printf(_("Lost connection with server: %s"),
3149 g_strerror(errno)); 3149 g_strerror(errno));
3150 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3150 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3151 g_free(tmp); 3151 g_free(tmp);
3152 return; 3152 return;
3153 } else if (len == 0) { 3153 } else if (len == 0) {
3154 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3154 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3155 _("Server closed the connection")); 3155 _("Server closed the connection"));
3156 return; 3156 return;
3157 } 3157 }
3158 gc->last_received = time(NULL); 3158 purple_connection_update_last_received(gc);
3159 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); 3159 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
3160 memcpy(yd->rxqueue + yd->rxlen, buf, len); 3160 memcpy(yd->rxqueue + yd->rxlen, buf, len);
3161 yd->rxlen += len; 3161 yd->rxlen += len;
3162 3162
3163 while (1) { 3163 while (1) {
3233 struct yahoo_packet *pkt; 3233 struct yahoo_packet *pkt;
3234 3234
3235 if (source < 0) { 3235 if (source < 0) {
3236 gchar *tmp; 3236 gchar *tmp;
3237 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); 3237 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3238 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3238 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3239 g_free(tmp); 3239 g_free(tmp);
3240 return; 3240 return;
3241 } 3241 }
3242 3242
3243 yd = gc->proto_data; 3243 yd = purple_connection_get_protocol_data(gc);
3244 yd->fd = source; 3244 yd->fd = source;
3245 3245
3246 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id); 3246 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id);
3247 3247
3248 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); 3248 yahoo_packet_hash_str(pkt, 1, purple_normalize(purple_connection_get_account(gc), purple_account_get_username(purple_connection_get_account(gc))));
3249 yahoo_packet_send_and_free(pkt, yd); 3249 yahoo_packet_send_and_free(pkt, yd);
3250 3250
3251 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); 3251 yd->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc);
3252 } 3252 }
3253 3253
3254 #ifdef TRY_WEBMESSENGER_LOGIN 3254 #ifdef TRY_WEBMESSENGER_LOGIN
3255 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message) 3255 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message)
3256 { 3256 {
3259 struct yahoo_packet *pkt; 3259 struct yahoo_packet *pkt;
3260 3260
3261 if (source < 0) { 3261 if (source < 0) {
3262 gchar *tmp; 3262 gchar *tmp;
3263 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); 3263 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3264 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3264 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3265 g_free(tmp); 3265 g_free(tmp);
3266 return; 3266 return;
3267 } 3267 }
3268 3268
3269 yd = gc->proto_data; 3269 yd = purple_connection_get_protocol_data(gc);
3270 yd->fd = source; 3270 yd->fd = source;
3271 3271
3272 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id); 3272 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id);
3273 3273
3274 yahoo_packet_hash(pkt, "sss", 0, 3274 yahoo_packet_hash(pkt, "sss", 0,
3275 purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), 3275 purple_normalize(purple_connection_get_account(gc), purple_account_get_username(purple_connection_get_account(gc))),
3276 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), 3276 1, purple_normalize(purple_connection_get_account(gc), purple_account_get_username(purple_connection_get_account(gc))),
3277 6, yd->auth); 3277 6, yd->auth);
3278 yahoo_packet_send_and_free(pkt, yd); 3278 yahoo_packet_send_and_free(pkt, yd);
3279 3279
3280 g_free(yd->auth); 3280 g_free(yd->auth);
3281 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); 3281 yd->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc);
3282 } 3282 }
3283 3283
3284 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) 3284 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond)
3285 { 3285 {
3286 PurpleConnection *gc = data; 3286 PurpleConnection *gc = data;
3287 PurpleAccount *account = purple_connection_get_account(gc); 3287 PurpleAccount *account = purple_connection_get_account(gc);
3288 YahooData *yd = gc->proto_data; 3288 YahooData *yd = purple_connection_get_protocol_data(gc);
3289 char bufread[2048], *i = bufread, *buf = bufread; 3289 char bufread[2048], *i = bufread, *buf = bufread;
3290 int len; 3290 int len;
3291 GString *s; 3291 GString *s;
3292 3292
3293 len = read(source, bufread, sizeof(bufread) - 1); 3293 len = read(source, bufread, sizeof(bufread) - 1);
3299 /* No worries */ 3299 /* No worries */
3300 return; 3300 return;
3301 3301
3302 tmp = g_strdup_printf(_("Lost connection with server: %s"), 3302 tmp = g_strdup_printf(_("Lost connection with server: %s"),
3303 g_strerror(errno)); 3303 g_strerror(errno));
3304 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3304 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3305 g_free(tmp); 3305 g_free(tmp);
3306 return; 3306 return;
3307 } else if (len == 0) { 3307 } else if (len == 0) {
3308 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3308 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3309 _("Server closed the connection")); 3309 _("Server closed the connection"));
3310 return; 3310 return;
3311 } 3311 }
3312 3312
3313 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) { 3313 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) {
3319 } 3319 }
3320 buf[len] = '\0'; 3320 buf[len] = '\0';
3321 3321
3322 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && 3322 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) &&
3323 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { 3323 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) {
3324 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3324 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3325 _("Received unexpected HTTP response from server")); 3325 _("Received unexpected HTTP response from server"));
3326 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf); 3326 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf);
3327 return; 3327 return;
3328 } 3328 }
3329 3329
3340 * It seems to work without these 3340 * It seems to work without these
3341 */ 3341 */
3342 } 3342 }
3343 3343
3344 yd->auth = g_string_free(s, FALSE); 3344 yd->auth = g_string_free(s, FALSE);
3345 purple_input_remove(gc->inpa); 3345 purple_input_remove(yd->inpa);
3346 yd->inpa = 0;
3346 close(source); 3347 close(source);
3347 g_free(yd->rxqueue); 3348 g_free(yd->rxqueue);
3348 yd->rxqueue = NULL; 3349 yd->rxqueue = NULL;
3349 yd->rxlen = 0; 3350 yd->rxlen = 0;
3350 /* Now we have our cookies to login with. I'll go get the milk. */ 3351 /* Now we have our cookies to login with. I'll go get the milk. */
3351 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com", 3352 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com",
3352 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), 3353 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
3353 yahoo_got_web_connected, gc) == NULL) { 3354 yahoo_got_web_connected, gc) == NULL) {
3354 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3355 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3355 _("Unable to connect")); 3356 _("Unable to connect"));
3356 return; 3357 return;
3357 } 3358 }
3358 } 3359 }
3359 3360
3360 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) 3361 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond)
3361 { 3362 {
3362 PurpleConnection *gc; 3363 PurpleConnection *gc = data;
3363 YahooData *yd; 3364 YahooData *yd = purple_connection_get_protocol_data(gc);
3364 int written, remaining; 3365 int written, remaining;
3365
3366 gc = data;
3367 yd = gc->proto_data;
3368 3366
3369 remaining = strlen(yd->auth) - yd->auth_written; 3367 remaining = strlen(yd->auth) - yd->auth_written;
3370 written = write(source, yd->auth + yd->auth_written, remaining); 3368 written = write(source, yd->auth + yd->auth_written, remaining);
3371 3369
3372 if (written < 0 && errno == EAGAIN) 3370 if (written < 0 && errno == EAGAIN)
3373 written = 0; 3371 written = 0;
3374 else if (written <= 0) { 3372 else if (written <= 0) {
3375 gchar *tmp; 3373 gchar *tmp;
3376 g_free(yd->auth); 3374 g_free(yd->auth);
3377 yd->auth = NULL; 3375 yd->auth = NULL;
3378 if (gc->inpa) 3376 if (yd->inpa) {
3379 purple_input_remove(gc->inpa); 3377 purple_input_remove(yd->inpa);
3380 gc->inpa = 0; 3378 yd->inpa = 0;
3379 }
3381 tmp = g_strdup_printf(_("Lost connection with %s: %s"), 3380 tmp = g_strdup_printf(_("Lost connection with %s: %s"),
3382 "login.yahoo.com:80", g_strerror(errno)); 3381 "login.yahoo.com:80", g_strerror(errno));
3383 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3382 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3384 g_free(tmp); 3383 g_free(tmp);
3385 return; 3384 return;
3386 } 3385 }
3387 3386
3388 if (written < remaining) { 3387 if (written < remaining) {
3391 } 3390 }
3392 3391
3393 g_free(yd->auth); 3392 g_free(yd->auth);
3394 yd->auth = NULL; 3393 yd->auth = NULL;
3395 yd->auth_written = 0; 3394 yd->auth_written = 0;
3396 purple_input_remove(gc->inpa); 3395 purple_input_remove(yd->inpa);
3397 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, yahoo_web_pending, gc); 3396 yd->inpa = purple_input_add(source, PURPLE_INPUT_READ, yahoo_web_pending, gc);
3398 } 3397 }
3399 3398
3400 static void yahoo_got_cookies(gpointer data, gint source, const gchar *error_message) 3399 static void yahoo_got_cookies(gpointer data, gint source, const gchar *error_message)
3401 { 3400 {
3402 PurpleConnection *gc = data; 3401 PurpleConnection *gc = data;
3402 YahooData *yd = purple_connection_get_protocol_data(gc);
3403 3403
3404 if (source < 0) { 3404 if (source < 0) {
3405 gchar *tmp; 3405 gchar *tmp;
3406 tmp = g_strdup_printf(_("Unable to establish a connection with %s: %s"), 3406 tmp = g_strdup_printf(_("Unable to establish a connection with %s: %s"),
3407 "login.yahoo.com:80", error_message); 3407 "login.yahoo.com:80", error_message);
3408 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3408 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3409 g_free(tmp); 3409 g_free(tmp);
3410 return; 3410 return;
3411 } 3411 }
3412 3412
3413 if (gc->inpa == 0) 3413 if (yd->inpa == 0)
3414 { 3414 {
3415 gc->inpa = purple_input_add(source, PURPLE_INPUT_WRITE, 3415 yd->inpa = purple_input_add(source, PURPLE_INPUT_WRITE,
3416 yahoo_got_cookies_send_cb, gc); 3416 yahoo_got_cookies_send_cb, gc);
3417 yahoo_got_cookies_send_cb(gc, source, PURPLE_INPUT_WRITE); 3417 yahoo_got_cookies_send_cb(gc, source, PURPLE_INPUT_WRITE);
3418 } 3418 }
3419 } 3419 }
3420 3420
3472 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, 3472 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
3473 const gchar *url_text, size_t len, const gchar *error_message) 3473 const gchar *url_text, size_t len, const gchar *error_message)
3474 { 3474 {
3475 PurpleConnection *gc = (PurpleConnection *)user_data; 3475 PurpleConnection *gc = (PurpleConnection *)user_data;
3476 PurpleAccount *account = purple_connection_get_account(gc); 3476 PurpleAccount *account = purple_connection_get_account(gc);
3477 YahooData *yd = gc->proto_data; 3477 YahooData *yd = purple_connection_get_protocol_data(gc);
3478 const char *sn = purple_account_get_username(account); 3478 const char *sn = purple_account_get_username(account);
3479 const char *pass = purple_connection_get_password(gc); 3479 const char *pass = purple_connection_get_password(gc);
3480 GHashTable *hash = yahoo_login_page_hash(url_text, len); 3480 GHashTable *hash = yahoo_login_page_hash(url_text, len);
3481 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); 3481 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login=");
3482 char md5[33], *hashp = md5, *chal; 3482 char md5[33], *hashp = md5, *chal;
3487 3487
3488 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 3488 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
3489 3489
3490 if (error_message != NULL) 3490 if (error_message != NULL)
3491 { 3491 {
3492 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3492 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3493 error_message); 3493 error_message);
3494 return; 3494 return;
3495 } 3495 }
3496 3496
3497 url = g_string_append(url, sn); 3497 url = g_string_append(url, sn);
3537 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" 3537 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n"
3538 "Host: login.yahoo.com\r\n\r\n"); 3538 "Host: login.yahoo.com\r\n\r\n");
3539 g_hash_table_destroy(hash); 3539 g_hash_table_destroy(hash);
3540 yd->auth = g_string_free(url, FALSE); 3540 yd->auth = g_string_free(url, FALSE);
3541 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { 3541 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) {
3542 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3542 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3543 _("Unable to connect")); 3543 _("Unable to connect"));
3544 return; 3544 return;
3545 } 3545 }
3546 3546
3547 purple_cipher_context_destroy(context); 3547 purple_cipher_context_destroy(context);
3617 purple_debug_error("yahoo", "Unable to retrieve server info. %" 3617 purple_debug_error("yahoo", "Unable to retrieve server info. %"
3618 G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len, 3618 G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len,
3619 error_message ? error_message : "(null)"); 3619 error_message ? error_message : "(null)");
3620 3620
3621 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ 3621 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */
3622 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3622 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3623 _("Unable to connect: The server returned an empty response.")); 3623 _("Unable to connect: The server returned an empty response."));
3624 } else { 3624 } else {
3625 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port, 3625 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port,
3626 yahoo_got_connected, gc) == NULL) { 3626 yahoo_got_connected, gc) == NULL) {
3627 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3627 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3628 _("Unable to connect")); 3628 _("Unable to connect"));
3629 } 3629 }
3630 } 3630 }
3631 } else { 3631 } else {
3632 strings = g_strsplit(url_text, "\r\n", -1); 3632 strings = g_strsplit(url_text, "\r\n", -1);
3644 } 3644 }
3645 } 3645 }
3646 3646
3647 if(cs_server) { /* got an address; get on with connecting */ 3647 if(cs_server) { /* got an address; get on with connecting */
3648 if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL) 3648 if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL)
3649 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3649 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3650 _("Unable to connect")); 3650 _("Unable to connect"));
3651 } else { 3651 } else {
3652 purple_debug_error("yahoo", "No CS address retrieved! Server " 3652 purple_debug_error("yahoo", "No CS address retrieved! Server "
3653 "response:\n%s\n", url_text ? url_text : "(null)"); 3653 "response:\n%s\n", url_text ? url_text : "(null)");
3654 3654
3655 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ 3655 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */
3656 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3656 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3657 _("Unable to connect: The server's response did not contain " 3657 _("Unable to connect: The server's response did not contain "
3658 "the necessary information")); 3658 "the necessary information"));
3659 } else 3659 } else
3660 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port, 3660 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port,
3661 yahoo_got_connected, gc) == NULL) { 3661 yahoo_got_connected, gc) == NULL) {
3662 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3662 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3663 _("Unable to connect")); 3663 _("Unable to connect"));
3664 } 3664 }
3665 } 3665 }
3666 } 3666 }
3667 3667
3669 g_free(cs_server); 3669 g_free(cs_server);
3670 } 3670 }
3671 3671
3672 void yahoo_login(PurpleAccount *account) { 3672 void yahoo_login(PurpleAccount *account) {
3673 PurpleConnection *gc = purple_account_get_connection(account); 3673 PurpleConnection *gc = purple_account_get_connection(account);
3674 YahooData *yd = gc->proto_data = g_new0(YahooData, 1); 3674 YahooData *yd = g_new0(YahooData, 1);
3675 PurpleStatus *status = purple_account_get_active_status(account); 3675 PurpleStatus *status = purple_account_get_active_status(account);
3676 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); 3676 gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
3677 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); 3677 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE);
3678 PurpleUtilFetchUrlData *url_data; 3678 PurpleUtilFetchUrlData *url_data;
3679 3679
3680 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; 3680 purple_connection_set_protocol_data(gc, yd);
3681 purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC);
3681 3682
3682 purple_connection_update_progress(gc, _("Connecting"), 1, 2); 3683 purple_connection_update_progress(gc, _("Connecting"), 1, 2);
3683 3684
3684 purple_connection_set_display_name(gc, purple_account_get_username(account)); 3685 purple_connection_set_display_name(gc, purple_account_get_username(account));
3685 3686
3706 3707
3707 yahoo_picture_check(account); 3708 yahoo_picture_check(account);
3708 3709
3709 /* Get the pager server. Actually start connecting in the callback since we 3710 /* Get the pager server. Actually start connecting in the callback since we
3710 * must have the contents of the HTTP response to proceed. */ 3711 * must have the contents of the HTTP response to proceed. */
3711 url_data = purple_util_fetch_url_request_len_with_account( 3712 url_data = purple_util_fetch_url_request(
3712 proxy_ssl ? purple_connection_get_account(gc) : NULL, 3713 proxy_ssl ? purple_connection_get_account(gc) : NULL,
3713 yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : YAHOO_PAGER_HOST_REQ_URL, 3714 yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : YAHOO_PAGER_HOST_REQ_URL,
3714 use_whole_url ? TRUE : FALSE, 3715 use_whole_url ? TRUE : FALSE,
3715 YAHOO_CLIENT_USERAGENT, FALSE, NULL, FALSE, -1, 3716 YAHOO_CLIENT_USERAGENT, FALSE, NULL, FALSE, -1,
3716 yahoo_got_pager_server, yd); 3717 yahoo_got_pager_server, yd);
3719 3720
3720 return; 3721 return;
3721 } 3722 }
3722 3723
3723 void yahoo_close(PurpleConnection *gc) { 3724 void yahoo_close(PurpleConnection *gc) {
3724 YahooData *yd = (YahooData *)gc->proto_data; 3725 YahooData *yd = purple_connection_get_protocol_data(gc);
3725 GSList *l; 3726 GSList *l;
3726 3727
3727 if (gc->inpa) 3728 if (yd->inpa) {
3728 purple_input_remove(gc->inpa); 3729 purple_input_remove(yd->inpa);
3730 yd->inpa = 0;
3731 }
3729 3732
3730 while (yd->url_datas) { 3733 while (yd->url_datas) {
3731 purple_util_fetch_url_cancel(yd->url_datas->data); 3734 purple_util_fetch_url_cancel(yd->url_datas->data);
3732 yd->url_datas = g_slist_delete_link(yd->url_datas, yd->url_datas); 3735 yd->url_datas = g_slist_delete_link(yd->url_datas, yd->url_datas);
3733 } 3736 }
3808 yahoo_personal_details_reset(&yd->ypd, TRUE); 3811 yahoo_personal_details_reset(&yd->ypd, TRUE);
3809 3812
3810 g_free(yd->current_list15_grp); 3813 g_free(yd->current_list15_grp);
3811 3814
3812 g_free(yd); 3815 g_free(yd);
3813 gc->proto_data = NULL; 3816 purple_connection_set_protocol_data(gc, NULL);
3814 } 3817 }
3815 3818
3816 const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b) 3819 const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b)
3817 { 3820 {
3818 return "yahoo"; 3821 return "yahoo";
3825 YahooFriend *f; 3828 YahooFriend *f;
3826 PurplePresence *presence; 3829 PurplePresence *presence;
3827 3830
3828 if (!b || !(account = purple_buddy_get_account(b)) || 3831 if (!b || !(account = purple_buddy_get_account(b)) ||
3829 !(gc = purple_account_get_connection(account)) || 3832 !(gc = purple_account_get_connection(account)) ||
3830 !gc->proto_data) 3833 !purple_connection_get_protocol_data(gc))
3831 return NULL; 3834 return NULL;
3832 3835
3833 f = yahoo_friend_find(gc, purple_buddy_get_name(b)); 3836 f = yahoo_friend_find(gc, purple_buddy_get_name(b));
3834 if (!f) { 3837 if (!f) {
3835 return "not-authorized"; 3838 return "not-authorized";
3890 3893
3891 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 3894 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
3892 3895
3893 buddy = (PurpleBuddy *) node; 3896 buddy = (PurpleBuddy *) node;
3894 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 3897 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
3895 yd = gc->proto_data; 3898 yd = purple_connection_get_protocol_data(gc);
3896 id = yd->conf_id; 3899 id = yd->conf_id;
3897 3900
3898 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 3901 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
3899 g_hash_table_replace(components, g_strdup("room"), 3902 g_hash_table_replace(components, g_strdup("room"),
3900 g_strdup_printf("%s-%d", purple_connection_get_display_name(gc), id)); 3903 g_strdup_printf("%s-%d", purple_connection_get_display_name(gc), id));
4034 if (presence != NULL) 4037 if (presence != NULL)
4035 purple_notify_user_info_add_pair_plaintext(user_info, _("Presence"), presence); 4038 purple_notify_user_info_add_pair_plaintext(user_info, _("Presence"), presence);
4036 4039
4037 if (f && full) { 4040 if (f && full) {
4038 YahooPersonalDetails *ypd = &f->ypd; 4041 YahooPersonalDetails *ypd = &f->ypd;
4039 int i; 4042 if (ypd->phone.home && *ypd->phone.home)
4040 struct { 4043 purple_notify_user_info_add_pair_plaintext(user_info, _("Home Phone Number"), ypd->phone.home);
4041 char *id; 4044 if (ypd->phone.work && *ypd->phone.work)
4042 char *text; 4045 purple_notify_user_info_add_pair_plaintext(user_info, _("Work Phone Number"), ypd->phone.work);
4043 char *value; 4046 if (ypd->phone.mobile && *ypd->phone.mobile)
4044 } yfields[] = { 4047 purple_notify_user_info_add_pair_plaintext(user_info, _("Mobile Phone Number"), ypd->phone.mobile);
4045 {"hp", N_("Home Phone Number"), ypd->phone.home},
4046 {"wp", N_("Work Phone Number"), ypd->phone.work},
4047 {"mo", N_("Mobile Phone Number"), ypd->phone.mobile},
4048 {NULL, NULL, NULL}
4049 };
4050 for (i = 0; yfields[i].id; i++) {
4051 if (!yfields[i].value || !*yfields[i].value)
4052 continue;
4053 purple_notify_user_info_add_pair(user_info, _(yfields[i].text), yfields[i].value);
4054 }
4055 } 4048 }
4056 } 4049 }
4057 4050
4058 static void yahoo_addbuddyfrommenu_cb(PurpleBlistNode *node, gpointer data) 4051 static void yahoo_addbuddyfrommenu_cb(PurpleBlistNode *node, gpointer data)
4059 { 4052 {
4063 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 4056 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
4064 4057
4065 buddy = (PurpleBuddy *) node; 4058 buddy = (PurpleBuddy *) node;
4066 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 4059 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
4067 4060
4068 yahoo_add_buddy(gc, buddy, NULL); 4061 yahoo_add_buddy(gc, buddy, NULL, NULL);
4069 } 4062 }
4070 4063
4071 4064
4072 static void yahoo_chat_goto_menu(PurpleBlistNode *node, gpointer data) 4065 static void yahoo_chat_goto_menu(PurpleBlistNode *node, gpointer data)
4073 { 4066 {
4083 } 4076 }
4084 4077
4085 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { 4078 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) {
4086 GList *m = NULL; 4079 GList *m = NULL;
4087 PurpleMenuAction *act; 4080 PurpleMenuAction *act;
4088 YahooData *yd = (YahooData *) gc->proto_data; 4081 YahooData *yd = purple_connection_get_protocol_data(gc);
4089 4082
4090 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { 4083 if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
4091 if (f->presence != YAHOO_PRESENCE_ONLINE) { 4084 if (f->presence != YAHOO_PRESENCE_ONLINE) {
4092 act = purple_menu_action_new(_("Appear Online"), 4085 act = purple_menu_action_new(_("Appear Online"),
4093 PURPLE_CALLBACK(yahoo_presence_settings), 4086 PURPLE_CALLBACK(yahoo_presence_settings),
4143 { 4136 {
4144 GList *m = NULL; 4137 GList *m = NULL;
4145 PurpleMenuAction *act; 4138 PurpleMenuAction *act;
4146 4139
4147 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 4140 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
4148 YahooData *yd = gc->proto_data; 4141 YahooData *yd = purple_connection_get_protocol_data(gc);
4149 static char buf2[1024]; 4142 static char buf2[1024];
4150 YahooFriend *f; 4143 YahooFriend *f;
4151 4144
4152 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); 4145 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy));
4153 4146
4226 } 4219 }
4227 } 4220 }
4228 4221
4229 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) 4222 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields)
4230 { 4223 {
4231 YahooData *yd = gc->proto_data; 4224 YahooData *yd = purple_connection_get_protocol_data(gc);
4232 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; 4225 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")];
4233 4226
4234 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); 4227 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id);
4235 yahoo_packet_hash_str(pkt, 3, name); 4228 yahoo_packet_hash_str(pkt, 3, name);
4236 yahoo_packet_send_and_free(pkt, yd); 4229 yahoo_packet_send_and_free(pkt, yd);
4243 const gchar *token, size_t len, const gchar *error_message) 4236 const gchar *token, size_t len, const gchar *error_message)
4244 { 4237 {
4245 PurpleConnection *gc = user_data; 4238 PurpleConnection *gc = user_data;
4246 gboolean set_cookie = FALSE; 4239 gboolean set_cookie = FALSE;
4247 gchar *url; 4240 gchar *url;
4248 YahooData *yd = gc->proto_data; 4241 YahooData *yd = purple_connection_get_protocol_data(gc);
4249 4242
4250 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); 4243 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
4251 4244
4252 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 4245 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
4253 4246
4279 { 4272 {
4280 /* Setup a cookie that can be used by the browser */ 4273 /* Setup a cookie that can be used by the browser */
4281 /* XXX I have no idea how this will work with Yahoo! Japan. */ 4274 /* XXX I have no idea how this will work with Yahoo! Japan. */
4282 4275
4283 PurpleConnection *gc = action->context; 4276 PurpleConnection *gc = action->context;
4284 YahooData *yd = gc->proto_data; 4277 YahooData *yd = purple_connection_get_protocol_data(gc);
4285 4278
4286 PurpleUtilFetchUrlData *url_data; 4279 PurpleUtilFetchUrlData *url_data;
4287 const char* base_url = "http://login.yahoo.com"; 4280 const char* base_url = "http://login.yahoo.com";
4288 /* use whole URL if using HTTP Proxy */ 4281 /* use whole URL if using HTTP Proxy */
4289 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); 4282 gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
4294 "Host: login.yahoo.com\r\n" 4287 "Host: login.yahoo.com\r\n"
4295 "Content-Length: 0\r\n\r\n", 4288 "Content-Length: 0\r\n\r\n",
4296 use_whole_url ? base_url : "", 4289 use_whole_url ? base_url : "",
4297 yd->cookie_t, yd->cookie_y); 4290 yd->cookie_t, yd->cookie_y);
4298 4291
4299 url_data = purple_util_fetch_url_request_len_with_account( 4292 url_data = purple_util_fetch_url_request(
4300 purple_connection_get_account(gc), base_url, use_whole_url, 4293 purple_connection_get_account(gc), base_url, use_whole_url,
4301 YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1, 4294 YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1,
4302 yahoo_get_inbox_token_cb, gc); 4295 yahoo_get_inbox_token_cb, gc);
4303 4296
4304 g_free(request); 4297 g_free(request);
4393 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, 4386 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
4394 const gchar *webdata, size_t len, const gchar *error_message) 4387 const gchar *webdata, size_t len, const gchar *error_message)
4395 { 4388 {
4396 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; 4389 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data;
4397 PurpleConnection *gc = sms_cb_data->gc; 4390 PurpleConnection *gc = sms_cb_data->gc;
4398 YahooData *yd = gc->proto_data; 4391 YahooData *yd = purple_connection_get_protocol_data(gc);
4399 char *status = NULL; 4392 char *status = NULL;
4400 char *carrier = NULL; 4393 char *carrier = NULL;
4401 PurpleAccount *account = purple_connection_get_account(gc); 4394 PurpleAccount *account = purple_connection_get_account(gc);
4402 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); 4395 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account);
4403 4396
4448 } 4441 }
4449 } 4442 }
4450 4443
4451 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) 4444 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data)
4452 { 4445 {
4453 YahooData *yd = gc->proto_data; 4446 YahooData *yd = purple_connection_get_protocol_data(gc);
4454 PurpleUtilFetchUrlData *url_data; 4447 PurpleUtilFetchUrlData *url_data;
4455 struct yahoo_sms_carrier_cb_data *sms_cb_data; 4448 struct yahoo_sms_carrier_cb_data *sms_cb_data;
4456 char *validate_request_str = NULL; 4449 char *validate_request_str = NULL;
4457 char *request = NULL; 4450 char *request = NULL;
4458 gboolean use_whole_url = FALSE; 4451 gboolean use_whole_url = FALSE;
4483 "Content-Length: %" G_GSIZE_FORMAT "\r\n" 4476 "Content-Length: %" G_GSIZE_FORMAT "\r\n"
4484 "Cache-Control: no-cache\r\n\r\n%s", 4477 "Cache-Control: no-cache\r\n\r\n%s",
4485 YAHOO_CLIENT_VERSION, yd->cookie_t, yd->cookie_y, strlen(validate_request_str), validate_request_str); 4478 YAHOO_CLIENT_VERSION, yd->cookie_t, yd->cookie_y, strlen(validate_request_str), validate_request_str);
4486 4479
4487 /* use whole URL if using HTTP Proxy */ 4480 /* use whole URL if using HTTP Proxy */
4488 if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP)) 4481 if ((purple_account_get_proxy_info(purple_connection_get_account(gc))) && (purple_proxy_info_get_type(purple_account_get_proxy_info(purple_connection_get_account(gc))) == PURPLE_PROXY_HTTP))
4489 use_whole_url = TRUE; 4482 use_whole_url = TRUE;
4490 4483
4491 url_data = purple_util_fetch_url_request_len_with_account( 4484 url_data = purple_util_fetch_url_request(
4492 purple_connection_get_account(gc), YAHOO_SMS_CARRIER_URL, use_whole_url, 4485 purple_connection_get_account(gc), YAHOO_SMS_CARRIER_URL, use_whole_url,
4493 YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1, 4486 YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1,
4494 yahoo_get_sms_carrier_cb, data); 4487 yahoo_get_sms_carrier_cb, data);
4495 4488
4496 g_free(request); 4489 g_free(request);
4508 } 4501 }
4509 } 4502 }
4510 4503
4511 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) 4504 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags)
4512 { 4505 {
4513 YahooData *yd = gc->proto_data; 4506 YahooData *yd = purple_connection_get_protocol_data(gc);
4514 struct yahoo_packet *pkt = NULL; 4507 struct yahoo_packet *pkt = NULL;
4515 char *msg = yahoo_html_to_codes(what); 4508 char *msg = yahoo_html_to_codes(what);
4516 char *msg2; 4509 char *msg2;
4517 gboolean utf8 = TRUE; 4510 gboolean utf8 = TRUE;
4518 PurpleWhiteboard *wb; 4511 PurpleWhiteboard *wb;
4619 * just so that we don't inadvertantly reset their IMVironment back 4612 * just so that we don't inadvertantly reset their IMVironment back
4620 * to nothing. 4613 * to nothing.
4621 * 4614 *
4622 * If they have not set an IMVironment, then use the default. 4615 * If they have not set an IMVironment, then use the default.
4623 */ 4616 */
4624 wb = purple_whiteboard_get_session(gc->account, who); 4617 wb = purple_whiteboard_get_session(purple_connection_get_account(gc), who);
4625 if (wb) 4618 if (wb)
4626 yahoo_packet_hash_str(pkt, 63, DOODLE_IMV_KEY); 4619 yahoo_packet_hash_str(pkt, 63, DOODLE_IMV_KEY);
4627 else 4620 else
4628 { 4621 {
4629 const char *imv; 4622 const char *imv;
4665 return ret; 4658 return ret;
4666 } 4659 }
4667 4660
4668 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) 4661 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
4669 { 4662 {
4670 YahooData *yd = gc->proto_data; 4663 YahooData *yd = purple_connection_get_protocol_data(gc);
4671 struct yahoo_p2p_data *p2p_data; 4664 struct yahoo_p2p_data *p2p_data;
4672 YahooFederation fed = YAHOO_FEDERATION_NONE; 4665 YahooFederation fed = YAHOO_FEDERATION_NONE;
4673 struct yahoo_packet *pkt = NULL; 4666 struct yahoo_packet *pkt = NULL;
4674 4667
4675 fed = yahoo_get_federation_from_name(who); 4668 fed = yahoo_get_federation_from_name(who);
4736 if (!purple_status_is_active(status)) 4729 if (!purple_status_is_active(status))
4737 return; 4730 return;
4738 4731
4739 gc = purple_account_get_connection(account); 4732 gc = purple_account_get_connection(account);
4740 presence = purple_status_get_presence(status); 4733 presence = purple_status_get_presence(status);
4741 yd = (YahooData *)gc->proto_data; 4734 yd = purple_connection_get_protocol_data(gc);
4742 old_status = yd->current_status; 4735 old_status = yd->current_status;
4743 4736
4744 yd->current_status = get_yahoo_status_from_purple_status(status); 4737 yd->current_status = get_yahoo_status_from_purple_status(status);
4745 4738
4746 if (yd->current_status == YAHOO_STATUS_CUSTOM) 4739 if (yd->current_status == YAHOO_STATUS_CUSTOM)
4802 } 4795 }
4803 } 4796 }
4804 4797
4805 void yahoo_set_idle(PurpleConnection *gc, int idle) 4798 void yahoo_set_idle(PurpleConnection *gc, int idle)
4806 { 4799 {
4807 YahooData *yd = gc->proto_data; 4800 YahooData *yd = purple_connection_get_protocol_data(gc);
4808 struct yahoo_packet *pkt = NULL; 4801 struct yahoo_packet *pkt = NULL;
4809 char *msg = NULL, *msg2 = NULL; 4802 char *msg = NULL, *msg2 = NULL;
4810 PurpleStatus *status = NULL; 4803 PurpleStatus *status = NULL;
4811 gboolean invisible = FALSE; 4804 gboolean invisible = FALSE;
4812 4805
4921 } 4914 }
4922 4915
4923 void yahoo_keepalive(PurpleConnection *gc) 4916 void yahoo_keepalive(PurpleConnection *gc)
4924 { 4917 {
4925 struct yahoo_packet *pkt; 4918 struct yahoo_packet *pkt;
4926 YahooData *yd = gc->proto_data; 4919 YahooData *yd = purple_connection_get_protocol_data(gc);
4927 time_t now = time(NULL); 4920 time_t now = time(NULL);
4928 4921
4929 /* We're only allowed to send a ping once an hour or the servers will boot us */ 4922 /* We're only allowed to send a ping once an hour or the servers will boot us */
4930 if ((now - yd->last_ping) >= PING_TIMEOUT) { 4923 if ((now - yd->last_ping) >= PING_TIMEOUT) {
4931 yd->last_ping = now; 4924 yd->last_ping = now;
4952 yahoo_packet_send_and_free(pkt, yd); 4945 yahoo_packet_send_and_free(pkt, yd);
4953 } 4946 }
4954 4947
4955 } 4948 }
4956 4949
4957 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) 4950 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g, const char *message)
4958 { 4951 {
4959 YahooData *yd = (YahooData *)gc->proto_data; 4952 YahooData *yd = purple_connection_get_protocol_data(gc);
4960 struct yahoo_packet *pkt; 4953 struct yahoo_packet *pkt;
4961 const char *group = NULL; 4954 const char *group = NULL;
4962 char *group2; 4955 char *group2;
4963 const char *bname; 4956 const char *bname;
4964 const char *fed_bname; 4957 const char *fed_bname;
5017 g_free(group2); 5010 g_free(group2);
5018 } 5011 }
5019 5012
5020 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 5013 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
5021 { 5014 {
5022 YahooData *yd = (YahooData *)gc->proto_data; 5015 YahooData *yd = purple_connection_get_protocol_data(gc);
5023 struct yahoo_packet *pkt; 5016 struct yahoo_packet *pkt;
5024 GSList *buddies, *l; 5017 GSList *buddies, *l;
5025 PurpleGroup *g; 5018 PurpleGroup *g;
5026 gboolean remove = TRUE; 5019 gboolean remove = TRUE;
5027 char *cg; 5020 char *cg;
5073 yahoo_packet_send_and_free(pkt, yd); 5066 yahoo_packet_send_and_free(pkt, yd);
5074 g_free(cg); 5067 g_free(cg);
5075 } 5068 }
5076 5069
5077 void yahoo_add_deny(PurpleConnection *gc, const char *who) { 5070 void yahoo_add_deny(PurpleConnection *gc, const char *who) {
5078 YahooData *yd = (YahooData *)gc->proto_data; 5071 YahooData *yd = purple_connection_get_protocol_data(gc);
5079 struct yahoo_packet *pkt; 5072 struct yahoo_packet *pkt;
5080 YahooFederation fed = YAHOO_FEDERATION_NONE; 5073 YahooFederation fed = YAHOO_FEDERATION_NONE;
5081 5074
5082 if (!yd->logged_in) 5075 if (!yd->logged_in)
5083 return; 5076 return;
5096 5089
5097 yahoo_packet_send_and_free(pkt, yd); 5090 yahoo_packet_send_and_free(pkt, yd);
5098 } 5091 }
5099 5092
5100 void yahoo_rem_deny(PurpleConnection *gc, const char *who) { 5093 void yahoo_rem_deny(PurpleConnection *gc, const char *who) {
5101 YahooData *yd = (YahooData *)gc->proto_data; 5094 YahooData *yd = purple_connection_get_protocol_data(gc);
5102 struct yahoo_packet *pkt; 5095 struct yahoo_packet *pkt;
5103 YahooFederation fed = YAHOO_FEDERATION_NONE; 5096 YahooFederation fed = YAHOO_FEDERATION_NONE;
5104 5097
5105 if (!yd->logged_in) 5098 if (!yd->logged_in)
5106 return; 5099 return;
5124 PurpleAccount *account; 5117 PurpleAccount *account;
5125 GSList *deny; 5118 GSList *deny;
5126 5119
5127 account = purple_connection_get_account(gc); 5120 account = purple_connection_get_account(gc);
5128 5121
5129 switch (account->perm_deny) 5122 switch (purple_account_get_privacy_type(account))
5130 { 5123 {
5131 case PURPLE_PRIVACY_ALLOW_ALL: 5124 case PURPLE_PRIVACY_ALLOW_ALL:
5132 for (deny = account->deny; deny; deny = deny->next) 5125 for (deny = account->deny; deny; deny = deny->next)
5133 yahoo_rem_deny(gc, deny->data); 5126 yahoo_rem_deny(gc, deny->data);
5134 break; 5127 break;
5144 } 5137 }
5145 5138
5146 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, 5139 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who,
5147 const char *old_group, const char *new_group) 5140 const char *old_group, const char *new_group)
5148 { 5141 {
5149 YahooData *yd = gc->proto_data; 5142 YahooData *yd = purple_connection_get_protocol_data(gc);
5150 struct yahoo_packet *pkt; 5143 struct yahoo_packet *pkt;
5151 char *gpn, *gpo; 5144 char *gpn, *gpo;
5152 YahooFriend *f = yahoo_friend_find(gc, who); 5145 YahooFriend *f = yahoo_friend_find(gc, who);
5153 const char *temp = NULL; 5146 const char *temp = NULL;
5154 5147
5191 } 5184 }
5192 5185
5193 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, 5186 void yahoo_rename_group(PurpleConnection *gc, const char *old_name,
5194 PurpleGroup *group, GList *moved_buddies) 5187 PurpleGroup *group, GList *moved_buddies)
5195 { 5188 {
5196 YahooData *yd = gc->proto_data; 5189 YahooData *yd = purple_connection_get_protocol_data(gc);
5197 struct yahoo_packet *pkt; 5190 struct yahoo_packet *pkt;
5198 char *gpn, *gpo; 5191 char *gpn, *gpo;
5199 5192
5200 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL); 5193 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL);
5201 gpo = yahoo_string_encode(gc, old_name, NULL); 5194 gpo = yahoo_string_encode(gc, old_name, NULL);
5220 PurpleAccount *account = purple_conversation_get_account(c); 5213 PurpleAccount *account = purple_conversation_get_account(c);
5221 5214
5222 if (*args && args[0]) 5215 if (*args && args[0])
5223 return PURPLE_CMD_RET_FAILED; 5216 return PURPLE_CMD_RET_FAILED;
5224 5217
5225 purple_prpl_send_attention(account->gc, c->name, YAHOO_BUZZ); 5218 purple_prpl_send_attention(purple_account_get_connection(account), purple_conversation_get_name(c), YAHOO_BUZZ);
5226 5219
5227 return PURPLE_CMD_RET_OK; 5220 return PURPLE_CMD_RET_OK;
5228 } 5221 }
5229 5222
5230 PurpleCmdRet 5223 PurpleCmdRet
5235 PurpleConnection *gc; 5228 PurpleConnection *gc;
5236 5229
5237 if (!args || !args[0]) 5230 if (!args || !args[0])
5238 return PURPLE_CMD_RET_FAILED; 5231 return PURPLE_CMD_RET_FAILED;
5239 5232
5240 gc = purple_conversation_get_gc(conv); 5233 gc = purple_conversation_get_connection(conv);
5241 purple_debug_info("yahoo", "Trying to join %s \n", args[0]); 5234 purple_debug_info("yahoo", "Trying to join %s \n", args[0]);
5242 5235
5243 comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 5236 comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
5244 g_hash_table_replace(comp, g_strdup("room"), g_ascii_strdown(args[0], -1)); 5237 g_hash_table_replace(comp, g_strdup("room"), g_ascii_strdown(args[0], -1));
5245 g_hash_table_replace(comp, g_strdup("type"), g_strdup("Chat")); 5238 g_hash_table_replace(comp, g_strdup("type"), g_strdup("Chat"));
5269 gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type) 5262 gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type)
5270 { 5263 {
5271 PurpleConversation *c; 5264 PurpleConversation *c;
5272 5265
5273 c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, 5266 c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
5274 username, gc->account); 5267 username, purple_connection_get_account(gc));
5275 5268
5276 g_return_val_if_fail(c != NULL, FALSE); 5269 g_return_val_if_fail(c != NULL, FALSE);
5277 5270
5278 purple_debug_info("yahoo", "Sending <ding> on account %s to buddy %s.\n", 5271 purple_debug_info("yahoo", "Sending <ding> on account %s to buddy %s.\n",
5279 username, c->name); 5272 username, purple_conversation_get_name(c));
5280 purple_conv_im_send_with_flags(PURPLE_CONV_IM(c), "<ding>", PURPLE_MESSAGE_INVISIBLE); 5273 purple_conv_im_send_with_flags(PURPLE_CONV_IM(c), "<ding>", PURPLE_MESSAGE_INVISIBLE);
5281 5274
5282 return TRUE; 5275 return TRUE;
5283 } 5276 }
5284 5277