| 27766:7c7acc54590e | 27990:3de06f2e0daa |
|---|---|
| 454 g_free(tmpcookie); | 454 g_free(tmpcookie); |
| 455 | 455 |
| 456 return cookie; | 456 return cookie; |
| 457 } | 457 } |
| 458 | 458 |
| 459 static void yahoo_process_cookie(struct yahoo_data *yd, char *c) | 459 static void yahoo_process_cookie(YahooData *yd, char *c) |
| 460 { | 460 { |
| 461 if (c[0] == 'Y') { | 461 if (c[0] == 'Y') { |
| 462 if (yd->cookie_y) | 462 if (yd->cookie_y) |
| 463 g_free(yd->cookie_y); | 463 g_free(yd->cookie_y); |
| 464 yd->cookie_y = _getcookie(c); | 464 yd->cookie_y = _getcookie(c); |
| 474 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt) | 474 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 475 { | 475 { |
| 476 GSList *l = pkt->hash; | 476 GSList *l = pkt->hash; |
| 477 | 477 |
| 478 PurpleAccount *account = purple_connection_get_account(gc); | 478 PurpleAccount *account = purple_connection_get_account(gc); |
| 479 struct yahoo_data *yd = gc->proto_data; | 479 YahooData *yd = gc->proto_data; |
| 480 GHashTable *ht; | 480 GHashTable *ht; |
| 481 char *norm_bud = NULL; | 481 char *norm_bud = NULL; |
| 482 char *temp = NULL; | 482 char *temp = NULL; |
| 483 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */ | 483 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */ |
| 484 /* But what if you had no friends? */ | 484 /* But what if you had no friends? */ |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); | 578 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); |
| 579 | 579 |
| 580 /* The reporter of ticket #9745 determined that we weren't retrieving the | |
| 581 * aliases during buddy list retrieval, so we never updated aliases that | |
| 582 * changed while we were signed off. */ | |
| 583 yahoo_fetch_aliases(gc); | |
| 584 | |
| 580 /* Now that we have processed the buddy list, we can say yahoo has connected */ | 585 /* Now that we have processed the buddy list, we can say yahoo has connected */ |
| 581 purple_connection_set_display_name(gc, purple_normalize(account, purple_account_get_username(account))); | 586 purple_connection_set_display_name(gc, purple_normalize(account, purple_account_get_username(account))); |
| 587 yd->logged_in = TRUE; | |
| 588 purple_debug_info("yahoo","Authentication: Connection established\n"); | |
| 582 purple_connection_set_state(gc, PURPLE_CONNECTED); | 589 purple_connection_set_state(gc, PURPLE_CONNECTED); |
| 583 yd->logged_in = TRUE; | |
| 584 if (yd->picture_upload_todo) { | 590 if (yd->picture_upload_todo) { |
| 585 yahoo_buddy_icon_upload(gc, yd->picture_upload_todo); | 591 yahoo_buddy_icon_upload(gc, yd->picture_upload_todo); |
| 586 yd->picture_upload_todo = NULL; | 592 yd->picture_upload_todo = NULL; |
| 587 } | 593 } |
| 588 yahoo_set_status(account, purple_account_get_active_status(account)); | 594 yahoo_set_status(account, purple_account_get_active_status(account)); |
| 589 purple_debug_info("yahoo","Authentication: Connection established\n"); | |
| 590 | 595 |
| 591 g_hash_table_destroy(ht); | 596 g_hash_table_destroy(ht); |
| 592 g_free(norm_bud); | 597 g_free(norm_bud); |
| 593 g_free(temp); | 598 g_free(temp); |
| 594 } | 599 } |
| 600 gboolean got_serv_list = FALSE; | 605 gboolean got_serv_list = FALSE; |
| 601 PurpleBuddy *b; | 606 PurpleBuddy *b; |
| 602 PurpleGroup *g; | 607 PurpleGroup *g; |
| 603 YahooFriend *f = NULL; | 608 YahooFriend *f = NULL; |
| 604 PurpleAccount *account = purple_connection_get_account(gc); | 609 PurpleAccount *account = purple_connection_get_account(gc); |
| 605 struct yahoo_data *yd = gc->proto_data; | 610 YahooData *yd = gc->proto_data; |
| 606 GHashTable *ht; | 611 GHashTable *ht; |
| 607 | 612 |
| 608 char **lines; | 613 char **lines; |
| 609 char **split; | 614 char **split; |
| 610 char **buddies; | 615 char **buddies; |
| 747 char *stat = NULL; | 752 char *stat = NULL; |
| 748 char *game = NULL; | 753 char *game = NULL; |
| 749 YahooFriend *f = NULL; | 754 YahooFriend *f = NULL; |
| 750 GSList *l = pkt->hash; | 755 GSList *l = pkt->hash; |
| 751 gint val_11 = 0; | 756 gint val_11 = 0; |
| 752 struct yahoo_data *yd = gc->proto_data; | 757 YahooData *yd = gc->proto_data; |
| 753 gboolean msn = FALSE; | 758 gboolean msn = FALSE; |
| 754 | 759 |
| 755 account = purple_connection_get_account(gc); | 760 account = purple_connection_get_account(gc); |
| 756 | 761 |
| 757 while (l) { | 762 while (l) { |
| 842 static void yahoo_process_sms_message(PurpleConnection *gc, struct yahoo_packet *pkt) | 847 static void yahoo_process_sms_message(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 843 { | 848 { |
| 844 PurpleAccount *account; | 849 PurpleAccount *account; |
| 845 GSList *l = pkt->hash; | 850 GSList *l = pkt->hash; |
| 846 struct _yahoo_im *sms = NULL; | 851 struct _yahoo_im *sms = NULL; |
| 847 struct yahoo_data *yd; | 852 YahooData *yd; |
| 848 char *server_msg = NULL; | 853 char *server_msg = NULL; |
| 849 char *m; | 854 char *m; |
| 850 | 855 |
| 851 yd = gc->proto_data; | 856 yd = gc->proto_data; |
| 852 account = purple_connection_get_account(gc); | 857 account = purple_connection_get_account(gc); |
| 902 | 907 |
| 903 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */ | 908 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */ |
| 904 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type) | 909 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type) |
| 905 { | 910 { |
| 906 PurpleAccount *account; | 911 PurpleAccount *account; |
| 907 struct yahoo_data *yd = gc->proto_data; | 912 YahooData *yd = gc->proto_data; |
| 908 GSList *l = pkt->hash; | 913 GSList *l = pkt->hash; |
| 909 GSList *list = NULL; | 914 GSList *list = NULL; |
| 910 struct _yahoo_im *im = NULL; | 915 struct _yahoo_im *im = NULL; |
| 911 const char *imv = NULL; | 916 const char *imv = NULL; |
| 912 gint val_11 = 0; | 917 gint val_11 = 0; |
| 1137 static void | 1142 static void |
| 1138 yahoo_buddy_add_authorize_cb(gpointer data) | 1143 yahoo_buddy_add_authorize_cb(gpointer data) |
| 1139 { | 1144 { |
| 1140 struct yahoo_add_request *add_req = data; | 1145 struct yahoo_add_request *add_req = data; |
| 1141 struct yahoo_packet *pkt; | 1146 struct yahoo_packet *pkt; |
| 1142 struct yahoo_data *yd = add_req->gc->proto_data; | 1147 YahooData *yd = add_req->gc->proto_data; |
| 1143 const char *who = add_req->who; | 1148 const char *who = add_req->who; |
| 1144 | 1149 |
| 1145 if (add_req->protocol == 2) | 1150 if (add_req->protocol == 2) |
| 1146 who += 4; | 1151 who += 4; |
| 1147 | 1152 |
| 1148 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0); | 1153 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 1149 yahoo_packet_hash(pkt, "ssiii", | 1154 yahoo_packet_hash(pkt, "ssiii", |
| 1150 1, add_req->id, | 1155 1, add_req->id, |
| 1151 5, who, | 1156 5, who, |
| 1152 241, add_req->protocol, | 1157 241, add_req->protocol, |
| 1153 13, 1, | 1158 13, 1, |
| 1160 } | 1165 } |
| 1161 | 1166 |
| 1162 static void | 1167 static void |
| 1163 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) | 1168 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) |
| 1164 { | 1169 { |
| 1165 struct yahoo_data *yd = add_req->gc->proto_data; | 1170 YahooData *yd = add_req->gc->proto_data; |
| 1166 struct yahoo_packet *pkt; | 1171 struct yahoo_packet *pkt; |
| 1167 char *encoded_msg = NULL; | 1172 char *encoded_msg = NULL; |
| 1168 const char *who = add_req->who; | 1173 const char *who = add_req->who; |
| 1169 | 1174 |
| 1170 if (add_req->protocol == 2) | 1175 if (add_req->protocol == 2) |
| 1172 | 1177 |
| 1173 if (msg && *msg) | 1178 if (msg && *msg) |
| 1174 encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); | 1179 encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); |
| 1175 | 1180 |
| 1176 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, | 1181 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, |
| 1177 YAHOO_STATUS_AVAILABLE, 0); | 1182 YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 1178 | 1183 |
| 1179 yahoo_packet_hash(pkt, "ssiiiis", | 1184 yahoo_packet_hash(pkt, "ssiiiis", |
| 1180 1, add_req->id, | 1185 1, add_req->id, |
| 1181 5, who, | 1186 5, who, |
| 1182 241, add_req->protocol, | 1187 241, add_req->protocol, |
| 1212 } | 1217 } |
| 1213 | 1218 |
| 1214 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) | 1219 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) |
| 1215 { | 1220 { |
| 1216 char *notify_msg; | 1221 char *notify_msg; |
| 1217 struct yahoo_data *yd = gc->proto_data; | 1222 YahooData *yd = gc->proto_data; |
| 1218 | 1223 |
| 1219 if (who == NULL) | 1224 if (who == NULL) |
| 1220 return; | 1225 return; |
| 1221 | 1226 |
| 1222 if (reason != NULL) { | 1227 if (reason != NULL) { |
| 1519 } | 1524 } |
| 1520 | 1525 |
| 1521 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) | 1526 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 1522 { | 1527 { |
| 1523 PurpleAccount *account = purple_connection_get_account(gc); | 1528 PurpleAccount *account = purple_connection_get_account(gc); |
| 1524 struct yahoo_data *yd = gc->proto_data; | 1529 YahooData *yd = gc->proto_data; |
| 1525 const char *who = NULL; | 1530 const char *who = NULL; |
| 1526 const char *email = NULL; | 1531 const char *email = NULL; |
| 1527 const char *subj = NULL; | 1532 const char *subj = NULL; |
| 1528 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); | 1533 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); |
| 1529 int count = 0; | 1534 int count = 0; |
| 1603 *out = '\0'; | 1608 *out = '\0'; |
| 1604 } | 1609 } |
| 1605 | 1610 |
| 1606 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) | 1611 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) |
| 1607 { | 1612 { |
| 1608 struct yahoo_data *yd = gc->proto_data; | 1613 YahooData *yd = gc->proto_data; |
| 1609 PurpleAccount *account = purple_connection_get_account(gc); | 1614 PurpleAccount *account = purple_connection_get_account(gc); |
| 1610 const char *name = purple_normalize(account, purple_account_get_username(account)); | 1615 const char *name = purple_normalize(account, purple_account_get_username(account)); |
| 1611 PurpleCipher *md5_cipher; | 1616 PurpleCipher *md5_cipher; |
| 1612 PurpleCipherContext *md5_ctx; | 1617 PurpleCipherContext *md5_ctx; |
| 1613 guchar md5_digest[16]; | 1618 guchar md5_digest[16]; |
| 1623 | 1628 |
| 1624 to_y64(base64_string, md5_digest, 16); | 1629 to_y64(base64_string, md5_digest, 16); |
| 1625 | 1630 |
| 1626 purple_debug_info("yahoo", "yahoo status: %d\n", yd->current_status); | 1631 purple_debug_info("yahoo", "yahoo status: %d\n", yd->current_status); |
| 1627 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, yd->session_id); | 1632 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, yd->session_id); |
| 1628 if(yd->jp) { | 1633 |
| 1629 yahoo_packet_hash(pkt, "ssssssss", | 1634 yahoo_packet_hash(pkt, "sssssssss", |
| 1630 1, name, | 1635 1, name, |
| 1631 0, name, | 1636 0, name, |
| 1632 277, yd->cookie_y, | 1637 277, yd->cookie_y, |
| 1633 278, yd->cookie_t, | 1638 278, yd->cookie_t, |
| 1634 307, base64_string, | 1639 307, base64_string, |
| 1635 2, name, | 1640 244, yd->jp ? YAHOOJP_CLIENT_VERSION_ID : YAHOO_CLIENT_VERSION_ID, |
| 1636 2, "1", | 1641 2, name, |
| 1637 135, YAHOOJP_CLIENT_VERSION); | 1642 2, "1", |
| 1638 } else { | 1643 135, yd->jp ? YAHOOJP_CLIENT_VERSION : YAHOO_CLIENT_VERSION); |
| 1639 yahoo_packet_hash(pkt, "sssssssss", | 1644 |
| 1640 1, name, | |
| 1641 0, name, | |
| 1642 277, yd->cookie_y, | |
| 1643 278, yd->cookie_t, | |
| 1644 307, base64_string, | |
| 1645 244, YAHOO_CLIENT_VERSION_ID, | |
| 1646 2, name, | |
| 1647 2, "1", | |
| 1648 135, YAHOO_CLIENT_VERSION); | |
| 1649 } | |
| 1650 if (yd->picture_checksum) | 1645 if (yd->picture_checksum) |
| 1651 yahoo_packet_hash_int(pkt, 192, yd->picture_checksum); | 1646 yahoo_packet_hash_int(pkt, 192, yd->picture_checksum); |
| 1652 yahoo_packet_send_and_free(pkt, yd); | 1647 yahoo_packet_send_and_free(pkt, yd); |
| 1653 | 1648 |
| 1654 purple_cipher_context_destroy(md5_ctx); | 1649 purple_cipher_context_destroy(md5_ctx); |
| 1656 | 1651 |
| 1657 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message) | 1652 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message) |
| 1658 { | 1653 { |
| 1659 struct yahoo_auth_data *auth_data = user_data; | 1654 struct yahoo_auth_data *auth_data = user_data; |
| 1660 PurpleConnection *gc = auth_data->gc; | 1655 PurpleConnection *gc = auth_data->gc; |
| 1661 struct yahoo_data *yd; | 1656 YahooData *yd; |
| 1662 gboolean try_login_on_error = FALSE; | 1657 gboolean try_login_on_error = FALSE; |
| 1663 | 1658 |
| 1664 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n"); | 1659 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n"); |
| 1665 | 1660 |
| 1666 if (!PURPLE_CONNECTION_IS_VALID(gc)) { | 1661 if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 1667 g_free(auth_data->seed); | 1662 g_free(auth_data->seed); |
| 1668 g_free(auth_data); | 1663 g_free(auth_data); |
| 1669 g_return_if_reached(); | 1664 g_return_if_reached(); |
| 1670 } | 1665 } |
| 1671 | 1666 |
| 1672 yd = (struct yahoo_data *)gc->proto_data; | 1667 yd = (YahooData *)gc->proto_data; |
| 1673 | 1668 |
| 1674 if (error_message != NULL) { | 1669 if (error_message != NULL) { |
| 1675 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); | 1670 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); |
| 1676 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); | 1671 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); |
| 1677 g_free(auth_data->seed); | 1672 g_free(auth_data->seed); |
| 1825 error_reason = g_strdup(_("Username or password missing")); | 1820 error_reason = g_strdup(_("Username or password missing")); |
| 1826 error = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; | 1821 error = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
| 1827 break; | 1822 break; |
| 1828 default: | 1823 default: |
| 1829 /* Unknown error! */ | 1824 /* Unknown error! */ |
| 1830 error_reason = g_strdup(_("Unknown error")); | 1825 error_reason = g_strdup_printf(_("Unknown error (%d)"), response_no); |
| 1831 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR; | 1826 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR; |
| 1832 break; | 1827 break; |
| 1833 } | 1828 } |
| 1834 purple_debug_error("yahoo", "Authentication error: %s. Code %d\n", | 1829 purple_debug_error("yahoo", "Authentication error: %s. Code %d\n", |
| 1835 error_reason, response_no); | 1830 error_reason, response_no); |
| 2031 } | 2026 } |
| 2032 | 2027 |
| 2033 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) | 2028 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2034 { | 2029 { |
| 2035 #ifdef TRY_WEBMESSENGER_LOGIN | 2030 #ifdef TRY_WEBMESSENGER_LOGIN |
| 2036 struct yahoo_data *yd = gc->proto_data; | 2031 YahooData *yd = gc->proto_data; |
| 2037 #endif /* TRY_WEBMESSENGER_LOGIN */ | 2032 #endif /* TRY_WEBMESSENGER_LOGIN */ |
| 2038 GSList *l = pkt->hash; | 2033 GSList *l = pkt->hash; |
| 2039 int err = 0; | 2034 int err = 0; |
| 2040 char *msg; | 2035 char *msg; |
| 2041 char *url = NULL; | 2036 char *url = NULL; |
| 2087 break; | 2082 break; |
| 2088 case 14: | 2083 case 14: |
| 2089 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); | 2084 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); |
| 2090 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; | 2085 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
| 2091 break; | 2086 break; |
| 2087 case 1013: | |
| 2088 msg = g_strdup(_("Invalid username")); | |
| 2089 reason = PURPLE_CONNECTION_ERROR_INVALID_USERNAME; | |
| 2090 break; | |
| 2092 default: | 2091 default: |
| 2093 msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); | 2092 msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); |
| 2094 } | 2093 } |
| 2095 | 2094 |
| 2096 if (url) | 2095 if (url) |
| 2111 char *group = NULL; | 2110 char *group = NULL; |
| 2112 char *decoded_group; | 2111 char *decoded_group; |
| 2113 char *buf; | 2112 char *buf; |
| 2114 YahooFriend *f; | 2113 YahooFriend *f; |
| 2115 GSList *l = pkt->hash; | 2114 GSList *l = pkt->hash; |
| 2116 struct yahoo_data *yd = gc->proto_data; | 2115 YahooData *yd = gc->proto_data; |
| 2117 int protocol = 0; | 2116 int protocol = 0; |
| 2118 gboolean msn = FALSE; | 2117 gboolean msn = FALSE; |
| 2119 | 2118 |
| 2120 while (l) { | 2119 while (l) { |
| 2121 struct yahoo_pair *pair = l->data; | 2120 struct yahoo_pair *pair = l->data; |
| 2198 { | 2197 { |
| 2199 struct yahoo_p2p_data *p2p_data = value; | 2198 struct yahoo_p2p_data *p2p_data = value; |
| 2200 PurpleConnection *gc = user_data; | 2199 PurpleConnection *gc = user_data; |
| 2201 struct yahoo_packet *pkt_to_send; | 2200 struct yahoo_packet *pkt_to_send; |
| 2202 PurpleAccount *account; | 2201 PurpleAccount *account; |
| 2203 struct yahoo_data *yd = gc->proto_data; | 2202 YahooData *yd = gc->proto_data; |
| 2204 | 2203 |
| 2205 account = purple_connection_get_account(gc); | 2204 account = purple_connection_get_account(gc); |
| 2206 | 2205 |
| 2207 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); | 2206 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 2208 yahoo_packet_hash(pkt_to_send, "ssisi", | 2207 yahoo_packet_hash(pkt_to_send, "ssisi", |
| 2217 } | 2216 } |
| 2218 | 2217 |
| 2219 static gboolean yahoo_p2p_keepalive(gpointer data) | 2218 static gboolean yahoo_p2p_keepalive(gpointer data) |
| 2220 { | 2219 { |
| 2221 PurpleConnection *gc = data; | 2220 PurpleConnection *gc = data; |
| 2222 struct yahoo_data *yd = gc->proto_data; | 2221 YahooData *yd = gc->proto_data; |
| 2223 | 2222 |
| 2224 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); | 2223 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); |
| 2225 | 2224 |
| 2226 return TRUE; | 2225 return TRUE; |
| 2227 } | 2226 } |
| 2258 char *who = NULL; | 2257 char *who = NULL; |
| 2259 GSList *l = pkt->hash; | 2258 GSList *l = pkt->hash; |
| 2260 struct yahoo_packet *pkt_to_send; | 2259 struct yahoo_packet *pkt_to_send; |
| 2261 PurpleAccount *account; | 2260 PurpleAccount *account; |
| 2262 int val_13_to_send = 0; | 2261 int val_13_to_send = 0; |
| 2263 struct yahoo_data *yd; | 2262 YahooData *yd; |
| 2264 YahooFriend *f; | 2263 YahooFriend *f; |
| 2265 | 2264 |
| 2266 if(!(p2p_data = data)) | 2265 if(!(p2p_data = data)) |
| 2267 return ; | 2266 return ; |
| 2268 | 2267 |
| 2345 int pos = 0; | 2344 int pos = 0; |
| 2346 int pktlen; | 2345 int pktlen; |
| 2347 struct yahoo_packet *pkt; | 2346 struct yahoo_packet *pkt; |
| 2348 guchar *start = NULL; | 2347 guchar *start = NULL; |
| 2349 struct yahoo_p2p_data *p2p_data; | 2348 struct yahoo_p2p_data *p2p_data; |
| 2350 struct yahoo_data *yd; | 2349 YahooData *yd; |
| 2351 | 2350 |
| 2352 if(!(p2p_data = data)) | 2351 if(!(p2p_data = data)) |
| 2353 return ; | 2352 return ; |
| 2354 yd = p2p_data->gc->proto_data; | 2353 yd = p2p_data->gc->proto_data; |
| 2355 | 2354 |
| 2417 | 2416 |
| 2418 static void yahoo_p2p_server_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond) | 2417 static void yahoo_p2p_server_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond) |
| 2419 { | 2418 { |
| 2420 int acceptfd; | 2419 int acceptfd; |
| 2421 struct yahoo_p2p_data *p2p_data; | 2420 struct yahoo_p2p_data *p2p_data; |
| 2422 struct yahoo_data *yd; | 2421 YahooData *yd; |
| 2423 | 2422 |
| 2424 if(!(p2p_data = data)) | 2423 if(!(p2p_data = data)) |
| 2425 return ; | 2424 return ; |
| 2426 yd = p2p_data->gc->proto_data; | 2425 yd = p2p_data->gc->proto_data; |
| 2427 | 2426 |
| 2456 } | 2455 } |
| 2457 | 2456 |
| 2458 static gboolean yahoo_cancel_p2p_server_listen_cb(gpointer data) | 2457 static gboolean yahoo_cancel_p2p_server_listen_cb(gpointer data) |
| 2459 { | 2458 { |
| 2460 struct yahoo_p2p_data *p2p_data; | 2459 struct yahoo_p2p_data *p2p_data; |
| 2461 struct yahoo_data *yd; | 2460 YahooData *yd; |
| 2462 | 2461 |
| 2463 if(!(p2p_data = data)) | 2462 if(!(p2p_data = data)) |
| 2464 return FALSE; | 2463 return FALSE; |
| 2465 | 2464 |
| 2466 yd = p2p_data->gc->proto_data; | 2465 yd = p2p_data->gc->proto_data; |
| 2477 } | 2476 } |
| 2478 | 2477 |
| 2479 static void yahoo_p2p_server_listen_cb(int listenfd, gpointer data) | 2478 static void yahoo_p2p_server_listen_cb(int listenfd, gpointer data) |
| 2480 { | 2479 { |
| 2481 struct yahoo_p2p_data *p2p_data; | 2480 struct yahoo_p2p_data *p2p_data; |
| 2482 struct yahoo_data *yd; | 2481 YahooData *yd; |
| 2483 | 2482 |
| 2484 if(!(p2p_data = data)) | 2483 if(!(p2p_data = data)) |
| 2485 return ; | 2484 return ; |
| 2486 | 2485 |
| 2487 if(listenfd == -1) { | 2486 if(listenfd == -1) { |
| 2509 char temp_str[100]; | 2508 char temp_str[100]; |
| 2510 gchar *base64_ip = NULL; | 2509 gchar *base64_ip = NULL; |
| 2511 YahooFriend *f; | 2510 YahooFriend *f; |
| 2512 struct yahoo_packet *pkt; | 2511 struct yahoo_packet *pkt; |
| 2513 PurpleAccount *account; | 2512 PurpleAccount *account; |
| 2514 struct yahoo_data *yd = gc->proto_data; | 2513 YahooData *yd = gc->proto_data; |
| 2515 struct yahoo_p2p_data *p2p_data; | 2514 struct yahoo_p2p_data *p2p_data; |
| 2516 | 2515 |
| 2517 f = yahoo_friend_find(gc, who); | 2516 f = yahoo_friend_find(gc, who); |
| 2518 account = purple_connection_get_account(gc); | 2517 account = purple_connection_get_account(gc); |
| 2519 | 2518 |
| 2577 static void yahoo_p2p_init_cb(gpointer data, gint source, const gchar *error_message) | 2576 static void yahoo_p2p_init_cb(gpointer data, gint source, const gchar *error_message) |
| 2578 { | 2577 { |
| 2579 struct yahoo_p2p_data *p2p_data; | 2578 struct yahoo_p2p_data *p2p_data; |
| 2580 struct yahoo_packet *pkt_to_send; | 2579 struct yahoo_packet *pkt_to_send; |
| 2581 PurpleAccount *account; | 2580 PurpleAccount *account; |
| 2582 struct yahoo_data *yd; | 2581 YahooData *yd; |
| 2583 | 2582 |
| 2584 if(!(p2p_data = data)) | 2583 if(!(p2p_data = data)) |
| 2585 return ; | 2584 return ; |
| 2586 yd = p2p_data->gc->proto_data; | 2585 yd = p2p_data->gc->proto_data; |
| 2587 | 2586 |
| 2898 yahoo_process_avatar_update(gc, pkt); | 2897 yahoo_process_avatar_update(gc, pkt); |
| 2899 break; | 2898 break; |
| 2900 case YAHOO_SERVICE_AUDIBLE: | 2899 case YAHOO_SERVICE_AUDIBLE: |
| 2901 yahoo_process_audible(gc, pkt); | 2900 yahoo_process_audible(gc, pkt); |
| 2902 break; | 2901 break; |
| 2902 case YAHOO_SERVICE_CONTACT_DETAILS: | |
| 2903 yahoo_process_contact_details(gc, pkt); | |
| 2904 break; | |
| 2903 case YAHOO_SERVICE_FILETRANS_15: | 2905 case YAHOO_SERVICE_FILETRANS_15: |
| 2904 yahoo_process_filetrans_15(gc, pkt); | 2906 yahoo_process_filetrans_15(gc, pkt); |
| 2905 break; | 2907 break; |
| 2906 case YAHOO_SERVICE_FILETRANS_INFO_15: | 2908 case YAHOO_SERVICE_FILETRANS_INFO_15: |
| 2907 yahoo_process_filetrans_info_15(gc, pkt); | 2909 yahoo_process_filetrans_info_15(gc, pkt); |
| 2920 } | 2922 } |
| 2921 | 2923 |
| 2922 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) | 2924 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) |
| 2923 { | 2925 { |
| 2924 PurpleConnection *gc = data; | 2926 PurpleConnection *gc = data; |
| 2925 struct yahoo_data *yd = gc->proto_data; | 2927 YahooData *yd = gc->proto_data; |
| 2926 char buf[1024]; | 2928 char buf[1024]; |
| 2927 int len; | 2929 int len; |
| 2928 | 2930 |
| 2929 len = read(yd->fd, buf, sizeof(buf)); | 2931 len = read(yd->fd, buf, sizeof(buf)); |
| 2930 | 2932 |
| 3017 } | 3019 } |
| 3018 | 3020 |
| 3019 static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message) | 3021 static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message) |
| 3020 { | 3022 { |
| 3021 PurpleConnection *gc = data; | 3023 PurpleConnection *gc = data; |
| 3022 struct yahoo_data *yd; | 3024 YahooData *yd; |
| 3023 struct yahoo_packet *pkt; | 3025 struct yahoo_packet *pkt; |
| 3024 | 3026 |
| 3025 if (source < 0) { | 3027 if (source < 0) { |
| 3026 gchar *tmp; | 3028 gchar *tmp; |
| 3027 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); | 3029 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); |
| 3031 } | 3033 } |
| 3032 | 3034 |
| 3033 yd = gc->proto_data; | 3035 yd = gc->proto_data; |
| 3034 yd->fd = source; | 3036 yd->fd = source; |
| 3035 | 3037 |
| 3036 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, 0); | 3038 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id); |
| 3037 | 3039 |
| 3038 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); | 3040 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); |
| 3039 yahoo_packet_send_and_free(pkt, yd); | 3041 yahoo_packet_send_and_free(pkt, yd); |
| 3040 | 3042 |
| 3041 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); | 3043 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); |
| 3043 | 3045 |
| 3044 #ifdef TRY_WEBMESSENGER_LOGIN | 3046 #ifdef TRY_WEBMESSENGER_LOGIN |
| 3045 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message) | 3047 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message) |
| 3046 { | 3048 { |
| 3047 PurpleConnection *gc = data; | 3049 PurpleConnection *gc = data; |
| 3048 struct yahoo_data *yd; | 3050 YahooData *yd; |
| 3049 struct yahoo_packet *pkt; | 3051 struct yahoo_packet *pkt; |
| 3050 | 3052 |
| 3051 if (source < 0) { | 3053 if (source < 0) { |
| 3052 gchar *tmp; | 3054 gchar *tmp; |
| 3053 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); | 3055 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); |
| 3057 } | 3059 } |
| 3058 | 3060 |
| 3059 yd = gc->proto_data; | 3061 yd = gc->proto_data; |
| 3060 yd->fd = source; | 3062 yd->fd = source; |
| 3061 | 3063 |
| 3062 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | 3064 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id); |
| 3063 | 3065 |
| 3064 yahoo_packet_hash(pkt, "sss", 0, | 3066 yahoo_packet_hash(pkt, "sss", 0, |
| 3065 purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), | 3067 purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), |
| 3066 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), | 3068 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), |
| 3067 6, yd->auth); | 3069 6, yd->auth); |
| 3073 | 3075 |
| 3074 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) | 3076 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) |
| 3075 { | 3077 { |
| 3076 PurpleConnection *gc = data; | 3078 PurpleConnection *gc = data; |
| 3077 PurpleAccount *account = purple_connection_get_account(gc); | 3079 PurpleAccount *account = purple_connection_get_account(gc); |
| 3078 struct yahoo_data *yd = gc->proto_data; | 3080 YahooData *yd = gc->proto_data; |
| 3079 char bufread[2048], *i = bufread, *buf = bufread; | 3081 char bufread[2048], *i = bufread, *buf = bufread; |
| 3080 int len; | 3082 int len; |
| 3081 GString *s; | 3083 GString *s; |
| 3082 | 3084 |
| 3083 len = read(source, bufread, sizeof(bufread) - 1); | 3085 len = read(source, bufread, sizeof(bufread) - 1); |
| 3148 } | 3150 } |
| 3149 | 3151 |
| 3150 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) | 3152 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) |
| 3151 { | 3153 { |
| 3152 PurpleConnection *gc; | 3154 PurpleConnection *gc; |
| 3153 struct yahoo_data *yd; | 3155 YahooData *yd; |
| 3154 int written, remaining; | 3156 int written, remaining; |
| 3155 | 3157 |
| 3156 gc = data; | 3158 gc = data; |
| 3157 yd = gc->proto_data; | 3159 yd = gc->proto_data; |
| 3158 | 3160 |
| 3262 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, | 3264 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
| 3263 const gchar *url_text, size_t len, const gchar *error_message) | 3265 const gchar *url_text, size_t len, const gchar *error_message) |
| 3264 { | 3266 { |
| 3265 PurpleConnection *gc = (PurpleConnection *)user_data; | 3267 PurpleConnection *gc = (PurpleConnection *)user_data; |
| 3266 PurpleAccount *account = purple_connection_get_account(gc); | 3268 PurpleAccount *account = purple_connection_get_account(gc); |
| 3267 struct yahoo_data *yd = gc->proto_data; | 3269 YahooData *yd = gc->proto_data; |
| 3268 const char *sn = purple_account_get_username(account); | 3270 const char *sn = purple_account_get_username(account); |
| 3269 const char *pass = purple_connection_get_password(gc); | 3271 const char *pass = purple_connection_get_password(gc); |
| 3270 GHashTable *hash = yahoo_login_page_hash(url_text, len); | 3272 GHashTable *hash = yahoo_login_page_hash(url_text, len); |
| 3271 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); | 3273 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); |
| 3272 char md5[33], *hashp = md5, *chal; | 3274 char md5[33], *hashp = md5, *chal; |
| 3403 } | 3405 } |
| 3404 } | 3406 } |
| 3405 | 3407 |
| 3406 void yahoo_login(PurpleAccount *account) { | 3408 void yahoo_login(PurpleAccount *account) { |
| 3407 PurpleConnection *gc = purple_account_get_connection(account); | 3409 PurpleConnection *gc = purple_account_get_connection(account); |
| 3408 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); | 3410 YahooData *yd = gc->proto_data = g_new0(YahooData, 1); |
| 3409 PurpleStatus *status = purple_account_get_active_status(account); | 3411 PurpleStatus *status = purple_account_get_active_status(account); |
| 3412 const char *server = NULL; | |
| 3413 int pager_port = 0; | |
| 3414 | |
| 3410 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; | 3415 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; |
| 3411 | 3416 |
| 3412 purple_connection_update_progress(gc, _("Connecting"), 1, 2); | 3417 purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
| 3413 | 3418 |
| 3414 purple_connection_set_display_name(gc, purple_account_get_username(account)); | 3419 purple_connection_set_display_name(gc, purple_account_get_username(account)); |
| 3415 | 3420 |
| 3421 yd->gc = gc; | |
| 3416 yd->yahoo_local_p2p_server_fd = -1; | 3422 yd->yahoo_local_p2p_server_fd = -1; |
| 3417 yd->fd = -1; | 3423 yd->fd = -1; |
| 3418 yd->txhandler = 0; | 3424 yd->txhandler = 0; |
| 3419 /* TODO: Is there a good grow size for the buffer? */ | 3425 /* TODO: Is there a good grow size for the buffer? */ |
| 3420 yd->txbuf = purple_circ_buffer_new(0); | 3426 yd->txbuf = purple_circ_buffer_new(0); |
| 3421 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); | 3427 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
| 3422 yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 3428 yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 3423 yd->xfer_peer_idstring_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | 3429 yd->xfer_peer_idstring_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); |
| 3424 yd->peers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_p2p_disconnect_destroy_data); | 3430 yd->peers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 3431 yahoo_p2p_disconnect_destroy_data); | |
| 3425 yd->sms_carrier = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 3432 yd->sms_carrier = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 3426 yd->yahoo_p2p_timer = purple_timeout_add_seconds(YAHOO_P2P_KEEPALIVE_SECS, yahoo_p2p_keepalive, gc); | 3433 yd->yahoo_p2p_timer = purple_timeout_add_seconds(YAHOO_P2P_KEEPALIVE_SECS, |
| 3434 yahoo_p2p_keepalive, gc); | |
| 3427 yd->confs = NULL; | 3435 yd->confs = NULL; |
| 3428 yd->conf_id = 2; | 3436 yd->conf_id = 2; |
| 3429 yd->last_keepalive = yd->last_ping = time(NULL); | 3437 yd->last_keepalive = yd->last_ping = time(NULL); |
| 3430 | 3438 |
| 3431 yd->current_status = get_yahoo_status_from_purple_status(status); | 3439 yd->current_status = get_yahoo_status_from_purple_status(status); |
| 3440 yd->jp = yahoo_is_japan(account); | |
| 3432 | 3441 |
| 3433 yahoo_server_check(account); | 3442 yahoo_server_check(account); |
| 3434 yahoo_picture_check(account); | 3443 yahoo_picture_check(account); |
| 3435 | 3444 |
| 3436 if (yahoo_is_japan(account)) { | 3445 server = purple_account_get_string(account, "server", |
| 3437 yd->jp = TRUE; | 3446 yd->jp ? YAHOOJP_PAGER_HOST : YAHOO_PAGER_HOST); |
| 3438 if (purple_proxy_connect(gc, account, | 3447 pager_port = purple_account_get_int(account, "port", YAHOO_PAGER_PORT); |
| 3439 purple_account_get_string(account, "server", YAHOOJP_PAGER_HOST), | 3448 |
| 3440 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), | 3449 if (purple_proxy_connect(gc, account, server, pager_port, yahoo_got_connected, gc) == NULL) |
| 3441 yahoo_got_connected, gc) == NULL) | 3450 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 3442 { | 3451 _("Unable to connect")); |
| 3443 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 3452 |
| 3444 _("Unable to connect")); | 3453 return; |
| 3445 return; | |
| 3446 } | |
| 3447 } else { | |
| 3448 yd->jp = FALSE; | |
| 3449 if (purple_proxy_connect(gc, account, | |
| 3450 purple_account_get_string(account, "server", YAHOO_PAGER_HOST), | |
| 3451 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
| 3452 yahoo_got_connected, gc) == NULL) | |
| 3453 { | |
| 3454 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
| 3455 _("Unable to connect")); | |
| 3456 return; | |
| 3457 } | |
| 3458 } | |
| 3459 } | 3454 } |
| 3460 | 3455 |
| 3461 void yahoo_close(PurpleConnection *gc) { | 3456 void yahoo_close(PurpleConnection *gc) { |
| 3462 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 3457 YahooData *yd = (YahooData *)gc->proto_data; |
| 3463 GSList *l; | 3458 GSList *l; |
| 3464 | 3459 |
| 3465 if (gc->inpa) | 3460 if (gc->inpa) |
| 3466 purple_input_remove(gc->inpa); | 3461 purple_input_remove(gc->inpa); |
| 3467 | 3462 |
| 3538 g_free(yd->pending_chat_id); | 3533 g_free(yd->pending_chat_id); |
| 3539 g_free(yd->pending_chat_topic); | 3534 g_free(yd->pending_chat_topic); |
| 3540 g_free(yd->pending_chat_goto); | 3535 g_free(yd->pending_chat_goto); |
| 3541 g_strfreev(yd->profiles); | 3536 g_strfreev(yd->profiles); |
| 3542 | 3537 |
| 3543 yahoo_personal_details_reset(&yd->ypd); | 3538 yahoo_personal_details_reset(&yd->ypd, TRUE); |
| 3544 | 3539 |
| 3545 g_free(yd->current_list15_grp); | 3540 g_free(yd->current_list15_grp); |
| 3546 | 3541 |
| 3547 g_free(yd); | 3542 g_free(yd); |
| 3548 gc->proto_data = NULL; | 3543 gc->proto_data = NULL; |
| 3555 | 3550 |
| 3556 const char *yahoo_list_emblem(PurpleBuddy *b) | 3551 const char *yahoo_list_emblem(PurpleBuddy *b) |
| 3557 { | 3552 { |
| 3558 PurpleAccount *account; | 3553 PurpleAccount *account; |
| 3559 PurpleConnection *gc; | 3554 PurpleConnection *gc; |
| 3560 struct yahoo_data *yd; | 3555 YahooData *yd; |
| 3561 YahooFriend *f; | 3556 YahooFriend *f; |
| 3562 PurplePresence *presence; | 3557 PurplePresence *presence; |
| 3563 | 3558 |
| 3564 if (!b || !(account = purple_buddy_get_account(b)) || | 3559 if (!b || !(account = purple_buddy_get_account(b)) || |
| 3565 !(gc = purple_account_get_connection(account)) || | 3560 !(gc = purple_account_get_connection(account)) || |
| 3618 | 3613 |
| 3619 PurpleBuddy *buddy; | 3614 PurpleBuddy *buddy; |
| 3620 PurpleConnection *gc; | 3615 PurpleConnection *gc; |
| 3621 | 3616 |
| 3622 GHashTable *components; | 3617 GHashTable *components; |
| 3623 struct yahoo_data *yd; | 3618 YahooData *yd; |
| 3624 int id; | 3619 int id; |
| 3625 | 3620 |
| 3626 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 3621 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 3627 | 3622 |
| 3628 buddy = (PurpleBuddy *) node; | 3623 buddy = (PurpleBuddy *) node; |
| 3655 static void yahoo_game(PurpleBlistNode *node, gpointer data) { | 3650 static void yahoo_game(PurpleBlistNode *node, gpointer data) { |
| 3656 | 3651 |
| 3657 PurpleBuddy *buddy; | 3652 PurpleBuddy *buddy; |
| 3658 PurpleConnection *gc; | 3653 PurpleConnection *gc; |
| 3659 | 3654 |
| 3660 struct yahoo_data *yd; | 3655 YahooData *yd; |
| 3661 const char *game; | 3656 const char *game; |
| 3662 char *game2; | 3657 char *game2; |
| 3663 char *t; | 3658 char *t; |
| 3664 char url[256]; | 3659 char url[256]; |
| 3665 YahooFriend *f; | 3660 YahooFriend *f; |
| 3666 | 3661 |
| 3667 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 3662 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 3668 | 3663 |
| 3669 buddy = (PurpleBuddy *) node; | 3664 buddy = (PurpleBuddy *) node; |
| 3670 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 3665 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 3671 yd = (struct yahoo_data *) gc->proto_data; | 3666 yd = (YahooData *) gc->proto_data; |
| 3672 | 3667 |
| 3673 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); | 3668 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); |
| 3674 if (!f) | 3669 if (!f) |
| 3675 return; | 3670 return; |
| 3676 | 3671 |
| 3771 g_free(escaped); | 3766 g_free(escaped); |
| 3772 } | 3767 } |
| 3773 | 3768 |
| 3774 if (presence != NULL) | 3769 if (presence != NULL) |
| 3775 purple_notify_user_info_add_pair(user_info, _("Presence"), presence); | 3770 purple_notify_user_info_add_pair(user_info, _("Presence"), presence); |
| 3771 | |
| 3772 if (full) { | |
| 3773 YahooPersonalDetails *ypd = &f->ypd; | |
| 3774 int i; | |
| 3775 struct { | |
| 3776 char *id; | |
| 3777 char *text; | |
| 3778 char *value; | |
| 3779 } yfields[] = { | |
| 3780 {"hp", N_("Home Phone Number"), ypd->phone.home}, | |
| 3781 {"wp", N_("Work Phone Number"), ypd->phone.work}, | |
| 3782 {"mo", N_("Mobile Phone Number"), ypd->phone.mobile}, | |
| 3783 {NULL, NULL, NULL} | |
| 3784 }; | |
| 3785 for (i = 0; yfields[i].id; i++) { | |
| 3786 if (!yfields[i].value || !*yfields[i].value) | |
| 3787 continue; | |
| 3788 purple_notify_user_info_add_pair(user_info, _(yfields[i].text), yfields[i].value); | |
| 3789 } | |
| 3790 } | |
| 3776 } | 3791 } |
| 3777 | 3792 |
| 3778 static void yahoo_addbuddyfrommenu_cb(PurpleBlistNode *node, gpointer data) | 3793 static void yahoo_addbuddyfrommenu_cb(PurpleBlistNode *node, gpointer data) |
| 3779 { | 3794 { |
| 3780 PurpleBuddy *buddy; | 3795 PurpleBuddy *buddy; |
| 3803 } | 3818 } |
| 3804 | 3819 |
| 3805 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { | 3820 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { |
| 3806 GList *m = NULL; | 3821 GList *m = NULL; |
| 3807 PurpleMenuAction *act; | 3822 PurpleMenuAction *act; |
| 3808 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; | 3823 YahooData *yd = (YahooData *) gc->proto_data; |
| 3809 | 3824 |
| 3810 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { | 3825 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
| 3811 if (f->presence != YAHOO_PRESENCE_ONLINE) { | 3826 if (f->presence != YAHOO_PRESENCE_ONLINE) { |
| 3812 act = purple_menu_action_new(_("Appear Online"), | 3827 act = purple_menu_action_new(_("Appear Online"), |
| 3813 PURPLE_CALLBACK(yahoo_presence_settings), | 3828 PURPLE_CALLBACK(yahoo_presence_settings), |
| 3847 PurpleConnection *gc = purple_account_get_connection(account); | 3862 PurpleConnection *gc = purple_account_get_connection(account); |
| 3848 | 3863 |
| 3849 yahoo_doodle_initiate(gc, purple_buddy_get_name(b)); | 3864 yahoo_doodle_initiate(gc, purple_buddy_get_name(b)); |
| 3850 } | 3865 } |
| 3851 | 3866 |
| 3867 static void | |
| 3868 yahoo_userinfo_blist_node(PurpleBlistNode *node, gpointer data) | |
| 3869 { | |
| 3870 PurpleBuddy *b = (PurpleBuddy *)node; | |
| 3871 PurpleAccount *account = purple_buddy_get_account(b); | |
| 3872 PurpleConnection *gc = purple_account_get_connection(account); | |
| 3873 | |
| 3874 yahoo_set_userinfo_for_buddy(gc, b); | |
| 3875 } | |
| 3876 | |
| 3852 static GList *yahoo_buddy_menu(PurpleBuddy *buddy) | 3877 static GList *yahoo_buddy_menu(PurpleBuddy *buddy) |
| 3853 { | 3878 { |
| 3854 GList *m = NULL; | 3879 GList *m = NULL; |
| 3855 PurpleMenuAction *act; | 3880 PurpleMenuAction *act; |
| 3856 | 3881 |
| 3857 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 3882 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 3858 struct yahoo_data *yd = gc->proto_data; | 3883 YahooData *yd = gc->proto_data; |
| 3859 static char buf2[1024]; | 3884 static char buf2[1024]; |
| 3860 YahooFriend *f; | 3885 YahooFriend *f; |
| 3861 | 3886 |
| 3862 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); | 3887 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); |
| 3863 | 3888 |
| 3908 | 3933 |
| 3909 if (f) { | 3934 if (f) { |
| 3910 act = purple_menu_action_new(_("Presence Settings"), NULL, NULL, | 3935 act = purple_menu_action_new(_("Presence Settings"), NULL, NULL, |
| 3911 build_presence_submenu(f, gc)); | 3936 build_presence_submenu(f, gc)); |
| 3912 m = g_list_append(m, act); | 3937 m = g_list_append(m, act); |
| 3913 } | 3938 |
| 3914 | |
| 3915 if (f) { | |
| 3916 act = purple_menu_action_new(_("Start Doodling"), | 3939 act = purple_menu_action_new(_("Start Doodling"), |
| 3917 PURPLE_CALLBACK(yahoo_doodle_blist_node), | 3940 PURPLE_CALLBACK(yahoo_doodle_blist_node), |
| 3918 NULL, NULL); | 3941 NULL, NULL); |
| 3919 m = g_list_append(m, act); | 3942 m = g_list_append(m, act); |
| 3943 | |
| 3944 act = purple_menu_action_new(_("Set User Info..."), | |
| 3945 PURPLE_CALLBACK(yahoo_userinfo_blist_node), | |
| 3946 NULL, NULL); | |
| 3947 m = g_list_append(m, act); | |
| 3920 } | 3948 } |
| 3921 | 3949 |
| 3922 return m; | 3950 return m; |
| 3923 } | 3951 } |
| 3924 | 3952 |
| 3931 } | 3959 } |
| 3932 } | 3960 } |
| 3933 | 3961 |
| 3934 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) | 3962 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) |
| 3935 { | 3963 { |
| 3936 struct yahoo_data *yd = gc->proto_data; | 3964 YahooData *yd = gc->proto_data; |
| 3937 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; | 3965 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; |
| 3938 | 3966 |
| 3939 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | 3967 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 3940 yahoo_packet_hash_str(pkt, 3, name); | 3968 yahoo_packet_hash_str(pkt, 3, name); |
| 3941 yahoo_packet_send_and_free(pkt, yd); | 3969 yahoo_packet_send_and_free(pkt, yd); |
| 3942 | 3970 |
| 3943 purple_connection_set_display_name(gc, name); | 3971 purple_connection_set_display_name(gc, name); |
| 3944 } | 3972 } |
| 3948 const gchar *token, size_t len, const gchar *error_message) | 3976 const gchar *token, size_t len, const gchar *error_message) |
| 3949 { | 3977 { |
| 3950 PurpleConnection *gc = user_data; | 3978 PurpleConnection *gc = user_data; |
| 3951 gboolean set_cookie = FALSE; | 3979 gboolean set_cookie = FALSE; |
| 3952 gchar *url; | 3980 gchar *url; |
| 3953 struct yahoo_data *yd = gc->proto_data; | 3981 YahooData *yd = gc->proto_data; |
| 3954 | 3982 |
| 3955 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); | 3983 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
| 3956 | 3984 |
| 3957 yd->url_datas = g_slist_remove(yd->url_datas, url_data); | 3985 yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
| 3958 | 3986 |
| 3984 { | 4012 { |
| 3985 /* Setup a cookie that can be used by the browser */ | 4013 /* Setup a cookie that can be used by the browser */ |
| 3986 /* XXX I have no idea how this will work with Yahoo! Japan. */ | 4014 /* XXX I have no idea how this will work with Yahoo! Japan. */ |
| 3987 | 4015 |
| 3988 PurpleConnection *gc = action->context; | 4016 PurpleConnection *gc = action->context; |
| 3989 struct yahoo_data *yd = gc->proto_data; | 4017 YahooData *yd = gc->proto_data; |
| 3990 | 4018 |
| 3991 PurpleUtilFetchUrlData *url_data; | 4019 PurpleUtilFetchUrlData *url_data; |
| 3992 const char* base_url = "http://login.yahoo.com"; | 4020 const char* base_url = "http://login.yahoo.com"; |
| 3993 /* use whole URL if using HTTP Proxy */ | 4021 /* use whole URL if using HTTP Proxy */ |
| 3994 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); | 4022 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); |
| 4028 { | 4056 { |
| 4029 PurpleRequestFields *fields; | 4057 PurpleRequestFields *fields; |
| 4030 PurpleRequestFieldGroup *group; | 4058 PurpleRequestFieldGroup *group; |
| 4031 PurpleRequestField *field; | 4059 PurpleRequestField *field; |
| 4032 PurpleConnection *gc = (PurpleConnection *) action->context; | 4060 PurpleConnection *gc = (PurpleConnection *) action->context; |
| 4033 struct yahoo_data *yd = purple_connection_get_protocol_data(gc); | 4061 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 4034 const char *name = purple_connection_get_display_name(gc); | 4062 const char *name = purple_connection_get_display_name(gc); |
| 4035 int iter; | 4063 int iter; |
| 4036 | 4064 |
| 4037 fields = purple_request_fields_new(); | 4065 fields = purple_request_fields_new(); |
| 4038 group = purple_request_field_group_new(NULL); | 4066 group = purple_request_field_group_new(NULL); |
| 4098 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, | 4126 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
| 4099 const gchar *webdata, size_t len, const gchar *error_message) | 4127 const gchar *webdata, size_t len, const gchar *error_message) |
| 4100 { | 4128 { |
| 4101 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; | 4129 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; |
| 4102 PurpleConnection *gc = sms_cb_data->gc; | 4130 PurpleConnection *gc = sms_cb_data->gc; |
| 4103 struct yahoo_data *yd = gc->proto_data; | 4131 YahooData *yd = gc->proto_data; |
| 4104 char *mobile_no = NULL; | 4132 char *mobile_no = NULL; |
| 4105 char *status = NULL; | 4133 char *status = NULL; |
| 4106 char *carrier = NULL; | 4134 char *carrier = NULL; |
| 4107 PurpleAccount *account = purple_connection_get_account(gc); | 4135 PurpleAccount *account = purple_connection_get_account(gc); |
| 4108 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); | 4136 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); |
| 4149 } | 4177 } |
| 4150 } | 4178 } |
| 4151 | 4179 |
| 4152 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) | 4180 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) |
| 4153 { | 4181 { |
| 4154 struct yahoo_data *yd = gc->proto_data; | 4182 YahooData *yd = gc->proto_data; |
| 4155 PurpleUtilFetchUrlData *url_data; | 4183 PurpleUtilFetchUrlData *url_data; |
| 4156 struct yahoo_sms_carrier_cb_data *sms_cb_data; | 4184 struct yahoo_sms_carrier_cb_data *sms_cb_data; |
| 4157 char *validate_request_str = NULL; | 4185 char *validate_request_str = NULL; |
| 4158 char *request = NULL; | 4186 char *request = NULL; |
| 4159 gboolean use_whole_url = FALSE; | 4187 gboolean use_whole_url = FALSE; |
| 4207 } | 4235 } |
| 4208 } | 4236 } |
| 4209 | 4237 |
| 4210 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) | 4238 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) |
| 4211 { | 4239 { |
| 4212 struct yahoo_data *yd = gc->proto_data; | 4240 YahooData *yd = gc->proto_data; |
| 4213 struct yahoo_packet *pkt = NULL; | 4241 struct yahoo_packet *pkt = NULL; |
| 4214 char *msg = yahoo_html_to_codes(what); | 4242 char *msg = yahoo_html_to_codes(what); |
| 4215 char *msg2; | 4243 char *msg2; |
| 4216 gboolean utf8 = TRUE; | 4244 gboolean utf8 = TRUE; |
| 4217 PurpleWhiteboard *wb; | 4245 PurpleWhiteboard *wb; |
| 4270 g_free(msg2); | 4298 g_free(msg2); |
| 4271 return -1; | 4299 return -1; |
| 4272 } | 4300 } |
| 4273 | 4301 |
| 4274 alias = purple_account_get_alias(account); | 4302 alias = purple_account_get_alias(account); |
| 4275 pkt = yahoo_packet_new(YAHOO_SERVICE_SMS_MSG, YAHOO_STATUS_AVAILABLE, 0); | 4303 pkt = yahoo_packet_new(YAHOO_SERVICE_SMS_MSG, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4276 yahoo_packet_hash(pkt, "sssss", | 4304 yahoo_packet_hash(pkt, "sssss", |
| 4277 1, purple_connection_get_display_name(gc), | 4305 1, purple_connection_get_display_name(gc), |
| 4278 69, alias, | 4306 69, alias, |
| 4279 5, who + 1, | 4307 5, who + 1, |
| 4280 68, carrier, | 4308 68, carrier, |
| 4285 g_free(msg2); | 4313 g_free(msg2); |
| 4286 | 4314 |
| 4287 return ret; | 4315 return ret; |
| 4288 } | 4316 } |
| 4289 | 4317 |
| 4290 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | 4318 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id); |
| 4291 if(msn) { | 4319 if(msn) { |
| 4292 yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who+4); | 4320 yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who+4); |
| 4293 yahoo_packet_hash_int(pkt, 241, 2); | 4321 yahoo_packet_hash_int(pkt, 241, 2); |
| 4294 } | 4322 } |
| 4295 else { | 4323 else { |
| 4358 return ret; | 4386 return ret; |
| 4359 } | 4387 } |
| 4360 | 4388 |
| 4361 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) | 4389 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) |
| 4362 { | 4390 { |
| 4363 struct yahoo_data *yd = gc->proto_data; | 4391 YahooData *yd = gc->proto_data; |
| 4364 struct yahoo_p2p_data *p2p_data; | 4392 struct yahoo_p2p_data *p2p_data; |
| 4365 gboolean msn = !g_strncasecmp(who, "msn/", 4); | 4393 gboolean msn = !g_strncasecmp(who, "msn/", 4); |
| 4366 struct yahoo_packet *pkt = NULL; | 4394 struct yahoo_packet *pkt = NULL; |
| 4367 | 4395 |
| 4368 /* Don't do anything if sms is being typed */ | 4396 /* Don't do anything if sms is being typed */ |
| 4369 if( strncmp(who, "+", 1) == 0 ) | 4397 if( strncmp(who, "+", 1) == 0 ) |
| 4370 return 0; | 4398 return 0; |
| 4371 | 4399 |
| 4372 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); | 4400 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, yd->session_id); |
| 4373 | 4401 |
| 4374 /* check to see if p2p link exists, send through it */ | 4402 /* check to see if p2p link exists, send through it */ |
| 4375 if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !msn ) { | 4403 if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !msn ) { |
| 4376 yahoo_packet_hash(pkt, "sssssis", 49, "TYPING", 1, purple_connection_get_display_name(gc), | 4404 yahoo_packet_hash(pkt, "sssssis", 49, "TYPING", 1, purple_connection_get_display_name(gc), |
| 4377 14, " ", 13, state == PURPLE_TYPING ? "1" : "0", | 4405 14, " ", 13, state == PURPLE_TYPING ? "1" : "0", |
| 4403 | 4431 |
| 4404 void yahoo_set_status(PurpleAccount *account, PurpleStatus *status) | 4432 void yahoo_set_status(PurpleAccount *account, PurpleStatus *status) |
| 4405 { | 4433 { |
| 4406 PurpleConnection *gc; | 4434 PurpleConnection *gc; |
| 4407 PurplePresence *presence; | 4435 PurplePresence *presence; |
| 4408 struct yahoo_data *yd; | 4436 YahooData *yd; |
| 4409 struct yahoo_packet *pkt; | 4437 struct yahoo_packet *pkt; |
| 4410 int old_status; | 4438 int old_status; |
| 4411 const char *msg = NULL; | 4439 const char *msg = NULL; |
| 4412 char *tmp = NULL; | 4440 char *tmp = NULL; |
| 4413 char *conv_msg = NULL; | 4441 char *conv_msg = NULL; |
| 4416 if (!purple_status_is_active(status)) | 4444 if (!purple_status_is_active(status)) |
| 4417 return; | 4445 return; |
| 4418 | 4446 |
| 4419 gc = purple_account_get_connection(account); | 4447 gc = purple_account_get_connection(account); |
| 4420 presence = purple_status_get_presence(status); | 4448 presence = purple_status_get_presence(status); |
| 4421 yd = (struct yahoo_data *)gc->proto_data; | 4449 yd = (YahooData *)gc->proto_data; |
| 4422 old_status = yd->current_status; | 4450 old_status = yd->current_status; |
| 4423 | 4451 |
| 4424 yd->current_status = get_yahoo_status_from_purple_status(status); | 4452 yd->current_status = get_yahoo_status_from_purple_status(status); |
| 4425 | 4453 |
| 4426 if (yd->current_status == YAHOO_STATUS_CUSTOM) | 4454 if (yd->current_status == YAHOO_STATUS_CUSTOM) |
| 4439 g_free(tmp); | 4467 g_free(tmp); |
| 4440 } | 4468 } |
| 4441 } | 4469 } |
| 4442 | 4470 |
| 4443 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { | 4471 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
| 4444 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | 4472 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4445 yahoo_packet_hash_str(pkt, 13, "2"); | 4473 yahoo_packet_hash_str(pkt, 13, "2"); |
| 4446 yahoo_packet_send_and_free(pkt, yd); | 4474 yahoo_packet_send_and_free(pkt, yd); |
| 4447 | 4475 |
| 4448 return; | 4476 return; |
| 4449 } | 4477 } |
| 4450 | 4478 |
| 4451 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4479 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4452 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4480 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
| 4453 | 4481 |
| 4454 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4482 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
| 4455 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | 4483 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
| 4456 yahoo_packet_hash_str(pkt, 19, conv_msg); | 4484 yahoo_packet_hash_str(pkt, 19, conv_msg); |
| 4466 yahoo_packet_hash_str(pkt, 47, "1"); | 4494 yahoo_packet_hash_str(pkt, 47, "1"); |
| 4467 | 4495 |
| 4468 yahoo_packet_send_and_free(pkt, yd); | 4496 yahoo_packet_send_and_free(pkt, yd); |
| 4469 | 4497 |
| 4470 if (old_status == YAHOO_STATUS_INVISIBLE) { | 4498 if (old_status == YAHOO_STATUS_INVISIBLE) { |
| 4471 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | 4499 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4472 yahoo_packet_hash_str(pkt, 13, "1"); | 4500 yahoo_packet_hash_str(pkt, 13, "1"); |
| 4473 yahoo_packet_send_and_free(pkt, yd); | 4501 yahoo_packet_send_and_free(pkt, yd); |
| 4474 | 4502 |
| 4475 /* Any per-session presence settings are removed */ | 4503 /* Any per-session presence settings are removed */ |
| 4476 g_hash_table_foreach(yd->friends, yahoo_session_presence_remove, NULL); | 4504 g_hash_table_foreach(yd->friends, yahoo_session_presence_remove, NULL); |
| 4478 } | 4506 } |
| 4479 } | 4507 } |
| 4480 | 4508 |
| 4481 void yahoo_set_idle(PurpleConnection *gc, int idle) | 4509 void yahoo_set_idle(PurpleConnection *gc, int idle) |
| 4482 { | 4510 { |
| 4483 struct yahoo_data *yd = gc->proto_data; | 4511 YahooData *yd = gc->proto_data; |
| 4484 struct yahoo_packet *pkt = NULL; | 4512 struct yahoo_packet *pkt = NULL; |
| 4485 char *msg = NULL, *msg2 = NULL; | 4513 char *msg = NULL, *msg2 = NULL; |
| 4486 PurpleStatus *status = NULL; | 4514 PurpleStatus *status = NULL; |
| 4487 | 4515 |
| 4488 if (idle && yd->current_status != YAHOO_STATUS_CUSTOM) | 4516 if (idle && yd->current_status != YAHOO_STATUS_CUSTOM) |
| 4490 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | 4518 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { |
| 4491 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4519 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
| 4492 yd->current_status = get_yahoo_status_from_purple_status(status); | 4520 yd->current_status = get_yahoo_status_from_purple_status(status); |
| 4493 } | 4521 } |
| 4494 | 4522 |
| 4495 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4523 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4496 | 4524 |
| 4497 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4525 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
| 4498 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4526 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
| 4499 const char *tmp; | 4527 const char *tmp; |
| 4500 if (status == NULL) | 4528 if (status == NULL) |
| 4584 } | 4612 } |
| 4585 | 4613 |
| 4586 void yahoo_keepalive(PurpleConnection *gc) | 4614 void yahoo_keepalive(PurpleConnection *gc) |
| 4587 { | 4615 { |
| 4588 struct yahoo_packet *pkt; | 4616 struct yahoo_packet *pkt; |
| 4589 struct yahoo_data *yd = gc->proto_data; | 4617 YahooData *yd = gc->proto_data; |
| 4590 time_t now = time(NULL); | 4618 time_t now = time(NULL); |
| 4591 | 4619 |
| 4592 /* We're only allowed to send a ping once an hour or the servers will boot us */ | 4620 /* We're only allowed to send a ping once an hour or the servers will boot us */ |
| 4593 if ((now - yd->last_ping) >= PING_TIMEOUT) { | 4621 if ((now - yd->last_ping) >= PING_TIMEOUT) { |
| 4594 yd->last_ping = now; | 4622 yd->last_ping = now; |
| 4596 /* The native client will only send PING or CHATPING */ | 4624 /* The native client will only send PING or CHATPING */ |
| 4597 if (yd->chat_online) { | 4625 if (yd->chat_online) { |
| 4598 if (yd->wm) { | 4626 if (yd->wm) { |
| 4599 ycht_chat_send_keepalive(yd->ycht); | 4627 ycht_chat_send_keepalive(yd->ycht); |
| 4600 } else { | 4628 } else { |
| 4601 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); | 4629 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4602 yahoo_packet_hash_str(pkt, 109, purple_connection_get_display_name(gc)); | 4630 yahoo_packet_hash_str(pkt, 109, purple_connection_get_display_name(gc)); |
| 4603 yahoo_packet_send_and_free(pkt, yd); | 4631 yahoo_packet_send_and_free(pkt, yd); |
| 4604 } | 4632 } |
| 4605 } else { | 4633 } else { |
| 4606 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | 4634 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4607 yahoo_packet_send_and_free(pkt, yd); | 4635 yahoo_packet_send_and_free(pkt, yd); |
| 4608 } | 4636 } |
| 4609 } | 4637 } |
| 4610 | 4638 |
| 4611 if ((now - yd->last_keepalive) >= KEEPALIVE_TIMEOUT) { | 4639 if ((now - yd->last_keepalive) >= KEEPALIVE_TIMEOUT) { |
| 4612 yd->last_keepalive = now; | 4640 yd->last_keepalive = now; |
| 4613 pkt = yahoo_packet_new(YAHOO_SERVICE_KEEPALIVE, YAHOO_STATUS_AVAILABLE, 0); | 4641 pkt = yahoo_packet_new(YAHOO_SERVICE_KEEPALIVE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4614 yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); | 4642 yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); |
| 4615 yahoo_packet_send_and_free(pkt, yd); | 4643 yahoo_packet_send_and_free(pkt, yd); |
| 4616 } | 4644 } |
| 4617 | 4645 |
| 4618 } | 4646 } |
| 4619 | 4647 |
| 4620 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) | 4648 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) |
| 4621 { | 4649 { |
| 4622 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 4650 YahooData *yd = (YahooData *)gc->proto_data; |
| 4623 struct yahoo_packet *pkt; | 4651 struct yahoo_packet *pkt; |
| 4624 const char *group = NULL; | 4652 const char *group = NULL; |
| 4625 char *group2; | 4653 char *group2; |
| 4626 YahooFriend *f; | 4654 YahooFriend *f; |
| 4627 const char *bname; | 4655 const char *bname; |
| 4642 group = purple_group_get_name(g); | 4670 group = purple_group_get_name(g); |
| 4643 else | 4671 else |
| 4644 group = "Buddies"; | 4672 group = "Buddies"; |
| 4645 | 4673 |
| 4646 group2 = yahoo_string_encode(gc, group, NULL); | 4674 group2 = yahoo_string_encode(gc, group, NULL); |
| 4647 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | 4675 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4648 if(msn) { | 4676 if(msn) { |
| 4649 yahoo_packet_hash(pkt, "sssssssssss", | 4677 yahoo_packet_hash(pkt, "sssssssssss", |
| 4650 14, "", | 4678 14, "", |
| 4651 65, group2, | 4679 65, group2, |
| 4652 97, "1", | 4680 97, "1", |
| 4681 g_free(group2); | 4709 g_free(group2); |
| 4682 } | 4710 } |
| 4683 | 4711 |
| 4684 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 4712 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 4685 { | 4713 { |
| 4686 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 4714 YahooData *yd = (YahooData *)gc->proto_data; |
| 4687 struct yahoo_packet *pkt; | 4715 struct yahoo_packet *pkt; |
| 4688 GSList *buddies, *l; | 4716 GSList *buddies, *l; |
| 4689 PurpleGroup *g; | 4717 PurpleGroup *g; |
| 4690 gboolean remove = TRUE; | 4718 gboolean remove = TRUE; |
| 4691 char *cg; | 4719 char *cg; |
| 4714 | 4742 |
| 4715 if (remove) | 4743 if (remove) |
| 4716 g_hash_table_remove(yd->friends, bname); | 4744 g_hash_table_remove(yd->friends, bname); |
| 4717 | 4745 |
| 4718 cg = yahoo_string_encode(gc, gname, NULL); | 4746 cg = yahoo_string_encode(gc, gname, NULL); |
| 4719 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | 4747 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4720 | 4748 |
| 4721 if(msn) | 4749 if(msn) |
| 4722 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), | 4750 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
| 4723 7, bname+4, 65, cg); | 4751 7, bname+4, 65, cg); |
| 4724 else | 4752 else |
| 4729 yahoo_packet_send_and_free(pkt, yd); | 4757 yahoo_packet_send_and_free(pkt, yd); |
| 4730 g_free(cg); | 4758 g_free(cg); |
| 4731 } | 4759 } |
| 4732 | 4760 |
| 4733 void yahoo_add_deny(PurpleConnection *gc, const char *who) { | 4761 void yahoo_add_deny(PurpleConnection *gc, const char *who) { |
| 4734 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 4762 YahooData *yd = (YahooData *)gc->proto_data; |
| 4735 struct yahoo_packet *pkt; | 4763 struct yahoo_packet *pkt; |
| 4736 | 4764 |
| 4737 if (!yd->logged_in) | 4765 if (!yd->logged_in) |
| 4738 return; | 4766 return; |
| 4739 | 4767 |
| 4740 if (!who || who[0] == '\0') | 4768 if (!who || who[0] == '\0') |
| 4741 return; | 4769 return; |
| 4742 | 4770 |
| 4743 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | 4771 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4744 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), | 4772 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
| 4745 7, who, 13, "1"); | 4773 7, who, 13, "1"); |
| 4746 yahoo_packet_send_and_free(pkt, yd); | 4774 yahoo_packet_send_and_free(pkt, yd); |
| 4747 } | 4775 } |
| 4748 | 4776 |
| 4749 void yahoo_rem_deny(PurpleConnection *gc, const char *who) { | 4777 void yahoo_rem_deny(PurpleConnection *gc, const char *who) { |
| 4750 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 4778 YahooData *yd = (YahooData *)gc->proto_data; |
| 4751 struct yahoo_packet *pkt; | 4779 struct yahoo_packet *pkt; |
| 4752 | 4780 |
| 4753 if (!yd->logged_in) | 4781 if (!yd->logged_in) |
| 4754 return; | 4782 return; |
| 4755 | 4783 |
| 4756 if (!who || who[0] == '\0') | 4784 if (!who || who[0] == '\0') |
| 4757 return; | 4785 return; |
| 4758 | 4786 |
| 4759 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | 4787 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4760 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), 7, who, 13, "2"); | 4788 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), 7, who, 13, "2"); |
| 4761 yahoo_packet_send_and_free(pkt, yd); | 4789 yahoo_packet_send_and_free(pkt, yd); |
| 4762 } | 4790 } |
| 4763 | 4791 |
| 4764 void yahoo_set_permit_deny(PurpleConnection *gc) | 4792 void yahoo_set_permit_deny(PurpleConnection *gc) |
| 4786 } | 4814 } |
| 4787 | 4815 |
| 4788 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, | 4816 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, |
| 4789 const char *old_group, const char *new_group) | 4817 const char *old_group, const char *new_group) |
| 4790 { | 4818 { |
| 4791 struct yahoo_data *yd = gc->proto_data; | 4819 YahooData *yd = gc->proto_data; |
| 4792 struct yahoo_packet *pkt; | 4820 struct yahoo_packet *pkt; |
| 4793 char *gpn, *gpo; | 4821 char *gpn, *gpo; |
| 4794 YahooFriend *f = yahoo_friend_find(gc, who); | 4822 YahooFriend *f = yahoo_friend_find(gc, who); |
| 4795 gboolean msn = FALSE; | 4823 gboolean msn = FALSE; |
| 4796 const char *temp = NULL; | 4824 const char *temp = NULL; |
| 4817 g_free(gpn); | 4845 g_free(gpn); |
| 4818 g_free(gpo); | 4846 g_free(gpo); |
| 4819 return; | 4847 return; |
| 4820 } | 4848 } |
| 4821 | 4849 |
| 4822 pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, 0); | 4850 pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4823 if(f->protocol) | 4851 if(f->protocol) |
| 4824 yahoo_packet_hash(pkt, "ssssissss", 1, purple_connection_get_display_name(gc), | 4852 yahoo_packet_hash(pkt, "ssssissss", 1, purple_connection_get_display_name(gc), |
| 4825 302, "240", 300, "240", 7, temp, 241, f->protocol, 224, gpo, 264, gpn, 301, | 4853 302, "240", 300, "240", 7, temp, 241, f->protocol, 224, gpo, 264, gpn, 301, |
| 4826 "240", 303, "240"); | 4854 "240", 303, "240"); |
| 4827 else | 4855 else |
| 4835 } | 4863 } |
| 4836 | 4864 |
| 4837 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, | 4865 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, |
| 4838 PurpleGroup *group, GList *moved_buddies) | 4866 PurpleGroup *group, GList *moved_buddies) |
| 4839 { | 4867 { |
| 4840 struct yahoo_data *yd = gc->proto_data; | 4868 YahooData *yd = gc->proto_data; |
| 4841 struct yahoo_packet *pkt; | 4869 struct yahoo_packet *pkt; |
| 4842 char *gpn, *gpo; | 4870 char *gpn, *gpo; |
| 4843 | 4871 |
| 4844 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL); | 4872 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL); |
| 4845 gpo = yahoo_string_encode(gc, old_name, NULL); | 4873 gpo = yahoo_string_encode(gc, old_name, NULL); |
| 4847 g_free(gpn); | 4875 g_free(gpn); |
| 4848 g_free(gpo); | 4876 g_free(gpo); |
| 4849 return; | 4877 return; |
| 4850 } | 4878 } |
| 4851 | 4879 |
| 4852 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | 4880 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 4853 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), | 4881 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
| 4854 65, gpo, 67, gpn); | 4882 65, gpo, 67, gpn); |
| 4855 yahoo_packet_send_and_free(pkt, yd); | 4883 yahoo_packet_send_and_free(pkt, yd); |
| 4856 g_free(gpn); | 4884 g_free(gpn); |
| 4857 g_free(gpo); | 4885 g_free(gpo); |
| 4876 yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, | 4904 yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, |
| 4877 char **args, char **error, void *data) | 4905 char **args, char **error, void *data) |
| 4878 { | 4906 { |
| 4879 GHashTable *comp; | 4907 GHashTable *comp; |
| 4880 PurpleConnection *gc; | 4908 PurpleConnection *gc; |
| 4881 struct yahoo_data *yd; | 4909 YahooData *yd; |
| 4882 int id; | 4910 int id; |
| 4883 | 4911 |
| 4884 if (!args || !args[0]) | 4912 if (!args || !args[0]) |
| 4885 return PURPLE_CMD_RET_FAILED; | 4913 return PURPLE_CMD_RET_FAILED; |
| 4886 | 4914 |