changeset 25015:7f0321038c53

Implement a sane mechanism for switching an OSCAR account to SSL. The user checks the box and, if their login server is one of the default ones used in libpurple, change it to the SSL server. If the user unchecks the box, change it back. I'm not happy with this, but it works. It might be sensible to adjust our connecting server and not change the account option)
author Paul Aurich <paul@darkrain42.org>
date Thu, 18 Dec 2008 05:27:39 +0000
parents d265a11c6446
children ff5e2356683f
files libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscarcommon.h
diffstat 2 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Thu Dec 18 05:05:40 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Dec 18 05:27:39 2008 +0000
@@ -1512,7 +1512,7 @@
 		gc->flags |= PURPLE_CONNECTION_AUTO_RESP;
 	}
 
-	od->use_ssl = purple_account_get_bool(account, "use_ssl", FALSE);
+	od->use_ssl = purple_account_get_bool(account, "use_ssl", OSCAR_DEFAULT_USE_SSL);
 
 	/* Connect to core Purple signals */
 	purple_prefs_connect_callback(gc, "/purple/away/idle_reporting", idle_reporting_pref_cb, gc);
@@ -1521,12 +1521,20 @@
 	newconn = flap_connection_new(od, SNAC_FAMILY_AUTH);
 	if (od->use_ssl) {
 		if (purple_ssl_is_supported()) {
-			/* FIXME SSL: This won't really work... Need to match on the server being the default
-			 * non-ssl server and, if so, connect to the default ssl one (and possibly update
-			 * the account setting).
+			const char *server = purple_account_get_string(account, "server", OSCAR_DEFAULT_SSL_LOGIN_SERVER);
+			/* If the account's server is what the oscar prpl has offered as
+			 * the default login server through the vast eons (all two of
+			 * said default options, AFAIK) and the user wants SSL, we'll
+			 * do what we know is best for them and change the setting out
+			 * from under them to the SSL login server.
 			 */
-			newconn->gsc = purple_ssl_connect(account,
-					purple_account_get_string(account, "server", OSCAR_DEFAULT_SSL_LOGIN_SERVER),
+			if (!strcmp(server, OSCAR_DEFAULT_LOGIN_SERVER) || !strcmp(server, OSCAR_OLD_LOGIN_SERVER)) {
+				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;
+			}
+
+			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 {
@@ -1534,8 +1542,19 @@
 					_("SSL support unavailable"));
 		}
 	} else {
-		newconn->connect_data = purple_proxy_connect(NULL, account,
-				purple_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER),
+		const char *server = purple_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER);
+
+		/* 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)) {
+			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;
+		}
+
+		newconn->connect_data = purple_proxy_connect(NULL, account, server,
 				purple_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT),
 				connection_established_cb, newconn);
 	}
--- a/libpurple/protocols/oscar/oscarcommon.h	Thu Dec 18 05:05:40 2008 +0000
+++ b/libpurple/protocols/oscar/oscarcommon.h	Thu Dec 18 05:27:39 2008 +0000
@@ -33,6 +33,7 @@
 #define OSCAR_DEFAULT_LOGIN_SERVER "login.messaging.aol.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