changeset 32353:cb486df263ef

Introduce purple_account_register_completed() to handle the invoking of any registration callback.
author andrew.victor@mxit.com
date Sun, 06 Nov 2011 19:46:57 +0000
parents c94e2bfae121
children ec6371d4cae8
files ChangeLog.API libpurple/account.c libpurple/account.h libpurple/protocols/gg/gg.c libpurple/protocols/jabber/jabber.c
diffstat 5 files changed, 28 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Sun Nov 06 13:34:58 2011 +0000
+++ b/ChangeLog.API	Sun Nov 06 19:46:57 2011 +0000
@@ -6,6 +6,7 @@
 		* pidgin_create_webview
 		* purple_account_get_ui_data
 		* purple_account_set_ui_data
+		* purple_account_register_completed
 		* purple_conv_chat_cb_get_alias
 		* purple_conv_chat_cb_get_flags
 		* purple_conv_chat_cb_is_buddy
--- a/libpurple/account.c	Sun Nov 06 13:34:58 2011 +0000
+++ b/libpurple/account.c	Sun Nov 06 19:46:57 2011 +0000
@@ -1119,6 +1119,15 @@
 }
 
 void
+purple_account_register_completed(PurpleAccount *account, gboolean succeeded)
+{
+	g_return_if_fail(account != NULL);
+
+	if (account->registration_cb)
+		(account->registration_cb)(account, succeeded, account->registration_cb_user_data);
+}
+
+void
 purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
 {
 	g_return_if_fail(account != NULL);
--- a/libpurple/account.h	Sun Nov 06 13:34:58 2011 +0000
+++ b/libpurple/account.h	Sun Nov 06 19:46:57 2011 +0000
@@ -221,6 +221,15 @@
 void purple_account_register(PurpleAccount *account);
 
 /**
+ * Registration of the account was completed.
+ * Calls the registration call-back set with purple_account_set_register_callback().
+ *
+ * @param account The account being registered.
+ * @param succeeded Was the account registration successful?
+ */
+void purple_account_register_completed(PurpleAccount *account, gboolean succeeded);
+
+/**
  * Unregisters an account (deleting it from the server).
  *
  * @param account The account to unregister.
--- a/libpurple/protocols/gg/gg.c	Sun Nov 06 13:34:58 2011 +0000
+++ b/libpurple/protocols/gg/gg.c	Sun Nov 06 19:46:57 2011 +0000
@@ -391,8 +391,8 @@
 	purple_notify_info(NULL, _("New Gadu-Gadu Account Registered"),
 			 _("Registration completed successfully!"), NULL);
 
-	if(account->registration_cb)
-		(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
+	purple_account_register_completed(account, TRUE);
+
 	/* TODO: the currently open Accounts Window will not be updated withthe
 	 * new username and etc, we need to somehow have it refresh at this
 	 * point
@@ -402,8 +402,7 @@
 	purple_account_disconnect(account);
 
 exit_err:
-	if(account->registration_cb)
-		(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+	purple_account_register_completed(account, FALSE);
 
 	gg_register_free(h);
 	g_free(email);
--- a/libpurple/protocols/jabber/jabber.c	Sun Nov 06 13:34:58 2011 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Nov 06 19:46:57 2011 +0000
@@ -1144,8 +1144,7 @@
 		if(js->registration) {
 			buf = g_strdup_printf(_("Registration of %s@%s successful"),
 					js->user->node, js->user->domain);
-			if(account->registration_cb)
-				(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
+			purple_account_register_completed(account, TRUE);
 		} else {
 			g_return_if_fail(to != NULL);
 			buf = g_strdup_printf(_("Registration to %s successful"),
@@ -1163,8 +1162,7 @@
 		purple_notify_error(NULL, _("Registration Failed"),
 				_("Registration Failed"), msg);
 		g_free(msg);
-		if(account->registration_cb)
-			(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+		purple_account_register_completed(account, FALSE);
 	}
 	g_free(to);
 	if(js->registration)
@@ -1288,8 +1286,7 @@
 {
 	PurpleAccount *account = purple_connection_get_account(cbdata->js->gc);
 	if(account && cbdata->js->registration) {
-		if(account->registration_cb)
-			(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+		purple_account_register_completed(account, FALSE);
 		jabber_connection_schedule_close(cbdata->js);
 	}
 	g_free(cbdata->who);
@@ -1358,8 +1355,7 @@
 		if(js->registration) {
 			purple_notify_error(NULL, _("Already Registered"),
 								_("Already Registered"), NULL);
-			if(account->registration_cb)
-				(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+			purple_account_register_completed(account, FALSE);
 			jabber_connection_schedule_close(js);
 			return;
 		}
@@ -1380,8 +1376,8 @@
 
 				if(js->registration) {
 					js->gc->wants_to_die = TRUE;
-					if(account->registration_cb) /* succeeded, but we have no login info */
-						(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
+					/* succeeded, but we have no login info */
+					purple_account_register_completed(account, TRUE);
 					jabber_connection_schedule_close(js);
 				}
 				return;