Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/libymsg.c @ 32459:fcf841ffd620
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
author | andrew.victor@mxit.com |
---|---|
date | Tue, 30 Aug 2011 20:03:11 +0000 |
parents | dc3ea8f6381a |
children | d5ddf2d1ee04 |
comparison
equal
deleted
inserted
replaced
32458:1a3723704543 | 32459:fcf841ffd620 |
---|---|
494 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt) | 494 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt) |
495 { | 495 { |
496 GSList *l = pkt->hash; | 496 GSList *l = pkt->hash; |
497 | 497 |
498 PurpleAccount *account = purple_connection_get_account(gc); | 498 PurpleAccount *account = purple_connection_get_account(gc); |
499 YahooData *yd = gc->proto_data; | 499 YahooData *yd = purple_connection_get_protocol_data(gc); |
500 GHashTable *ht; | 500 GHashTable *ht; |
501 char *norm_bud = NULL; | 501 char *norm_bud = NULL; |
502 char *temp = NULL; | 502 char *temp = NULL; |
503 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */ | 503 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */ |
504 /* But what if you had no friends? */ | 504 /* But what if you had no friends? */ |
636 GSList *l = pkt->hash; | 636 GSList *l = pkt->hash; |
637 gboolean export = FALSE; | 637 gboolean export = FALSE; |
638 gboolean got_serv_list = FALSE; | 638 gboolean got_serv_list = FALSE; |
639 YahooFriend *f = NULL; | 639 YahooFriend *f = NULL; |
640 PurpleAccount *account = purple_connection_get_account(gc); | 640 PurpleAccount *account = purple_connection_get_account(gc); |
641 YahooData *yd = gc->proto_data; | 641 YahooData *yd = purple_connection_get_protocol_data(gc); |
642 GHashTable *ht; | 642 GHashTable *ht; |
643 | 643 |
644 char **lines; | 644 char **lines; |
645 char **split; | 645 char **split; |
646 char **buddies; | 646 char **buddies; |
785 char *stat = NULL; | 785 char *stat = NULL; |
786 char *game = NULL; | 786 char *game = NULL; |
787 YahooFriend *f = NULL; | 787 YahooFriend *f = NULL; |
788 GSList *l = pkt->hash; | 788 GSList *l = pkt->hash; |
789 gint val_11 = 0; | 789 gint val_11 = 0; |
790 YahooData *yd = gc->proto_data; | 790 YahooData *yd = purple_connection_get_protocol_data(gc); |
791 YahooFederation fed = YAHOO_FEDERATION_NONE; | 791 YahooFederation fed = YAHOO_FEDERATION_NONE; |
792 | 792 |
793 account = purple_connection_get_account(gc); | 793 account = purple_connection_get_account(gc); |
794 | 794 |
795 while (l) { | 795 while (l) { |
897 struct _yahoo_im *sms = NULL; | 897 struct _yahoo_im *sms = NULL; |
898 YahooData *yd; | 898 YahooData *yd; |
899 char *server_msg = NULL; | 899 char *server_msg = NULL; |
900 char *m; | 900 char *m; |
901 | 901 |
902 yd = gc->proto_data; | 902 yd = purple_connection_get_protocol_data(gc); |
903 account = purple_connection_get_account(gc); | 903 account = purple_connection_get_account(gc); |
904 | 904 |
905 while (l != NULL) { | 905 while (l != NULL) { |
906 struct yahoo_pair *pair = l->data; | 906 struct yahoo_pair *pair = l->data; |
907 if (pair->key == 4) { | 907 if (pair->key == 4) { |
958 | 958 |
959 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */ | 959 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */ |
960 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type) | 960 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type) |
961 { | 961 { |
962 PurpleAccount *account; | 962 PurpleAccount *account; |
963 YahooData *yd = gc->proto_data; | 963 YahooData *yd = purple_connection_get_protocol_data(gc); |
964 GSList *l = pkt->hash; | 964 GSList *l = pkt->hash; |
965 GSList *list = NULL; | 965 GSList *list = NULL; |
966 struct _yahoo_im *im = NULL; | 966 struct _yahoo_im *im = NULL; |
967 | 967 |
968 account = purple_connection_get_account(gc); | 968 account = purple_connection_get_account(gc); |
1200 static void | 1200 static void |
1201 yahoo_buddy_add_authorize_cb(gpointer data) | 1201 yahoo_buddy_add_authorize_cb(gpointer data) |
1202 { | 1202 { |
1203 struct yahoo_add_request *add_req = data; | 1203 struct yahoo_add_request *add_req = data; |
1204 struct yahoo_packet *pkt; | 1204 struct yahoo_packet *pkt; |
1205 YahooData *yd = add_req->gc->proto_data; | 1205 YahooData *yd = purple_connection_get_protocol_data(add_req->gc); |
1206 const char *who = add_req->who; | 1206 const char *who = add_req->who; |
1207 | 1207 |
1208 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id); | 1208 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id); |
1209 if (add_req->fed) { | 1209 if (add_req->fed) { |
1210 who += 4; | 1210 who += 4; |
1231 } | 1231 } |
1232 | 1232 |
1233 static void | 1233 static void |
1234 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) | 1234 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) |
1235 { | 1235 { |
1236 YahooData *yd = add_req->gc->proto_data; | 1236 YahooData *yd = purple_connection_get_protocol_data(add_req->gc); |
1237 struct yahoo_packet *pkt; | 1237 struct yahoo_packet *pkt; |
1238 char *encoded_msg = NULL; | 1238 char *encoded_msg = NULL; |
1239 const char *who = add_req->who; | 1239 const char *who = add_req->who; |
1240 | 1240 |
1241 if (msg && *msg) | 1241 if (msg && *msg) |
1293 } | 1293 } |
1294 | 1294 |
1295 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) | 1295 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) |
1296 { | 1296 { |
1297 char *notify_msg; | 1297 char *notify_msg; |
1298 YahooData *yd = gc->proto_data; | 1298 YahooData *yd = purple_connection_get_protocol_data(gc); |
1299 | 1299 |
1300 if (who == NULL) | 1300 if (who == NULL) |
1301 return; | 1301 return; |
1302 | 1302 |
1303 if (reason != NULL) { | 1303 if (reason != NULL) { |
1623 } | 1623 } |
1624 | 1624 |
1625 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) | 1625 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) |
1626 { | 1626 { |
1627 PurpleAccount *account = purple_connection_get_account(gc); | 1627 PurpleAccount *account = purple_connection_get_account(gc); |
1628 YahooData *yd = gc->proto_data; | 1628 YahooData *yd = purple_connection_get_protocol_data(gc); |
1629 const char *who = NULL; | 1629 const char *who = NULL; |
1630 const char *email = NULL; | 1630 const char *email = NULL; |
1631 const char *subj = NULL; | 1631 const char *subj = NULL; |
1632 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); | 1632 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); |
1633 int count = 0; | 1633 int count = 0; |
1707 *out = '\0'; | 1707 *out = '\0'; |
1708 } | 1708 } |
1709 | 1709 |
1710 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) | 1710 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) |
1711 { | 1711 { |
1712 YahooData *yd = gc->proto_data; | 1712 YahooData *yd = purple_connection_get_protocol_data(gc); |
1713 PurpleAccount *account = purple_connection_get_account(gc); | 1713 PurpleAccount *account = purple_connection_get_account(gc); |
1714 const char *name = purple_normalize(account, purple_account_get_username(account)); | 1714 const char *name = purple_normalize(account, purple_account_get_username(account)); |
1715 PurpleCipher *md5_cipher; | 1715 PurpleCipher *md5_cipher; |
1716 PurpleCipherContext *md5_ctx; | 1716 PurpleCipherContext *md5_ctx; |
1717 guchar md5_digest[16]; | 1717 guchar md5_digest[16]; |
2205 } | 2205 } |
2206 | 2206 |
2207 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) | 2207 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) |
2208 { | 2208 { |
2209 #ifdef TRY_WEBMESSENGER_LOGIN | 2209 #ifdef TRY_WEBMESSENGER_LOGIN |
2210 YahooData *yd = gc->proto_data; | 2210 YahooData *yd = purple_connection_get_protocol_data(gc); |
2211 #endif /* TRY_WEBMESSENGER_LOGIN */ | 2211 #endif /* TRY_WEBMESSENGER_LOGIN */ |
2212 GSList *l = pkt->hash; | 2212 GSList *l = pkt->hash; |
2213 int err = 0; | 2213 int err = 0; |
2214 char *msg; | 2214 char *msg; |
2215 char *url = NULL; | 2215 char *url = NULL; |
2298 char *group = NULL; | 2298 char *group = NULL; |
2299 char *decoded_group; | 2299 char *decoded_group; |
2300 char *buf; | 2300 char *buf; |
2301 YahooFriend *f; | 2301 YahooFriend *f; |
2302 GSList *l = pkt->hash; | 2302 GSList *l = pkt->hash; |
2303 YahooData *yd = gc->proto_data; | 2303 YahooData *yd = purple_connection_get_protocol_data(gc); |
2304 YahooFederation fed = YAHOO_FEDERATION_NONE; | 2304 YahooFederation fed = YAHOO_FEDERATION_NONE; |
2305 | 2305 |
2306 while (l) { | 2306 while (l) { |
2307 struct yahoo_pair *pair = l->data; | 2307 struct yahoo_pair *pair = l->data; |
2308 | 2308 |
2392 { | 2392 { |
2393 struct yahoo_p2p_data *p2p_data = value; | 2393 struct yahoo_p2p_data *p2p_data = value; |
2394 PurpleConnection *gc = user_data; | 2394 PurpleConnection *gc = user_data; |
2395 struct yahoo_packet *pkt_to_send; | 2395 struct yahoo_packet *pkt_to_send; |
2396 PurpleAccount *account; | 2396 PurpleAccount *account; |
2397 YahooData *yd = gc->proto_data; | 2397 YahooData *yd = purple_connection_get_protocol_data(gc); |
2398 | 2398 |
2399 account = purple_connection_get_account(gc); | 2399 account = purple_connection_get_account(gc); |
2400 | 2400 |
2401 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); | 2401 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); |
2402 yahoo_packet_hash(pkt_to_send, "ssisi", | 2402 yahoo_packet_hash(pkt_to_send, "ssisi", |
2411 } | 2411 } |
2412 | 2412 |
2413 static gboolean yahoo_p2p_keepalive(gpointer data) | 2413 static gboolean yahoo_p2p_keepalive(gpointer data) |
2414 { | 2414 { |
2415 PurpleConnection *gc = data; | 2415 PurpleConnection *gc = data; |
2416 YahooData *yd = gc->proto_data; | 2416 YahooData *yd = purple_connection_get_protocol_data(gc); |
2417 | 2417 |
2418 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); | 2418 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); |
2419 | 2419 |
2420 return TRUE; | 2420 return TRUE; |
2421 } | 2421 } |
2458 YahooFriend *f; | 2458 YahooFriend *f; |
2459 | 2459 |
2460 if(!(p2p_data = data)) | 2460 if(!(p2p_data = data)) |
2461 return ; | 2461 return ; |
2462 | 2462 |
2463 yd = p2p_data->gc->proto_data; | 2463 yd = purple_connection_get_protocol_data(p2p_data->gc); |
2464 | 2464 |
2465 /* lets see whats in the packet */ | 2465 /* lets see whats in the packet */ |
2466 while (l) { | 2466 while (l) { |
2467 struct yahoo_pair *pair = l->data; | 2467 struct yahoo_pair *pair = l->data; |
2468 | 2468 |
2543 struct yahoo_p2p_data *p2p_data; | 2543 struct yahoo_p2p_data *p2p_data; |
2544 YahooData *yd; | 2544 YahooData *yd; |
2545 | 2545 |
2546 if(!(p2p_data = data)) | 2546 if(!(p2p_data = data)) |
2547 return ; | 2547 return ; |
2548 yd = p2p_data->gc->proto_data; | 2548 yd = purple_connection_get_protocol_data(p2p_data->gc); |
2549 | 2549 |
2550 len = read(source, buf, sizeof(buf)); | 2550 len = read(source, buf, sizeof(buf)); |
2551 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) | 2551 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) |
2552 return ; /* No Worries*/ | 2552 return ; /* No Worries*/ |
2553 else if (len <= 0) | 2553 else if (len <= 0) |
2615 struct yahoo_p2p_data *p2p_data; | 2615 struct yahoo_p2p_data *p2p_data; |
2616 YahooData *yd; | 2616 YahooData *yd; |
2617 | 2617 |
2618 if(!(p2p_data = data)) | 2618 if(!(p2p_data = data)) |
2619 return ; | 2619 return ; |
2620 yd = p2p_data->gc->proto_data; | 2620 yd = purple_connection_get_protocol_data(p2p_data->gc); |
2621 | 2621 |
2622 acceptfd = accept(source, NULL, 0); | 2622 acceptfd = accept(source, NULL, 0); |
2623 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) | 2623 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) |
2624 return; | 2624 return; |
2625 else if(acceptfd == -1) { | 2625 else if(acceptfd == -1) { |
2655 YahooData *yd; | 2655 YahooData *yd; |
2656 | 2656 |
2657 if(!(p2p_data = data)) | 2657 if(!(p2p_data = data)) |
2658 return FALSE; | 2658 return FALSE; |
2659 | 2659 |
2660 yd = p2p_data->gc->proto_data; | 2660 yd = purple_connection_get_protocol_data(p2p_data->gc); |
2661 | 2661 |
2662 purple_debug_warning("yahoo","yahoo p2p server timeout, peer failed to connect\n"); | 2662 purple_debug_warning("yahoo","yahoo p2p server timeout, peer failed to connect\n"); |
2663 yahoo_p2p_disconnect_destroy_data(data); | 2663 yahoo_p2p_disconnect_destroy_data(data); |
2664 purple_input_remove(yd->yahoo_p2p_server_watcher); | 2664 purple_input_remove(yd->yahoo_p2p_server_watcher); |
2665 yd->yahoo_p2p_server_watcher = 0; | 2665 yd->yahoo_p2p_server_watcher = 0; |
2676 YahooData *yd; | 2676 YahooData *yd; |
2677 | 2677 |
2678 if(!(p2p_data = data)) | 2678 if(!(p2p_data = data)) |
2679 return ; | 2679 return ; |
2680 | 2680 |
2681 yd = p2p_data->gc->proto_data; | 2681 yd = purple_connection_get_protocol_data(p2p_data->gc); |
2682 yd->listen_data = NULL; | 2682 yd->listen_data = NULL; |
2683 | 2683 |
2684 if(listenfd == -1) { | 2684 if(listenfd == -1) { |
2685 purple_debug_warning("yahoo","p2p: error starting p2p server\n"); | 2685 purple_debug_warning("yahoo","p2p: error starting p2p server\n"); |
2686 yahoo_p2p_disconnect_destroy_data(data); | 2686 yahoo_p2p_disconnect_destroy_data(data); |
2704 char temp_str[100]; | 2704 char temp_str[100]; |
2705 gchar *base64_ip = NULL; | 2705 gchar *base64_ip = NULL; |
2706 YahooFriend *f; | 2706 YahooFriend *f; |
2707 struct yahoo_packet *pkt; | 2707 struct yahoo_packet *pkt; |
2708 PurpleAccount *account; | 2708 PurpleAccount *account; |
2709 YahooData *yd = gc->proto_data; | 2709 YahooData *yd = purple_connection_get_protocol_data(gc); |
2710 struct yahoo_p2p_data *p2p_data; | 2710 struct yahoo_p2p_data *p2p_data; |
2711 const char *norm_username; | 2711 const char *norm_username; |
2712 | 2712 |
2713 f = yahoo_friend_find(gc, who); | 2713 f = yahoo_friend_find(gc, who); |
2714 account = purple_connection_get_account(gc); | 2714 account = purple_connection_get_account(gc); |
2785 struct yahoo_packet *pkt_to_send; | 2785 struct yahoo_packet *pkt_to_send; |
2786 PurpleAccount *account; | 2786 PurpleAccount *account; |
2787 YahooData *yd; | 2787 YahooData *yd; |
2788 | 2788 |
2789 p2p_data = data; | 2789 p2p_data = data; |
2790 yd = p2p_data->gc->proto_data; | 2790 yd = purple_connection_get_protocol_data(p2p_data->gc); |
2791 | 2791 |
2792 if(error_message != NULL) { | 2792 if(error_message != NULL) { |
2793 purple_debug_warning("yahoo","p2p: %s\n",error_message); | 2793 purple_debug_warning("yahoo","p2p: %s\n",error_message); |
2794 yahoo_send_p2p_pkt(p2p_data->gc, p2p_data->host_username, 2);/* send p2p init packet with val_13=2 */ | 2794 yahoo_send_p2p_pkt(p2p_data->gc, p2p_data->host_username, 2);/* send p2p init packet with val_13=2 */ |
2795 | 2795 |
3130 } | 3130 } |
3131 | 3131 |
3132 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) | 3132 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) |
3133 { | 3133 { |
3134 PurpleConnection *gc = data; | 3134 PurpleConnection *gc = data; |
3135 YahooData *yd = gc->proto_data; | 3135 YahooData *yd = purple_connection_get_protocol_data(gc); |
3136 char buf[1024]; | 3136 char buf[1024]; |
3137 int len; | 3137 int len; |
3138 | 3138 |
3139 len = read(yd->fd, buf, sizeof(buf)); | 3139 len = read(yd->fd, buf, sizeof(buf)); |
3140 | 3140 |
3238 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); | 3238 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
3239 g_free(tmp); | 3239 g_free(tmp); |
3240 return; | 3240 return; |
3241 } | 3241 } |
3242 | 3242 |
3243 yd = gc->proto_data; | 3243 yd = purple_connection_get_protocol_data(gc); |
3244 yd->fd = source; | 3244 yd->fd = source; |
3245 | 3245 |
3246 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id); | 3246 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id); |
3247 | 3247 |
3248 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); | 3248 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); |
3264 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); | 3264 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
3265 g_free(tmp); | 3265 g_free(tmp); |
3266 return; | 3266 return; |
3267 } | 3267 } |
3268 | 3268 |
3269 yd = gc->proto_data; | 3269 yd = purple_connection_get_protocol_data(gc); |
3270 yd->fd = source; | 3270 yd->fd = source; |
3271 | 3271 |
3272 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id); | 3272 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id); |
3273 | 3273 |
3274 yahoo_packet_hash(pkt, "sss", 0, | 3274 yahoo_packet_hash(pkt, "sss", 0, |
3283 | 3283 |
3284 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) | 3284 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) |
3285 { | 3285 { |
3286 PurpleConnection *gc = data; | 3286 PurpleConnection *gc = data; |
3287 PurpleAccount *account = purple_connection_get_account(gc); | 3287 PurpleAccount *account = purple_connection_get_account(gc); |
3288 YahooData *yd = gc->proto_data; | 3288 YahooData *yd = purple_connection_get_protocol_data(gc); |
3289 char bufread[2048], *i = bufread, *buf = bufread; | 3289 char bufread[2048], *i = bufread, *buf = bufread; |
3290 int len; | 3290 int len; |
3291 GString *s; | 3291 GString *s; |
3292 | 3292 |
3293 len = read(source, bufread, sizeof(bufread) - 1); | 3293 len = read(source, bufread, sizeof(bufread) - 1); |
3362 PurpleConnection *gc; | 3362 PurpleConnection *gc; |
3363 YahooData *yd; | 3363 YahooData *yd; |
3364 int written, remaining; | 3364 int written, remaining; |
3365 | 3365 |
3366 gc = data; | 3366 gc = data; |
3367 yd = gc->proto_data; | 3367 yd = purple_connection_get_protocol_data(gc); |
3368 | 3368 |
3369 remaining = strlen(yd->auth) - yd->auth_written; | 3369 remaining = strlen(yd->auth) - yd->auth_written; |
3370 written = write(source, yd->auth + yd->auth_written, remaining); | 3370 written = write(source, yd->auth + yd->auth_written, remaining); |
3371 | 3371 |
3372 if (written < 0 && errno == EAGAIN) | 3372 if (written < 0 && errno == EAGAIN) |
3472 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, | 3472 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
3473 const gchar *url_text, size_t len, const gchar *error_message) | 3473 const gchar *url_text, size_t len, const gchar *error_message) |
3474 { | 3474 { |
3475 PurpleConnection *gc = (PurpleConnection *)user_data; | 3475 PurpleConnection *gc = (PurpleConnection *)user_data; |
3476 PurpleAccount *account = purple_connection_get_account(gc); | 3476 PurpleAccount *account = purple_connection_get_account(gc); |
3477 YahooData *yd = gc->proto_data; | 3477 YahooData *yd = purple_connection_get_protocol_data(gc); |
3478 const char *sn = purple_account_get_username(account); | 3478 const char *sn = purple_account_get_username(account); |
3479 const char *pass = purple_connection_get_password(gc); | 3479 const char *pass = purple_connection_get_password(gc); |
3480 GHashTable *hash = yahoo_login_page_hash(url_text, len); | 3480 GHashTable *hash = yahoo_login_page_hash(url_text, len); |
3481 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); | 3481 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); |
3482 char md5[33], *hashp = md5, *chal; | 3482 char md5[33], *hashp = md5, *chal; |
3669 g_free(cs_server); | 3669 g_free(cs_server); |
3670 } | 3670 } |
3671 | 3671 |
3672 void yahoo_login(PurpleAccount *account) { | 3672 void yahoo_login(PurpleAccount *account) { |
3673 PurpleConnection *gc = purple_account_get_connection(account); | 3673 PurpleConnection *gc = purple_account_get_connection(account); |
3674 YahooData *yd = gc->proto_data = g_new0(YahooData, 1); | 3674 YahooData *yd = g_new0(YahooData, 1); |
3675 PurpleStatus *status = purple_account_get_active_status(account); | 3675 PurpleStatus *status = purple_account_get_active_status(account); |
3676 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); | 3676 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); |
3677 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); | 3677 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); |
3678 PurpleUtilFetchUrlData *url_data; | 3678 PurpleUtilFetchUrlData *url_data; |
3679 | 3679 |
3680 purple_connection_set_protocol_data(gc, yd); | |
3680 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; | 3681 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; |
3681 | 3682 |
3682 purple_connection_update_progress(gc, _("Connecting"), 1, 2); | 3683 purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
3683 | 3684 |
3684 purple_connection_set_display_name(gc, purple_account_get_username(account)); | 3685 purple_connection_set_display_name(gc, purple_account_get_username(account)); |
3719 | 3720 |
3720 return; | 3721 return; |
3721 } | 3722 } |
3722 | 3723 |
3723 void yahoo_close(PurpleConnection *gc) { | 3724 void yahoo_close(PurpleConnection *gc) { |
3724 YahooData *yd = (YahooData *)gc->proto_data; | 3725 YahooData *yd = purple_connection_get_protocol_data(gc); |
3725 GSList *l; | 3726 GSList *l; |
3726 | 3727 |
3727 if (gc->inpa) | 3728 if (gc->inpa) |
3728 purple_input_remove(gc->inpa); | 3729 purple_input_remove(gc->inpa); |
3729 | 3730 |
3808 yahoo_personal_details_reset(&yd->ypd, TRUE); | 3809 yahoo_personal_details_reset(&yd->ypd, TRUE); |
3809 | 3810 |
3810 g_free(yd->current_list15_grp); | 3811 g_free(yd->current_list15_grp); |
3811 | 3812 |
3812 g_free(yd); | 3813 g_free(yd); |
3813 gc->proto_data = NULL; | 3814 purple_connection_set_protocol_data(gc, NULL); |
3814 } | 3815 } |
3815 | 3816 |
3816 const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b) | 3817 const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b) |
3817 { | 3818 { |
3818 return "yahoo"; | 3819 return "yahoo"; |
3825 YahooFriend *f; | 3826 YahooFriend *f; |
3826 PurplePresence *presence; | 3827 PurplePresence *presence; |
3827 | 3828 |
3828 if (!b || !(account = purple_buddy_get_account(b)) || | 3829 if (!b || !(account = purple_buddy_get_account(b)) || |
3829 !(gc = purple_account_get_connection(account)) || | 3830 !(gc = purple_account_get_connection(account)) || |
3830 !gc->proto_data) | 3831 !purple_connection_get_protocol_data(gc)) |
3831 return NULL; | 3832 return NULL; |
3832 | 3833 |
3833 f = yahoo_friend_find(gc, purple_buddy_get_name(b)); | 3834 f = yahoo_friend_find(gc, purple_buddy_get_name(b)); |
3834 if (!f) { | 3835 if (!f) { |
3835 return "not-authorized"; | 3836 return "not-authorized"; |
3890 | 3891 |
3891 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 3892 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
3892 | 3893 |
3893 buddy = (PurpleBuddy *) node; | 3894 buddy = (PurpleBuddy *) node; |
3894 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 3895 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
3895 yd = gc->proto_data; | 3896 yd = purple_connection_get_protocol_data(gc); |
3896 id = yd->conf_id; | 3897 id = yd->conf_id; |
3897 | 3898 |
3898 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 3899 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
3899 g_hash_table_replace(components, g_strdup("room"), | 3900 g_hash_table_replace(components, g_strdup("room"), |
3900 g_strdup_printf("%s-%d", purple_connection_get_display_name(gc), id)); | 3901 g_strdup_printf("%s-%d", purple_connection_get_display_name(gc), id)); |
4073 } | 4074 } |
4074 | 4075 |
4075 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { | 4076 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { |
4076 GList *m = NULL; | 4077 GList *m = NULL; |
4077 PurpleMenuAction *act; | 4078 PurpleMenuAction *act; |
4078 YahooData *yd = (YahooData *) gc->proto_data; | 4079 YahooData *yd = purple_connection_get_protocol_data(gc); |
4079 | 4080 |
4080 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { | 4081 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
4081 if (f->presence != YAHOO_PRESENCE_ONLINE) { | 4082 if (f->presence != YAHOO_PRESENCE_ONLINE) { |
4082 act = purple_menu_action_new(_("Appear Online"), | 4083 act = purple_menu_action_new(_("Appear Online"), |
4083 PURPLE_CALLBACK(yahoo_presence_settings), | 4084 PURPLE_CALLBACK(yahoo_presence_settings), |
4133 { | 4134 { |
4134 GList *m = NULL; | 4135 GList *m = NULL; |
4135 PurpleMenuAction *act; | 4136 PurpleMenuAction *act; |
4136 | 4137 |
4137 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 4138 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
4138 YahooData *yd = gc->proto_data; | 4139 YahooData *yd = purple_connection_get_protocol_data(gc); |
4139 static char buf2[1024]; | 4140 static char buf2[1024]; |
4140 YahooFriend *f; | 4141 YahooFriend *f; |
4141 | 4142 |
4142 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); | 4143 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); |
4143 | 4144 |
4216 } | 4217 } |
4217 } | 4218 } |
4218 | 4219 |
4219 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) | 4220 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) |
4220 { | 4221 { |
4221 YahooData *yd = gc->proto_data; | 4222 YahooData *yd = purple_connection_get_protocol_data(gc); |
4222 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; | 4223 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; |
4223 | 4224 |
4224 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); | 4225 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4225 yahoo_packet_hash_str(pkt, 3, name); | 4226 yahoo_packet_hash_str(pkt, 3, name); |
4226 yahoo_packet_send_and_free(pkt, yd); | 4227 yahoo_packet_send_and_free(pkt, yd); |
4233 const gchar *token, size_t len, const gchar *error_message) | 4234 const gchar *token, size_t len, const gchar *error_message) |
4234 { | 4235 { |
4235 PurpleConnection *gc = user_data; | 4236 PurpleConnection *gc = user_data; |
4236 gboolean set_cookie = FALSE; | 4237 gboolean set_cookie = FALSE; |
4237 gchar *url; | 4238 gchar *url; |
4238 YahooData *yd = gc->proto_data; | 4239 YahooData *yd = purple_connection_get_protocol_data(gc); |
4239 | 4240 |
4240 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); | 4241 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
4241 | 4242 |
4242 yd->url_datas = g_slist_remove(yd->url_datas, url_data); | 4243 yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
4243 | 4244 |
4269 { | 4270 { |
4270 /* Setup a cookie that can be used by the browser */ | 4271 /* Setup a cookie that can be used by the browser */ |
4271 /* XXX I have no idea how this will work with Yahoo! Japan. */ | 4272 /* XXX I have no idea how this will work with Yahoo! Japan. */ |
4272 | 4273 |
4273 PurpleConnection *gc = action->context; | 4274 PurpleConnection *gc = action->context; |
4274 YahooData *yd = gc->proto_data; | 4275 YahooData *yd = purple_connection_get_protocol_data(gc); |
4275 | 4276 |
4276 PurpleUtilFetchUrlData *url_data; | 4277 PurpleUtilFetchUrlData *url_data; |
4277 const char* base_url = "http://login.yahoo.com"; | 4278 const char* base_url = "http://login.yahoo.com"; |
4278 /* use whole URL if using HTTP Proxy */ | 4279 /* use whole URL if using HTTP Proxy */ |
4279 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); | 4280 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); |
4383 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, | 4384 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
4384 const gchar *webdata, size_t len, const gchar *error_message) | 4385 const gchar *webdata, size_t len, const gchar *error_message) |
4385 { | 4386 { |
4386 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; | 4387 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; |
4387 PurpleConnection *gc = sms_cb_data->gc; | 4388 PurpleConnection *gc = sms_cb_data->gc; |
4388 YahooData *yd = gc->proto_data; | 4389 YahooData *yd = purple_connection_get_protocol_data(gc); |
4389 char *status = NULL; | 4390 char *status = NULL; |
4390 char *carrier = NULL; | 4391 char *carrier = NULL; |
4391 PurpleAccount *account = purple_connection_get_account(gc); | 4392 PurpleAccount *account = purple_connection_get_account(gc); |
4392 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); | 4393 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); |
4393 | 4394 |
4438 } | 4439 } |
4439 } | 4440 } |
4440 | 4441 |
4441 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) | 4442 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) |
4442 { | 4443 { |
4443 YahooData *yd = gc->proto_data; | 4444 YahooData *yd = purple_connection_get_protocol_data(gc); |
4444 PurpleUtilFetchUrlData *url_data; | 4445 PurpleUtilFetchUrlData *url_data; |
4445 struct yahoo_sms_carrier_cb_data *sms_cb_data; | 4446 struct yahoo_sms_carrier_cb_data *sms_cb_data; |
4446 char *validate_request_str = NULL; | 4447 char *validate_request_str = NULL; |
4447 char *request = NULL; | 4448 char *request = NULL; |
4448 gboolean use_whole_url = FALSE; | 4449 gboolean use_whole_url = FALSE; |
4498 } | 4499 } |
4499 } | 4500 } |
4500 | 4501 |
4501 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) | 4502 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) |
4502 { | 4503 { |
4503 YahooData *yd = gc->proto_data; | 4504 YahooData *yd = purple_connection_get_protocol_data(gc); |
4504 struct yahoo_packet *pkt = NULL; | 4505 struct yahoo_packet *pkt = NULL; |
4505 char *msg = yahoo_html_to_codes(what); | 4506 char *msg = yahoo_html_to_codes(what); |
4506 char *msg2; | 4507 char *msg2; |
4507 gboolean utf8 = TRUE; | 4508 gboolean utf8 = TRUE; |
4508 PurpleWhiteboard *wb; | 4509 PurpleWhiteboard *wb; |
4655 return ret; | 4656 return ret; |
4656 } | 4657 } |
4657 | 4658 |
4658 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) | 4659 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) |
4659 { | 4660 { |
4660 YahooData *yd = gc->proto_data; | 4661 YahooData *yd = purple_connection_get_protocol_data(gc); |
4661 struct yahoo_p2p_data *p2p_data; | 4662 struct yahoo_p2p_data *p2p_data; |
4662 YahooFederation fed = YAHOO_FEDERATION_NONE; | 4663 YahooFederation fed = YAHOO_FEDERATION_NONE; |
4663 struct yahoo_packet *pkt = NULL; | 4664 struct yahoo_packet *pkt = NULL; |
4664 | 4665 |
4665 fed = yahoo_get_federation_from_name(who); | 4666 fed = yahoo_get_federation_from_name(who); |
4726 if (!purple_status_is_active(status)) | 4727 if (!purple_status_is_active(status)) |
4727 return; | 4728 return; |
4728 | 4729 |
4729 gc = purple_account_get_connection(account); | 4730 gc = purple_account_get_connection(account); |
4730 presence = purple_status_get_presence(status); | 4731 presence = purple_status_get_presence(status); |
4731 yd = (YahooData *)gc->proto_data; | 4732 yd = purple_connection_get_protocol_data(gc); |
4732 old_status = yd->current_status; | 4733 old_status = yd->current_status; |
4733 | 4734 |
4734 yd->current_status = get_yahoo_status_from_purple_status(status); | 4735 yd->current_status = get_yahoo_status_from_purple_status(status); |
4735 | 4736 |
4736 if (yd->current_status == YAHOO_STATUS_CUSTOM) | 4737 if (yd->current_status == YAHOO_STATUS_CUSTOM) |
4792 } | 4793 } |
4793 } | 4794 } |
4794 | 4795 |
4795 void yahoo_set_idle(PurpleConnection *gc, int idle) | 4796 void yahoo_set_idle(PurpleConnection *gc, int idle) |
4796 { | 4797 { |
4797 YahooData *yd = gc->proto_data; | 4798 YahooData *yd = purple_connection_get_protocol_data(gc); |
4798 struct yahoo_packet *pkt = NULL; | 4799 struct yahoo_packet *pkt = NULL; |
4799 char *msg = NULL, *msg2 = NULL; | 4800 char *msg = NULL, *msg2 = NULL; |
4800 PurpleStatus *status = NULL; | 4801 PurpleStatus *status = NULL; |
4801 gboolean invisible = FALSE; | 4802 gboolean invisible = FALSE; |
4802 | 4803 |
4911 } | 4912 } |
4912 | 4913 |
4913 void yahoo_keepalive(PurpleConnection *gc) | 4914 void yahoo_keepalive(PurpleConnection *gc) |
4914 { | 4915 { |
4915 struct yahoo_packet *pkt; | 4916 struct yahoo_packet *pkt; |
4916 YahooData *yd = gc->proto_data; | 4917 YahooData *yd = purple_connection_get_protocol_data(gc); |
4917 time_t now = time(NULL); | 4918 time_t now = time(NULL); |
4918 | 4919 |
4919 /* We're only allowed to send a ping once an hour or the servers will boot us */ | 4920 /* We're only allowed to send a ping once an hour or the servers will boot us */ |
4920 if ((now - yd->last_ping) >= PING_TIMEOUT) { | 4921 if ((now - yd->last_ping) >= PING_TIMEOUT) { |
4921 yd->last_ping = now; | 4922 yd->last_ping = now; |
4944 | 4945 |
4945 } | 4946 } |
4946 | 4947 |
4947 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) | 4948 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) |
4948 { | 4949 { |
4949 YahooData *yd = (YahooData *)gc->proto_data; | 4950 YahooData *yd = purple_connection_get_protocol_data(gc); |
4950 struct yahoo_packet *pkt; | 4951 struct yahoo_packet *pkt; |
4951 const char *group = NULL; | 4952 const char *group = NULL; |
4952 char *group2; | 4953 char *group2; |
4953 const char *bname; | 4954 const char *bname; |
4954 const char *fed_bname; | 4955 const char *fed_bname; |
5007 g_free(group2); | 5008 g_free(group2); |
5008 } | 5009 } |
5009 | 5010 |
5010 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 5011 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
5011 { | 5012 { |
5012 YahooData *yd = (YahooData *)gc->proto_data; | 5013 YahooData *yd = purple_connection_get_protocol_data(gc); |
5013 struct yahoo_packet *pkt; | 5014 struct yahoo_packet *pkt; |
5014 GSList *buddies, *l; | 5015 GSList *buddies, *l; |
5015 PurpleGroup *g; | 5016 PurpleGroup *g; |
5016 gboolean remove = TRUE; | 5017 gboolean remove = TRUE; |
5017 char *cg; | 5018 char *cg; |
5063 yahoo_packet_send_and_free(pkt, yd); | 5064 yahoo_packet_send_and_free(pkt, yd); |
5064 g_free(cg); | 5065 g_free(cg); |
5065 } | 5066 } |
5066 | 5067 |
5067 void yahoo_add_deny(PurpleConnection *gc, const char *who) { | 5068 void yahoo_add_deny(PurpleConnection *gc, const char *who) { |
5068 YahooData *yd = (YahooData *)gc->proto_data; | 5069 YahooData *yd = purple_connection_get_protocol_data(gc); |
5069 struct yahoo_packet *pkt; | 5070 struct yahoo_packet *pkt; |
5070 YahooFederation fed = YAHOO_FEDERATION_NONE; | 5071 YahooFederation fed = YAHOO_FEDERATION_NONE; |
5071 | 5072 |
5072 if (!yd->logged_in) | 5073 if (!yd->logged_in) |
5073 return; | 5074 return; |
5086 | 5087 |
5087 yahoo_packet_send_and_free(pkt, yd); | 5088 yahoo_packet_send_and_free(pkt, yd); |
5088 } | 5089 } |
5089 | 5090 |
5090 void yahoo_rem_deny(PurpleConnection *gc, const char *who) { | 5091 void yahoo_rem_deny(PurpleConnection *gc, const char *who) { |
5091 YahooData *yd = (YahooData *)gc->proto_data; | 5092 YahooData *yd = purple_connection_get_protocol_data(gc); |
5092 struct yahoo_packet *pkt; | 5093 struct yahoo_packet *pkt; |
5093 YahooFederation fed = YAHOO_FEDERATION_NONE; | 5094 YahooFederation fed = YAHOO_FEDERATION_NONE; |
5094 | 5095 |
5095 if (!yd->logged_in) | 5096 if (!yd->logged_in) |
5096 return; | 5097 return; |
5134 } | 5135 } |
5135 | 5136 |
5136 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, | 5137 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, |
5137 const char *old_group, const char *new_group) | 5138 const char *old_group, const char *new_group) |
5138 { | 5139 { |
5139 YahooData *yd = gc->proto_data; | 5140 YahooData *yd = purple_connection_get_protocol_data(gc); |
5140 struct yahoo_packet *pkt; | 5141 struct yahoo_packet *pkt; |
5141 char *gpn, *gpo; | 5142 char *gpn, *gpo; |
5142 YahooFriend *f = yahoo_friend_find(gc, who); | 5143 YahooFriend *f = yahoo_friend_find(gc, who); |
5143 const char *temp = NULL; | 5144 const char *temp = NULL; |
5144 | 5145 |
5181 } | 5182 } |
5182 | 5183 |
5183 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, | 5184 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, |
5184 PurpleGroup *group, GList *moved_buddies) | 5185 PurpleGroup *group, GList *moved_buddies) |
5185 { | 5186 { |
5186 YahooData *yd = gc->proto_data; | 5187 YahooData *yd = purple_connection_get_protocol_data(gc); |
5187 struct yahoo_packet *pkt; | 5188 struct yahoo_packet *pkt; |
5188 char *gpn, *gpo; | 5189 char *gpn, *gpo; |
5189 | 5190 |
5190 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL); | 5191 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL); |
5191 gpo = yahoo_string_encode(gc, old_name, NULL); | 5192 gpo = yahoo_string_encode(gc, old_name, NULL); |