[tracker/gdbus-porting-rebased: 58/65] miner-rss: GDBus port of tracker-miner-rss.c



commit a18d1ba616f440fe54e0a22afdd1ba6618897503
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Jan 10 11:37:37 2011 +0100

    miner-rss: GDBus port of tracker-miner-rss.c

 src/libtracker-common/tracker-ontologies.h |    1 +
 src/miners/rss/tracker-miner-rss.c         |   85 ++++++++++------------------
 2 files changed, 31 insertions(+), 55 deletions(-)
---
diff --git a/src/libtracker-common/tracker-ontologies.h b/src/libtracker-common/tracker-ontologies.h
index 295e113..c054f65 100644
--- a/src/libtracker-common/tracker-ontologies.h
+++ b/src/libtracker-common/tracker-ontologies.h
@@ -48,6 +48,7 @@ G_BEGIN_DECLS
 #define TRACKER_SLO_PREFIX      "http://www.tracker-project.org/temp/slo#";
 #define TRACKER_NMM_PREFIX      "http://www.tracker-project.org/temp/nmm#";
 #define TRACKER_MLO_PREFIX      "http://www.tracker-project.org/temp/mlo#";
+#define TRACKER_MFO_PREFIX      "http://www.tracker-project.org/temp/mfo#";
 
 #define TRACKER_DATASOURCE_URN_PREFIX	  \
 	"urn:nepomuk:datasource:"
diff --git a/src/miners/rss/tracker-miner-rss.c b/src/miners/rss/tracker-miner-rss.c
index cba200a..49cb4d4 100644
--- a/src/miners/rss/tracker-miner-rss.c
+++ b/src/miners/rss/tracker-miner-rss.c
@@ -24,7 +24,7 @@
 
 #include <libgrss.h>
 
-#include <libtracker-common/tracker-dbus-glib.h>
+#include <libtracker-common/tracker-ontologies.h>
 
 #include <glib/gi18n.h>
 
@@ -44,6 +44,8 @@ struct _TrackerMinerRSSPrivate {
 
 	FeedsPool *pool;
 	gint now_fetching;
+	GDBusConnection *connection;
+	guint graph_updated_id;
 };
 
 static void         miner_started               (TrackerMiner    *miner);
@@ -93,84 +95,57 @@ tracker_miner_rss_class_init (TrackerMinerRSSClass *klass)
 }
 
 static void
-subjects_added_cb (DBusGProxy *proxy,
-                   gchar     **subjects,
-                   gpointer    user_data)
+graph_updated_cb (GDBusConnection *connection,
+                  const gchar     *sender_name,
+                  const gchar     *object_path,
+                  const gchar     *interface_name,
+                  const gchar     *signal_name,
+                  GVariant        *parameters,
+                  gpointer         user_data)
 {
-	TrackerMinerRSS *miner;
-
-	miner = TRACKER_MINER_RSS (user_data);
-
-	g_message ("Subjects added: %d", subjects ? g_strv_length (subjects) : 0);
-
-	/* TODO Add only the channels added? */
-	retrieve_and_schedule_feeds (miner);
-}
-
-static void
-subjects_removed_cb (DBusGProxy *proxy,
-                     gchar     **subjects,
-                     gpointer    user_data)
-{
-	TrackerMinerRSS *miner;
-
-	miner = TRACKER_MINER_RSS (user_data);
+	g_message ("Subjects added or removed");
 
-	g_message ("Subjects removed: %d", subjects ? g_strv_length (subjects) : 0);
-
-	/* TODO Remove only the channels removed? */
-	retrieve_and_schedule_feeds (miner);
+	retrieve_and_schedule_feeds (user_data);
 }
 
 static void
 tracker_miner_rss_init (TrackerMinerRSS *object)
 {
-	DBusGConnection *connection;
-	DBusGProxy *proxy;
 	GError *error = NULL;
 	TrackerMinerRSSPrivate *priv;
 
 	g_message ("Initializing...");
 
-	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+	priv = TRACKER_MINER_RSS_GET_PRIVATE (object);
+
+	priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
 
-	if (!connection) {
+	if (!priv->connection) {
 		g_critical ("Could not connect to the D-Bus session bus, %s",
 			    error ? error->message : "no error given.");
 		g_error_free (error);
 		return;
 	}
 
-	proxy = dbus_g_proxy_new_for_name (connection,
-	                                   TRACKER_DBUS_SERVICE, /* org.freedesktop.Tracker1 */
-	                                   TRACKER_DBUS_OBJECT_FEED,
-	                                   TRACKER_DBUS_INTERFACE_FEED);
-
-	/* "org.freedesktop.Tracker1", */
-	/*                                   "/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedChannel", */
-	/*                                   "org.freedesktop.Tracker1.Resources.Class"); */
-
-	if (!proxy) {
-		g_message ("Could not create DBusGProxy for interface:'%s'",
-		           TRACKER_DBUS_INTERFACE_FEED);
-		return;
-	}
-
-	priv = TRACKER_MINER_RSS_GET_PRIVATE (object);
-
 	priv->pool = feeds_pool_new ();
 	g_signal_connect (priv->pool, "feed-fetching", G_CALLBACK (change_status), object);
 	g_signal_connect (priv->pool, "feed-ready", G_CALLBACK (feed_fetched), object);
 	priv->now_fetching = 0;
 
-	g_message ("Listening for feed changes on D-Bus interface...");
-	g_message ("  Path:'%s'", TRACKER_DBUS_OBJECT_FEED);
-
-	dbus_g_proxy_add_signal (proxy, "SubjectsAdded", G_TYPE_STRV, G_TYPE_INVALID);
-	dbus_g_proxy_connect_signal (proxy, "SubjectsAdded", G_CALLBACK (subjects_added_cb), object, NULL);
-
-	dbus_g_proxy_add_signal (proxy, "SubjectsRemoved", G_TYPE_STRV, G_TYPE_INVALID);
-	dbus_g_proxy_connect_signal (proxy, "SubjectsRemoved", G_CALLBACK (subjects_removed_cb), object, NULL);
+	g_message ("Listening for GraphUpdated changes on D-Bus interface...");
+	g_message ("  arg0:'%s'", TRACKER_MFO_PREFIX "FeedChannel");
+
+	priv->graph_updated_id =
+		g_dbus_connection_signal_subscribe  (priv->connection,
+		                                     "org.freedesktop.Tracker1",
+		                                     "org.freedesktop.Tracker1.Resources",
+		                                     "GraphUpdated",
+		                                     "/org/freedesktop/Tracker1/Resources",
+		                                     TRACKER_MFO_PREFIX "FeedChannel",
+		                                     G_DBUS_SIGNAL_FLAGS_NONE,
+		                                     graph_updated_cb,
+		                                     object,
+		                                     NULL);
 }
 
 static void



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