diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-chandler.c | 102 | ||||
-rw-r--r-- | libempathy/empathy-filter.c | 18 |
2 files changed, 57 insertions, 63 deletions
diff --git a/libempathy/empathy-chandler.c b/libempathy/empathy-chandler.c index 8e2637718..a294febf4 100644 --- a/libempathy/empathy-chandler.c +++ b/libempathy/empathy-chandler.c @@ -21,28 +21,17 @@ #include <config.h> -#include <dbus/dbus-glib.h> - #include <telepathy-glib/dbus.h> #include <telepathy-glib/connection.h> #include <telepathy-glib/channel.h> +#include <extensions/extensions.h> #include "empathy-chandler.h" #include "empathy-debug.h" -#include "empathy-marshal.h" #define DEBUG_DOMAIN "EmpathyChandler" -static gboolean empathy_chandler_handle_channel (EmpathyChandler *chandler, - const gchar *bus_name, - const gchar *connection, - const gchar *channel_type, - const gchar *channel, - guint handle_type, - guint handle, - GError **error); - -#include "empathy-chandler-glue.h" +static void chandler_iface_init (EmpSvcChandlerClass *klass); enum { NEW_CHANNEL, @@ -51,7 +40,43 @@ enum { static guint signals[LAST_SIGNAL]; -G_DEFINE_TYPE (EmpathyChandler, empathy_chandler, G_TYPE_OBJECT) +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) +{ + EmpathyChandler *chandler = EMPATHY_CHANDLER (self); + TpChannel *chan; + TpConnection *conn; + static TpDBusDaemon *daemon = NULL; + + if (!daemon) { + 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); + 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); + + g_object_unref (chan); + g_object_unref (conn); + + emp_svc_chandler_return_from_handle_channel (context); +} static void empathy_chandler_class_init (EmpathyChandlerClass *klass) @@ -68,6 +93,15 @@ empathy_chandler_class_init (EmpathyChandlerClass *klass) } static void +chandler_iface_init (EmpSvcChandlerClass *klass) +{ +#define IMPLEMENT(x) emp_svc_chandler_implement_##x \ + (klass, my_##x) + IMPLEMENT (handle_channel); +#undef IMPLEMENT +} + +static void empathy_chandler_init (EmpathyChandler *chandler) { } @@ -76,18 +110,11 @@ EmpathyChandler * empathy_chandler_new (const gchar *bus_name, const gchar *object_path) { - static gboolean initialized = FALSE; EmpathyChandler *chandler; DBusGProxy *proxy; guint result; GError *error = NULL; - if (!initialized) { - dbus_g_object_type_install_info (EMPATHY_TYPE_CHANDLER, - &dbus_glib_empathy_chandler_object_info); - initialized = TRUE; - } - proxy = dbus_g_proxy_new_for_name (tp_get_bus (), DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, @@ -116,36 +143,3 @@ empathy_chandler_new (const gchar *bus_name, return chandler; } -static gboolean -empathy_chandler_handle_channel (EmpathyChandler *chandler, - const gchar *bus_name, - const gchar *connection, - const gchar *channel_type, - const gchar *channel, - guint handle_type, - guint handle, - GError **error) -{ - TpChannel *chan; - TpConnection *conn; - static TpDBusDaemon *daemon = NULL; - - if (!daemon) { - 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); - 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); - - g_object_unref (chan); - g_object_unref (conn); - - return TRUE; -} - diff --git a/libempathy/empathy-filter.c b/libempathy/empathy-filter.c index 3c42fded3..4299073a4 100644 --- a/libempathy/empathy-filter.c +++ b/libempathy/empathy-filter.c @@ -41,7 +41,7 @@ struct _EmpathyFilterPriv { static void empathy_filter_class_init (EmpathyFilterClass *klass); static void empathy_filter_init (EmpathyFilter *filter); -static void filter_iface_init (EmpSvcFilterClass *iface); +static void filter_iface_init (EmpSvcFilterClass *klass); enum { PROCESS, @@ -56,14 +56,14 @@ G_DEFINE_TYPE_WITH_CODE (EmpathyFilter, empathy_filter, G_TYPE_OBJECT, filter_iface_init)); static void -my_filter_channel (EmpSvcFilter *self, - const gchar *bus_name, - const gchar *connection, - const gchar *channel_type, - const gchar *channel, - guint handle_type, - guint handle, - guint id, +my_filter_channel (EmpSvcFilter *self, + const gchar *bus_name, + const gchar *connection, + const gchar *channel_type, + const gchar *channel, + guint handle_type, + guint handle, + guint id, DBusGMethodInvocation *context) { EmpathyFilter *filter = EMPATHY_FILTER (self); |