[gnome-documents] model: periodically refresh the gdata miner



commit 6f9d4f937f2344372620f0cdfd3f8d4a674ef4b0
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Aug 23 17:54:47 2011 -0400

    model: periodically refresh the gdata miner
    
    This is not perfect yet; see comments in the code.

 TODO                |    1 -
 src/trackerModel.js |   21 ++++++++++++++++++---
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/TODO b/TODO
index cfa98be..c51ab41 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-- sync miner process at startup and periodically
 - implement starred category
 - implement shared category
 - implement device listing
diff --git a/src/trackerModel.js b/src/trackerModel.js
index 930a5e6..30507da 100644
--- a/src/trackerModel.js
+++ b/src/trackerModel.js
@@ -21,6 +21,7 @@
 
 const DBus = imports.dbus;
 const Lang = imports.lang;
+const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 
 const Gio = imports.gi.Gio;
@@ -46,6 +47,7 @@ const ModelColumns = {
 };
 
 const OFFSET_STEP = 50;
+const MINER_REFRESH_TIMEOUT = 60; /* seconds */
 
 const TrackerColumns = {
     URN: 0,
@@ -198,6 +200,14 @@ TrackerModel.prototype = {
 
         // startup a refresh of the gdocs cache
         this._miner = new GDataMiner.GDataMiner();
+        this._refreshMinerNow();
+    },
+
+    _onSettingsChanged: function() {
+        this._refresh();
+    },
+
+    _refreshMinerNow: function() {
         this._miner.RefreshDBRemote(DBus.CALL_FLAG_START, Lang.bind(this,
             function(res, error) {
                 if (error) {
@@ -205,13 +215,18 @@ TrackerModel.prototype = {
                     return;
                 }
 
+                // FIXME: we must have a way to know from the miner if there were
+                // no changes processed, to avoid uselessly refreshing the view.
+                // That requires support for the Changes feed in libgdata, see
+                // https://bugzilla.gnome.org/show_bug.cgi?id=654652
                 this._emitModelUpdatePending();
                 this._refresh();
+
+                Mainloop.timeout_add_seconds(MINER_REFRESH_TIMEOUT,
+                                             Lang.bind(this, this._refreshMinerNow));
             }));
-    },
 
-    _onSettingsChanged: function() {
-        this._refresh();
+        return false;
     },
 
     _addRowFromCursor: function(cursor) {



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