diff options
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-account-widget-private.h | 7 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 45 |
2 files changed, 50 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-account-widget-private.h b/libempathy-gtk/empathy-account-widget-private.h index db8dc7ddf..d15aa550d 100644 --- a/libempathy-gtk/empathy-account-widget-private.h +++ b/libempathy-gtk/empathy-account-widget-private.h @@ -34,6 +34,13 @@ struct _EmpathyAccountWidgetUIDetails { GtkBuilder *gui; char *default_focus; + + /* an optional callback to call after calling + * empathy_account_settings_apply_async () -- must use a GSimpleAsyncResult + * which sets a gboolean indicating reconnect_required */ + void (* additional_apply_async) (EmpathyAccountWidget *, + GAsyncReadyCallback callback, + gpointer user_data); }; diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index c1d625c91..95d998eef 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -756,16 +756,19 @@ account_widget_account_enabled_cb (GObject *source_object, g_object_unref (widget); } +static void account_widget_applied_continue (EmpathyAccountWidget *widget, + gboolean reconnect_required); +static void account_widget_applied_additional_cb (GObject *widget, + GAsyncResult *result, gpointer user_data); + static void account_widget_applied_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GError *error = NULL; - TpAccount *account; EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object); EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data); - EmpathyAccountWidgetPriv *priv = GET_PRIV (widget); gboolean reconnect_required; empathy_account_settings_apply_finish (settings, res, &reconnect_required, @@ -778,6 +781,44 @@ account_widget_applied_cb (GObject *source_object, return; } + DEBUG ("First stage apply complete: reconnect_required = %s", + reconnect_required ? "yes" : "no"); + + /* if there is additional work for this widget, do that now */ + if (widget->ui_details->additional_apply_async != NULL) + widget->ui_details->additional_apply_async (widget, + account_widget_applied_additional_cb, + GUINT_TO_POINTER (reconnect_required)); + else + account_widget_applied_continue (widget, reconnect_required); +} + +static void +account_widget_applied_additional_cb (GObject *obj, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (obj); + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + gboolean reconnect_required = GPOINTER_TO_UINT (user_data); + + /* we don't care about the error status, the async method can report it, + * just get the result */ + reconnect_required |= g_simple_async_result_get_op_res_gboolean (simple); + + DEBUG ("Second stage apply complete: reconnect_required = %s", + reconnect_required ? "yes" : "no"); + + account_widget_applied_continue (widget, reconnect_required); +} + +static void +account_widget_applied_continue (EmpathyAccountWidget *widget, + gboolean reconnect_required) +{ + EmpathyAccountWidgetPriv *priv = GET_PRIV (widget); + TpAccount *account; + account = empathy_account_settings_get_account (priv->settings); if (account != NULL) |