/soc/2013/ankitkv/gobjectification: 6e2b46ef6743: Add a timeout ...
Ankit Vani
a at nevitus.org
Tue Oct 1 15:46:12 EDT 2013
Changeset: 6e2b46ef6743b2d04d5240251f63453c005f02b6
Author: Ankit Vani <a at nevitus.org>
Date: 2013-10-02 01:14 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/6e2b46ef6743
Description:
Add a timeout for calling registration callback.
This ensures that account and connection are still valid while protocol handles a failure.
diffstat:
libpurple/account.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diffs (46 lines):
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -188,17 +188,34 @@ purple_account_unregister_got_password_c
g_free(cbb);
}
+static gboolean
+purple_account_register_completed_cb(gpointer *data)
+{
+ PurpleAccount *account = PURPLE_ACCOUNT(data[0]);
+ gboolean succeeded = (data[1] != NULL);
+ PurpleAccountPrivate *priv;
+
+ g_free(data);
+
+ g_return_val_if_fail(account != NULL, FALSE);
+
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
+ if (priv->registration_cb)
+ (priv->registration_cb)(account, succeeded, priv->registration_cb_user_data);
+
+ return FALSE;
+}
+
void
purple_account_register_completed(PurpleAccount *account, gboolean succeeded)
{
- PurpleAccountPrivate *priv;
-
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
-
- if (priv->registration_cb)
- (priv->registration_cb)(account, succeeded, priv->registration_cb_user_data);
+ gpointer *data = g_new0(gpointer, 2);
+ data[0] = account;
+ data[1] = succeeded ? GINT_TO_POINTER(1) : NULL;
+
+ purple_timeout_add(0, (GSourceFunc)purple_account_register_completed_cb,
+ (gpointer)data);
}
void
More information about the Commits
mailing list