[gnome-documents] all: update for miner changes



commit d48b55bf0a1b9c8c3ec3e09be10d49d8a00b64f1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Sep 15 13:38:38 2011 -0400

    all: update for miner changes

 src/sources.js           |   50 +++++----------------------------------------
 src/trackerController.js |    3 ++
 src/trackerUtils.js      |   40 ------------------------------------
 3 files changed, 9 insertions(+), 84 deletions(-)
---
diff --git a/src/sources.js b/src/sources.js
index f703cd1..e063de1 100644
--- a/src/sources.js
+++ b/src/sources.js
@@ -55,21 +55,10 @@ Source.prototype = {
             this.name = params.name;
         }
 
-        this._initCallback = params.initCallback;
-
         if (this.id == 'all' || this.id == 'local') {
             this.resourceUrn = null;
-            Mainloop.idle_add(Lang.bind(this,
-                function() {
-                    this._initCallback();
-                    return false;
-                }));
         } else {
-            TrackerUtils.resourceUrnFromSourceId(this.id, Lang.bind(this,
-                function(resourceUrn) {
-                    this.resourceUrn = resourceUrn;
-                    this._initCallback();
-                }));
+            this.resourceUrn = 'gd:goa-account:' + this.id;
         }
     },
 
@@ -102,19 +91,14 @@ SourceManager.prototype = {
         this._sources = {};
         this._activeSource = null;
 
-        // two outstanding ops for the local sources
-        this._outstandingOps = 2;
-
         // Translators: this refers to documents
         let source = new Source({ id: 'all',
-                                  name: _("All"),
-                                  initCallback: Lang.bind(this, this._asyncSourceCollector) });
+                                  name: _("All") });
         this._sources[source.id] = source;
 
         // Translators: this refers to local documents
         source = new Source({ id: 'local',
-                              name: _("Local"),
-                              initCallback: Lang.bind(this, this._asyncSourceCollector) });
+                              name: _("Local") });
         this._sources[source.id] = source;
 
         Global.goaClient.connect('account-changed', Lang.bind(this, this._refreshGoaAccounts));
@@ -123,12 +107,8 @@ SourceManager.prototype = {
     },
 
     _refreshGoaAccounts: function() {
-        let haveGoa = false;
-        let foundGoa = false;
-
         for (idx in this._sources) {
             if (this._sources[idx].object) {
-                haveGoa = true;
                 delete this._sources[idx];
             }
         }
@@ -144,29 +124,16 @@ SourceManager.prototype = {
                 if (!object.get_documents())
                     return;
 
-                foundGoa = true;
-
-                this._outstandingOps++;
-                let source = new Source({ object: object,
-                                          initCallback: Lang.bind(this, this._asyncSourceCollector) });
+                let source = new Source({ object: object });
                 this._sources[source.id] = source;
             }));
 
-        if (!foundGoa && haveGoa)
-            this.emit('sources-changed');
-
         let activeSourceId = Global.settings.get_string('active-source');
-        if (this._sources[activeSourceId])
+        if (!this._sources[activeSourceId])
             activeSourceId = 'all';
 
         this.setActiveSourceId(activeSourceId);
-    },
-
-    _asyncSourceCollector: function() {
-        this._outstandingOps--;
-
-        if (this._outstandingOps == 0)
-            this.emit('sources-changed');
+        this.emit('sources-changed');
     },
 
     setActiveSourceId: function(id) {
@@ -175,11 +142,6 @@ SourceManager.prototype = {
         if (!source)
             return;
 
-        // wait for the uninitialized source to return and
-        // emit sources-changed instead
-        if (this.object && !this.resourceUrn)
-            return;
-
         if (this._activeSource == source)
             return;
 
diff --git a/src/trackerController.js b/src/trackerController.js
index 508c5e1..1fc5ee7 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -58,6 +58,9 @@ TrackerController.prototype = {
         this._filterController = Global.filterController;
         this._filterController.connect('filter-changed',
                                        Lang.bind(this, this._onFilterChanged));
+
+        // perform initial query
+        this._refresh();
     },
 
     _refreshMinerNow: function() {
diff --git a/src/trackerUtils.js b/src/trackerUtils.js
index 97353f6..6152e52 100644
--- a/src/trackerUtils.js
+++ b/src/trackerUtils.js
@@ -23,46 +23,6 @@ const GLib = imports.gi.GLib;
 
 const Global = imports.global;
 
-function resourceUrnFromSourceId(sourceId, callback) {
-    let sparql = ('SELECT ?urn WHERE { ?urn a nie:DataSource; nao:identifier \"goa:documents:%s\" }').format(sourceId);
-
-    Global.connection.query_async
-        (sparql, null,
-         function(object, res) {
-             let cursor = null;
-             let urn = '';
-
-             try {
-                 cursor = object.query_finish(res);
-             } catch (e) {
-                 log('Unable to resolve account ID -> resource URN: ' + e.toString());
-
-                 callback(urn);
-                 return;
-             }
-
-             cursor.next_async(null,
-                 function(object, res) {
-                     try {
-                         let valid = cursor.next_finish(res);
-
-                         if (valid)
-                             urn = cursor.get_string(0)[0];
-
-                         cursor.close();
-                         callback(urn);
-                     } catch (e) {
-                         log('Unable to resolve account ID -> resource URN: ' + e.toString());
-
-                         cursor.close();
-                         callback(urn);
-
-                         return;
-                     }
-                 });
-         });
-}
-
 function setFavorite(urn, isFavorite, callback) {
     let sparql = ('%s { <%s> nao:hasTag nao:predefined-tag-favorite }').format((isFavorite ? 'INSERT OR REPLACE' : 'DELETE'), urn);
 



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