diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-22 02:02:37 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-22 02:02:37 +0800 |
commit | 067e77dceb1e0c01f33ce4c743e88c7214403b8a (patch) | |
tree | 67af09c0c3cfc0f5754549ee5e1bc4ad637a8f01 /libempathy/empathy-account.c | |
parent | 08c068fc1b90777c3a2b9c313e282f93f24b3f71 (diff) | |
download | gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.tar gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.tar.gz gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.tar.bz2 gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.tar.lz gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.tar.xz gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.tar.zst gsoc2013-empathy-067e77dceb1e0c01f33ce4c743e88c7214403b8a.zip |
Add removed signal on EmpathyAccount
Diffstat (limited to 'libempathy/empathy-account.c')
-rw-r--r-- | libempathy/empathy-account.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c index 5727a8a25..51dd26316 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -42,6 +42,7 @@ enum { STATUS_CHANGED, PRESENCE_CHANGED, + REMOVED, LAST_SIGNAL }; @@ -84,6 +85,7 @@ struct _EmpathyAccountPriv gboolean enabled; gboolean valid; gboolean ready; + gboolean removed; /* Timestamp when the connection got connected in seconds since the epoch */ glong connect_time; @@ -325,6 +327,22 @@ empathy_account_properties_changed (TpAccount *proxy, } static void +empathy_account_removed_cb (TpAccount *proxy, + gpointer user_data, + GObject *weak_object) +{ + EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object); + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->removed) + return; + + priv->removed = TRUE; + + g_signal_emit (account, signals[REMOVED], 0); +} + +static void empathy_account_got_all_cb (TpProxy *proxy, GHashTable *properties, const GError *error, @@ -421,6 +439,21 @@ empathy_account_parse_unique_name (const gchar *bus_name, } static void +account_invalidated_cb (TpProxy *proxy, guint domain, gint code, + gchar *message, gpointer user_data) +{ + EmpathyAccount *account = EMPATHY_ACCOUNT (user_data); + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->removed) + return; + + priv->removed = TRUE; + + g_signal_emit (account, signals[REMOVED], 0); +} + +static void empathy_account_constructed (GObject *object) { EmpathyAccount *account = EMPATHY_ACCOUNT (object); @@ -428,6 +461,9 @@ empathy_account_constructed (GObject *object) priv->account = tp_account_new (priv->dbus, priv->unique_name, NULL); + g_signal_connect (priv->account, "invalidated", + G_CALLBACK (account_invalidated_cb), object); + empathy_account_parse_unique_name (priv->unique_name, &(priv->proto_name), &(priv->cm_name)); @@ -437,6 +473,10 @@ empathy_account_constructed (GObject *object) empathy_account_properties_changed, NULL, NULL, object, NULL); + tp_cli_account_connect_to_removed (priv->account, + empathy_account_removed_cb, + NULL, NULL, object, NULL); + tp_cli_dbus_properties_call_get_all (priv->account, -1, TP_IFACE_ACCOUNT, empathy_account_got_all_cb, @@ -558,6 +598,13 @@ empathy_account_class_init (EmpathyAccountClass *empathy_account_class) 0, NULL, NULL, _empathy_marshal_VOID__UINT_STRING_STRING, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); + + signals[REMOVED] = g_signal_new ("removed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } void |