changeset 21373:cbf197042bad

Add the old error to the account-error-changed signal.
author Will Thompson <will.thompson@collabora.co.uk>
date Sun, 28 Oct 2007 13:01:45 +0000
parents b6b69faafbe3
children 71c1f2da4ff2
files doc/account-signals.dox libpurple/account.c pidgin/gtkblist.c
diffstat 3 files changed, 31 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/doc/account-signals.dox	Sun Oct 28 11:04:04 2007 +0000
+++ b/doc/account-signals.dox	Sun Oct 28 13:01:45 2007 +0000
@@ -144,12 +144,14 @@
 
  @signaldef account-error-changed
   @signalproto
-void (*account_error_changed)(PurpleAccount *account, const PurpleAccountCurrentError *current_error);
+void (*account_error_changed)(PurpleAccount *account, const PurpleAccountCurrentError *old_error, const PurpleAccountCurrentError *current_error);
   @endsignalproto
   @signaldesc
    Emitted when @a account's error changes.
-  @param account       The account whose error has changed.
-  @param current_error The account's current error, or @c NULL if it has no error.
+  @param account   The account whose error has changed.
+  @param old_error The account's previous error, or @c NULL if it had no
+                   error.
+  @param new_error The account's new error, or @c NULL if it has no error.
   @see purple_account_get_current_error()
   @since 2.3.0
  @endsignaldef
--- a/libpurple/account.c	Sun Oct 28 11:04:04 2007 +0000
+++ b/libpurple/account.c	Sun Oct 28 13:01:45 2007 +0000
@@ -2236,14 +2236,18 @@
 clear_current_error(PurpleAccount *account)
 {
 	PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+	PurpleAccountCurrentError *old;
+
 	if (priv->current_error)
 	{
-		g_free (priv->current_error);
+		old = priv->current_error;
 		priv->current_error = NULL;
+		purple_signal_emit(purple_accounts_get_handle(),
+		                   "account-error-changed",
+		                   account, old, priv->current_error);
+		g_free (old);
 	}
 
-	purple_signal_emit(purple_accounts_get_handle(), "account-error-changed",
-	                   account, priv->current_error);
 }
 
 static void
@@ -2262,14 +2266,16 @@
 {
 	PurpleAccount *account = purple_connection_get_account(gc);
 	PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
-
-	if (!priv->current_error)
-		priv->current_error = g_new0(PurpleAccountCurrentError, 1);
+	PurpleAccountCurrentError *old = priv->current_error;
+
+	priv->current_error = g_new0(PurpleAccountCurrentError, 1);
 	priv->current_error->reason = err;
 	priv->current_error->description = desc;
 
-	purple_signal_emit(purple_accounts_get_handle(), "account-error-changed",
-	                   account, priv->current_error);
+	purple_signal_emit(purple_accounts_get_handle(),
+	                   "account-error-changed",
+	                   account, old, priv->current_error);
+	g_free(old);
 }
 
 const PurpleAccountCurrentError *
@@ -2581,9 +2587,11 @@
 						purple_value_new(PURPLE_TYPE_STRING));
 
 	purple_signal_register(handle, "account-error-changed",
-	                       purple_marshal_VOID__POINTER_POINTER, NULL, 2,
+	                       purple_marshal_VOID__POINTER_POINTER_POINTER,
+	                       NULL, 3,
 	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
 	                                        PURPLE_SUBTYPE_ACCOUNT),
+	                       purple_value_new(PURPLE_TYPE_POINTER),
 	                       purple_value_new(PURPLE_TYPE_POINTER));
 
 	purple_signal_connect(conn_handle, "signed-on", handle,
--- a/pidgin/gtkblist.c	Sun Oct 28 11:04:04 2007 +0000
+++ b/pidgin/gtkblist.c	Sun Oct 28 13:01:45 2007 +0000
@@ -4393,12 +4393,14 @@
 	gtk_widget_show_all(gtkblist->error_buttons);
 }
 
-void
-account_error_changed_cb(PurpleAccount *account,
-                         PurpleAccountCurrentError *err)
-{
-	if (err)
-		pidgin_blist_update_account_error_state(account, err->description);
+static void
+update_account_error_state(PurpleAccount *account,
+                           PurpleAccountCurrentError *old,
+                           PurpleAccountCurrentError *new,
+                           PidginBuddyList *gtkblist)
+{
+	if (new)
+		pidgin_blist_update_account_error_state(account, new->description);
 	else
 		pidgin_blist_update_account_error_state(account, NULL);
 }
@@ -4967,7 +4969,7 @@
 	                      PURPLE_CALLBACK(account_status_changed),
 	                      gtkblist);
 	purple_signal_connect(handle, "account-error-changed", gtkblist,
-	                      PURPLE_CALLBACK(account_error_changed_cb),
+	                      PURPLE_CALLBACK(update_account_error_state),
 	                      gtkblist);
 
 	handle = pidgin_account_get_handle();