diff libpurple/protocols/oscar/oscar.c @ 31085:4297feb30ad1

Merged everything related to ICQ server changes. applied changes from b6d7712e90b68610df3bd2d8cbaf46d94c8b3794 through d849dc2a852a4ffdd345a150f0b88ab37de36e36 applied changes from 7aedaac3ed815cab16d758474a829d5ec5a59e4b through d849dc2a852a4ffdd345a150f0b88ab37de36e36
author ivan.komarov@soc.pidgin.im
date Sat, 30 Oct 2010 21:36:34 +0000
parents 001897406060
children 1558900f47e5
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Sat Oct 30 21:27:00 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sat Oct 30 21:36:34 2010 +0000
@@ -612,6 +612,18 @@
 		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 @@
 				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 @@
 			 * 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,
@@ -969,8 +981,8 @@
 	conn->cookie = g_memdup(cookie, cookielen);
 
 	/*
-	 * tls_certname is only set (and must be set if we get this far) if
-	 * SSL is enabled.
+	 * Use SSL only if the server provided us with a tls_certname. The server might not specify a tls_certname even if we requested to use TLS, 
+	 * and that is something we should be prepared to.
 	 */
 	if (tls_certname)
 	{
@@ -5666,13 +5678,13 @@
 	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);