pidgin: 6a3e4347: Some improvements to the new CS-via-HTTP...
rekkanoryo at pidgin.im
rekkanoryo at pidgin.im
Sat Apr 3 01:11:40 EDT 2010
-----------------------------------------------------------------
Revision: 6a3e434792d4a871f84d3a8b6c98952491c3caad
Ancestor: 1a1746f06141d503935b2b6b46108d5119b96915
Author: rekkanoryo at pidgin.im
Date: 2010-04-03T05:09:28
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6a3e434792d4a871f84d3a8b6c98952491c3caad
Modified files:
libpurple/protocols/yahoo/libymsg.c
ChangeLog:
Some improvements to the new CS-via-HTTP stuff, sparked by Stu's suggestion to
iterate over the entire respose returned from the HTTP GET.
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libymsg.c cd664620ade3d4b883d0ef7d81cc37d942d84acf
+++ libpurple/protocols/yahoo/libymsg.c c77bac81b5360092ad2746ba9698fd8ae7e5ba88
@@ -3512,54 +3512,46 @@ static void yahoo_got_pager_server(Purpl
PurpleConnection *gc = yd->gc;
PurpleAccount *a = purple_connection_get_account(gc);
gchar **strings = NULL, *cs_server = NULL;
- int port = 0;
+ int port = 0, stringslen = 0;
- if(error_message != NULL) {
- purple_debug_error("yahoo", "Login failed. Unable to retrieve server "
- "info: %s\n", error_message);
+ if(error_message != NULL || len == 0) {
+ purple_debug_error("yahoo", "Unable to retrieve server info. %"
+ G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len,
+ error_message ? error_message : "(null)");
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Unable to retrieve server information"));
- return;
- }
+ _("Unable to connect: The server returned an empty response."));
+ } else {
+ strings = g_strsplit(url_text, "\n", -1);
- if(len == 0) {
- purple_debug_error("yahoo", "Login failed. Unable to retrieve server "
- "info: Server did not return any useful data.\n");
- purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Unable to retrieve server information"));
- return;
- }
+ if((stringslen = g_strv_length(strings)) > 1) {
+ int i;
- strings = g_strsplit(url_text, "\n", -1);
-
- if(g_strv_length(strings) > 1) {
- if(g_ascii_strncasecmp(strings[1], "CS_IP_ADDRESS=", 14) == 0) {
- cs_server = g_strdup(&strings[1][14]);
- purple_debug_info("yahoo", "Got CS IP address: %s\n", cs_server);
- } else {
- purple_debug_error("yahoo", "Login failed. Unable to retrieve "
- "server info: The server returned information, but it was "
- "not in the ""expected format.\n");
+ for(i = 0; i < stringslen; i++) {
+ if(g_ascii_strncasecmp(strings[i], "COLO_CAPACITY=", 14) == 0) {
+ purple_debug_info("yahoo", "Got COLO Capacity: %s\n", &(strings[i][14]));
+ } else if(g_ascii_strncasecmp(strings[i], "CS_IP_ADDRESS=", 14) == 0) {
+ cs_server = g_strdup(&strings[i][14]);
+ purple_debug_info("yahoo", "Got CS IP address: %s\n", cs_server);
+ }
+ }
}
- } else {
- purple_debug_error("yahoo", "Login failed. Unable to retrieve server "
- "info: The server returned information, but it was not in the "
- "expected format.\n");
- }
- g_strfreev(strings);
+ if(cs_server) { /* got an address; get on with connecting */
+ port = purple_account_get_int(a, "port", YAHOO_PAGER_PORT);
- if(cs_server) { /* got an address; get on with connecting */
- port = purple_account_get_int(a, "port", YAHOO_PAGER_PORT);
-
- if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL)
+ if(purple_proxy_connect(gc, a, cs_server, port, yahoo_got_connected, gc) == NULL)
+ purple_connection_error_reason(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)");
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Unable to connect"));
- } else {
- purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Unable to retrieve server information"));
+ _("Unable to connect: The server's response did not contain "
+ "the necessary information"));
+ }
}
+ g_strfreev(strings);
g_free(cs_server);
}
More information about the Commits
mailing list