pidgin: d914357c: Introduce purple_account_register_comple...

andrew.victor at mxit.com andrew.victor at mxit.com
Sun Nov 6 15:35:42 EST 2011


----------------------------------------------------------------------
Revision: d914357c1482880fed2c89e136d5957688ff4732
Parent:   cd6af594b2f3a5abb56fcedffd6244f07ce32c18
Author:   andrew.victor at mxit.com
Date:     11/06/11 14:46:57
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d914357c1482880fed2c89e136d5957688ff4732

Changelog: 

Introduce purple_account_register_completed() to handle the invoking of any
 registration callback.


Changes against parent cd6af594b2f3a5abb56fcedffd6244f07ce32c18

  patched  ChangeLog.API
  patched  libpurple/account.c
  patched  libpurple/account.h
  patched  libpurple/protocols/gg/gg.c
  patched  libpurple/protocols/jabber/jabber.c

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	f8a6d992e6a1e9fd28662e7f2939d15ec1d06d6b
+++ libpurple/protocols/jabber/jabber.c	58ff61f585f0961486f3691a85446cc2a1df632e
@@ -1144,8 +1144,7 @@ jabber_registration_result_cb(JabberStre
 		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 @@ jabber_registration_result_cb(JabberStre
 		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 @@ jabber_register_cancel_cb(JabberRegister
 {
 	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 @@ void jabber_register_parse(JabberStream 
 		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 @@ void jabber_register_parse(JabberStream 
 
 				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;
============================================================
--- libpurple/protocols/gg/gg.c	a7291521e92254509be5b68a50d91f831c4c27d2
+++ libpurple/protocols/gg/gg.c	25797b5bc894306d983de39abac7645326e59c8d
@@ -391,8 +391,8 @@ static void ggp_callback_register_accoun
 	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 @@ exit_err:
 	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);
============================================================
--- libpurple/account.c	f78e7bae178409802bc0e622073411d6471892d0
+++ libpurple/account.c	55f3c965cc45250d55fc6a71496a45d0044482d1
@@ -1119,6 +1119,15 @@ void
 }
 
 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);
============================================================
--- libpurple/account.h	0559f07996744acc2624a2a517c87712ad86d57b
+++ libpurple/account.h	f60c9eeda1b127560d597bd2530cf2f8412b99c1
@@ -221,6 +221,15 @@ void purple_account_register(PurpleAccou
 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.
============================================================
--- ChangeLog.API	6fce763da0852ce469c31bdd043f41fdc2bd7d92
+++ ChangeLog.API	6198226490213770e70a2b80f1bb8a7c4e235383
@@ -6,6 +6,7 @@ version 3.0.0 (??/??/????):
 		* 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


More information about the Commits mailing list