libpurple/protocols/yahoo/libymsg.c

changeset 32157
39ba2e2492ee
parent 32147
f16364a9c7fb
child 32160
bef9224f485f
equal deleted inserted replaced
32156:dff89601e951 32157:39ba2e2492ee
157 char *fedname = NULL; 157 char *fedname = NULL;
158 158
159 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 159 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
160 if (!purple_account_get_remember_password(account)) 160 if (!purple_account_get_remember_password(account))
161 purple_account_set_password(account, NULL); 161 purple_account_set_password(account, NULL);
162 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE, 162 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE,
163 _("You have signed on from another location")); 163 _("You have signed on from another location"));
164 return; 164 return;
165 } 165 }
166 166
167 while (l) { 167 while (l) {
1801 1801
1802 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 1802 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
1803 1803
1804 if (error_message != NULL) { 1804 if (error_message != NULL) {
1805 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); 1805 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message);
1806 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1806 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1807 g_free(auth_data->seed); 1807 g_free(auth_data->seed);
1808 g_free(auth_data); 1808 g_free(auth_data);
1809 return; 1809 return;
1810 } 1810 }
1811 else if (len > 0 && ret_data && *ret_data) { 1811 else if (len > 0 && ret_data && *ret_data) {
1888 break; 1888 break;
1889 } 1889 }
1890 if(error_reason) { 1890 if(error_reason) {
1891 purple_debug_error("yahoo", "Authentication error: %s. " 1891 purple_debug_error("yahoo", "Authentication error: %s. "
1892 "Code %d\n", error_reason, response_no); 1892 "Code %d\n", error_reason, response_no);
1893 purple_connection_error_reason(gc, error, error_reason); 1893 purple_connection_error(gc, error, error_reason);
1894 g_free(error_reason); 1894 g_free(error_reason);
1895 g_free(auth_data->seed); 1895 g_free(auth_data->seed);
1896 g_free(auth_data); 1896 g_free(auth_data);
1897 return; 1897 return;
1898 } 1898 }
1917 1917
1918 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 1918 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
1919 1919
1920 if (error_message != NULL) { 1920 if (error_message != NULL) {
1921 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message); 1921 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message);
1922 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1922 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1923 g_free(auth_data->seed); 1923 g_free(auth_data->seed);
1924 g_free(auth_data); 1924 g_free(auth_data);
1925 return; 1925 return;
1926 } 1926 }
1927 else if (len > 0 && ret_data && *ret_data) { 1927 else if (len > 0 && ret_data && *ret_data) {
1998 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 1998 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
1999 break; 1999 break;
2000 } 2000 }
2001 purple_debug_error("yahoo", "Authentication error: %s. Code %d\n", 2001 purple_debug_error("yahoo", "Authentication error: %s. Code %d\n",
2002 error_reason, response_no); 2002 error_reason, response_no);
2003 purple_connection_error_reason(gc, error, error_reason); 2003 purple_connection_error(gc, error, error_reason);
2004 g_free(error_reason); 2004 g_free(error_reason);
2005 g_free(auth_data->seed); 2005 g_free(auth_data->seed);
2006 g_free(auth_data); 2006 g_free(auth_data);
2007 g_free(token); 2007 g_free(token);
2008 } 2008 }
2038 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); 2038 gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE);
2039 2039
2040 purple_debug_info("yahoo", "Authentication: In yahoo_auth16_stage1\n"); 2040 purple_debug_info("yahoo", "Authentication: In yahoo_auth16_stage1\n");
2041 2041
2042 if(!purple_ssl_is_supported()) { 2042 if(!purple_ssl_is_supported()) {
2043 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable")); 2043 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable"));
2044 return; 2044 return;
2045 } 2045 }
2046 2046
2047 auth_data = g_new0(struct yahoo_auth_data, 1); 2047 auth_data = g_new0(struct yahoo_auth_data, 1);
2048 auth_data->gc = gc; 2048 auth_data->gc = gc;
2283 if (url) 2283 if (url)
2284 fullmsg = g_strdup_printf("%s\n%s", msg, url); 2284 fullmsg = g_strdup_printf("%s\n%s", msg, url);
2285 else 2285 else
2286 fullmsg = g_strdup(msg); 2286 fullmsg = g_strdup(msg);
2287 2287
2288 purple_connection_error_reason(gc, reason, fullmsg); 2288 purple_connection_error(gc, reason, fullmsg);
2289 g_free(msg); 2289 g_free(msg);
2290 g_free(fullmsg); 2290 g_free(fullmsg);
2291 } 2291 }
2292 2292
2293 static void yahoo_process_addbuddy(PurpleConnection *gc, struct yahoo_packet *pkt) 2293 static void yahoo_process_addbuddy(PurpleConnection *gc, struct yahoo_packet *pkt)
3145 /* No worries */ 3145 /* No worries */
3146 return; 3146 return;
3147 3147
3148 tmp = g_strdup_printf(_("Lost connection with server: %s"), 3148 tmp = g_strdup_printf(_("Lost connection with server: %s"),
3149 g_strerror(errno)); 3149 g_strerror(errno));
3150 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3150 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3151 g_free(tmp); 3151 g_free(tmp);
3152 return; 3152 return;
3153 } else if (len == 0) { 3153 } else if (len == 0) {
3154 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3154 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3155 _("Server closed the connection")); 3155 _("Server closed the connection"));
3156 return; 3156 return;
3157 } 3157 }
3158 gc->last_received = time(NULL); 3158 gc->last_received = time(NULL);
3159 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); 3159 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
3233 struct yahoo_packet *pkt; 3233 struct yahoo_packet *pkt;
3234 3234
3235 if (source < 0) { 3235 if (source < 0) {
3236 gchar *tmp; 3236 gchar *tmp;
3237 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); 3237 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3238 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3238 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3239 g_free(tmp); 3239 g_free(tmp);
3240 return; 3240 return;
3241 } 3241 }
3242 3242
3243 yd = gc->proto_data; 3243 yd = gc->proto_data;
3259 struct yahoo_packet *pkt; 3259 struct yahoo_packet *pkt;
3260 3260
3261 if (source < 0) { 3261 if (source < 0) {
3262 gchar *tmp; 3262 gchar *tmp;
3263 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message); 3263 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3264 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3264 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3265 g_free(tmp); 3265 g_free(tmp);
3266 return; 3266 return;
3267 } 3267 }
3268 3268
3269 yd = gc->proto_data; 3269 yd = gc->proto_data;
3299 /* No worries */ 3299 /* No worries */
3300 return; 3300 return;
3301 3301
3302 tmp = g_strdup_printf(_("Lost connection with server: %s"), 3302 tmp = g_strdup_printf(_("Lost connection with server: %s"),
3303 g_strerror(errno)); 3303 g_strerror(errno));
3304 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3304 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3305 g_free(tmp); 3305 g_free(tmp);
3306 return; 3306 return;
3307 } else if (len == 0) { 3307 } else if (len == 0) {
3308 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3308 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3309 _("Server closed the connection")); 3309 _("Server closed the connection"));
3310 return; 3310 return;
3311 } 3311 }
3312 3312
3313 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) { 3313 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) {
3319 } 3319 }
3320 buf[len] = '\0'; 3320 buf[len] = '\0';
3321 3321
3322 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && 3322 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) &&
3323 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { 3323 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) {
3324 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3324 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3325 _("Received unexpected HTTP response from server")); 3325 _("Received unexpected HTTP response from server"));
3326 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf); 3326 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf);
3327 return; 3327 return;
3328 } 3328 }
3329 3329
3349 yd->rxlen = 0; 3349 yd->rxlen = 0;
3350 /* Now we have our cookies to login with. I'll go get the milk. */ 3350 /* Now we have our cookies to login with. I'll go get the milk. */
3351 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com", 3351 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com",
3352 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), 3352 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
3353 yahoo_got_web_connected, gc) == NULL) { 3353 yahoo_got_web_connected, gc) == NULL) {
3354 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3354 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3355 _("Unable to connect")); 3355 _("Unable to connect"));
3356 return; 3356 return;
3357 } 3357 }
3358 } 3358 }
3359 3359
3378 if (gc->inpa) 3378 if (gc->inpa)
3379 purple_input_remove(gc->inpa); 3379 purple_input_remove(gc->inpa);
3380 gc->inpa = 0; 3380 gc->inpa = 0;
3381 tmp = g_strdup_printf(_("Lost connection with %s: %s"), 3381 tmp = g_strdup_printf(_("Lost connection with %s: %s"),
3382 "login.yahoo.com:80", g_strerror(errno)); 3382 "login.yahoo.com:80", g_strerror(errno));
3383 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3383 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3384 g_free(tmp); 3384 g_free(tmp);
3385 return; 3385 return;
3386 } 3386 }
3387 3387
3388 if (written < remaining) { 3388 if (written < remaining) {
3403 3403
3404 if (source < 0) { 3404 if (source < 0) {
3405 gchar *tmp; 3405 gchar *tmp;
3406 tmp = g_strdup_printf(_("Unable to establish a connection with %s: %s"), 3406 tmp = g_strdup_printf(_("Unable to establish a connection with %s: %s"),
3407 "login.yahoo.com:80", error_message); 3407 "login.yahoo.com:80", error_message);
3408 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3408 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3409 g_free(tmp); 3409 g_free(tmp);
3410 return; 3410 return;
3411 } 3411 }
3412 3412
3413 if (gc->inpa == 0) 3413 if (gc->inpa == 0)
3487 3487
3488 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 3488 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
3489 3489
3490 if (error_message != NULL) 3490 if (error_message != NULL)
3491 { 3491 {
3492 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3492 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3493 error_message); 3493 error_message);
3494 return; 3494 return;
3495 } 3495 }
3496 3496
3497 url = g_string_append(url, sn); 3497 url = g_string_append(url, sn);
3537 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" 3537 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n"
3538 "Host: login.yahoo.com\r\n\r\n"); 3538 "Host: login.yahoo.com\r\n\r\n");
3539 g_hash_table_destroy(hash); 3539 g_hash_table_destroy(hash);
3540 yd->auth = g_string_free(url, FALSE); 3540 yd->auth = g_string_free(url, FALSE);
3541 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { 3541 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) {
3542 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3542 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3543 _("Unable to connect")); 3543 _("Unable to connect"));
3544 return; 3544 return;
3545 } 3545 }
3546 3546
3547 purple_cipher_context_destroy(context); 3547 purple_cipher_context_destroy(context);
3617 purple_debug_error("yahoo", "Unable to retrieve server info. %" 3617 purple_debug_error("yahoo", "Unable to retrieve server info. %"
3618 G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len, 3618 G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len,
3619 error_message ? error_message : "(null)"); 3619 error_message ? error_message : "(null)");
3620 3620
3621 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ 3621 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */
3622 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3622 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3623 _("Unable to connect: The server returned an empty response.")); 3623 _("Unable to connect: The server returned an empty response."));
3624 } else { 3624 } else {
3625 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port, 3625 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port,
3626 yahoo_got_connected, gc) == NULL) { 3626 yahoo_got_connected, gc) == NULL) {
3627 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3627 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3628 _("Unable to connect")); 3628 _("Unable to connect"));
3629 } 3629 }
3630 } 3630 }
3631 } else { 3631 } else {
3632 strings = g_strsplit(url_text, "\r\n", -1); 3632 strings = g_strsplit(url_text, "\r\n", -1);
3644 } 3644 }
3645 } 3645 }
3646 3646
3647 if(cs_server) { /* got an address; get on with connecting */ 3647 if(cs_server) { /* got an address; get on with connecting */
3648 if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL) 3648 if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL)
3649 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3649 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3650 _("Unable to connect")); 3650 _("Unable to connect"));
3651 } else { 3651 } else {
3652 purple_debug_error("yahoo", "No CS address retrieved! Server " 3652 purple_debug_error("yahoo", "No CS address retrieved! Server "
3653 "response:\n%s\n", url_text ? url_text : "(null)"); 3653 "response:\n%s\n", url_text ? url_text : "(null)");
3654 3654
3655 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ 3655 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */
3656 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3656 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3657 _("Unable to connect: The server's response did not contain " 3657 _("Unable to connect: The server's response did not contain "
3658 "the necessary information")); 3658 "the necessary information"));
3659 } else 3659 } else
3660 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port, 3660 if(purple_proxy_connect(gc, a, YAHOO_PAGER_HOST_FALLBACK, port,
3661 yahoo_got_connected, gc) == NULL) { 3661 yahoo_got_connected, gc) == NULL) {
3662 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3662 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3663 _("Unable to connect")); 3663 _("Unable to connect"));
3664 } 3664 }
3665 } 3665 }
3666 } 3666 }
3667 3667

mercurial