adium.1-4: 91e41e52: *** Plucked rev 4d84bf43ba957bf41286f442...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Sun Apr 18 17:50:05 EDT 2010


-----------------------------------------------------------------
Revision: 91e41e5288f7f90048a8cf7d05bedc87aacfa3de
Ancestor: 692d75f8dc28e433931f5a4b036c145f132c42ba
Author: rekkanoryo at pidgin.im
Date: 2010-04-17T00:09:49
Branch: im.pidgin.adium.1-4
URL: http://d.pidgin.im/viewmtn/revision/info/91e41e5288f7f90048a8cf7d05bedc87aacfa3de

Modified files:
        libpurple/protocols/yahoo/libyahoo.c
        libpurple/protocols/yahoo/libyahoojp.c
        libpurple/protocols/yahoo/libymsg.c
        libpurple/protocols/yahoo/libymsg.h

ChangeLog: 

*** Plucked rev 4d84bf43ba957bf41286f4424b54e4b7788e587c (rekkanoryo at pidgin.im):
Ladies and gentlemen, I give you HTTP-based retrieval of the Yahoo CS server
address, thus eliminating the need for the old "Pager server" account option.
This method makes us a bit less distinguishable from the official client, as
the official clients do the same HTTP request.  Fixes #11555.

*** Plucked rev 6a3e434792d4a871f84d3a8b6c98952491c3caad (rekkanoryo at pidgin.im):
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.

*** Plucked rev 465c5796090f150d2555e873a0b38b61d7dbe0ac (rekkanoryo at pidgin.im):
Clarify an error condition I was able to duplicate reliably last night.

*** Plucked rev 3ef9bbfad62576f3db5044c28101c08446179946 (rekkanoryo at pidgin.im):
Small tweaks:
 * Split the CS lookup response on \\r\\n, not just \\n.
 * Send key 59 with a value of the configured roomlist locale for the account
   during login.

The key 59 addition may fix some weird Yahoo Chat issues, but I haven't tested
in great detail.  This makes us appear a bit more like the official client.

*** Plucked rev f93594a81b0e180378f83d1a964c014fc2d8ae99 (rekkanoryo at pidgin.im):
Trim some cruft.


-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libyahoo.c	706ac2c745153342476c250e96b5c3ee377f2ca3
+++ libpurple/protocols/yahoo/libyahoo.c	041d8d1c6c8af460ca0c894e5d656aac0e49ccc9
@@ -306,9 +306,6 @@ init_plugin(PurplePlugin *plugin)
 {
 	PurpleAccountOption *option;
 
-	option = purple_account_option_string_new(_("Pager server"), "server", YAHOO_PAGER_HOST);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
 	option = purple_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
@@ -333,12 +330,6 @@ init_plugin(PurplePlugin *plugin)
 #if 0
 	option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
-	option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
-	option = purple_account_option_int_new(_("Yahoo Chat port"), "ycht-port", YAHOO_YCHT_PORT);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 #endif
 
 	my_protocol = plugin;
============================================================
--- libpurple/protocols/yahoo/libyahoojp.c	2684dc955d3dd9528250dce5180ba49418288844
+++ libpurple/protocols/yahoo/libyahoojp.c	bec20f85706c05d30a7133fbc2ff51ae75129c75
@@ -202,9 +202,6 @@ init_plugin(PurplePlugin *plugin)
 {
 	PurpleAccountOption *option;
 
-	option = purple_account_option_string_new(_("Pager server"), "server", YAHOOJP_PAGER_HOST);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
 	option = purple_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
@@ -229,12 +226,6 @@ init_plugin(PurplePlugin *plugin)
 #if 0
 	option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
-	option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
-	option = purple_account_option_int_new(_("Yahoo Chat port"), "ycht-port", YAHOO_YCHT_PORT);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 #endif
 
 	yahoojp_register_commands();
============================================================
--- libpurple/protocols/yahoo/libymsg.c	1674c03710a8e86e59ea81cf8e6b75b815ad70da
+++ libpurple/protocols/yahoo/libymsg.c	1e301b892f246379488cb72167722bd090a199cf
@@ -1733,6 +1733,8 @@ static void yahoo_auth16_stage3(PurpleCo
 				244, yd->jp ? YAHOOJP_CLIENT_VERSION_ID : YAHOO_CLIENT_VERSION_ID,
 				2, name,
 				2, "1",
+				/* Should send key 59, value of bcookie here--need to fetch it first! */
+				98, purple_account_get_string(account, "room_list_locale", yd->jp ? "jp" : "us"),
 				135, yd->jp ? YAHOOJP_CLIENT_VERSION : YAHOO_CLIENT_VERSION);
 
 	if (yd->picture_checksum)
@@ -1897,7 +1899,8 @@ static void yahoo_auth16_stage1_cb(Purpl
 					break;
 				case 1213:
 					/* security lock from too many failed login attempts */
-					error_reason = g_strdup(_("Account locked: Too many failed login attempts.  Logging into the Yahoo! website may fix this."));
+					error_reason = g_strdup(_("Account locked: Too many failed login "
+								"attempts.  Logging into the Yahoo! website may fix this."));
 					error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
 					break;
 				case 1235:
@@ -1906,9 +1909,16 @@ static void yahoo_auth16_stage1_cb(Purpl
 					error = PURPLE_CONNECTION_ERROR_INVALID_USERNAME;
 					break;
 				case 1214:
+					/* indicates a lock of some description */
+					error_reason = g_strdup(_("Account locked: Unknown reason.  Logging "
+								"into the Yahoo! website may fix this."));
+					error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
+					break;
 				case 1236:
-					/* indicates a lock of some description */
-					error_reason = g_strdup(_("Account locked: Unknown reason.  Logging into the Yahoo! website may fix this."));
+					/* indicates a lock due to logging in too frequently */
+					error_reason = g_strdup(_("Account locked: You have been logging in too "
+								"frequently.  Wait a few minutes before trying to connect "
+								"again.  Logging into the Yahoo! website may help."));
 					error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
 					break;
 				case 100:
@@ -3454,17 +3464,6 @@ yahoo_login_page_cb(PurpleUtilFetchUrlDa
 }
 #endif /* TRY_WEBMESSENGER_LOGIN */
 
-static void yahoo_server_check(PurpleAccount *account)
-{
-	const char *server;
-
-	server = purple_account_get_string(account, "server", YAHOO_PAGER_HOST);
-
-	if (*server == '\0' || g_str_equal(server, "scs.yahoo.com") ||
-			g_str_equal(server, "scs.msg.yahoo.com"))
-		purple_account_set_string(account, "server", YAHOO_PAGER_HOST);
-}
-
 static void yahoo_picture_check(PurpleAccount *account)
 {
 	PurpleConnection *gc = purple_account_get_connection(account);
@@ -3519,12 +3518,61 @@ static int get_yahoo_status_from_purple_
 	}
 }
 
+static void yahoo_got_pager_server(PurpleUtilFetchUrlData *url_data,
+		gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message)
+{
+	YahooData *yd = user_data;
+	PurpleConnection *gc = yd->gc;
+	PurpleAccount *a = purple_connection_get_account(gc);
+	gchar **strings = NULL, *cs_server = NULL;
+	int port = 0, stringslen = 0;
+
+	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 connect: The server returned an empty response."));
+	} else {
+		strings = g_strsplit(url_text, "\r\n", -1);
+
+		if((stringslen = g_strv_length(strings)) > 1) {
+			int i;
+
+			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);
+				}
+			}
+		}
+
+		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)
+				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: The server's response did not contain "
+						"the necessary information"));
+		}
+	}
+
+	g_strfreev(strings);
+	g_free(cs_server);
+}
+
 void yahoo_login(PurpleAccount *account) {
 	PurpleConnection *gc = purple_account_get_connection(account);
 	YahooData *yd = gc->proto_data = g_new0(YahooData, 1);
 	PurpleStatus *status = purple_account_get_active_status(account);
-	const char *server = NULL;
-	int pager_port = 0;
+	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
 
 	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC;
 
@@ -3533,6 +3581,7 @@ void yahoo_login(PurpleAccount *account)
 	purple_connection_set_display_name(gc, purple_account_get_username(account));
 
 	yd->gc = gc;
+	yd->jp = yahoo_is_japan(account);
 	yd->yahoo_local_p2p_server_fd = -1;
 	yd->fd = -1;
 	yd->txhandler = 0;
@@ -3551,19 +3600,18 @@ void yahoo_login(PurpleAccount *account)
 	yd->last_keepalive = yd->last_ping = time(NULL);
 
 	yd->current_status = get_yahoo_status_from_purple_status(status);
-	yd->jp = yahoo_is_japan(account);
 
-	yahoo_server_check(account);
 	yahoo_picture_check(account);
 
-	server = purple_account_get_string(account, "server",
-					yd->jp ? YAHOOJP_PAGER_HOST : YAHOO_PAGER_HOST);
-	pager_port = purple_account_get_int(account, "port", YAHOO_PAGER_PORT);
+	/* Get the pager server.  Actually start connecting in the callback since we
+	 * must have the contents of the HTTP response to proceed. */
+	purple_util_fetch_url_request_len_with_account(
+			purple_connection_get_account(gc),
+			yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : YAHOO_PAGER_HOST_REQ_URL,
+			use_whole_url ? TRUE : FALSE,
+			YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1,
+			yahoo_got_pager_server, yd);
 
-	if (purple_proxy_connect(gc, account, server, pager_port, yahoo_got_connected, gc) == NULL)
-		purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
-						_("Unable to connect"));
-
 	return;
 }
 
============================================================
--- libpurple/protocols/yahoo/libymsg.h	9b1bc461d632ad323841d19aec418fb79477945f
+++ libpurple/protocols/yahoo/libymsg.h	2636f0324aa4cc58ccd1ef513b06ff1c87565367
@@ -29,6 +29,7 @@
 #include "cmds.h"
 #include "prpl.h"
 
+#define YAHOO_PAGER_HOST_REQ_URL "http://vcs1.msg.yahoo.com/capacity"
 #define YAHOO_PAGER_PORT 5050
 #define YAHOO_PAGER_PORT_P2P 5101
 #define YAHOO_LOGIN_URL "https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token=%s"
@@ -45,6 +46,7 @@
 #define YAHOO_ROOMLIST_LOCALE "us"
 
 /* Yahoo! JAPAN stuff */
+#define YAHOOJP_PAGER_HOST_REQ_URL "http://cs1.msg.vip.ogk.yahoo.co.jp/capacity"
 #define YAHOOJP_TOKEN_URL "https://login.yahoo.co.jp/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
 #define YAHOOJP_LOGIN_URL "https://login.yahoo.co.jp/config/pwtoken_login?src=ymsgr&ts=&token=%s"
 #define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/"


More information about the Commits mailing list