diff libpurple/protocols/jabber/auth.c @ 30909:25e200cb3532

propagate from branch 'im.pidgin.pidgin' (head dca20e09164518b0f7a773edd7e9649f41d8873d) to branch 'im.pidgin.cpw.malu.xmpp.google_refactor' (head 7823c556f2d1bbca43f5ef9f0fea30cabc5d313f)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 31 Aug 2010 18:28:10 +0000
parents 4072761e3454
children cea7e713ef07
line wrap: on
line diff
--- a/libpurple/protocols/jabber/auth.c	Fri Apr 09 22:14:51 2010 +0000
+++ b/libpurple/protocols/jabber/auth.c	Tue Aug 31 18:28:10 2010 +0000
@@ -45,35 +45,6 @@
                                JabberIqType type, const char *id,
                                xmlnode *packet, gpointer data);
 
-gboolean
-jabber_process_starttls(JabberStream *js, xmlnode *packet)
-{
-	PurpleAccount *account;
-	xmlnode *starttls;
-
-	account = purple_connection_get_account(js->gc);
-
-	if((starttls = xmlnode_get_child(packet, "starttls"))) {
-		if(purple_ssl_is_supported()) {
-			jabber_send_raw(js,
-					"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
-			return TRUE;
-		} else if(xmlnode_get_child(starttls, "required")) {
-			purple_connection_error_reason(js->gc,
-				PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
-				_("Server requires TLS/SSL, but no TLS/SSL support was found."));
-			return TRUE;
-		} else if(purple_account_get_bool(account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) {
-			purple_connection_error_reason(js->gc,
-				 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
-				_("You require encryption, but no TLS/SSL support was found."));
-			return TRUE;
-		}
-	}
-
-	return FALSE;
-}
-
 static void finish_plaintext_authentication(JabberStream *js)
 {
 	JabberIq *iq;
@@ -152,7 +123,7 @@
 	if (!PURPLE_CONNECTION_IS_VALID(gc))
 		return;
 
-	/* Disable the account as the user has canceled connecting */
+	/* Disable the account as the user has cancelled connecting */
 	purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE);
 }
 #endif
@@ -187,7 +158,7 @@
 
 		if (mech_name && *mech_name)
 			mechanisms = g_slist_prepend(mechanisms, mech_name);
-		else if (mech_name)
+		else
 			g_free(mech_name);
 
 	}
@@ -208,6 +179,11 @@
 		}
 	}
 
+	while (mechanisms) {
+		g_free(mechanisms->data);
+		mechanisms = g_slist_delete_link(mechanisms, mechanisms);
+	}
+
 	if (js->auth_mech == NULL) {
 		/* Found no good mechanisms... */
 		purple_connection_error_reason(js->gc,
@@ -275,7 +251,8 @@
 		g_free(msg);
 	} else if (type == JABBER_IQ_RESULT) {
 		query = xmlnode_get_child(packet, "query");
-		if(js->stream_id && xmlnode_get_child(query, "digest")) {
+		if (js->stream_id && *js->stream_id &&
+				xmlnode_get_child(query, "digest")) {
 			char *s, *hash;
 
 			iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
@@ -293,8 +270,10 @@
 			g_free(s);
 			jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
 			jabber_iq_send(iq);
-
-		} else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) {
+		} else if ((x = xmlnode_get_child(query, "crammd5"))) {
+			/* For future reference, this appears to be a custom OS X extension
+			 * to non-SASL authentication.
+			 */
 			const char *challenge;
 			gchar digest[33];
 			PurpleCipherContext *hmac;
@@ -364,7 +343,8 @@
 	 * is requiring SSL/TLS, we need to enforce it.
 	 */
 	if (!jabber_stream_is_ssl(js) &&
-			purple_account_get_bool(account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) {
+			g_str_equal("require_tls",
+				purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) {
 		purple_connection_error_reason(js->gc,
 			PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
 			_("You require encryption, but it is not available on this server."));