empathy r919 - trunk/libempathy



Author: xclaesse
Date: Fri Apr 11 14:11:31 2008
New Revision: 919
URL: http://svn.gnome.org/viewvc/empathy?rev=919&view=rev

Log:
Make use of generated API for EmpathyFilter


Modified:
   trunk/libempathy/Makefile.am
   trunk/libempathy/empathy-filter.c

Modified: trunk/libempathy/Makefile.am
==============================================================================
--- trunk/libempathy/Makefile.am	(original)
+++ trunk/libempathy/Makefile.am	Fri Apr 11 14:11:31 2008
@@ -108,12 +108,6 @@
 	echo "#include \"empathy-marshal.h\"" > $@ && \
 	$(GLIB_GENMARSHAL) --body --prefix=_$(subst -,_,$*)_marshal $< >> $*-marshal.c
 
-empathy-chandler-glue.h: empathy-chandler.xml Makefile
-	$(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=empathy_chandler --mode=glib-server --output=$@ $<
-empathy-filter-glue.h: empathy-filter.xml Makefile
-	$(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=empathy_filter --mode=glib-server --output=$@ $<
-
-
 empathy-enum-types.h: stamp-empathy-enum-types.h
 	@true
 stamp-empathy-enum-types.h: $(libempathy_headers) Makefile
@@ -172,8 +166,6 @@
 
 EXTRA_DIST = 			\
 	empathy-marshal.list	\
-	empathy-chandler.xml	\
-	empathy-filter.xml	\
 	$(stylesheet_DATA)	\
 	$(dtd_DATA)		\
 	$(ircnetworks_DATA)

Modified: trunk/libempathy/empathy-filter.c
==============================================================================
--- trunk/libempathy/empathy-filter.c	(original)
+++ trunk/libempathy/empathy-filter.c	Fri Apr 11 14:11:31 2008
@@ -24,6 +24,7 @@
 #include <telepathy-glib/dbus.h>
 #include <telepathy-glib/connection.h>
 
+#include <extensions/extensions.h>
 #include "empathy-filter.h"
 #include "empathy-debug.h"
 #include "empathy-utils.h"
@@ -38,20 +39,9 @@
 	GHashTable *table;
 };
 
-static void     empathy_filter_class_init     (EmpathyFilterClass *klass);
-static void     empathy_filter_init           (EmpathyFilter      *filter);
-static void     filter_finalize               (GObject            *object);
-static gboolean empathy_filter_filter_channel (EmpathyFilter      *filter,
-					       const gchar        *bus_name,
-					       const gchar        *connection,
-					       const gchar        *channel_type,
-					       const gchar        *channel,
-					       guint               handle_type,
-					       guint               handle,
-					       guint               id,
-					       GError            **error);
-
-#include "empathy-filter-glue.h"
+static void empathy_filter_class_init (EmpathyFilterClass *klass);
+static void empathy_filter_init       (EmpathyFilter      *filter);
+static void filter_iface_init         (EmpSvcFilterClass  *iface);
 
 enum {
 	PROCESS,
@@ -61,7 +51,57 @@
 
 static guint signals[LAST_SIGNAL];
 
-G_DEFINE_TYPE (EmpathyFilter, empathy_filter, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_CODE (EmpathyFilter, empathy_filter, G_TYPE_OBJECT,
+			 G_IMPLEMENT_INTERFACE (EMP_TYPE_SVC_FILTER,
+						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,
+		   DBusGMethodInvocation *context)
+{
+	EmpathyFilter       *filter = EMPATHY_FILTER (self);
+	EmpathyFilterPriv   *priv = GET_PRIV (filter);
+	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);
+
+	g_hash_table_insert (priv->table, chan, GUINT_TO_POINTER (id));
+
+	empathy_debug (DEBUG_DOMAIN, "New channel to be filtred: "
+				     "type=%s handle=%d id=%d",
+				     channel_type, handle, id);
+
+	g_signal_emit (filter, signals[NEW_CHANNEL], 0, chan);
+
+	g_object_unref (conn);
+
+	emp_svc_filter_return_from_filter_channel (context);
+}
+
+static void
+filter_finalize (GObject *object)
+{
+	EmpathyFilterPriv *priv;
+
+	priv = GET_PRIV (object);
+
+	g_hash_table_destroy (priv->table);
+}
 
 static void
 empathy_filter_class_init (EmpathyFilterClass *klass)
@@ -94,6 +134,15 @@
 }
 
 static void
+filter_iface_init (EmpSvcFilterClass *klass)
+{
+#define IMPLEMENT(x) emp_svc_filter_implement_##x \
+    (klass, my_##x)
+  IMPLEMENT (filter_channel);
+#undef IMPLEMENT
+}
+
+static void
 empathy_filter_init (EmpathyFilter *filter)
 {
 	EmpathyFilterPriv *priv;
@@ -105,16 +154,6 @@
 					     NULL);
 }
 
-static void
-filter_finalize (GObject *object)
-{
-	EmpathyFilterPriv *priv;
-
-	priv = GET_PRIV (object);
-
-	g_hash_table_destroy (priv->table);
-}
-
 EmpathyFilter *
 empathy_filter_new (const gchar *bus_name,
 		    const gchar *object_path,
@@ -122,19 +161,12 @@
 		    guint        priority,
 		    guint        flags)
 {
-	static gboolean  initialized = FALSE;
 	MissionControl  *mc;
 	EmpathyFilter   *filter;
 	DBusGProxy      *proxy;
 	guint            result;
 	GError          *error = NULL;
 
-	if (!initialized) {
-		dbus_g_object_type_install_info (EMPATHY_TYPE_FILTER,
-						 &dbus_glib_empathy_filter_object_info);
-		initialized = TRUE;
-	}
-
 	proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
 					   DBUS_SERVICE_DBUS,
 					   DBUS_PATH_DBUS,
@@ -191,46 +223,9 @@
 
 	empathy_debug (DEBUG_DOMAIN, "Processing channel id %d: %s",
 		       id, process ? "Yes" : "No");
-	g_signal_emit (filter, signals[PROCESS], 0, id, process);
-	g_hash_table_remove (priv->table, channel);
-}
-
-static gboolean
-empathy_filter_filter_channel (EmpathyFilter  *filter,
-			       const gchar    *bus_name,
-			       const gchar    *connection,
-			       const gchar    *channel_type,
-			       const gchar    *channel,
-			       guint           handle_type,
-			       guint           handle,
-			       guint           id,
-			       GError        **error)
-{
-	EmpathyFilterPriv   *priv;
-	TpChannel           *chan;
-	TpConnection        *conn;
-	static TpDBusDaemon *daemon = NULL;
 
-	priv = GET_PRIV (filter);
-
-	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);
-
-	g_hash_table_insert (priv->table, chan, GUINT_TO_POINTER (id));
-
-	empathy_debug (DEBUG_DOMAIN, "New channel to be filtred: "
-				     "type=%s handle=%d id=%d",
-				     channel_type, handle, id);
+	emp_svc_filter_emit_process (filter, id, process);
 
-	g_signal_emit (filter, signals[NEW_CHANNEL], 0, chan);
-
-	g_object_unref (conn);
-
-	return TRUE;
+	g_hash_table_remove (priv->table, channel);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]