pidgin: 4d84bf43: Ladies and gentlemen, I give you HTTP-ba...
rekkanoryo at pidgin.im
rekkanoryo at pidgin.im
Fri Apr 2 02:46:14 EDT 2010
-----------------------------------------------------------------
Revision: 4d84bf43ba957bf41286f4424b54e4b7788e587c
Ancestor: 3781ab1c1ef9b364a1739b4519e3a69c7d359fa5
Author: rekkanoryo at pidgin.im
Date: 2010-04-02T06:42:32
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4d84bf43ba957bf41286f4424b54e4b7788e587c
Modified files:
libpurple/protocols/yahoo/libyahoo.c
libpurple/protocols/yahoo/libyahoojp.c
libpurple/protocols/yahoo/libymsg.c
libpurple/protocols/yahoo/libymsg.h
ChangeLog:
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.
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libyahoo.c a039bd598dca88ff0d52405b0b3e6d527e22b005
+++ libpurple/protocols/yahoo/libyahoo.c ea0392e3f4b8635517ffe6445c3f9502d3497bf2
@@ -307,9 +307,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);
============================================================
--- libpurple/protocols/yahoo/libyahoojp.c ee7d7528b33a34379c2f8ccba55703a61e6aa35c
+++ libpurple/protocols/yahoo/libyahoojp.c bcb0e2c31501f3d4084e575437c79f8b638ac6d0
@@ -203,9 +203,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);
============================================================
--- libpurple/protocols/yahoo/libymsg.c 1b69a57ae7d594303a9e9c9d4f40a5e21eed7fa8
+++ libpurple/protocols/yahoo/libymsg.c cd664620ade3d4b883d0ef7d81cc37d942d84acf
@@ -3451,17 +3451,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);
@@ -3516,12 +3505,69 @@ 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;
+
+ if(error_message != NULL) {
+ purple_debug_error("yahoo", "Login failed. Unable to retrieve server "
+ "info: %s\n", error_message);
+ purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
+ _("Unable to retrieve server information"));
+ return;
+ }
+
+ 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;
+ }
+
+ 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");
+ }
+ } 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(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_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
+ _("Unable to retrieve server information"));
+ }
+
+ 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;
@@ -3530,6 +3576,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;
@@ -3548,19 +3595,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 9e5bbf356e75ade5eef41ed8fe90d42829d7e76d
+++ libpurple/protocols/yahoo/libymsg.h 5172382c3c01be9dbe68bc0c99b717c95bdb1628
@@ -30,6 +30,7 @@
#include "prpl.h"
#define YAHOO_PAGER_HOST "scsa.msg.yahoo.com"
+#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"
@@ -47,6 +48,7 @@
/* really we should get the list of servers from
http://update.messenger.yahoo.co.jp/servers.html */
#define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp"
+#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