diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2010-12-08 17:32:06 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2010-12-08 17:32:06 +0800 |
commit | b1a60391b1ca744b3bd5c3218488ccd4cab9b86c (patch) | |
tree | a5227957441b435e825d2a2b8f202572d4ba1f19 /libempathy/empathy-account-settings.c | |
parent | fdfca8f9fa60962a6e808e8c9cdb2173205457b0 (diff) | |
download | gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.tar gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.tar.gz gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.tar.bz2 gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.tar.lz gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.tar.xz gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.tar.zst gsoc2013-empathy-b1a60391b1ca744b3bd5c3218488ccd4cab9b86c.zip |
account-settings: store the TpProtocol object and notify::ready when it's prepared
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy/empathy-account-settings.c')
-rw-r--r-- | libempathy/empathy-account-settings.c | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index e5191a96c..c5c1be8b1 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -59,6 +59,7 @@ struct _EmpathyAccountSettingsPriv TpAccountManager *account_manager; TpConnectionManager *manager; + TpProtocol *protocol_obj; TpAccount *account; gchar *cm_name; @@ -80,6 +81,7 @@ struct _EmpathyAccountSettingsPriv GList *required_params; gulong managers_ready_id; + gboolean preparing_protocol; GSimpleAsyncResult *apply_result; }; @@ -336,6 +338,10 @@ empathy_account_settings_dispose (GObject *object) g_object_unref (priv->account); priv->account = NULL; + if (priv->protocol_obj != NULL) + g_object_unref (priv->protocol_obj); + priv->protocol_obj = NULL; + /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_account_settings_parent_class)->dispose) G_OBJECT_CLASS (empathy_account_settings_parent_class)->dispose (object); @@ -385,10 +391,29 @@ empathy_account_settings_finalize (GObject *object) } static void +empathy_account_settings_protocol_obj_prepared_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyAccountSettings *self = user_data; + GError *error = NULL; + + if (!tp_proxy_prepare_finish (source, result, &error)) + { + DEBUG ("Failed to prepare protocol object: %s", error->message); + g_clear_error (&error); + return; + } + + empathy_account_settings_check_readyness (self); +} + +static void empathy_account_settings_check_readyness (EmpathyAccountSettings *self) { EmpathyAccountSettingsPriv *priv = GET_PRIV (self); const TpConnectionManagerProtocol *tp_protocol; + GQuark features[] = { TP_PROTOCOL_FEATURE_CORE, 0 }; if (priv->ready) return; @@ -400,12 +425,17 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) if (!empathy_connection_managers_is_ready (priv->managers)) return; - priv->manager = empathy_connection_managers_get_cm ( - priv->managers, priv->cm_name); + if (priv->manager == NULL) + { + priv->manager = empathy_connection_managers_get_cm ( + priv->managers, priv->cm_name); + } if (priv->manager == NULL) return; + g_object_ref (priv->manager); + if (priv->account != NULL) { g_free (priv->display_name); @@ -440,7 +470,21 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) } } - g_object_ref (priv->manager); + if (priv->protocol_obj == NULL) + { + priv->protocol_obj = g_object_ref ( + tp_connection_manager_get_protocol_object (priv->manager, + priv->protocol)); + } + + if (!tp_proxy_is_prepared (priv->protocol_obj, TP_PROTOCOL_FEATURE_CORE) + && !priv->preparing_protocol) + { + priv->preparing_protocol = TRUE; + tp_proxy_prepare_async (priv->protocol_obj, features, + empathy_account_settings_protocol_obj_prepared_cb, self); + return; + } priv->ready = TRUE; g_object_notify (G_OBJECT (self), "ready"); |