cpw.darkrain42.oscar.ssl: 8a336a3d: Implement a sane mechanism for switching...

paul at darkrain42.org paul at darkrain42.org
Wed Jan 14 01:56:52 EST 2009


-----------------------------------------------------------------
Revision: 8a336a3d256ee3435232fad10bd222d3bab817ac
Ancestor: 027a2a6c551607b375bdb34066df802a1de608fc
Author: paul at darkrain42.org
Date: 2008-12-18T05:27:39
Branch: im.pidgin.cpw.darkrain42.oscar.ssl
URL: http://d.pidgin.im/viewmtn/revision/info/8a336a3d256ee3435232fad10bd222d3bab817ac

Modified files:
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/oscar/oscarcommon.h

ChangeLog: 

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)

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c	f9cedbbc1ad3199c0ba0f42a19dfb5566f9fb82d
+++ libpurple/protocols/oscar/oscar.c	10c80a843b133af1786842094e18bd8f5c80395a
@@ -1512,7 +1512,7 @@ oscar_login(PurpleAccount *account)
 		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 @@ oscar_login(PurpleAccount *account)
 	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 @@ oscar_login(PurpleAccount *account)
 					_("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);
 	}
============================================================
--- libpurple/protocols/oscar/oscarcommon.h	7f462e73048eb7a1e1a43d7f41a15df7aca67647
+++ libpurple/protocols/oscar/oscarcommon.h	28a31bbf8b7c1efe7eec1e0101424bca7dea1e71
@@ -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


More information about the Commits mailing list