cpw.ivan: b6d7712e: The AIM login servers will stop working ...

ivan.komarov at soc.pidgin.im ivan.komarov at soc.pidgin.im
Fri Oct 29 18:34:10 EDT 2010


----------------------------------------------------------------------
Revision: b6d7712e90b68610df3bd2d8cbaf46d94c8b3794
Parent:   7aedaac3ed815cab16d758474a829d5ec5a59e4b
Author:   ivan.komarov at soc.pidgin.im
Date:     10/29/10 18:24:10
Branch:   im.pidgin.cpw.ivan
URL: http://d.pidgin.im/viewmtn/revision/info/b6d7712e90b68610df3bd2d8cbaf46d94c8b3794

Changelog: 

The AIM login servers will stop working for ICQ soon; ICQ will have a separate set
of login-related servers.

The changes include (I'm copying this from a mail I received from one of the guys
behind ICQ):
"""
SNAC based authentication method:
1) For ICQ UINs please switch login.oscar.aol.com to login.icq.com and
slogin.oscar.aol.com to slogin.icq.com

OpenAuth based authentication method:
1) For ICQ UINs please switch https://api.screenname.aol.com to
 https://api.login.icq.net
2) For ICQ UINs please switch http://api.oscar.aol.com to http://api.icq.net
"""

I also was instructed to change "ars.oscar.aol.com" to "ars.icq.com" as a PEER_PROXY
for ICQ UINs.


Changes against parent 7aedaac3ed815cab16d758474a829d5ec5a59e4b

  patched  libpurple/protocols/oscar/clientlogin.c
  patched  libpurple/protocols/oscar/libaim.c
  patched  libpurple/protocols/oscar/libicq.c
  patched  libpurple/protocols/oscar/oscar.c
  patched  libpurple/protocols/oscar/oscarcommon.h
  patched  libpurple/protocols/oscar/peer.c
  patched  libpurple/protocols/oscar/peer.h

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c	532807f16e71bee475f95741b7cbce6358c18113
+++ libpurple/protocols/oscar/oscar.c	1e471df2982afd8628093c5f0d321056de00a3d7
@@ -612,6 +612,18 @@ recent_buddies_pref_cb(const char *name,
 		aim_ssi_setpresence(od, presence | AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES);
 }
 
+static const gchar *login_servers[] = {
+	AIM_DEFAULT_LOGIN_SERVER,
+	AIM_DEFAULT_SSL_LOGIN_SERVER,
+	ICQ_DEFAULT_LOGIN_SERVER,
+	ICQ_DEFAULT_SSL_LOGIN_SERVER,
+};
+
+static const gchar *get_login_server(gboolean is_icq, gboolean use_ssl)
+{
+	return login_servers[is_icq*2 + use_ssl];
+}
+
 void
 oscar_login(PurpleAccount *account)
 {
@@ -725,7 +737,7 @@ oscar_login(PurpleAccount *account)
 				return;
 			}
 
-			server = purple_account_get_string(account, "server", OSCAR_DEFAULT_SSL_LOGIN_SERVER);
+			server = purple_account_get_string(account, "server", get_login_server(od->icq, TRUE));
 
 			/*
 			 * If the account's server is what the oscar prpl has offered as
@@ -734,27 +746,27 @@ oscar_login(PurpleAccount *account)
 			 * do what we know is best for them and change the setting out
 			 * from under them to the SSL login server.
 			 */
-			if (!strcmp(server, OSCAR_DEFAULT_LOGIN_SERVER) || !strcmp(server, OSCAR_OLD_LOGIN_SERVER)) {
+			if (!strcmp(server, get_login_server(od->icq, FALSE))) {
 				purple_debug_info("oscar", "Account uses SSL, so changing server to default SSL server\n");
-				purple_account_set_string(account, "server", OSCAR_DEFAULT_SSL_LOGIN_SERVER);
-				server = OSCAR_DEFAULT_SSL_LOGIN_SERVER;
+				purple_account_set_string(account, "server", get_login_server(od->icq, TRUE));
+				server = get_login_server(od->icq, TRUE);
 			}
 
 			newconn->gsc = purple_ssl_connect(account, server,
 					purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT),
 					ssl_connection_established_cb, ssl_connection_error_cb, newconn);
 		} else {
-			server = purple_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER);
+			server = purple_account_get_string(account, "server", get_login_server(od->icq, FALSE));
 
 			/*
 			 * See the comment above. We do the reverse here. If they don't want
 			 * SSL but their server is set to OSCAR_DEFAULT_SSL_LOGIN_SERVER,
 			 * set it back to the default.
 			 */
-			if (!strcmp(server, OSCAR_DEFAULT_SSL_LOGIN_SERVER)) {
+			if (!strcmp(server, get_login_server(od->icq, TRUE))) {
 				purple_debug_info("oscar", "Account does not use SSL, so changing server back to non-SSL\n");
-				purple_account_set_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER);
-				server = OSCAR_DEFAULT_LOGIN_SERVER;
+				purple_account_set_string(account, "server", get_login_server(od->icq, FALSE));
+				server = get_login_server(od->icq, FALSE);
 			}
 
 			newconn->connect_data = purple_proxy_connect(NULL, account, server,
@@ -5660,13 +5672,13 @@ static gboolean oscar_uri_handler(const 
 	return FALSE;
 }
 
-void oscar_init(PurplePlugin *plugin)
+void oscar_init(PurplePlugin *plugin, gboolean is_icq)
 {
 	PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
 	PurpleAccountOption *option;
 	static gboolean init = FALSE;
 
-	option = purple_account_option_string_new(_("Server"), "server", OSCAR_DEFAULT_LOGIN_SERVER);
+	option = purple_account_option_string_new(_("Server"), "server", get_login_server(is_icq, FALSE));
 	prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
 
 	option = purple_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT);
============================================================
--- libpurple/protocols/oscar/peer.c	3445f821e51360f72e1abf3cc6a0ab48a0d1c3f2
+++ libpurple/protocols/oscar/peer.c	815bc7a8ebfe86c526229a62531dabb0b62e4d0e
@@ -879,7 +879,9 @@ peer_connection_trynext(PeerConnection *
 		}
 
 		conn->verified_connect_data = purple_proxy_connect(NULL, account,
-				(conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER,
+				(conn->proxyip != NULL)
+					? conn->proxyip
+					: (conn->od->icq ? ICQ_PEER_PROXY_SERVER : AIM_PEER_PROXY_SERVER),
 				PEER_PROXY_PORT,
 				peer_proxy_connection_established_cb, conn);
 		if (conn->verified_connect_data != NULL)
============================================================
--- libpurple/protocols/oscar/peer.h	3735dbc4a4e79c10135bb2ded024349b848e112c
+++ libpurple/protocols/oscar/peer.h	997991488f63d8f6fbfd9405f936fc02da2bd1e5
@@ -58,7 +58,8 @@ typedef struct _PeerConnection        Pe
 /*
  * For peer proxying
  */
-#define PEER_PROXY_SERVER         "ars.oscar.aol.com"
+#define AIM_PEER_PROXY_SERVER         "ars.oscar.aol.com"
+#define ICQ_PEER_PROXY_SERVER         "ars.icq.com"
 #define PEER_PROXY_PORT           5190   /* The port we should always connect to */
 #define PEER_PROXY_PACKET_VERSION 0x044a
 
============================================================
--- libpurple/protocols/oscar/libaim.c	d7e13c0f5fc1b33af3710c5504025e4bc31c6c86
+++ libpurple/protocols/oscar/libaim.c	fd35b535d84ba879bc58374776423811f39d5b05
@@ -143,7 +143,7 @@ init_plugin(PurplePlugin *plugin)
 static void
 init_plugin(PurplePlugin *plugin)
 {
-	oscar_init(plugin);
+	oscar_init(plugin, FALSE);
 }
 
 PURPLE_INIT_PLUGIN(aim, init_plugin, info);
============================================================
--- libpurple/protocols/oscar/libicq.c	e1261be8fea48c6fe1427ca0e4215fc30845ee02
+++ libpurple/protocols/oscar/libicq.c	0ae91ecea3a8be3ecb51e978a895e6928faa7d48
@@ -155,7 +155,7 @@ init_plugin(PurplePlugin *plugin)
 {
 	PurpleAccountOption *option;
 
-	oscar_init(plugin);
+	oscar_init(plugin, TRUE);
 
 	option = purple_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
============================================================
--- libpurple/protocols/oscar/oscarcommon.h	0bc9985d11166bdfb5d992dae2a00784269e379e
+++ libpurple/protocols/oscar/oscarcommon.h	c0c1c79bb1873b915a8e9c90a4d103107d18d257
@@ -32,10 +32,13 @@
 #include "notify.h"
 #include "status.h"
 
-#define OSCAR_DEFAULT_LOGIN_SERVER "login.messaging.aol.com"
+#define AIM_DEFAULT_LOGIN_SERVER "login.oscar.aol.com"
+#define AIM_DEFAULT_SSL_LOGIN_SERVER "slogin.oscar.aol.com"
+#define ICQ_DEFAULT_LOGIN_SERVER "login.icq.com"
+#define ICQ_DEFAULT_SSL_LOGIN_SERVER "slogin.icq.com"
+
 #define OSCAR_DEFAULT_LOGIN_PORT 5190
-#define OSCAR_DEFAULT_SSL_LOGIN_SERVER "slogin.oscar.aol.com"
-#define OSCAR_OLD_LOGIN_SERVER "login.oscar.aol.com"
+
 #ifndef _WIN32
 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1"
 #else
@@ -96,4 +99,4 @@ GList *oscar_actions(PurplePlugin *plugi
 gboolean oscar_offline_message(const PurpleBuddy *buddy);
 void oscar_format_username(PurpleConnection *gc, const char *nick);
 GList *oscar_actions(PurplePlugin *plugin, gpointer context);
-void oscar_init(PurplePlugin *plugin);
+void oscar_init(PurplePlugin *plugin, gboolean is_icq);
============================================================
--- libpurple/protocols/oscar/clientlogin.c	f66d45ff55ef44bed415ddbd25e47f2d60c8d5ea
+++ libpurple/protocols/oscar/clientlogin.c	25bf71722aa11fb10901602921e94d27f2c0096d
@@ -42,9 +42,37 @@
 #include "cipher.h"
 #include "core.h"
 
-#define URL_CLIENT_LOGIN "https://api.screenname.aol.com/auth/clientLogin"
-#define URL_START_OSCAR_SESSION "https://api.oscar.aol.com/aim/startOSCARSession"
+#define AIM_LOGIN_HOST "api.screenname.aol.com"
+#define ICQ_LOGIN_HOST "api.login.icq.net"
 
+#define AIM_API_HOST "api.oscar.aol.com"
+#define ICQ_API_HOST "api.icq.net"
+
+#define CLIENT_LOGIN_PAGE "/auth/clientLogin"
+#define START_OSCAR_SESSION_PAGE "/aim/startOSCARSession"
+
+#define HTTPS_FORMAT_URL(host, page) "https://" host page
+
+static const gchar *client_login_urls[] = {
+	HTTPS_FORMAT_URL(AIM_LOGIN_HOST, CLIENT_LOGIN_PAGE),
+	HTTPS_FORMAT_URL(ICQ_LOGIN_HOST, CLIENT_LOGIN_PAGE),
+};
+
+static const gchar *start_oscar_session_urls[] = {
+	HTTPS_FORMAT_URL(AIM_API_HOST, START_OSCAR_SESSION_PAGE),
+	HTTPS_FORMAT_URL(ICQ_API_HOST, START_OSCAR_SESSION_PAGE),
+};
+
+static const gchar *get_client_login_url(OscarData *od)
+{
+	return client_login_urls[od->icq];
+}
+
+static const gchar *get_start_oscar_session_url(OscarData *od)
+{
+	return start_oscar_session_urls[od->icq];
+}
+
 /*
  * Using clientLogin requires a developer ID.  This key is for libpurple.
  * It is the default key for all libpurple-based clients.  AOL encourages
@@ -125,6 +153,7 @@ static gboolean parse_start_oscar_sessio
 
 static gboolean parse_start_oscar_session_response(PurpleConnection *gc, const gchar *response, gsize response_len, char **host, unsigned short *port, char **cookie, char **tls_certname)
 {
+	OscarData *od = purple_connection_get_protocol_data(gc);
 	xmlnode *response_node, *tmp_node, *data_node;
 	xmlnode *host_node = NULL, *port_node = NULL, *cookie_node = NULL, *tls_node = NULL;
 	gboolean use_tls;
@@ -142,7 +171,7 @@ static gboolean parse_start_oscar_sessio
 				"response as XML: %s\n", response);
 		/* Note to translators: %s in this string is a URL */
 		msg = generate_error_message(response_node,
-				URL_START_OSCAR_SESSION);
+				get_start_oscar_session_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -165,7 +194,7 @@ static gboolean parse_start_oscar_sessio
 		purple_debug_error("oscar", "startOSCARSession response was "
 				"missing statusCode: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_START_OSCAR_SESSION);
+				get_start_oscar_session_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -203,7 +232,7 @@ static gboolean parse_start_oscar_sessio
 		else {
 			char *msg;
 			msg = generate_error_message(response_node,
-					URL_START_OSCAR_SESSION);
+					get_start_oscar_session_url(od));
 			purple_connection_error_reason(gc,
 					PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg);
 			g_free(msg);
@@ -224,7 +253,7 @@ static gboolean parse_start_oscar_sessio
 		purple_debug_error("oscar", "startOSCARSession response was missing "
 				"something: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_START_OSCAR_SESSION);
+				get_start_oscar_session_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -247,7 +276,7 @@ static gboolean parse_start_oscar_sessio
 		purple_debug_error("oscar", "startOSCARSession response was missing "
 				"something: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_START_OSCAR_SESSION);
+				get_start_oscar_session_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -284,7 +313,7 @@ static void start_oscar_session_cb(Purpl
 		/* Note to translators: The first %s is a URL, the second is an
 		   error message. */
 		tmp = g_strdup_printf(_("Error requesting %s: %s"),
-				URL_START_OSCAR_SESSION, error_message);
+				get_start_oscar_session_url(od), error_message);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
 		g_free(tmp);
@@ -326,9 +355,9 @@ static void send_start_oscar_session(Osc
 			oscar_get_ui_info_int(od->icq ? "prpl-icq-distid"
 					: "prpl-aim-distid", 0x00000611),
 			get_client_key(od), hosttime, use_tls);
-	signature = generate_signature("GET", URL_START_OSCAR_SESSION,
+	signature = generate_signature("GET", get_start_oscar_session_url(od),
 			query_string, session_key);
-	url = g_strdup_printf(URL_START_OSCAR_SESSION "?%s&sig_sha256=%s",
+	url = g_strdup_printf("%s?%s&sig_sha256=%s", get_start_oscar_session_url(od),
 			query_string, signature);
 	g_free(query_string);
 	g_free(signature);
@@ -367,6 +396,7 @@ static gboolean parse_client_login_respo
  */
 static gboolean parse_client_login_response(PurpleConnection *gc, const gchar *response, gsize response_len, char **token, char **secret, time_t *hosttime)
 {
+	OscarData *od = purple_connection_get_protocol_data(gc);
 	xmlnode *response_node, *tmp_node, *data_node;
 	xmlnode *secret_node = NULL, *hosttime_node = NULL, *token_node = NULL, *tokena_node = NULL;
 	char *tmp;
@@ -379,7 +409,7 @@ static gboolean parse_client_login_respo
 		purple_debug_error("oscar", "clientLogin could not parse "
 				"response as XML: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_CLIENT_LOGIN);
+				get_client_login_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -403,7 +433,7 @@ static gboolean parse_client_login_respo
 		purple_debug_error("oscar", "clientLogin response was "
 				"missing statusCode: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_CLIENT_LOGIN);
+				get_client_login_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -446,7 +476,7 @@ static gboolean parse_client_login_respo
 		} else {
 			char *msg;
 			msg = generate_error_message(response_node,
-					URL_CLIENT_LOGIN);
+					get_client_login_url(od));
 			purple_connection_error_reason(gc,
 					PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg);
 			g_free(msg);
@@ -465,7 +495,7 @@ static gboolean parse_client_login_respo
 		purple_debug_error("oscar", "clientLogin response was missing "
 				"something: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_CLIENT_LOGIN);
+				get_client_login_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -483,7 +513,7 @@ static gboolean parse_client_login_respo
 		purple_debug_error("oscar", "clientLogin response was missing "
 				"something: %s\n", response);
 		msg = generate_error_message(response_node,
-				URL_CLIENT_LOGIN);
+				get_client_login_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
 		g_free(msg);
@@ -520,10 +550,10 @@ static void client_login_cb(PurpleUtilFe
 		gchar *tmp;
 		if (error_message != NULL)
 			tmp = g_strdup_printf(_("Error requesting %s: %s"),
-					URL_CLIENT_LOGIN, error_message);
+					get_client_login_url(od), error_message);
 		else
 			tmp = g_strdup_printf(_("Error requesting %s"),
-					URL_CLIENT_LOGIN);
+					get_client_login_url(od));
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
 		g_free(tmp);
@@ -599,7 +629,7 @@ void send_client_login(OscarData *od, co
 
 	/* Send the POST request  */
 	od->url_data = purple_util_fetch_url_request_len_with_account(
-			purple_connection_get_account(gc), URL_CLIENT_LOGIN,
+			purple_connection_get_account(gc), get_client_login_url(od),
 			TRUE, NULL, FALSE, request->str, FALSE, -1,
 			client_login_cb, od);
 	g_string_free(request, TRUE);


More information about the Commits mailing list