comparison libpurple/protocols/yahoo/libymsg.c @ 28036:8be4bea98188

merged with im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 27 Jul 2009 15:22:00 +0900
parents 0754698c49f4 908be3822215
children f1ce91569ed3
comparison
equal deleted inserted replaced
28022:c81386a2b292 28036:8be4bea98188
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? */
605 gboolean got_serv_list = FALSE; 605 gboolean got_serv_list = FALSE;
606 PurpleBuddy *b; 606 PurpleBuddy *b;
607 PurpleGroup *g; 607 PurpleGroup *g;
608 YahooFriend *f = NULL; 608 YahooFriend *f = NULL;
609 PurpleAccount *account = purple_connection_get_account(gc); 609 PurpleAccount *account = purple_connection_get_account(gc);
610 struct yahoo_data *yd = gc->proto_data; 610 YahooData *yd = gc->proto_data;
611 GHashTable *ht; 611 GHashTable *ht;
612 612
613 char **lines; 613 char **lines;
614 char **split; 614 char **split;
615 char **buddies; 615 char **buddies;
752 char *stat = NULL; 752 char *stat = NULL;
753 char *game = NULL; 753 char *game = NULL;
754 YahooFriend *f = NULL; 754 YahooFriend *f = NULL;
755 GSList *l = pkt->hash; 755 GSList *l = pkt->hash;
756 gint val_11 = 0; 756 gint val_11 = 0;
757 struct yahoo_data *yd = gc->proto_data; 757 YahooData *yd = gc->proto_data;
758 gboolean msn = FALSE; 758 gboolean msn = FALSE;
759 759
760 account = purple_connection_get_account(gc); 760 account = purple_connection_get_account(gc);
761 761
762 while (l) { 762 while (l) {
847 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)
848 { 848 {
849 PurpleAccount *account; 849 PurpleAccount *account;
850 GSList *l = pkt->hash; 850 GSList *l = pkt->hash;
851 struct _yahoo_im *sms = NULL; 851 struct _yahoo_im *sms = NULL;
852 struct yahoo_data *yd; 852 YahooData *yd;
853 char *server_msg = NULL; 853 char *server_msg = NULL;
854 char *m; 854 char *m;
855 855
856 yd = gc->proto_data; 856 yd = gc->proto_data;
857 account = purple_connection_get_account(gc); 857 account = purple_connection_get_account(gc);
907 907
908 /* 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 */
909 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)
910 { 910 {
911 PurpleAccount *account; 911 PurpleAccount *account;
912 struct yahoo_data *yd = gc->proto_data; 912 YahooData *yd = gc->proto_data;
913 GSList *l = pkt->hash; 913 GSList *l = pkt->hash;
914 GSList *list = NULL; 914 GSList *list = NULL;
915 struct _yahoo_im *im = NULL; 915 struct _yahoo_im *im = NULL;
916 const char *imv = NULL; 916 const char *imv = NULL;
917 gint val_11 = 0; 917 gint val_11 = 0;
1140 static void 1140 static void
1141 yahoo_buddy_add_authorize_cb(gpointer data) 1141 yahoo_buddy_add_authorize_cb(gpointer data)
1142 { 1142 {
1143 struct yahoo_add_request *add_req = data; 1143 struct yahoo_add_request *add_req = data;
1144 struct yahoo_packet *pkt; 1144 struct yahoo_packet *pkt;
1145 struct yahoo_data *yd = add_req->gc->proto_data; 1145 YahooData *yd = add_req->gc->proto_data;
1146 const char *who = add_req->who; 1146 const char *who = add_req->who;
1147 1147
1148 if (add_req->protocol == 2) 1148 if (add_req->protocol == 2)
1149 who += 4; 1149 who += 4;
1150 1150
1163 } 1163 }
1164 1164
1165 static void 1165 static void
1166 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) 1166 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg)
1167 { 1167 {
1168 struct yahoo_data *yd = add_req->gc->proto_data; 1168 YahooData *yd = add_req->gc->proto_data;
1169 struct yahoo_packet *pkt; 1169 struct yahoo_packet *pkt;
1170 char *encoded_msg = NULL; 1170 char *encoded_msg = NULL;
1171 const char *who = add_req->who; 1171 const char *who = add_req->who;
1172 1172
1173 if (add_req->protocol == 2) 1173 if (add_req->protocol == 2)
1215 } 1215 }
1216 1216
1217 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) 1217 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason)
1218 { 1218 {
1219 char *notify_msg; 1219 char *notify_msg;
1220 struct yahoo_data *yd = gc->proto_data; 1220 YahooData *yd = gc->proto_data;
1221 1221
1222 if (who == NULL) 1222 if (who == NULL)
1223 return; 1223 return;
1224 1224
1225 if (reason != NULL) { 1225 if (reason != NULL) {
1528 } 1528 }
1529 1529
1530 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) 1530 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt)
1531 { 1531 {
1532 PurpleAccount *account = purple_connection_get_account(gc); 1532 PurpleAccount *account = purple_connection_get_account(gc);
1533 struct yahoo_data *yd = gc->proto_data; 1533 YahooData *yd = gc->proto_data;
1534 const char *who = NULL; 1534 const char *who = NULL;
1535 const char *email = NULL; 1535 const char *email = NULL;
1536 const char *subj = NULL; 1536 const char *subj = NULL;
1537 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); 1537 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL);
1538 int count = 0; 1538 int count = 0;
1612 *out = '\0'; 1612 *out = '\0';
1613 } 1613 }
1614 1614
1615 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) 1615 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt)
1616 { 1616 {
1617 struct yahoo_data *yd = gc->proto_data; 1617 YahooData *yd = gc->proto_data;
1618 PurpleAccount *account = purple_connection_get_account(gc); 1618 PurpleAccount *account = purple_connection_get_account(gc);
1619 const char *name = purple_normalize(account, purple_account_get_username(account)); 1619 const char *name = purple_normalize(account, purple_account_get_username(account));
1620 PurpleCipher *md5_cipher; 1620 PurpleCipher *md5_cipher;
1621 PurpleCipherContext *md5_ctx; 1621 PurpleCipherContext *md5_ctx;
1622 guchar md5_digest[16]; 1622 guchar md5_digest[16];
1655 1655
1656 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message) 1656 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message)
1657 { 1657 {
1658 struct yahoo_auth_data *auth_data = user_data; 1658 struct yahoo_auth_data *auth_data = user_data;
1659 PurpleConnection *gc = auth_data->gc; 1659 PurpleConnection *gc = auth_data->gc;
1660 struct yahoo_data *yd; 1660 YahooData *yd;
1661 gboolean try_login_on_error = FALSE; 1661 gboolean try_login_on_error = FALSE;
1662 1662
1663 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n"); 1663 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n");
1664 1664
1665 if (!PURPLE_CONNECTION_IS_VALID(gc)) { 1665 if (!PURPLE_CONNECTION_IS_VALID(gc)) {
1666 g_free(auth_data->seed); 1666 g_free(auth_data->seed);
1667 g_free(auth_data); 1667 g_free(auth_data);
1668 g_return_if_reached(); 1668 g_return_if_reached();
1669 } 1669 }
1670 1670
1671 yd = (struct yahoo_data *)gc->proto_data; 1671 yd = (YahooData *)gc->proto_data;
1672 1672
1673 if (error_message != NULL) { 1673 if (error_message != NULL) {
1674 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); 1674 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message);
1675 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1675 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1676 g_free(auth_data->seed); 1676 g_free(auth_data->seed);
2030 } 2030 }
2031 2031
2032 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) 2032 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt)
2033 { 2033 {
2034 #ifdef TRY_WEBMESSENGER_LOGIN 2034 #ifdef TRY_WEBMESSENGER_LOGIN
2035 struct yahoo_data *yd = gc->proto_data; 2035 YahooData *yd = gc->proto_data;
2036 #endif /* TRY_WEBMESSENGER_LOGIN */ 2036 #endif /* TRY_WEBMESSENGER_LOGIN */
2037 GSList *l = pkt->hash; 2037 GSList *l = pkt->hash;
2038 int err = 0; 2038 int err = 0;
2039 char *msg; 2039 char *msg;
2040 char *url = NULL; 2040 char *url = NULL;
2114 char *group = NULL; 2114 char *group = NULL;
2115 char *decoded_group; 2115 char *decoded_group;
2116 char *buf; 2116 char *buf;
2117 YahooFriend *f; 2117 YahooFriend *f;
2118 GSList *l = pkt->hash; 2118 GSList *l = pkt->hash;
2119 struct yahoo_data *yd = gc->proto_data; 2119 YahooData *yd = gc->proto_data;
2120 int protocol = 0; 2120 int protocol = 0;
2121 gboolean msn = FALSE; 2121 gboolean msn = FALSE;
2122 2122
2123 while (l) { 2123 while (l) {
2124 struct yahoo_pair *pair = l->data; 2124 struct yahoo_pair *pair = l->data;
2201 { 2201 {
2202 struct yahoo_p2p_data *p2p_data = value; 2202 struct yahoo_p2p_data *p2p_data = value;
2203 PurpleConnection *gc = user_data; 2203 PurpleConnection *gc = user_data;
2204 struct yahoo_packet *pkt_to_send; 2204 struct yahoo_packet *pkt_to_send;
2205 PurpleAccount *account; 2205 PurpleAccount *account;
2206 struct yahoo_data *yd = gc->proto_data; 2206 YahooData *yd = gc->proto_data;
2207 2207
2208 account = purple_connection_get_account(gc); 2208 account = purple_connection_get_account(gc);
2209 2209
2210 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); 2210 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
2211 yahoo_packet_hash(pkt_to_send, "ssisi", 2211 yahoo_packet_hash(pkt_to_send, "ssisi",
2220 } 2220 }
2221 2221
2222 static gboolean yahoo_p2p_keepalive(gpointer data) 2222 static gboolean yahoo_p2p_keepalive(gpointer data)
2223 { 2223 {
2224 PurpleConnection *gc = data; 2224 PurpleConnection *gc = data;
2225 struct yahoo_data *yd = gc->proto_data; 2225 YahooData *yd = gc->proto_data;
2226 2226
2227 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); 2227 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc);
2228 2228
2229 return TRUE; 2229 return TRUE;
2230 } 2230 }
2261 char *who = NULL; 2261 char *who = NULL;
2262 GSList *l = pkt->hash; 2262 GSList *l = pkt->hash;
2263 struct yahoo_packet *pkt_to_send; 2263 struct yahoo_packet *pkt_to_send;
2264 PurpleAccount *account; 2264 PurpleAccount *account;
2265 int val_13_to_send = 0; 2265 int val_13_to_send = 0;
2266 struct yahoo_data *yd; 2266 YahooData *yd;
2267 YahooFriend *f; 2267 YahooFriend *f;
2268 2268
2269 if(!(p2p_data = data)) 2269 if(!(p2p_data = data))
2270 return ; 2270 return ;
2271 2271
2348 int pos = 0; 2348 int pos = 0;
2349 int pktlen; 2349 int pktlen;
2350 struct yahoo_packet *pkt; 2350 struct yahoo_packet *pkt;
2351 guchar *start = NULL; 2351 guchar *start = NULL;
2352 struct yahoo_p2p_data *p2p_data; 2352 struct yahoo_p2p_data *p2p_data;
2353 struct yahoo_data *yd; 2353 YahooData *yd;
2354 2354
2355 if(!(p2p_data = data)) 2355 if(!(p2p_data = data))
2356 return ; 2356 return ;
2357 yd = p2p_data->gc->proto_data; 2357 yd = p2p_data->gc->proto_data;
2358 2358
2420 2420
2421 static void yahoo_p2p_server_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond) 2421 static void yahoo_p2p_server_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond)
2422 { 2422 {
2423 int acceptfd; 2423 int acceptfd;
2424 struct yahoo_p2p_data *p2p_data; 2424 struct yahoo_p2p_data *p2p_data;
2425 struct yahoo_data *yd; 2425 YahooData *yd;
2426 2426
2427 if(!(p2p_data = data)) 2427 if(!(p2p_data = data))
2428 return ; 2428 return ;
2429 yd = p2p_data->gc->proto_data; 2429 yd = p2p_data->gc->proto_data;
2430 2430
2459 } 2459 }
2460 2460
2461 static gboolean yahoo_cancel_p2p_server_listen_cb(gpointer data) 2461 static gboolean yahoo_cancel_p2p_server_listen_cb(gpointer data)
2462 { 2462 {
2463 struct yahoo_p2p_data *p2p_data; 2463 struct yahoo_p2p_data *p2p_data;
2464 struct yahoo_data *yd; 2464 YahooData *yd;
2465 2465
2466 if(!(p2p_data = data)) 2466 if(!(p2p_data = data))
2467 return FALSE; 2467 return FALSE;
2468 2468
2469 yd = p2p_data->gc->proto_data; 2469 yd = p2p_data->gc->proto_data;
2480 } 2480 }
2481 2481
2482 static void yahoo_p2p_server_listen_cb(int listenfd, gpointer data) 2482 static void yahoo_p2p_server_listen_cb(int listenfd, gpointer data)
2483 { 2483 {
2484 struct yahoo_p2p_data *p2p_data; 2484 struct yahoo_p2p_data *p2p_data;
2485 struct yahoo_data *yd; 2485 YahooData *yd;
2486 2486
2487 if(!(p2p_data = data)) 2487 if(!(p2p_data = data))
2488 return ; 2488 return ;
2489 2489
2490 if(listenfd == -1) { 2490 if(listenfd == -1) {
2512 char temp_str[100]; 2512 char temp_str[100];
2513 gchar *base64_ip = NULL; 2513 gchar *base64_ip = NULL;
2514 YahooFriend *f; 2514 YahooFriend *f;
2515 struct yahoo_packet *pkt; 2515 struct yahoo_packet *pkt;
2516 PurpleAccount *account; 2516 PurpleAccount *account;
2517 struct yahoo_data *yd = gc->proto_data; 2517 YahooData *yd = gc->proto_data;
2518 struct yahoo_p2p_data *p2p_data; 2518 struct yahoo_p2p_data *p2p_data;
2519 2519
2520 f = yahoo_friend_find(gc, who); 2520 f = yahoo_friend_find(gc, who);
2521 account = purple_connection_get_account(gc); 2521 account = purple_connection_get_account(gc);
2522 2522
2580 static void yahoo_p2p_init_cb(gpointer data, gint source, const gchar *error_message) 2580 static void yahoo_p2p_init_cb(gpointer data, gint source, const gchar *error_message)
2581 { 2581 {
2582 struct yahoo_p2p_data *p2p_data; 2582 struct yahoo_p2p_data *p2p_data;
2583 struct yahoo_packet *pkt_to_send; 2583 struct yahoo_packet *pkt_to_send;
2584 PurpleAccount *account; 2584 PurpleAccount *account;
2585 struct yahoo_data *yd; 2585 YahooData *yd;
2586 2586
2587 if(!(p2p_data = data)) 2587 if(!(p2p_data = data))
2588 return ; 2588 return ;
2589 yd = p2p_data->gc->proto_data; 2589 yd = p2p_data->gc->proto_data;
2590 2590
2926 } 2926 }
2927 2927
2928 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) 2928 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond)
2929 { 2929 {
2930 PurpleConnection *gc = data; 2930 PurpleConnection *gc = data;
2931 struct yahoo_data *yd = gc->proto_data; 2931 YahooData *yd = gc->proto_data;
2932 char buf[1024]; 2932 char buf[1024];
2933 int len; 2933 int len;
2934 2934
2935 len = read(yd->fd, buf, sizeof(buf)); 2935 len = read(yd->fd, buf, sizeof(buf));
2936 2936
3023 } 3023 }
3024 3024
3025 static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message) 3025 static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message)
3026 { 3026 {
3027 PurpleConnection *gc = data; 3027 PurpleConnection *gc = data;
3028 struct yahoo_data *yd; 3028 YahooData *yd;
3029 struct yahoo_packet *pkt; 3029 struct yahoo_packet *pkt;
3030 3030
3031 if (source < 0) { 3031 if (source < 0) {
3032 gchar *tmp; 3032 gchar *tmp;
3033 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); 3033 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3049 3049
3050 #ifdef TRY_WEBMESSENGER_LOGIN 3050 #ifdef TRY_WEBMESSENGER_LOGIN
3051 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message) 3051 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message)
3052 { 3052 {
3053 PurpleConnection *gc = data; 3053 PurpleConnection *gc = data;
3054 struct yahoo_data *yd; 3054 YahooData *yd;
3055 struct yahoo_packet *pkt; 3055 struct yahoo_packet *pkt;
3056 3056
3057 if (source < 0) { 3057 if (source < 0) {
3058 gchar *tmp; 3058 gchar *tmp;
3059 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); 3059 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3079 3079
3080 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) 3080 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond)
3081 { 3081 {
3082 PurpleConnection *gc = data; 3082 PurpleConnection *gc = data;
3083 PurpleAccount *account = purple_connection_get_account(gc); 3083 PurpleAccount *account = purple_connection_get_account(gc);
3084 struct yahoo_data *yd = gc->proto_data; 3084 YahooData *yd = gc->proto_data;
3085 char bufread[2048], *i = bufread, *buf = bufread; 3085 char bufread[2048], *i = bufread, *buf = bufread;
3086 int len; 3086 int len;
3087 GString *s; 3087 GString *s;
3088 3088
3089 len = read(source, bufread, sizeof(bufread) - 1); 3089 len = read(source, bufread, sizeof(bufread) - 1);
3154 } 3154 }
3155 3155
3156 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) 3156 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond)
3157 { 3157 {
3158 PurpleConnection *gc; 3158 PurpleConnection *gc;
3159 struct yahoo_data *yd; 3159 YahooData *yd;
3160 int written, remaining; 3160 int written, remaining;
3161 3161
3162 gc = data; 3162 gc = data;
3163 yd = gc->proto_data; 3163 yd = gc->proto_data;
3164 3164
3268 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, 3268 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
3269 const gchar *url_text, size_t len, const gchar *error_message) 3269 const gchar *url_text, size_t len, const gchar *error_message)
3270 { 3270 {
3271 PurpleConnection *gc = (PurpleConnection *)user_data; 3271 PurpleConnection *gc = (PurpleConnection *)user_data;
3272 PurpleAccount *account = purple_connection_get_account(gc); 3272 PurpleAccount *account = purple_connection_get_account(gc);
3273 struct yahoo_data *yd = gc->proto_data; 3273 YahooData *yd = gc->proto_data;
3274 const char *sn = purple_account_get_username(account); 3274 const char *sn = purple_account_get_username(account);
3275 const char *pass = purple_connection_get_password(gc); 3275 const char *pass = purple_connection_get_password(gc);
3276 GHashTable *hash = yahoo_login_page_hash(url_text, len); 3276 GHashTable *hash = yahoo_login_page_hash(url_text, len);
3277 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); 3277 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login=");
3278 char md5[33], *hashp = md5, *chal; 3278 char md5[33], *hashp = md5, *chal;
3409 } 3409 }
3410 } 3410 }
3411 3411
3412 void yahoo_login(PurpleAccount *account) { 3412 void yahoo_login(PurpleAccount *account) {
3413 PurpleConnection *gc = purple_account_get_connection(account); 3413 PurpleConnection *gc = purple_account_get_connection(account);
3414 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); 3414 YahooData *yd = gc->proto_data = g_new0(YahooData, 1);
3415 PurpleStatus *status = purple_account_get_active_status(account); 3415 PurpleStatus *status = purple_account_get_active_status(account);
3416 const char *server = NULL; 3416 const char *server = NULL;
3417 int pager_port = 0; 3417 int pager_port = 0;
3418 3418
3419 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; 3419 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC;
3456 3456
3457 return; 3457 return;
3458 } 3458 }
3459 3459
3460 void yahoo_close(PurpleConnection *gc) { 3460 void yahoo_close(PurpleConnection *gc) {
3461 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 3461 YahooData *yd = (YahooData *)gc->proto_data;
3462 GSList *l; 3462 GSList *l;
3463 3463
3464 if (gc->inpa) 3464 if (gc->inpa)
3465 purple_input_remove(gc->inpa); 3465 purple_input_remove(gc->inpa);
3466 3466
3554 3554
3555 const char *yahoo_list_emblem(PurpleBuddy *b) 3555 const char *yahoo_list_emblem(PurpleBuddy *b)
3556 { 3556 {
3557 PurpleAccount *account; 3557 PurpleAccount *account;
3558 PurpleConnection *gc; 3558 PurpleConnection *gc;
3559 struct yahoo_data *yd; 3559 YahooData *yd;
3560 YahooFriend *f; 3560 YahooFriend *f;
3561 PurplePresence *presence; 3561 PurplePresence *presence;
3562 3562
3563 if (!b || !(account = purple_buddy_get_account(b)) || 3563 if (!b || !(account = purple_buddy_get_account(b)) ||
3564 !(gc = purple_account_get_connection(account)) || 3564 !(gc = purple_account_get_connection(account)) ||
3617 3617
3618 PurpleBuddy *buddy; 3618 PurpleBuddy *buddy;
3619 PurpleConnection *gc; 3619 PurpleConnection *gc;
3620 3620
3621 GHashTable *components; 3621 GHashTable *components;
3622 struct yahoo_data *yd; 3622 YahooData *yd;
3623 int id; 3623 int id;
3624 3624
3625 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 3625 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
3626 3626
3627 buddy = (PurpleBuddy *) node; 3627 buddy = (PurpleBuddy *) node;
3654 static void yahoo_game(PurpleBlistNode *node, gpointer data) { 3654 static void yahoo_game(PurpleBlistNode *node, gpointer data) {
3655 3655
3656 PurpleBuddy *buddy; 3656 PurpleBuddy *buddy;
3657 PurpleConnection *gc; 3657 PurpleConnection *gc;
3658 3658
3659 struct yahoo_data *yd; 3659 YahooData *yd;
3660 const char *game; 3660 const char *game;
3661 char *game2; 3661 char *game2;
3662 char *t; 3662 char *t;
3663 char url[256]; 3663 char url[256];
3664 YahooFriend *f; 3664 YahooFriend *f;
3665 3665
3666 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 3666 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
3667 3667
3668 buddy = (PurpleBuddy *) node; 3668 buddy = (PurpleBuddy *) node;
3669 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 3669 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
3670 yd = (struct yahoo_data *) gc->proto_data; 3670 yd = (YahooData *) gc->proto_data;
3671 3671
3672 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); 3672 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy));
3673 if (!f) 3673 if (!f)
3674 return; 3674 return;
3675 3675
3822 } 3822 }
3823 3823
3824 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { 3824 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) {
3825 GList *m = NULL; 3825 GList *m = NULL;
3826 PurpleMenuAction *act; 3826 PurpleMenuAction *act;
3827 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; 3827 YahooData *yd = (YahooData *) gc->proto_data;
3828 3828
3829 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { 3829 if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
3830 if (f->presence != YAHOO_PRESENCE_ONLINE) { 3830 if (f->presence != YAHOO_PRESENCE_ONLINE) {
3831 act = purple_menu_action_new(_("Appear Online"), 3831 act = purple_menu_action_new(_("Appear Online"),
3832 PURPLE_CALLBACK(yahoo_presence_settings), 3832 PURPLE_CALLBACK(yahoo_presence_settings),
3882 { 3882 {
3883 GList *m = NULL; 3883 GList *m = NULL;
3884 PurpleMenuAction *act; 3884 PurpleMenuAction *act;
3885 3885
3886 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 3886 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
3887 struct yahoo_data *yd = gc->proto_data; 3887 YahooData *yd = gc->proto_data;
3888 static char buf2[1024]; 3888 static char buf2[1024];
3889 YahooFriend *f; 3889 YahooFriend *f;
3890 3890
3891 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); 3891 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy));
3892 3892
3963 } 3963 }
3964 } 3964 }
3965 3965
3966 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) 3966 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields)
3967 { 3967 {
3968 struct yahoo_data *yd = gc->proto_data; 3968 YahooData *yd = gc->proto_data;
3969 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; 3969 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")];
3970 3970
3971 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); 3971 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id);
3972 yahoo_packet_hash_str(pkt, 3, name); 3972 yahoo_packet_hash_str(pkt, 3, name);
3973 yahoo_packet_send_and_free(pkt, yd); 3973 yahoo_packet_send_and_free(pkt, yd);
3980 const gchar *token, size_t len, const gchar *error_message) 3980 const gchar *token, size_t len, const gchar *error_message)
3981 { 3981 {
3982 PurpleConnection *gc = user_data; 3982 PurpleConnection *gc = user_data;
3983 gboolean set_cookie = FALSE; 3983 gboolean set_cookie = FALSE;
3984 gchar *url; 3984 gchar *url;
3985 struct yahoo_data *yd = gc->proto_data; 3985 YahooData *yd = gc->proto_data;
3986 3986
3987 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); 3987 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
3988 3988
3989 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 3989 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
3990 3990
4016 { 4016 {
4017 /* Setup a cookie that can be used by the browser */ 4017 /* Setup a cookie that can be used by the browser */
4018 /* XXX I have no idea how this will work with Yahoo! Japan. */ 4018 /* XXX I have no idea how this will work with Yahoo! Japan. */
4019 4019
4020 PurpleConnection *gc = action->context; 4020 PurpleConnection *gc = action->context;
4021 struct yahoo_data *yd = gc->proto_data; 4021 YahooData *yd = gc->proto_data;
4022 4022
4023 PurpleUtilFetchUrlData *url_data; 4023 PurpleUtilFetchUrlData *url_data;
4024 const char* base_url = "http://login.yahoo.com"; 4024 const char* base_url = "http://login.yahoo.com";
4025 /* use whole URL if using HTTP Proxy */ 4025 /* use whole URL if using HTTP Proxy */
4026 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); 4026 gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
4060 { 4060 {
4061 PurpleRequestFields *fields; 4061 PurpleRequestFields *fields;
4062 PurpleRequestFieldGroup *group; 4062 PurpleRequestFieldGroup *group;
4063 PurpleRequestField *field; 4063 PurpleRequestField *field;
4064 PurpleConnection *gc = (PurpleConnection *) action->context; 4064 PurpleConnection *gc = (PurpleConnection *) action->context;
4065 struct yahoo_data *yd = purple_connection_get_protocol_data(gc); 4065 YahooData *yd = purple_connection_get_protocol_data(gc);
4066 const char *name = purple_connection_get_display_name(gc); 4066 const char *name = purple_connection_get_display_name(gc);
4067 int iter; 4067 int iter;
4068 4068
4069 fields = purple_request_fields_new(); 4069 fields = purple_request_fields_new();
4070 group = purple_request_field_group_new(NULL); 4070 group = purple_request_field_group_new(NULL);
4130 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, 4130 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
4131 const gchar *webdata, size_t len, const gchar *error_message) 4131 const gchar *webdata, size_t len, const gchar *error_message)
4132 { 4132 {
4133 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; 4133 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data;
4134 PurpleConnection *gc = sms_cb_data->gc; 4134 PurpleConnection *gc = sms_cb_data->gc;
4135 struct yahoo_data *yd = gc->proto_data; 4135 YahooData *yd = gc->proto_data;
4136 char *mobile_no = NULL; 4136 char *mobile_no = NULL;
4137 char *status = NULL; 4137 char *status = NULL;
4138 char *carrier = NULL; 4138 char *carrier = NULL;
4139 PurpleAccount *account = purple_connection_get_account(gc); 4139 PurpleAccount *account = purple_connection_get_account(gc);
4140 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); 4140 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account);
4181 } 4181 }
4182 } 4182 }
4183 4183
4184 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) 4184 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data)
4185 { 4185 {
4186 struct yahoo_data *yd = gc->proto_data; 4186 YahooData *yd = gc->proto_data;
4187 PurpleUtilFetchUrlData *url_data; 4187 PurpleUtilFetchUrlData *url_data;
4188 struct yahoo_sms_carrier_cb_data *sms_cb_data; 4188 struct yahoo_sms_carrier_cb_data *sms_cb_data;
4189 char *validate_request_str = NULL; 4189 char *validate_request_str = NULL;
4190 char *request = NULL; 4190 char *request = NULL;
4191 gboolean use_whole_url = FALSE; 4191 gboolean use_whole_url = FALSE;
4239 } 4239 }
4240 } 4240 }
4241 4241
4242 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) 4242 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags)
4243 { 4243 {
4244 struct yahoo_data *yd = gc->proto_data; 4244 YahooData *yd = gc->proto_data;
4245 struct yahoo_packet *pkt = NULL; 4245 struct yahoo_packet *pkt = NULL;
4246 char *msg = yahoo_html_to_codes(what); 4246 char *msg = yahoo_html_to_codes(what);
4247 char *msg2; 4247 char *msg2;
4248 gboolean utf8 = TRUE; 4248 gboolean utf8 = TRUE;
4249 PurpleWhiteboard *wb; 4249 PurpleWhiteboard *wb;
4390 return ret; 4390 return ret;
4391 } 4391 }
4392 4392
4393 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) 4393 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
4394 { 4394 {
4395 struct yahoo_data *yd = gc->proto_data; 4395 YahooData *yd = gc->proto_data;
4396 struct yahoo_p2p_data *p2p_data; 4396 struct yahoo_p2p_data *p2p_data;
4397 gboolean msn = !g_strncasecmp(who, "msn/", 4); 4397 gboolean msn = !g_strncasecmp(who, "msn/", 4);
4398 struct yahoo_packet *pkt = NULL; 4398 struct yahoo_packet *pkt = NULL;
4399 4399
4400 /* Don't do anything if sms is being typed */ 4400 /* Don't do anything if sms is being typed */
4435 4435
4436 void yahoo_set_status(PurpleAccount *account, PurpleStatus *status) 4436 void yahoo_set_status(PurpleAccount *account, PurpleStatus *status)
4437 { 4437 {
4438 PurpleConnection *gc; 4438 PurpleConnection *gc;
4439 PurplePresence *presence; 4439 PurplePresence *presence;
4440 struct yahoo_data *yd; 4440 YahooData *yd;
4441 struct yahoo_packet *pkt; 4441 struct yahoo_packet *pkt;
4442 int old_status; 4442 int old_status;
4443 const char *msg = NULL; 4443 const char *msg = NULL;
4444 char *tmp = NULL; 4444 char *tmp = NULL;
4445 char *conv_msg = NULL; 4445 char *conv_msg = NULL;
4448 if (!purple_status_is_active(status)) 4448 if (!purple_status_is_active(status))
4449 return; 4449 return;
4450 4450
4451 gc = purple_account_get_connection(account); 4451 gc = purple_account_get_connection(account);
4452 presence = purple_status_get_presence(status); 4452 presence = purple_status_get_presence(status);
4453 yd = (struct yahoo_data *)gc->proto_data; 4453 yd = (YahooData *)gc->proto_data;
4454 old_status = yd->current_status; 4454 old_status = yd->current_status;
4455 4455
4456 yd->current_status = get_yahoo_status_from_purple_status(status); 4456 yd->current_status = get_yahoo_status_from_purple_status(status);
4457 4457
4458 if (yd->current_status == YAHOO_STATUS_CUSTOM) 4458 if (yd->current_status == YAHOO_STATUS_CUSTOM)
4510 } 4510 }
4511 } 4511 }
4512 4512
4513 void yahoo_set_idle(PurpleConnection *gc, int idle) 4513 void yahoo_set_idle(PurpleConnection *gc, int idle)
4514 { 4514 {
4515 struct yahoo_data *yd = gc->proto_data; 4515 YahooData *yd = gc->proto_data;
4516 struct yahoo_packet *pkt = NULL; 4516 struct yahoo_packet *pkt = NULL;
4517 char *msg = NULL, *msg2 = NULL; 4517 char *msg = NULL, *msg2 = NULL;
4518 PurpleStatus *status = NULL; 4518 PurpleStatus *status = NULL;
4519 gboolean utf8 = TRUE; 4519 gboolean utf8 = TRUE;
4520 4520
4617 } 4617 }
4618 4618
4619 void yahoo_keepalive(PurpleConnection *gc) 4619 void yahoo_keepalive(PurpleConnection *gc)
4620 { 4620 {
4621 struct yahoo_packet *pkt; 4621 struct yahoo_packet *pkt;
4622 struct yahoo_data *yd = gc->proto_data; 4622 YahooData *yd = gc->proto_data;
4623 time_t now = time(NULL); 4623 time_t now = time(NULL);
4624 4624
4625 /* We're only allowed to send a ping once an hour or the servers will boot us */ 4625 /* We're only allowed to send a ping once an hour or the servers will boot us */
4626 if ((now - yd->last_ping) >= PING_TIMEOUT) { 4626 if ((now - yd->last_ping) >= PING_TIMEOUT) {
4627 yd->last_ping = now; 4627 yd->last_ping = now;
4650 4650
4651 } 4651 }
4652 4652
4653 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) 4653 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g)
4654 { 4654 {
4655 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 4655 YahooData *yd = (YahooData *)gc->proto_data;
4656 struct yahoo_packet *pkt; 4656 struct yahoo_packet *pkt;
4657 const char *group = NULL; 4657 const char *group = NULL;
4658 char *group2; 4658 char *group2;
4659 YahooFriend *f; 4659 YahooFriend *f;
4660 const char *bname; 4660 const char *bname;
4714 g_free(group2); 4714 g_free(group2);
4715 } 4715 }
4716 4716
4717 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 4717 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
4718 { 4718 {
4719 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 4719 YahooData *yd = (YahooData *)gc->proto_data;
4720 struct yahoo_packet *pkt; 4720 struct yahoo_packet *pkt;
4721 GSList *buddies, *l; 4721 GSList *buddies, *l;
4722 PurpleGroup *g; 4722 PurpleGroup *g;
4723 gboolean remove = TRUE; 4723 gboolean remove = TRUE;
4724 char *cg; 4724 char *cg;
4762 yahoo_packet_send_and_free(pkt, yd); 4762 yahoo_packet_send_and_free(pkt, yd);
4763 g_free(cg); 4763 g_free(cg);
4764 } 4764 }
4765 4765
4766 void yahoo_add_deny(PurpleConnection *gc, const char *who) { 4766 void yahoo_add_deny(PurpleConnection *gc, const char *who) {
4767 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 4767 YahooData *yd = (YahooData *)gc->proto_data;
4768 struct yahoo_packet *pkt; 4768 struct yahoo_packet *pkt;
4769 4769
4770 if (!yd->logged_in) 4770 if (!yd->logged_in)
4771 return; 4771 return;
4772 4772
4778 7, who, 13, "1"); 4778 7, who, 13, "1");
4779 yahoo_packet_send_and_free(pkt, yd); 4779 yahoo_packet_send_and_free(pkt, yd);
4780 } 4780 }
4781 4781
4782 void yahoo_rem_deny(PurpleConnection *gc, const char *who) { 4782 void yahoo_rem_deny(PurpleConnection *gc, const char *who) {
4783 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 4783 YahooData *yd = (YahooData *)gc->proto_data;
4784 struct yahoo_packet *pkt; 4784 struct yahoo_packet *pkt;
4785 4785
4786 if (!yd->logged_in) 4786 if (!yd->logged_in)
4787 return; 4787 return;
4788 4788
4819 } 4819 }
4820 4820
4821 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, 4821 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who,
4822 const char *old_group, const char *new_group) 4822 const char *old_group, const char *new_group)
4823 { 4823 {
4824 struct yahoo_data *yd = gc->proto_data; 4824 YahooData *yd = gc->proto_data;
4825 struct yahoo_packet *pkt; 4825 struct yahoo_packet *pkt;
4826 char *gpn, *gpo; 4826 char *gpn, *gpo;
4827 YahooFriend *f = yahoo_friend_find(gc, who); 4827 YahooFriend *f = yahoo_friend_find(gc, who);
4828 gboolean msn = FALSE; 4828 gboolean msn = FALSE;
4829 const char *temp = NULL; 4829 const char *temp = NULL;
4868 } 4868 }
4869 4869
4870 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, 4870 void yahoo_rename_group(PurpleConnection *gc, const char *old_name,
4871 PurpleGroup *group, GList *moved_buddies) 4871 PurpleGroup *group, GList *moved_buddies)
4872 { 4872 {
4873 struct yahoo_data *yd = gc->proto_data; 4873 YahooData *yd = gc->proto_data;
4874 struct yahoo_packet *pkt; 4874 struct yahoo_packet *pkt;
4875 char *gpn, *gpo; 4875 char *gpn, *gpo;
4876 4876
4877 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL); 4877 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL);
4878 gpo = yahoo_string_encode(gc, old_name, NULL); 4878 gpo = yahoo_string_encode(gc, old_name, NULL);
4908 yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, 4908 yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd,
4909 char **args, char **error, void *data) 4909 char **args, char **error, void *data)
4910 { 4910 {
4911 GHashTable *comp; 4911 GHashTable *comp;
4912 PurpleConnection *gc; 4912 PurpleConnection *gc;
4913 struct yahoo_data *yd; 4913 YahooData *yd;
4914 int id; 4914 int id;
4915 4915
4916 if (!args || !args[0]) 4916 if (!args || !args[0])
4917 return PURPLE_CMD_RET_FAILED; 4917 return PURPLE_CMD_RET_FAILED;
4918 4918