[tracker/miner-flickr: 16/24] tracker-miner-flickr: Add progress information



commit 50531496068d7eab02a9801d57ce9b6cddfdbc60
Author: Adrien Bustany <abustany gnome org>
Date:   Wed Mar 24 10:27:48 2010 -0300

    tracker-miner-flickr: Add progress information

 src/miners/flickr/tracker-miner-flickr.vala |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/miners/flickr/tracker-miner-flickr.vala b/src/miners/flickr/tracker-miner-flickr.vala
index 5bdb94d..acf5d5c 100644
--- a/src/miners/flickr/tracker-miner-flickr.vala
+++ b/src/miners/flickr/tracker-miner-flickr.vala
@@ -78,6 +78,8 @@ public class MinerFlickr : Tracker.MinerWeb {
 	construct {
 		set ("name", MINER_NAME);
 		set ("associated", false);
+		set ("status", "Idle");
+		set ("progress", 1.0);
 
 		rest = new Rest.Proxy (FLICKR_REST_URL, false);
 
@@ -119,6 +121,9 @@ public class MinerFlickr : Tracker.MinerWeb {
 		Rest.ProxyCall albums_call;
 		Rest.XmlNode photosets_node;
 
+		set ("status", "Refreshing photo albums");
+		set ("progress", 0.0);
+
 		Idle.add (init_pull.callback);
 		yield;
 
@@ -134,6 +139,9 @@ public class MinerFlickr : Tracker.MinerWeb {
 		} catch (Error call_error) {
 			warning ("Could not get photosets list: %s", call_error.message);
 		}
+
+		set ("status", "Idle");
+		set ("progress", 1.0);
 		message ("Pull finished");
 	}
 
@@ -144,8 +152,11 @@ public class MinerFlickr : Tracker.MinerWeb {
 		string photoset_url;
 		Rest.ProxyCall photos_call;
 		SparqlBuilder builder;
+		uint n_photosets;
+		uint indexed_photosets = 0;
 
 		photoset_node = root_node.find ("photoset");
+		n_photosets = root_node.children.size ();
 
 		while (photoset_node != null) {
 			photoset_url = FLICKR_PHOTOSET_URL.printf (user_id, photoset_node.get_attr ("id"));
@@ -172,6 +183,8 @@ public class MinerFlickr : Tracker.MinerWeb {
 
 			query_queue.append (builder.get_result ());
 
+			set ("status", "Refresing album \"%s\"".printf (title_node.content));
+
 			try {
 				photos_call = rest.new_call ();
 				photos_call.add_params ("method", "flickr.photosets.getPhotos",
@@ -184,6 +197,9 @@ public class MinerFlickr : Tracker.MinerWeb {
 				warning ("Could not list photos for photoset %s: %s", photoset_url, call_error.message);
 			}
 			photoset_node = photoset_node.next;
+
+			indexed_photosets ++;
+			set ("progress", (1.0*indexed_photosets)/n_photosets);
 		}
 	}
 



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