diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-11 21:11:38 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-11 21:11:38 +0800 |
commit | ed0e0cf4f678d9e3b13570d217d7960b5ffebdac (patch) | |
tree | e6fe1d7460329c64110a89d07a435b7501a4790f /libempathy/empathy-chandler.c | |
parent | 86b1cd7924f9436c5060787b3025ff5b25679e82 (diff) | |
download | gsoc2013-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-chandler.c')
-rw-r--r-- | libempathy/empathy-chandler.c | 66 |
1 files changed, 52 insertions, 14 deletions
diff --git a/libempathy/empathy-chandler.c b/libempathy/empathy-chandler.c index a294febf4..2fdb37294 100644 --- a/libempathy/empathy-chandler.c +++ b/libempathy/empathy-chandler.c @@ -44,17 +44,20 @@ G_DEFINE_TYPE_WITH_CODE (EmpathyChandler, empathy_chandler, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (EMP_TYPE_SVC_CHANDLER, chandler_iface_init)); -static void -my_handle_channel (EmpSvcChandler *self, - const gchar *bus_name, - const gchar *connection, - const gchar *channel_type, - const gchar *channel, - guint handle_type, - guint handle, - DBusGMethodInvocation *context) +typedef struct { + EmpathyChandler *chandler; + gchar *bus_name; + gchar *connection; + gchar *channel_type; + gchar *channel; + guint handle_type; + guint handle; +} IdleData; + +static gboolean +handle_channel_idle_cb (gpointer data) { - EmpathyChandler *chandler = EMPATHY_CHANDLER (self); + IdleData *idle_data = data; TpChannel *chan; TpConnection *conn; static TpDBusDaemon *daemon = NULL; @@ -63,17 +66,52 @@ my_handle_channel (EmpSvcChandler *self, daemon = tp_dbus_daemon_new (tp_get_bus ()); } - conn = tp_connection_new (daemon, bus_name, connection, NULL); - chan = tp_channel_new (conn, channel, channel_type, handle_type, handle, NULL); + conn = tp_connection_new (daemon, idle_data->bus_name, + idle_data->connection, NULL); + chan = tp_channel_new (conn, idle_data->channel, idle_data->channel_type, + idle_data->handle_type, idle_data->handle, NULL); tp_channel_run_until_ready (chan, NULL, NULL); empathy_debug (DEBUG_DOMAIN, "New channel to be handled: " "type=%s handle=%d", - channel_type, handle); - g_signal_emit (chandler, signals[NEW_CHANNEL], 0, chan); + idle_data->channel_type, idle_data->handle); + g_signal_emit (idle_data->chandler, signals[NEW_CHANNEL], 0, chan); g_object_unref (chan); g_object_unref (conn); + g_free (idle_data->bus_name); + g_free (idle_data->connection); + g_free (idle_data->channel_type); + g_free (idle_data->channel); + g_slice_free (IdleData, idle_data); + + return FALSE; +} + +static void +my_handle_channel (EmpSvcChandler *self, + const gchar *bus_name, + const gchar *connection, + const gchar *channel_type, + const gchar *channel, + guint handle_type, + guint handle, + DBusGMethodInvocation *context) +{ + EmpathyChandler *chandler = EMPATHY_CHANDLER (self); + IdleData *data; + + data = g_slice_new (IdleData); + data->chandler = chandler; + data->bus_name = g_strdup (bus_name); + data->connection = g_strdup (connection); + data->channel_type = g_strdup (channel_type); + data->channel = g_strdup (channel); + data->handle_type = handle_type; + data->handle = handle; + g_idle_add_full (G_PRIORITY_HIGH, + handle_channel_idle_cb, + data, NULL); emp_svc_chandler_return_from_handle_channel (context); } |