aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-utils.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-04-11 21:11:38 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-04-11 21:11:38 +0800
commited0e0cf4f678d9e3b13570d217d7960b5ffebdac (patch)
treee6fe1d7460329c64110a89d07a435b7501a4790f /libempathy/empathy-utils.c
parent86b1cd7924f9436c5060787b3025ff5b25679e82 (diff)
downloadgsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.tar
gsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.tar.gz
gsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.tar.bz2
gsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.tar.lz
gsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.tar.xz
gsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.tar.zst
gsoc2013-empathy-ed0e0cf4f678d9e3b13570d217d7960b5ffebdac.zip
We can't use *_run_* API from dbus signal cb or method implementation. To avoid problems move the code to a g_idle cb.
svn path=/trunk/; revision=922
Diffstat (limited to 'libempathy/empathy-utils.c')
-rw-r--r--libempathy/empathy-utils.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index b4058cd38..46fb97027 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -633,3 +633,99 @@ empathy_channel_get_account (TpChannel *channel)
return account;
}
+
+typedef void (*AccountStatusChangedFunc) (MissionControl *mc,
+ TpConnectionStatus status,
+ McPresence presence,
+ TpConnectionStatusReason reason,
+ const gchar *unique_name,
+ gpointer *user_data);
+
+typedef struct {
+ AccountStatusChangedFunc handler;
+ gpointer user_data;
+ GClosureNotify free_func;
+} AccountStatusChangedData;
+
+typedef struct {
+ MissionControl *mc;
+ TpConnectionStatus status;
+ McPresence presence;
+ TpConnectionStatusReason reason;
+ gchar *unique_name;
+ AccountStatusChangedData *data;
+} InvocationData;
+
+static void
+account_status_changed_data_free (gpointer ptr,
+ GClosure *closure)
+{
+ AccountStatusChangedData *data = ptr;
+
+ if (data->free_func) {
+ data->free_func (data->user_data, closure);
+ }
+ g_slice_free (AccountStatusChangedData, data);
+}
+
+static gboolean
+account_status_changed_invoke_callback (gpointer data)
+{
+ InvocationData *invocation_data = data;
+
+ invocation_data->data->handler (invocation_data->mc,
+ invocation_data->status,
+ invocation_data->presence,
+ invocation_data->reason,
+ invocation_data->unique_name,
+ invocation_data->data->user_data);
+
+ g_free (invocation_data->unique_name);
+ g_slice_free (InvocationData, invocation_data);
+
+ return FALSE;
+}
+
+static void
+account_status_changed_cb (MissionControl *mc,
+ TpConnectionStatus status,
+ McPresence presence,
+ TpConnectionStatusReason reason,
+ const gchar *unique_name,
+ AccountStatusChangedData *data)
+{
+ InvocationData *invocation_data;
+
+ invocation_data = g_slice_new (InvocationData);
+ invocation_data->mc = mc;
+ invocation_data->status = status;
+ invocation_data->presence = presence;
+ invocation_data->reason = reason;
+ invocation_data->unique_name = g_strdup (unique_name);
+ invocation_data->data = data;
+ g_idle_add_full (G_PRIORITY_HIGH,
+ account_status_changed_invoke_callback,
+ invocation_data, NULL);
+}
+
+void
+empathy_connect_to_account_status_changed (MissionControl *mc,
+ GCallback handler,
+ gpointer user_data,
+ GClosureNotify free_func)
+{
+ AccountStatusChangedData *data;
+
+ g_return_if_fail (IS_MISSIONCONTROL (mc));
+ g_return_if_fail (handler != NULL);
+
+ data = g_slice_new (AccountStatusChangedData);
+
+ data->handler = (AccountStatusChangedFunc) handler;
+ data->user_data = user_data;
+ data->free_func = free_func;
+ dbus_g_proxy_connect_signal (DBUS_G_PROXY (mc), "AccountStatusChanged",
+ G_CALLBACK (account_status_changed_cb),
+ data, account_status_changed_data_free);
+}
+