diff libpurple/account.c @ 20152:0cb113dfb096

Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 18 Sep 2007 03:11:19 +0000
parents 6bf32c9e15a7
children 8e3ef71c4362 591267f6f1d5 2002a6a32b0c f387e8c671a4
line wrap: on
line diff
--- a/libpurple/account.c	Tue Sep 18 03:10:40 2007 +0000
+++ b/libpurple/account.c	Tue Sep 18 03:11:19 2007 +0000
@@ -917,7 +917,7 @@
 purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data)
 {
 	g_return_if_fail(account != NULL);
-	
+
 	account->registration_cb = cb;
 	account->registration_cb_user_data = user_data;
 }
@@ -937,10 +937,10 @@
 purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
 {
 	g_return_if_fail(account != NULL);
-	
+
 	purple_debug_info("account", "Unregistering account %s\n",
 					  purple_account_get_username(account));
-	
+
 	purple_connection_new_unregister(account, purple_account_get_password(account), cb, user_data);
 }
 
@@ -960,13 +960,21 @@
 	}
 
 	if(remember)
-	  purple_account_set_remember_password(account, TRUE);
+		purple_account_set_remember_password(account, TRUE);
 
 	purple_account_set_password(account, entry);
 
 	purple_connection_new(account, FALSE, entry);
 }
 
+static void
+request_password_cancel_cb(PurpleAccount *account, PurpleRequestFields *fields)
+{
+	/* Disable the account as the user has canceled connecting */
+	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
+}
+
+
 void
 purple_account_request_password(PurpleAccount *account, GCallback ok_cb,
 				GCallback cancel_cb, void *user_data)
@@ -1040,7 +1048,7 @@
 	if ((password == NULL) &&
 		!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
 		!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
-		purple_account_request_password(account, G_CALLBACK(request_password_ok_cb), NULL, account);
+		purple_account_request_password(account, G_CALLBACK(request_password_ok_cb), G_CALLBACK(request_password_cancel_cb), account);
 	else
 		purple_connection_new(account, FALSE, password);
 }
@@ -1111,18 +1119,18 @@
 	g_free(info);
 }
 
-void 
+void
 purple_account_request_close_with_account(PurpleAccount *account)
 {
 	GList *l, *l_next;
-	
+
 	g_return_if_fail(account != NULL);
-	
+
 	for (l = handles; l != NULL; l = l_next) {
 		PurpleAccountRequestInfo *info = l->data;
-		
+
 		l_next = l->next;
-		
+
 		if (info->account == account) {
 			handles = g_list_remove(handles, info);
 			purple_account_request_close_info(info);
@@ -1130,18 +1138,18 @@
 	}
 }
 
-void 
+void
 purple_account_request_close(void *ui_handle)
 {
 	GList *l, *l_next;
-	
+
 	g_return_if_fail(ui_handle != NULL);
-	
+
 	for (l = handles; l != NULL; l = l_next) {
 		PurpleAccountRequestInfo *info = l->data;
-		
+
 		l_next = l->next;
-		
+
 		if (info->ui_handle == ui_handle) {
 			handles = g_list_remove(handles, info);
 			purple_account_request_close_info(info);
@@ -1172,7 +1180,7 @@
 		handles = g_list_append(handles, info);
 		return info->ui_handle;
 	}
-	
+
 	return NULL;
 }
 
@@ -2443,7 +2451,7 @@
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
 							 			PURPLE_SUBTYPE_ACCOUNT),
 						 purple_value_new(PURPLE_TYPE_STRING));
-	
+
 	load_accounts();
 
 }