From: Jonny Lamb Date: Sat, 24 Oct 2009 15:02:52 +0000 (+0100) Subject: status-icon: port to new tp-glib account API X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=2b7894262b4e647760477a9e8b6f8add5b321128 status-icon: port to new tp-glib account API Signed-off-by: Jonny Lamb --- diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index 3af060ac..33c2da03 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -32,11 +32,11 @@ #include #include +#include #include #include #include -#include #include #include @@ -60,7 +60,7 @@ typedef struct { GtkStatusIcon *icon; EmpathyIdle *idle; - EmpathyAccountManager *account_manager; + TpAccountManager *account_manager; gboolean showing_event_icon; guint blink_timeout; EmpathyEventManager *event_manager; @@ -506,20 +506,18 @@ status_icon_create_menu (EmpathyStatusIcon *icon) } static void -status_icon_connection_changed_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus current, - TpConnectionStatus previous, - EmpathyStatusIcon *icon) +status_icon_status_changed_cb (TpAccount *account, + TpConnectionStatus current, + TpConnectionStatus previous, + TpConnectionStatusReason reason, + gchar *dbus_error_name, + GHashTable *details, + EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); - int connected_accounts; - /* Check for a connected account */ - connected_accounts = empathy_account_manager_get_connected_accounts (manager); - - gtk_action_set_sensitive (priv->new_message_item, connected_accounts > 0); + gtk_action_set_sensitive (priv->new_message_item, + empathy_account_manager_get_accounts_connected (NULL)); } static void @@ -531,10 +529,6 @@ status_icon_finalize (GObject *object) g_source_remove (priv->blink_timeout); } - g_signal_handlers_disconnect_by_func (priv->account_manager, - status_icon_connection_changed_cb, - object); - if (priv->notification) { notify_notification_close (priv->notification, NULL); g_object_unref (priv->notification); @@ -558,6 +552,28 @@ empathy_status_icon_class_init (EmpathyStatusIconClass *klass) g_type_class_add_private (object_class, sizeof (EmpathyStatusIconPriv)); } +static void +account_manager_prepared_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) +{ + GList *list, *l; + TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object); + EmpathyStatusIcon *icon = user_data; + + if (!tp_account_manager_prepare_finish (account_manager, result, NULL)) { + return; + } + + list = tp_account_manager_get_valid_accounts (account_manager); + for (l = list; l != NULL; l = l->next) { + empathy_signal_connect_weak (l->data, "status-changed", + G_CALLBACK (status_icon_status_changed_cb), + G_OBJECT (icon)); + } + g_list_free (list); +} + static void empathy_status_icon_init (EmpathyStatusIcon *icon) { @@ -567,13 +583,12 @@ empathy_status_icon_init (EmpathyStatusIcon *icon) icon->priv = priv; priv->icon = gtk_status_icon_new (); - priv->account_manager = empathy_account_manager_dup_singleton (); + priv->account_manager = tp_account_manager_dup (); priv->idle = empathy_idle_dup_singleton (); priv->event_manager = empathy_event_manager_dup_singleton (); - g_signal_connect (priv->account_manager, - "account-connection-changed", - G_CALLBACK (status_icon_connection_changed_cb), icon); + tp_account_manager_prepare_async (priv->account_manager, NULL, + account_manager_prepared_cb, icon); /* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */ empathy_conf_notify_add (empathy_conf_get (),