diff libpurple/protocols/jabber/auth.c @ 19674:55c47f7ab2a2

The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 07 Sep 2007 01:22:19 +0000
parents 47942d19f301
children 44b4e8bd759b
line wrap: on
line diff
--- a/libpurple/protocols/jabber/auth.c	Thu Sep 06 20:07:51 2007 +0000
+++ b/libpurple/protocols/jabber/auth.c	Fri Sep 07 01:22:19 2007 +0000
@@ -203,8 +203,15 @@
 	return TRUE;
 }
 	
-static void auth_pass_cb(JabberStream *js, PurpleRequestFields *fields)
+static void auth_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields)
 {
+	JabberStream *js;
+
+	/* The password prompt dialog doesn't get disposed if the account disconnects */
+	if (!PURPLE_CONNECTION_IS_VALID(conn))
+		return;
+
+	js = conn->proto_data;
 
 	if (!auth_pass_generic(js, fields))
 		return;
@@ -217,8 +224,16 @@
 }
 
 static void
-auth_old_pass_cb(JabberStream *js, PurpleRequestFields *fields)
+auth_old_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields)
 {
+	JabberStream *js;
+
+	/* The password prompt dialog doesn't get disposed if the account disconnects */
+	if (!PURPLE_CONNECTION_IS_VALID(conn))
+		return;
+
+	js = conn->proto_data;
+
 	if (!auth_pass_generic(js, fields))
 		return;
 	
@@ -228,9 +243,17 @@
 
 
 static void
-auth_no_pass_cb(JabberStream *js, PurpleRequestFields *fields)
+auth_no_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields)
 {
-	purple_connection_error(js->gc, _("Password is required to sign on."));
+	JabberStream *js;
+
+	/* The password prompt dialog doesn't get disposed if the account disconnects */
+	if (!PURPLE_CONNECTION_IS_VALID(conn))
+		return;
+
+	js = conn->proto_data;
+
+	purple_connection_error(conn, _("Password is required to sign on."));
 }
 
 static void jabber_auth_start_cyrus(JabberStream *js)
@@ -283,7 +306,7 @@
 				 */
 
 				if (!purple_account_get_password(js->gc->account)) {
-					purple_account_request_password(js->gc->account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js);
+					purple_account_request_password(js->gc->account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc);
 					return;
 
 				/* If we've got a password, but aren't sending
@@ -597,7 +620,7 @@
 	 */
 	
 	if (!purple_account_get_password(js->gc->account)) {
-		purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js);
+		purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc);
 		return;
 	}
 #endif