aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-22 02:02:37 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-22 02:02:37 +0800
commit067e77dceb1e0c01f33ce4c743e88c7214403b8a (patch)
tree67af09c0c3cfc0f5754549ee5e1bc4ad637a8f01 /libempathy
parent08c068fc1b90777c3a2b9c313e282f93f24b3f71 (diff)
downloadgsoc2013-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')
-rw-r--r--libempathy/empathy-account-manager.c17
-rw-r--r--libempathy/empathy-account.c47
2 files changed, 64 insertions, 0 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index 5d1363fce..7339acb9f 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -221,6 +221,20 @@ signal:
}
static void
+emp_account_removed_cb (EmpathyAccount *account, gpointer user_data)
+{
+ EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
+ EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
+
+ g_object_ref (account);
+ g_hash_table_remove (priv->accounts,
+ empathy_account_get_unique_name (account));
+
+ g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
+ g_object_unref (account);
+}
+
+static void
empathy_account_manager_check_ready (EmpathyAccountManager *manager)
{
EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
@@ -272,6 +286,9 @@ emp_account_ready_cb (GObject *obj, GParamSpec *spec, gpointer user_data)
g_signal_connect (account, "presence-changed",
G_CALLBACK (emp_account_presence_changed_cb), manager);
+ g_signal_connect (account, "removed",
+ G_CALLBACK (emp_account_removed_cb), manager);
+
empathy_account_manager_check_ready (manager);
}
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