diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2012-01-17 17:10:43 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2012-01-17 17:10:43 +0800 |
commit | 25a44d2984058a38f54ab6bd68027e524342e34b (patch) | |
tree | a698ac149fa82e1c93f0d1d25c45bc68d1ff9fc7 /src | |
parent | f17363e49737c2ad6bf304d7ed1dd2ccf8ca2b4c (diff) | |
parent | 5c615ca9c2ffcff23925c154e36dfeccf416ec30 (diff) | |
download | gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.tar gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.tar.gz gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.tar.bz2 gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.tar.lz gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.tar.xz gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.tar.zst gsoc2013-empathy-25a44d2984058a38f54ab6bd68027e524342e34b.zip |
Merge branch 'master' into call1
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-roster-window.c | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c index 629363a06..f45474cf2 100644 --- a/src/empathy-roster-window.c +++ b/src/empathy-roster-window.c @@ -1294,9 +1294,6 @@ roster_window_connection_changed_cb (TpAccount *account, { empathy_sound_manager_play (self->priv->sound_mgr, GTK_WIDGET (self), EMPATHY_SOUND_ACCOUNT_DISCONNECTED); - - /* remove balance action if required */ - roster_window_remove_balance_action (self, account); } if (current == TP_CONNECTION_STATUS_CONNECTED) @@ -1306,7 +1303,6 @@ roster_window_connection_changed_cb (TpAccount *account, /* Account connected without error, remove error message if any */ roster_window_remove_error (self, account); - roster_window_setup_balance (self, account); } } @@ -2053,30 +2049,62 @@ roster_window_account_removed_cb (TpAccountManager *manager, } static void +account_connection_notify_cb (TpAccount *account, + GParamSpec *spec, + EmpathyRosterWindow *self) +{ + TpConnection *conn; + + conn = tp_account_get_connection (account); + + if (conn != NULL) + { + roster_window_setup_balance (self, account); + } + else + { + /* remove balance action if required */ + roster_window_remove_balance_action (self, account); + } +} + +static void +add_account (EmpathyRosterWindow *self, + TpAccount *account) +{ + gulong handler_id; + + handler_id = GPOINTER_TO_UINT (g_hash_table_lookup ( + self->priv->status_changed_handlers, account)); + + /* connect signal only if it was not connected yet */ + if (handler_id != 0) + return; + + handler_id = g_signal_connect (account, "status-changed", + G_CALLBACK (roster_window_connection_changed_cb), self); + + g_hash_table_insert (self->priv->status_changed_handlers, + account, GUINT_TO_POINTER (handler_id)); + + /* roster_window_setup_balance() relies on the TpConnection to be ready on + * the TpAccount so we connect this signal as well. */ + tp_g_signal_connect_object (account, "notify::connection", + G_CALLBACK (account_connection_notify_cb), self, 0); + + roster_window_setup_balance (self, account); +} + +static void roster_window_account_validity_changed_cb (TpAccountManager *manager, TpAccount *account, gboolean valid, EmpathyRosterWindow *self) { if (valid) - { - gulong handler_id; - handler_id = GPOINTER_TO_UINT (g_hash_table_lookup ( - self->priv->status_changed_handlers, account)); - - /* connect signal only if it was not connected yet */ - if (handler_id == 0) - { - handler_id = g_signal_connect (account, - "status-changed", - G_CALLBACK (roster_window_connection_changed_cb), - self); - g_hash_table_insert (self->priv->status_changed_handlers, - account, GUINT_TO_POINTER (handler_id)); - } - } - - roster_window_account_removed_cb (manager, account, self); + add_account (self, account); + else + roster_window_account_removed_cb (manager, account, self); } static void @@ -2137,15 +2165,8 @@ account_manager_prepared_cb (GObject *source_object, for (j = accounts; j != NULL; j = j->next) { TpAccount *account = TP_ACCOUNT (j->data); - gulong handler_id; - handler_id = g_signal_connect (account, "status-changed", - G_CALLBACK (roster_window_connection_changed_cb), - self); - g_hash_table_insert (self->priv->status_changed_handlers, - account, GUINT_TO_POINTER (handler_id)); - - roster_window_setup_balance (self, account); + add_account (self, account); } g_signal_connect (manager, "account-validity-changed", |