From 68d69476f586e377ce45af014f7e4eeb8acd3b8d Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 23 Jul 2009 19:22:30 +0200 Subject: Respect the global presence when enabling an account --- libempathy/empathy-account-manager.c | 39 +++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index 7339acb9f..09bb68126 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -55,6 +55,13 @@ typedef struct { TpConnectionPresenceType global_presence; gchar *global_status; gchar *global_status_message; + + /* desired global presence, could be different + * from the actual global one. + */ + TpConnectionPresenceType desired_presence; + gchar *desired_status; + gchar *desired_status_message; } EmpathyAccountManagerPriv; enum { @@ -769,8 +776,6 @@ empathy_account_manager_request_global_presence ( const gchar *status, const gchar *message) { - /* FIXME should remember requested presence and set it on new accounts - as well */ EmpathyAccountManagerPriv *priv = GET_PRIV (manager); GHashTableIter iter; gpointer value; @@ -786,6 +791,23 @@ empathy_account_manager_request_global_presence ( if (ready) empathy_account_request_presence (account, type, status, message); } + + /* save the requested global presence, to use it in case we create + * new accounts. + */ + priv->desired_presence = type; + + if (tp_strdiff (priv->desired_status, status)) + { + g_free (priv->desired_status); + priv->desired_status = g_strdup (status); + } + + if (tp_strdiff (priv->desired_status_message, message)) + { + g_free (priv->desired_status_message); + priv->desired_status_message = g_strdup (message); + } } TpConnectionPresenceType @@ -875,6 +897,9 @@ EmpathyAccount * empathy_account_manager_create_account_finish ( EmpathyAccountManager *manager, GAsyncResult *result, GError **error) { + EmpathyAccount *retval; + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) return NULL; @@ -882,7 +907,15 @@ empathy_account_manager_create_account_finish ( g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (manager), empathy_account_manager_create_account_finish), NULL); - return EMPATHY_ACCOUNT (g_simple_async_result_get_op_res_gpointer ( + retval = EMPATHY_ACCOUNT (g_simple_async_result_get_op_res_gpointer ( G_SIMPLE_ASYNC_RESULT (result))); + + /* if we have an account, it's ready, as we waited for it. + * request the global presence now. + */ + empathy_account_request_presence (retval, priv->desired_presence, + priv->desired_status, priv->desired_status_message); + + return retval; } -- cgit v1.2.3