changeset 22054:658785fe1992

This makes authorization requests go away when the account is disconnected. It will leak the protocol's user_data, but without an API change, there isn't much that can be done about that. References #4609
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 09 Jan 2008 22:14:17 +0000
parents 40a70eb8edb1
children 895120b1b926
files libpurple/account.c pidgin/gtkaccount.c
diffstat 2 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/account.c	Wed Jan 09 19:10:27 2008 +0000
+++ b/libpurple/account.c	Wed Jan 09 22:14:17 2008 +0000
@@ -1219,7 +1219,11 @@
 	if (ops != NULL && ops->close_account_request != NULL)
 		ops->close_account_request(info->ui_handle);
 
+	/* TODO: This will leak info->user_data, but there is no callback to just clean that up */
+
+	g_free(info->user);
 	g_free(info);
+
 }
 
 void
@@ -1264,9 +1268,14 @@
 request_auth_cb(void *data)
 {
 	PurpleAccountRequestInfo *info = data;
+
+	handles = g_list_remove(handles, info);
+
 	info->auth_cb(info->userdata);
+
 	purple_signal_emit(purple_accounts_get_handle(),
 			"account-authorization-granted", info->account, info->user);
+
 	g_free(info->user);
 	g_free(info);
 }
@@ -1275,9 +1284,14 @@
 request_deny_cb(void *data)
 {
 	PurpleAccountRequestInfo *info = data;
+
+	handles = g_list_remove(handles, info);
+
 	info->deny_cb(info->userdata);
+
 	purple_signal_emit(purple_accounts_get_handle(),
 			"account-authorization-denied", info->account, info->user);
+
 	g_free(info->user);
 	g_free(info);
 }
--- a/pidgin/gtkaccount.c	Wed Jan 09 19:10:27 2008 +0000
+++ b/pidgin/gtkaccount.c	Wed Jan 09 22:14:17 2008 +0000
@@ -241,7 +241,7 @@
 
 	gtk_widget_grab_focus(dialog->protocol_menu);
 
-	if (!dialog->prpl_info || !dialog->prpl_info->register_user || 
+	if (!dialog->prpl_info || !dialog->prpl_info->register_user ||
 	    g_object_get_data(G_OBJECT(item), "fake")) {
 		gtk_widget_hide(dialog->register_button);
 	} else {
@@ -2478,6 +2478,7 @@
 						  _("Authorize"), authorize_and_add_cb,
 						  _("Deny"), deny_no_add_cb,
 						  NULL);
+		g_object_set_data(G_OBJECT(alert), "auth_and_add", aa);
 	} else {
 		alert = pidgin_make_mini_dialog(gc, PIDGIN_STOCK_DIALOG_QUESTION,
 						  _("Authorize buddy?"), buffer, user_data,
@@ -2489,13 +2490,20 @@
 
 	g_free(buffer);
 
-	return NULL;
+	return alert;
 }
 
 static void
 pidgin_accounts_request_close(void *ui_handle)
 {
-
+	/* This is super ugly, but without API changes, this is how it works */
+	struct auth_and_add *aa = g_object_get_data(G_OBJECT(ui_handle), "auth_and_add");
+	if (aa != NULL) {
+		g_free(aa->username);
+		g_free(aa->alias);
+		g_free(aa);
+	}
+	gtk_widget_destroy(GTK_WIDGET(ui_handle));
 }
 
 static PurpleAccountUiOps ui_ops =