Mercurial > pidgin
diff libpurple/protocols/yahoo/libymsg.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 02 Jun 2012 02:30:49 +0000 |
parents | f07501af8bae |
children |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/libymsg.c Sat Jun 02 02:30:13 2012 +0000 +++ b/libpurple/protocols/yahoo/libymsg.c Sat Jun 02 02:30:49 2012 +0000 @@ -159,7 +159,7 @@ if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { if (!purple_account_get_remember_password(account)) purple_account_set_password(account, NULL); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE, _("You have signed on from another location")); return; } @@ -337,12 +337,12 @@ if (!name) break; - b = purple_find_buddy(gc->account, name); + b = purple_find_buddy(purple_connection_get_account(gc), name); if (!cksum || (cksum == -1)) { if (f) yahoo_friend_set_buddy_icon_need_request(f, TRUE); - purple_buddy_icons_set_for_user(gc->account, name, NULL, 0, NULL); + purple_buddy_icons_set_for_user(purple_connection_get_account(gc), name, NULL, 0, NULL); break; } @@ -496,7 +496,7 @@ GSList *l = pkt->hash; PurpleAccount *account = purple_connection_get_account(gc); - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); GHashTable *ht; char *norm_bud = NULL; char *temp = NULL; @@ -573,7 +573,7 @@ yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_DO_NOT_CONNECT); } else { /* This buddy is on the ignore list (and therefore in no group) */ - purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n",account->username, norm_bud); + purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n", purple_account_get_username(account), norm_bud); purple_privacy_deny_add(account, norm_bud, 1); } @@ -634,11 +634,10 @@ static void yahoo_process_list(PurpleConnection *gc, struct yahoo_packet *pkt) { GSList *l = pkt->hash; - gboolean export = FALSE; gboolean got_serv_list = FALSE; YahooFriend *f = NULL; PurpleAccount *account = purple_connection_get_account(gc); - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); GHashTable *ht; char **lines; @@ -712,7 +711,6 @@ } b = purple_buddy_new(account, norm_bud, NULL); purple_blist_add_buddy(b, NULL, g, NULL); - export = TRUE; } yahoo_do_group_check(account, ht, norm_bud, grp); @@ -748,13 +746,13 @@ } if (got_serv_list && - ((account->perm_deny != PURPLE_PRIVACY_ALLOW_BUDDYLIST) && - (account->perm_deny != PURPLE_PRIVACY_DENY_ALL) && - (account->perm_deny != PURPLE_PRIVACY_ALLOW_USERS))) + ((purple_account_get_privacy_type(account) != PURPLE_PRIVACY_ALLOW_BUDDYLIST) && + (purple_account_get_privacy_type(account) != PURPLE_PRIVACY_DENY_ALL) && + (purple_account_get_privacy_type(account) != PURPLE_PRIVACY_ALLOW_USERS))) { - account->perm_deny = PURPLE_PRIVACY_DENY_USERS; + purple_account_set_privacy_type(account, PURPLE_PRIVACY_DENY_USERS); purple_debug_info("yahoo", "%s privacy defaulting to PURPLE_PRIVACY_DENY_USERS.\n", - account->username); + purple_account_get_username(account)); } if (yd->tmp_serv_plist) { @@ -763,7 +761,7 @@ f = yahoo_friend_find(gc, *bud); if (f) { purple_debug_info("yahoo", "%s setting presence for %s to PERM_OFFLINE\n", - account->username, *bud); + purple_account_get_username(account), *bud); f->presence = YAHOO_PRESENCE_PERM_OFFLINE; } } @@ -787,7 +785,7 @@ YahooFriend *f = NULL; GSList *l = pkt->hash; gint val_11 = 0; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); YahooFederation fed = YAHOO_FEDERATION_NONE; account = purple_connection_get_account(gc); @@ -899,7 +897,7 @@ char *server_msg = NULL; char *m; - yd = gc->proto_data; + yd = purple_connection_get_protocol_data(gc); account = purple_connection_get_account(gc); while (l != NULL) { @@ -960,7 +958,7 @@ static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type) { PurpleAccount *account; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); GSList *l = pkt->hash; GSList *list = NULL; struct _yahoo_im *im = NULL; @@ -1061,7 +1059,7 @@ doodle_session *ds; wb = purple_whiteboard_create(account, im->from, DOODLE_STATE_REQUESTED); - ds = wb->proto_data; + ds = purple_whiteboard_get_protocol_data(wb); ds->imv_key = g_strdup(pair->value); yahoo_doodle_command_send_request(gc, im->from, pair->value); @@ -1202,7 +1200,7 @@ { struct yahoo_add_request *add_req = data; struct yahoo_packet *pkt; - YahooData *yd = add_req->gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(add_req->gc); const char *who = add_req->who; pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id); @@ -1233,7 +1231,7 @@ static void yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) { - YahooData *yd = add_req->gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(add_req->gc); struct yahoo_packet *pkt; char *encoded_msg = NULL; const char *who = add_req->who; @@ -1295,7 +1293,7 @@ static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason) { char *notify_msg; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); if (who == NULL) return; @@ -1625,7 +1623,7 @@ static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) { PurpleAccount *account = purple_connection_get_account(gc); - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); const char *who = NULL; const char *email = NULL; const char *subj = NULL; @@ -1709,7 +1707,7 @@ static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); PurpleAccount *account = purple_connection_get_account(gc); const char *name = purple_normalize(account, purple_account_get_username(account)); PurpleCipher *md5_cipher; @@ -1803,7 +1801,7 @@ if (error_message != NULL) { purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); g_free(auth_data->seed); g_free(auth_data); return; @@ -1890,7 +1888,7 @@ if(error_reason) { purple_debug_error("yahoo", "Authentication error: %s. " "Code %d\n", error_reason, response_no); - purple_connection_error_reason(gc, error, error_reason); + purple_connection_error(gc, error, error_reason); g_free(error_reason); g_free(auth_data->seed); g_free(auth_data); @@ -1919,7 +1917,7 @@ if (error_message != NULL) { purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); g_free(auth_data->seed); g_free(auth_data); return; @@ -2000,7 +1998,7 @@ } purple_debug_error("yahoo", "Authentication error: %s. Code %d\n", error_reason, response_no); - purple_connection_error_reason(gc, error, error_reason); + purple_connection_error(gc, error, error_reason); g_free(error_reason); g_free(auth_data->seed); g_free(auth_data); @@ -2014,7 +2012,7 @@ gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token); - url_data = purple_util_fetch_url_request_len_with_account( + url_data = purple_util_fetch_url_request( proxy_ssl ? account : NULL, url, TRUE, YAHOO_CLIENT_USERAGENT, TRUE, NULL, TRUE, -1, yahoo_auth16_stage2, auth_data); if (url_data) @@ -2040,7 +2038,7 @@ purple_debug_info("yahoo", "Authentication: In yahoo_auth16_stage1\n"); if(!purple_ssl_is_supported()) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable")); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable")); return; } @@ -2055,7 +2053,7 @@ g_free(encoded_password); g_free(encoded_username); - url_data = purple_util_fetch_url_request_len_with_account( + url_data = purple_util_fetch_url_request( proxy_ssl ? account : NULL, url, TRUE, YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1, yahoo_auth16_stage1_cb, auth_data); @@ -2180,12 +2178,12 @@ who, (ignore ? "ignoring" : "unignoring")); if (ignore) { - b = purple_find_buddy(gc->account, who); + b = purple_find_buddy(purple_connection_get_account(gc), who); g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " "user is on your buddy list. Clicking \"Yes\" " "will remove and ignore the buddy."), who); purple_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, - gc->account, who, NULL, + purple_connection_get_account(gc), who, NULL, b, G_CALLBACK(ignore_buddy), G_CALLBACK(keep_buddy)); @@ -2207,14 +2205,14 @@ static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) { #ifdef TRY_WEBMESSENGER_LOGIN - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); #endif /* TRY_WEBMESSENGER_LOGIN */ GSList *l = pkt->hash; int err = 0; char *msg; char *url = NULL; char *fullmsg; - PurpleAccount *account = gc->account; + PurpleAccount *account = purple_connection_get_account(gc); PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; while (l) { @@ -2244,10 +2242,12 @@ yd->wm = TRUE; if (yd->fd >= 0) close(yd->fd); - if (gc->inpa) - purple_input_remove(gc->inpa); + if (yd->inpa) { + purple_input_remove(yd->inpa); + yd->inpa = 0; + } url_data = purple_util_fetch_url(WEBMESSENGER_URL, TRUE, - "Purple/" VERSION, FALSE, yahoo_login_page_cb, gc); + "Purple/" VERSION, FALSE, -1, yahoo_login_page_cb, gc); if (url_data != NULL) yd->url_datas = g_slist_prepend(yd->url_datas, url_data); return; @@ -2285,7 +2285,7 @@ else fullmsg = g_strdup(msg); - purple_connection_error_reason(gc, reason, fullmsg); + purple_connection_error(gc, reason, fullmsg); g_free(msg); g_free(fullmsg); } @@ -2300,7 +2300,7 @@ char *buf; YahooFriend *f; GSList *l = pkt->hash; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); YahooFederation fed = YAHOO_FEDERATION_NONE; while (l) { @@ -2394,7 +2394,7 @@ PurpleConnection *gc = user_data; struct yahoo_packet *pkt_to_send; PurpleAccount *account; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); account = purple_connection_get_account(gc); @@ -2413,7 +2413,7 @@ static gboolean yahoo_p2p_keepalive(gpointer data) { PurpleConnection *gc = data; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc); @@ -2460,7 +2460,7 @@ if(!(p2p_data = data)) return ; - yd = p2p_data->gc->proto_data; + yd = purple_connection_get_protocol_data(p2p_data->gc); /* lets see whats in the packet */ while (l) { @@ -2545,7 +2545,7 @@ if(!(p2p_data = data)) return ; - yd = p2p_data->gc->proto_data; + yd = purple_connection_get_protocol_data(p2p_data->gc); len = read(source, buf, sizeof(buf)); if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) @@ -2617,7 +2617,7 @@ if(!(p2p_data = data)) return ; - yd = p2p_data->gc->proto_data; + yd = purple_connection_get_protocol_data(p2p_data->gc); acceptfd = accept(source, NULL, 0); if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) @@ -2657,7 +2657,7 @@ if(!(p2p_data = data)) return FALSE; - yd = p2p_data->gc->proto_data; + yd = purple_connection_get_protocol_data(p2p_data->gc); purple_debug_warning("yahoo","yahoo p2p server timeout, peer failed to connect\n"); yahoo_p2p_disconnect_destroy_data(data); @@ -2678,7 +2678,7 @@ if(!(p2p_data = data)) return ; - yd = p2p_data->gc->proto_data; + yd = purple_connection_get_protocol_data(p2p_data->gc); yd->listen_data = NULL; if(listenfd == -1) { @@ -2706,7 +2706,7 @@ YahooFriend *f; struct yahoo_packet *pkt; PurpleAccount *account; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_p2p_data *p2p_data; const char *norm_username; @@ -2770,7 +2770,7 @@ if (yd->listen_data) purple_debug_warning("yahoo","p2p: Failed to create p2p server - server already exists\n"); else { - yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data); + yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_server_listen_cb, p2p_data); if (yd->listen_data == NULL) purple_debug_warning("yahoo","p2p: Failed to created p2p server\n"); } @@ -2787,7 +2787,7 @@ YahooData *yd; p2p_data = data; - yd = p2p_data->gc->proto_data; + yd = purple_connection_get_protocol_data(p2p_data->gc); if(error_message != NULL) { purple_debug_warning("yahoo","p2p: %s\n",error_message); @@ -3132,7 +3132,7 @@ static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) { PurpleConnection *gc = data; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); char buf[1024]; int len; @@ -3147,15 +3147,15 @@ tmp = g_strdup_printf(_("Lost connection with server: %s"), g_strerror(errno)); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } else if (len == 0) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Server closed the connection")); return; } - gc->last_received = time(NULL); + purple_connection_update_last_received(gc); yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); memcpy(yd->rxqueue + yd->rxlen, buf, len); yd->rxlen += len; @@ -3235,20 +3235,20 @@ if (source < 0) { gchar *tmp; tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } - yd = gc->proto_data; + yd = purple_connection_get_protocol_data(gc); yd->fd = source; pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id); - yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); + yahoo_packet_hash_str(pkt, 1, purple_normalize(purple_connection_get_account(gc), purple_account_get_username(purple_connection_get_account(gc)))); yahoo_packet_send_and_free(pkt, yd); - gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); + yd->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); } #ifdef TRY_WEBMESSENGER_LOGIN @@ -3261,31 +3261,31 @@ if (source < 0) { gchar *tmp; tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } - yd = gc->proto_data; + yd = purple_connection_get_protocol_data(gc); yd->fd = source; pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id); yahoo_packet_hash(pkt, "sss", 0, - purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), - 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), + purple_normalize(purple_connection_get_account(gc), purple_account_get_username(purple_connection_get_account(gc))), + 1, purple_normalize(purple_connection_get_account(gc), purple_account_get_username(purple_connection_get_account(gc))), 6, yd->auth); yahoo_packet_send_and_free(pkt, yd); g_free(yd->auth); - gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); + yd->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); } static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) { PurpleConnection *gc = data; PurpleAccount *account = purple_connection_get_account(gc); - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); char bufread[2048], *i = bufread, *buf = bufread; int len; GString *s; @@ -3301,11 +3301,11 @@ tmp = g_strdup_printf(_("Lost connection with server: %s"), g_strerror(errno)); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } else if (len == 0) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Server closed the connection")); return; } @@ -3321,7 +3321,7 @@ if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Received unexpected HTTP response from server")); purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf); return; @@ -3342,7 +3342,8 @@ } yd->auth = g_string_free(s, FALSE); - purple_input_remove(gc->inpa); + purple_input_remove(yd->inpa); + yd->inpa = 0; close(source); g_free(yd->rxqueue); yd->rxqueue = NULL; @@ -3351,7 +3352,7 @@ if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com", purple_account_get_int(account, "port", YAHOO_PAGER_PORT), yahoo_got_web_connected, gc) == NULL) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); return; } @@ -3359,13 +3360,10 @@ static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) { - PurpleConnection *gc; - YahooData *yd; + PurpleConnection *gc = data; + YahooData *yd = purple_connection_get_protocol_data(gc); int written, remaining; - gc = data; - yd = gc->proto_data; - remaining = strlen(yd->auth) - yd->auth_written; written = write(source, yd->auth + yd->auth_written, remaining); @@ -3375,12 +3373,13 @@ gchar *tmp; g_free(yd->auth); yd->auth = NULL; - if (gc->inpa) - purple_input_remove(gc->inpa); - gc->inpa = 0; + if (yd->inpa) { + purple_input_remove(yd->inpa); + yd->inpa = 0; + } tmp = g_strdup_printf(_("Lost connection with %s: %s"), "login.yahoo.com:80", g_strerror(errno)); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } @@ -3393,26 +3392,27 @@ g_free(yd->auth); yd->auth = NULL; yd->auth_written = 0; - purple_input_remove(gc->inpa); - gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, yahoo_web_pending, gc); + purple_input_remove(yd->inpa); + yd->inpa = purple_input_add(source, PURPLE_INPUT_READ, yahoo_web_pending, gc); } static void yahoo_got_cookies(gpointer data, gint source, const gchar *error_message) { PurpleConnection *gc = data; + YahooData *yd = purple_connection_get_protocol_data(gc); if (source < 0) { gchar *tmp; tmp = g_strdup_printf(_("Unable to establish a connection with %s: %s"), "login.yahoo.com:80", error_message); - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } - if (gc->inpa == 0) + if (yd->inpa == 0) { - gc->inpa = purple_input_add(source, PURPLE_INPUT_WRITE, + yd->inpa = purple_input_add(source, PURPLE_INPUT_WRITE, yahoo_got_cookies_send_cb, gc); yahoo_got_cookies_send_cb(gc, source, PURPLE_INPUT_WRITE); } @@ -3474,7 +3474,7 @@ { PurpleConnection *gc = (PurpleConnection *)user_data; PurpleAccount *account = purple_connection_get_account(gc); - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); const char *sn = purple_account_get_username(account); const char *pass = purple_connection_get_password(gc); GHashTable *hash = yahoo_login_page_hash(url_text, len); @@ -3489,7 +3489,7 @@ if (error_message != NULL) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); return; } @@ -3539,7 +3539,7 @@ g_hash_table_destroy(hash); yd->auth = g_string_free(url, FALSE); if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); return; } @@ -3619,12 +3619,12 @@ error_message ? error_message : "(null)"); if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect: The server returned an empty response.")); } else { if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port, yahoo_got_connected, gc) == NULL) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); } } @@ -3646,20 +3646,20 @@ if(cs_server) { /* got an address; get on with connecting */ if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL) - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); } else { purple_debug_error("yahoo", "No CS address retrieved! Server " "response:\n%s\n", url_text ? url_text : "(null)"); if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect: The server's response did not contain " "the necessary information")); } else if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port, yahoo_got_connected, gc) == NULL) { - purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); } } @@ -3671,13 +3671,14 @@ void yahoo_login(PurpleAccount *account) { PurpleConnection *gc = purple_account_get_connection(account); - YahooData *yd = gc->proto_data = g_new0(YahooData, 1); + YahooData *yd = g_new0(YahooData, 1); PurpleStatus *status = purple_account_get_active_status(account); gboolean use_whole_url = yahoo_account_use_http_proxy(gc); gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); PurpleUtilFetchUrlData *url_data; - gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; + purple_connection_set_protocol_data(gc, yd); + purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC); purple_connection_update_progress(gc, _("Connecting"), 1, 2); @@ -3708,7 +3709,7 @@ /* Get the pager server. Actually start connecting in the callback since we * must have the contents of the HTTP response to proceed. */ - url_data = purple_util_fetch_url_request_len_with_account( + url_data = purple_util_fetch_url_request( proxy_ssl ? purple_connection_get_account(gc) : NULL, yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : YAHOO_PAGER_HOST_REQ_URL, use_whole_url ? TRUE : FALSE, @@ -3721,11 +3722,13 @@ } void yahoo_close(PurpleConnection *gc) { - YahooData *yd = (YahooData *)gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); GSList *l; - if (gc->inpa) - purple_input_remove(gc->inpa); + if (yd->inpa) { + purple_input_remove(yd->inpa); + yd->inpa = 0; + } while (yd->url_datas) { purple_util_fetch_url_cancel(yd->url_datas->data); @@ -3810,7 +3813,7 @@ g_free(yd->current_list15_grp); g_free(yd); - gc->proto_data = NULL; + purple_connection_set_protocol_data(gc, NULL); } const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b) @@ -3827,7 +3830,7 @@ if (!b || !(account = purple_buddy_get_account(b)) || !(gc = purple_account_get_connection(account)) || - !gc->proto_data) + !purple_connection_get_protocol_data(gc)) return NULL; f = yahoo_friend_find(gc, purple_buddy_get_name(b)); @@ -3892,7 +3895,7 @@ buddy = (PurpleBuddy *) node; gc = purple_account_get_connection(purple_buddy_get_account(buddy)); - yd = gc->proto_data; + yd = purple_connection_get_protocol_data(gc); id = yd->conf_id; components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); @@ -4036,22 +4039,12 @@ if (f && full) { YahooPersonalDetails *ypd = &f->ypd; - int i; - struct { - char *id; - char *text; - char *value; - } yfields[] = { - {"hp", N_("Home Phone Number"), ypd->phone.home}, - {"wp", N_("Work Phone Number"), ypd->phone.work}, - {"mo", N_("Mobile Phone Number"), ypd->phone.mobile}, - {NULL, NULL, NULL} - }; - for (i = 0; yfields[i].id; i++) { - if (!yfields[i].value || !*yfields[i].value) - continue; - purple_notify_user_info_add_pair(user_info, _(yfields[i].text), yfields[i].value); - } + if (ypd->phone.home && *ypd->phone.home) + purple_notify_user_info_add_pair_plaintext(user_info, _("Home Phone Number"), ypd->phone.home); + if (ypd->phone.work && *ypd->phone.work) + purple_notify_user_info_add_pair_plaintext(user_info, _("Work Phone Number"), ypd->phone.work); + if (ypd->phone.mobile && *ypd->phone.mobile) + purple_notify_user_info_add_pair_plaintext(user_info, _("Mobile Phone Number"), ypd->phone.mobile); } } @@ -4065,7 +4058,7 @@ buddy = (PurpleBuddy *) node; gc = purple_account_get_connection(purple_buddy_get_account(buddy)); - yahoo_add_buddy(gc, buddy, NULL); + yahoo_add_buddy(gc, buddy, NULL, NULL); } @@ -4085,7 +4078,7 @@ static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { GList *m = NULL; PurpleMenuAction *act; - YahooData *yd = (YahooData *) gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); if (yd->current_status == YAHOO_STATUS_INVISIBLE) { if (f->presence != YAHOO_PRESENCE_ONLINE) { @@ -4145,7 +4138,7 @@ PurpleMenuAction *act; PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); static char buf2[1024]; YahooFriend *f; @@ -4228,7 +4221,7 @@ static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); @@ -4245,7 +4238,7 @@ PurpleConnection *gc = user_data; gboolean set_cookie = FALSE; gchar *url; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); @@ -4281,7 +4274,7 @@ /* XXX I have no idea how this will work with Yahoo! Japan. */ PurpleConnection *gc = action->context; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); PurpleUtilFetchUrlData *url_data; const char* base_url = "http://login.yahoo.com"; @@ -4296,7 +4289,7 @@ use_whole_url ? base_url : "", yd->cookie_t, yd->cookie_y); - url_data = purple_util_fetch_url_request_len_with_account( + url_data = purple_util_fetch_url_request( purple_connection_get_account(gc), base_url, use_whole_url, YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1, yahoo_get_inbox_token_cb, gc); @@ -4395,7 +4388,7 @@ { struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data; PurpleConnection *gc = sms_cb_data->gc; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); char *status = NULL; char *carrier = NULL; PurpleAccount *account = purple_connection_get_account(gc); @@ -4450,7 +4443,7 @@ static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); PurpleUtilFetchUrlData *url_data; struct yahoo_sms_carrier_cb_data *sms_cb_data; char *validate_request_str = NULL; @@ -4485,10 +4478,10 @@ YAHOO_CLIENT_VERSION, yd->cookie_t, yd->cookie_y, strlen(validate_request_str), validate_request_str); /* use whole URL if using HTTP Proxy */ - if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP)) + if ((purple_account_get_proxy_info(purple_connection_get_account(gc))) && (purple_proxy_info_get_type(purple_account_get_proxy_info(purple_connection_get_account(gc))) == PURPLE_PROXY_HTTP)) use_whole_url = TRUE; - url_data = purple_util_fetch_url_request_len_with_account( + url_data = purple_util_fetch_url_request( purple_connection_get_account(gc), YAHOO_SMS_CARRIER_URL, use_whole_url, YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1, yahoo_get_sms_carrier_cb, data); @@ -4510,7 +4503,7 @@ int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt = NULL; char *msg = yahoo_html_to_codes(what); char *msg2; @@ -4621,7 +4614,7 @@ * * If they have not set an IMVironment, then use the default. */ - wb = purple_whiteboard_get_session(gc->account, who); + wb = purple_whiteboard_get_session(purple_connection_get_account(gc), who); if (wb) yahoo_packet_hash_str(pkt, 63, DOODLE_IMV_KEY); else @@ -4667,7 +4660,7 @@ unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_p2p_data *p2p_data; YahooFederation fed = YAHOO_FEDERATION_NONE; struct yahoo_packet *pkt = NULL; @@ -4738,7 +4731,7 @@ gc = purple_account_get_connection(account); presence = purple_status_get_presence(status); - yd = (YahooData *)gc->proto_data; + yd = purple_connection_get_protocol_data(gc); old_status = yd->current_status; yd->current_status = get_yahoo_status_from_purple_status(status); @@ -4804,7 +4797,7 @@ void yahoo_set_idle(PurpleConnection *gc, int idle) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt = NULL; char *msg = NULL, *msg2 = NULL; PurpleStatus *status = NULL; @@ -4923,7 +4916,7 @@ void yahoo_keepalive(PurpleConnection *gc) { struct yahoo_packet *pkt; - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); time_t now = time(NULL); /* We're only allowed to send a ping once an hour or the servers will boot us */ @@ -4954,9 +4947,9 @@ } -void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g) +void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g, const char *message) { - YahooData *yd = (YahooData *)gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; const char *group = NULL; char *group2; @@ -5019,7 +5012,7 @@ void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { - YahooData *yd = (YahooData *)gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; GSList *buddies, *l; PurpleGroup *g; @@ -5075,7 +5068,7 @@ } void yahoo_add_deny(PurpleConnection *gc, const char *who) { - YahooData *yd = (YahooData *)gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; YahooFederation fed = YAHOO_FEDERATION_NONE; @@ -5098,7 +5091,7 @@ } void yahoo_rem_deny(PurpleConnection *gc, const char *who) { - YahooData *yd = (YahooData *)gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; YahooFederation fed = YAHOO_FEDERATION_NONE; @@ -5126,7 +5119,7 @@ account = purple_connection_get_account(gc); - switch (account->perm_deny) + switch (purple_account_get_privacy_type(account)) { case PURPLE_PRIVACY_ALLOW_ALL: for (deny = account->deny; deny; deny = deny->next) @@ -5146,7 +5139,7 @@ void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, const char *old_group, const char *new_group) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; char *gpn, *gpo; YahooFriend *f = yahoo_friend_find(gc, who); @@ -5193,7 +5186,7 @@ void yahoo_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; char *gpn, *gpo; @@ -5222,7 +5215,7 @@ if (*args && args[0]) return PURPLE_CMD_RET_FAILED; - purple_prpl_send_attention(account->gc, c->name, YAHOO_BUZZ); + purple_prpl_send_attention(purple_account_get_connection(account), purple_conversation_get_name(c), YAHOO_BUZZ); return PURPLE_CMD_RET_OK; } @@ -5237,7 +5230,7 @@ if (!args || !args[0]) return PURPLE_CMD_RET_FAILED; - gc = purple_conversation_get_gc(conv); + gc = purple_conversation_get_connection(conv); purple_debug_info("yahoo", "Trying to join %s \n", args[0]); comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); @@ -5271,12 +5264,12 @@ PurpleConversation *c; c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, - username, gc->account); + username, purple_connection_get_account(gc)); g_return_val_if_fail(c != NULL, FALSE); purple_debug_info("yahoo", "Sending <ding> on account %s to buddy %s.\n", - username, c->name); + username, purple_conversation_get_name(c)); purple_conv_im_send_with_flags(PURPLE_CONV_IM(c), "<ding>", PURPLE_MESSAGE_INVISIBLE); return TRUE;