[tracker] tracker-miner-rss: Added debug information to follow what is going on



commit e8396458a59b8ad88c2e049e9f993abb699ea8f1
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Apr 7 18:06:21 2010 +0100

    tracker-miner-rss: Added debug information to follow what is going on

 src/miners/rss/tracker-miner-rss.c |   86 ++++++++++++++++++++++++++++--------
 1 files changed, 67 insertions(+), 19 deletions(-)
---
diff --git a/src/miners/rss/tracker-miner-rss.c b/src/miners/rss/tracker-miner-rss.c
index bd0f3bd..dec5b81 100644
--- a/src/miners/rss/tracker-miner-rss.c
+++ b/src/miners/rss/tracker-miner-rss.c
@@ -32,6 +32,9 @@
 
 #define TRACKER_MINER_RSS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_MINER_RSS, TrackerMinerRSSPrivate))
 
+#define TRACKER_DBUS_OBJECT_FEED    TRACKER_DBUS_OBJECT "/Resources/Classes/mfo/FeedChannel"
+#define TRACKER_DBUS_INTERFACE_FEED TRACKER_DBUS_INTERFACE_RESOURCES ".Class"
+
 typedef struct _TrackerMinerRSSPrivate TrackerMinerRSSPrivate;
 
 struct _TrackerMinerRSSPrivate {
@@ -96,6 +99,8 @@ subjects_added_cb (DBusGProxy *proxy,
 
 	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);
 }
@@ -109,6 +114,8 @@ subjects_removed_cb (DBusGProxy *proxy,
 
 	miner = TRACKER_MINER_RSS (user_data);
 
+	g_message ("Subjects removed: %d", subjects ? g_strv_length (subjects) : 0);
+
 	/* TODO Remove only the channels removed? */
 	retrieve_and_schedule_feeds (miner);
 }
@@ -116,16 +123,34 @@ subjects_removed_cb (DBusGProxy *proxy,
 static void
 tracker_miner_rss_init (TrackerMinerRSS *object)
 {
-	DBusGProxy *wrap;
+	DBusGConnection *connection;
+	DBusGProxy *proxy;
+	GError *error = NULL;
 	TrackerMinerRSSPrivate *priv;
 
-	wrap = dbus_g_proxy_new_for_name (dbus_g_bus_get (DBUS_BUS_SESSION, NULL),
-	                                  "org.freedesktop.Tracker1",
-	                                  "/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedChannel",
-	                                  "org.freedesktop.Tracker1.Resources.Class");
+	g_message ("Initializing...");
+
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+	if (!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,
+	                                   TRACKER_DBUS_OBJECT_FEED,
+	                                   TRACKER_DBUS_INTERFACE_FEED);
 
-	if (wrap == NULL) {
-		g_warning ("Unable to listen for added and removed channels");
+	/* "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;
 	}
 
@@ -138,11 +163,14 @@ tracker_miner_rss_init (TrackerMinerRSS *object)
 
 	g_object_set (object, "progress", 0.0, "status", _("Initializing"), NULL);
 
-	dbus_g_proxy_add_signal (wrap, "SubjectsAdded", G_TYPE_STRV, G_TYPE_INVALID);
-	dbus_g_proxy_connect_signal (wrap, "SubjectsAdded", G_CALLBACK (subjects_added_cb), object, NULL);
+	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 (wrap, "SubjectsRemoved", G_TYPE_STRV, G_TYPE_INVALID);
-	dbus_g_proxy_connect_signal (wrap, "SubjectsRemoved", G_CALLBACK (subjects_removed_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);
 }
 
 static void
@@ -156,7 +184,7 @@ verify_channel_update (GObject      *source,
 
 	tracker_miner_execute_update_finish (TRACKER_MINER (source), result, &error);
 	if (error != NULL) {
-		g_critical ("Unable to update information about channel: %s", error->message);
+		g_critical ("Could not update channel information, %s", error->message);
 		g_error_free (error);
 	}
 }
@@ -168,6 +196,8 @@ update_updated_interval (TrackerMinerRSS *miner,
 {
 	TrackerSparqlBuilder *sparql;
 
+	g_message ("Updating mfo:updatedTime for channel '%s'", uri);
+
 	/* I hope there will be soon a SPARQL command to just update a
 	 * value instead to delete and re-insert it
 	 */
@@ -208,16 +238,20 @@ change_status (FeedsPool   *pool,
 	TrackerMinerRSS *miner;
 	TrackerMinerRSSPrivate *priv;
 
-	g_message ("Fetching %s", feed_channel_get_source (feed));
-
 	miner = TRACKER_MINER_RSS (user_data);
 	priv = TRACKER_MINER_RSS_GET_PRIVATE (miner);
 	avail = feeds_pool_get_listened_num (priv->pool);
 
 	priv->now_fetching++;
+
 	if (priv->now_fetching > avail)
 		priv->now_fetching = avail;
 
+	g_message ("Fetching channel '%s' (in progress: %d/%d)", 
+	           feed_channel_get_source (feed),
+	           priv->now_fetching,
+	           avail);
+
 	prog = ((gdouble) priv->now_fetching) / ((gdouble) avail);
 	g_object_set (miner, "progress", prog, "status", _("Fetching..."), NULL);
 }
@@ -233,7 +267,7 @@ verify_item_insertion (GObject      *source,
 
 	tracker_miner_execute_update_finish (TRACKER_MINER (source), result, &error);
 	if (error != NULL) {
-		g_critical ("Unable to create new item: %s", error->message);
+		g_critical ("Could not insert feed information, %s", error->message);
 		g_error_free (error);
 	}
 }
@@ -265,29 +299,36 @@ item_verify_reply_cb (GObject      *source_object,
 	                                                &error);
 
 	if (error != NULL) {
-		g_warning ("Unable to verify item existance: %s\n", error->message);
+		g_message ("Could not verify feed existance, %s", error->message);
 		g_error_free (error);
 		return;
 	}
 
 	values = g_ptr_array_index (response, 0);
-	if (g_strcmp0 (values[0], "1") == 0)
+	if (g_strcmp0 (values[0], "1") == 0) {
 		return;
+	}
 
 	item = user_data;
 
 	url = get_message_url (item);
 
+	g_message ("Updating feed information for '%s'", url);
+
 	sparql = tracker_sparql_builder_new_update ();
 
 	has_geopoint = feed_item_get_geo_point (item, &latitude, &longitude);
 	tracker_sparql_builder_insert_open (sparql, url);
 
 	if (has_geopoint) {
+		g_message ("  Geopoint, using longitude:%f, latitude:%f", 
+		           longitude, latitude);
+
 		tracker_sparql_builder_subject (sparql, "_:location");
 		tracker_sparql_builder_predicate (sparql, "a");
 		tracker_sparql_builder_object (sparql, "mlo:GeoLocation");
 		tracker_sparql_builder_predicate (sparql, "mlo:asGeoPoint");
+
 		tracker_sparql_builder_object_blank_open (sparql);
 		tracker_sparql_builder_predicate (sparql, "a");
 		tracker_sparql_builder_object (sparql, "mlo:GeoPoint");
@@ -311,6 +352,8 @@ item_verify_reply_cb (GObject      *source_object,
 
 	tmp_string = feed_item_get_title (item);
 	if (tmp_string != NULL) {
+		g_message ("  Title:'%s'", tmp_string);
+
 		tracker_sparql_builder_predicate (sparql, "nie:title");
 		tracker_sparql_builder_object_unvalidated (sparql, tmp_string);
 	}
@@ -373,6 +416,8 @@ check_if_save (TrackerMinerRSS *miner,
 	feed = feed_item_get_parent (item);
 	communication_channel = g_object_get_data (G_OBJECT (feed), "subject");
 
+	g_debug ("Verifying feed '%s' is stored", url);
+
 	query = g_strdup_printf ("ASK { ?message a mfo:FeedMessage; "
 	                         "nie:url \"%s\"; nmo:communicationChannel <%s> }",
 	                         url,
@@ -441,13 +486,15 @@ feeds_retrieve_cb (GObject      *source_object,
 	                                                &error);
 
 	if (error != NULL) {
-		g_warning ("Unable to retrieve list of feeds: %s\n", error->message);
+		g_message ("Could not retrieve feeds, %s", error->message);
 		g_error_free (error);
 		return;
 	}
 
 	channels = NULL;
 
+	g_message ("Found %d feeds", response->len);
+
 	for (i = 0; i < response->len; i++) {
 		values = g_ptr_array_index (response, i);
 
@@ -479,6 +526,8 @@ retrieve_and_schedule_feeds (TrackerMinerRSS *miner)
 {
 	const gchar *sparql;
 
+	g_message ("Retrieving and scheduling feeds...");
+
 	sparql = "SELECT ?chanUrl ?interval ?chanUrn WHERE "
 	         "{ ?chanUrn a mfo:FeedChannel . "
 	         "?chanUrn mfo:feedSettings ?settings . "
@@ -490,7 +539,6 @@ retrieve_and_schedule_feeds (TrackerMinerRSS *miner)
 	                              NULL,
 	                              feeds_retrieve_cb,
 	                              NULL);
-
 }
 
 static const gchar *



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