After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 640659 - Adding Zeitgeist Searchproviders to GNOME Shell
Adding Zeitgeist Searchproviders to GNOME Shell
Status: RESOLVED WONTFIX
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks: 645326
 
 
Reported: 2011-01-26 17:54 UTC by Seif Lotfy
Modified: 2011-07-24 19:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add zeitgeist.js which is a wrapper around the zeitgeist dbus api (8.26 KB, text/plain)
2011-01-26 17:59 UTC, Seif Lotfy
  Details
Add Asyc Searchproviders (thanks to magcius) by allowing searchproviders to add items at any time into their results Add new interface ZeitgeistAsyncSearchProvider Add new Searchproviders for Pictures, Movies, Music, Documents (24.02 KB, text/plain)
2011-01-26 18:00 UTC, Seif Lotfy
  Details
add "Other" categories and allow launching results (4.46 KB, text/plain)
2011-01-26 18:00 UTC, Seif Lotfy
  Details
clean up patch (9.17 KB, text/plain)
2011-01-26 18:00 UTC, Seif Lotfy
  Details
Add support for asynchronous search providers (7.57 KB, patch)
2011-01-26 19:59 UTC, Seif Lotfy
none Details | Review
Add Zeitgeist JS bindings (8.22 KB, patch)
2011-01-26 19:59 UTC, Seif Lotfy
needs-work Details | Review
Add support for Zeitgeist search providers (11.42 KB, patch)
2011-01-26 19:59 UTC, Seif Lotfy
needs-work Details | Review
Add Zeitgeist JS bindings (8.70 KB, patch)
2011-01-28 17:49 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add Zeitgeist JS bindings (8.71 KB, patch)
2011-01-28 23:16 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
179401: Add support for asynchronous search providers (9.03 KB, patch)
2011-01-28 23:17 UTC, Siegfried Gevatter (RainCT)
needs-work Details | Review
Add support for asynchronous search providers (9.15 KB, patch)
2011-01-29 12:37 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for Zeitgeist search providers (9.15 KB, patch)
2011-01-29 12:38 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add support for asynchronous search providers (7.58 KB, patch)
2011-02-01 22:30 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add Zeitgeist JS bindings (8.74 KB, patch)
2011-02-01 22:30 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add support for Zeitgeist search providers (10.16 KB, patch)
2011-02-01 22:31 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add Zeitgeist JS bindings (9.17 KB, patch)
2011-02-10 13:13 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for Zeitgeist search providers (14.99 KB, patch)
2011-02-10 13:14 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for asynchronous search providers (7.58 KB, patch)
2011-02-10 14:35 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add Zeitgeist JS bindings (9.17 KB, patch)
2011-02-10 14:37 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for asynchronous search providers (7.52 KB, patch)
2011-02-10 14:39 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add Zeitgeist JS bindings (9.17 KB, patch)
2011-02-10 14:42 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add support for Zeitgeist search providers (16.59 KB, patch)
2011-02-10 15:10 UTC, Siegfried Gevatter (RainCT)
reviewed Details | Review
Add Zeitgeist JS bindings (9.33 KB, patch)
2011-02-10 16:16 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for Zeitgeist search providers (16.57 KB, patch)
2011-02-10 16:17 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add Zeitgeist JS bindings (13.29 KB, patch)
2011-02-11 12:54 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for Zeitgeist search providers (16.25 KB, patch)
2011-02-11 12:54 UTC, Siegfried Gevatter (RainCT)
none Details | Review
Add support for asynchronous search providers (7.52 KB, patch)
2011-03-02 21:09 UTC, Federico Mena Quintero
needs-work Details | Review
search: support for asynchronous search providers (9.12 KB, patch)
2011-07-24 10:36 UTC, Philippe Normand
none Details | Review

Description Seif Lotfy 2011-01-26 17:54:16 UTC
This patch has 3 main changes:

1) Add the option of doing asynchronous searching with the Searchproviders by allowing them to add items to the results at any time

2) Add JS wrapper around the Zeitgeist API

§) Add ZeitgeistAsyncSearchProvider Interface and the relevant Searchproviders that inherit from it: Music, Video, Documents, Pictures, Other
Comment 1 Seif Lotfy 2011-01-26 17:59:39 UTC
Created attachment 179387 [details]
Add zeitgeist.js which is a wrapper around the zeitgeist dbus api
Comment 2 Seif Lotfy 2011-01-26 18:00:30 UTC
Created attachment 179388 [details]
Add Asyc Searchproviders (thanks to magcius) by allowing searchproviders to add items at any time into their results Add new interface ZeitgeistAsyncSearchProvider Add new Searchproviders for Pictures, Movies, Music, Documents
Comment 3 Seif Lotfy 2011-01-26 18:00:40 UTC
Created attachment 179389 [details]
add "Other" categories and allow launching results
Comment 4 Seif Lotfy 2011-01-26 18:00:50 UTC
Created attachment 179390 [details]
clean up patch

clean up docInfo
Comment 5 Jasper St. Pierre (not reading bugmail) 2011-01-26 18:12:39 UTC
Review of attachment 179388 [details]:

Please split this patch into two parts:

"Add support for asynchronous search providers"
"Add zeitgeist search providers"

Please merge correctly, and please squash the patches.
I will help you do this on IRC.
Comment 6 Seif Lotfy 2011-01-26 19:59:22 UTC
Created attachment 179401 [details] [review]
Add support for asynchronous search providers
Comment 7 Seif Lotfy 2011-01-26 19:59:26 UTC
Created attachment 179402 [details] [review]
Add Zeitgeist JS bindings
Comment 8 Seif Lotfy 2011-01-26 19:59:30 UTC
Created attachment 179403 [details] [review]
Add support for Zeitgeist search providers
Comment 9 Jasper St. Pierre (not reading bugmail) 2011-01-26 20:18:45 UTC
Review of attachment 179403 [details] [review]:

You need to use semicolons, and have some misaligned lines.

Additionally, see the Style Guide:

http://live.gnome.org/GnomeShell/StyleGuide

::: js/ui/docDisplay.js
@@ +58,3 @@
+ 
+function ZeitgeistAsyncSearchProvider() {
+    this._init(interpretations);

Where does 'interpretations' come from?

@@ +63,3 @@
+ZeitgeistAsyncSearchProvider.prototype = {
+    __proto__: Search.SearchProvider.prototype,
+    _init: function(title ,interpretations) {

Mismatch with constructor above.

style nit: should be (title, interpretations)

@@ +109,3 @@
+        this.tryCancelAsync();
+        var items = [];
+        log("--- Results for " + this._name)

No.

@@ +134,3 @@
+    __proto__: ZeitgeistAsyncSearchProvider.prototype,
+    _init: function() {
+        interpretations = ["http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document",

Ah, this is where "interpretations" comes from.

It's probably unintentional, but the lack of "var" or "let" makes it a global. Please don't do this.

::: js/ui/overview.js
@@ +166,3 @@
         this.viewSelector.addSearchProvider(new AppDisplay.PrefsSearchProvider());
         this.viewSelector.addSearchProvider(new PlaceDisplay.PlaceSearchProvider());
+        //this.viewSelector.addSearchProvider(new DocDisplay.DocSearchProvider());

Don't comment things out. Just remove it.
Comment 10 Jasper St. Pierre (not reading bugmail) 2011-01-26 20:18:47 UTC
Review of attachment 179403 [details] [review]:

You need to use semicolons, and have some misaligned lines.

Additionally, see the Style Guide:

http://live.gnome.org/GnomeShell/StyleGuide

::: js/ui/docDisplay.js
@@ +58,3 @@
+ 
+function ZeitgeistAsyncSearchProvider() {
+    this._init(interpretations);

Where does 'interpretations' come from?

@@ +63,3 @@
+ZeitgeistAsyncSearchProvider.prototype = {
+    __proto__: Search.SearchProvider.prototype,
+    _init: function(title ,interpretations) {

Mismatch with constructor above.

style nit: should be (title, interpretations)

@@ +109,3 @@
+        this.tryCancelAsync();
+        var items = [];
+        log("--- Results for " + this._name)

No.

@@ +134,3 @@
+    __proto__: ZeitgeistAsyncSearchProvider.prototype,
+    _init: function() {
+        interpretations = ["http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document",

Ah, this is where "interpretations" comes from.

It's probably unintentional, but the lack of "var" or "let" makes it a global. Please don't do this.

::: js/ui/overview.js
@@ +166,3 @@
         this.viewSelector.addSearchProvider(new AppDisplay.PrefsSearchProvider());
         this.viewSelector.addSearchProvider(new PlaceDisplay.PlaceSearchProvider());
+        //this.viewSelector.addSearchProvider(new DocDisplay.DocSearchProvider());

Don't comment things out. Just remove it.
Comment 11 Jasper St. Pierre (not reading bugmail) 2011-01-26 20:20:24 UTC
Review of attachment 179402 [details] [review]:

Not sure if there's a better way to do the objectification or simplification of the D-Bus messages, like having an alternate constructor like "Subject.fromSimplified();" and "new Subject().toSimplified();"

::: js/misc/zeitgeist.js
@@ +2,3 @@
+
+
+function objectifyEvents(rawEvents){

style nit: missing space between close parent and brace.

@@ +3,3 @@
+
+function objectifyEvents(rawEvents){
+    var events = [];

Please use "let" instead of "var".

@@ +97,3 @@
+        this.manifestation = manifestation;
+        this.actor = actor;
+        this.paylaod = payload;

'paylaod'?

@@ +225,3 @@
+FTS.prototype = {
+    _init: function() {
+        log("Zeitgeist: Created new FTS module");

No.

@@ +245,3 @@
+DBus.proxifyPrototype(FTS.prototype, ZeitgeistFTSIface);
+
+// Testing

Why is this section here and commented out?
Comment 12 Jasper St. Pierre (not reading bugmail) 2011-01-26 20:22:10 UTC
Review of attachment 179401 [details] [review]:

This looks to be the same as my patch, so I'll tackle any issues with it.
Comment 13 Siegfried Gevatter (RainCT) 2011-01-28 17:49:52 UTC
Created attachment 179532 [details] [review]
Add Zeitgeist JS bindings
Comment 14 Jasper St. Pierre (not reading bugmail) 2011-01-28 22:39:03 UTC
Review of attachment 179532 [details] [review]:

Overall, it's fine, but a couple of missing semicolons and mis-indented things.

::: js/misc/zeitgeist.js
@@ +25,3 @@
+
+const SIG_EVENT = 'asaasay'
+const MAX_TIMESTAMP = 9999999999999

Missing semicolons.

@@ +52,3 @@
+                       rawSubject[4], // mimetype
+                       rawSubject[5], // text
+                       rawSubject[6]) // storage

Missing semicolons.

@@ +59,3 @@
+    rawSubject[0] = subject.uri;
+    rawSubject[1] = subject.interpretation;
+    rawSubject[2] = subject.manifestation

Missing semicolons.

@@ +69,3 @@
+/* Zeitgeist Events */
+
+function Event(interpretation, manifestation, actor, subjects, payload) {

Is there a reason 'id' and 'timestamp' aren't in the constructor? It looks like you use 'new Event' and then set 'id' and 'timestamp' down below?

@@ +109,3 @@
+    rawEvent[2] = event.payload;
+    return rawEvent;
+}

Missing semicolons.

@@ +177,3 @@
+        function handler(results, error) {
+            if (error != null)
+                 log("Error querying Zeitgeist for events: "+error);

Indented by five spaces.

@@ +180,3 @@
+            else
+                callback(results.map(Event.fromPlain));
+        }

Missing semicolons.

@@ +217,3 @@
+        function handler(results, error) {
+            if (error != null)
+                 log("Error searching with Zeitgeist FTS: "+error);

Indented by five spaces.

@@ +220,3 @@
+            else
+                callback(results[0].map(Event.fromPlain));
+        }

Missing semicolons.
Comment 15 Siegfried Gevatter (RainCT) 2011-01-28 23:16:50 UTC
Created attachment 179557 [details] [review]
Add Zeitgeist JS bindings
Comment 16 Siegfried Gevatter (RainCT) 2011-01-28 23:17:05 UTC
Created attachment 179558 [details] [review]
179401: Add support for asynchronous search providers
Comment 17 Jasper St. Pierre (not reading bugmail) 2011-01-29 00:05:23 UTC
Review of attachment 179557 [details] [review]:

Looks fine to me.
Comment 18 Jasper St. Pierre (not reading bugmail) 2011-01-29 00:08:54 UTC
Review of attachment 179558 [details] [review]:

I'm not exactly sure what happened with the attachment name... are you using git-bz?

::: js/misc/docInfo.js
@@ +63,3 @@
+        this.timestamp = event.timestamp;
+        this.name = event.subjects[0].text;
+        this._lowerName = event.subjects[0].text.toLowerCase();

The private member looks a little ugly here, but personal preference.

@@ +68,3 @@
+        this.interpretation = this.subject.interpretation;
+        this.category = "";
+        this._icon = null;

Doesn't look like "category" and "_icon" are used.

::: js/ui/docDisplay.js
@@ +9,3 @@
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+const St = imports.gi.St;

St and Mainloop aren't being used.

@@ +16,2 @@
+// FIXME: The subject cache is never being emptied.
+var ZeitgeistSubjectCache = {};

Use 'let' although 'const' will work here as well.

@@ +59,3 @@
+function ZeitgeistAsyncSearchProvider() {
+    this._init(interpretations);
+}

This should look like:

function ZeitgeistAsyncSearchProvider(title, interpretations) {
    this._init(title, interpretations);
}

Although you never use the constructor itself.

@@ +67,3 @@
+        Search.SearchProvider.prototype._init.call(this, title);
+        this._ZGFTS = new Zeitgeist.FTS();
+        this.templates = []

Missing semicolons.

@@ +111,3 @@
+            uri = GLib.uri_unescape_string(uri, '');
+            if (GLib.file_test(uri, GLib.FileTest.EXISTS)) {
+                if (ZeitgeistSubjectCache[subject.uri] == undefined) {

if (ZeitgeistSubjectCache.hasOwnProperty(subject.uri)) {

@@ +115,3 @@
+                    ZeitgeistSubjectCache[info.uri] = info;
+                }
+                items.push(event.subjects[0].uri);

items.push(subject);

@@ +131,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Documents", interpretations);

Missing semicolons, additionally you probably want to use gettext for "Documents" here.

@@ +144,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Videos", interpretations);

Ditto.

@@ +159,3 @@
+            'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio',
+            'http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Music", interpretations);

Ditto.

@@ +172,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Pictures", interpretations);

Ditto.

@@ +190,3 @@
+            '!http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio',
+            '!http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Other", interpretations);

Semis, gettext.

This is also confusing, because you call the parent's init and then override the template behavior below.

Not sure if it would be better to have a '_createTemplates' function in the parent prototype that you override here.

@@ +194,3 @@
+        // Here we construct an AND-like query instead of OR-like
+        this.templates = []
+        let subjects = []

Watch out for those semicolons.
Comment 19 Jasper St. Pierre (not reading bugmail) 2011-01-29 00:08:55 UTC
Review of attachment 179558 [details] [review]:

I'm not exactly sure what happened with the attachment name... are you using git-bz?

::: js/misc/docInfo.js
@@ +63,3 @@
+        this.timestamp = event.timestamp;
+        this.name = event.subjects[0].text;
+        this._lowerName = event.subjects[0].text.toLowerCase();

The private member looks a little ugly here, but personal preference.

@@ +68,3 @@
+        this.interpretation = this.subject.interpretation;
+        this.category = "";
+        this._icon = null;

Doesn't look like "category" and "_icon" are used.

::: js/ui/docDisplay.js
@@ +9,3 @@
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+const St = imports.gi.St;

St and Mainloop aren't being used.

@@ +16,2 @@
+// FIXME: The subject cache is never being emptied.
+var ZeitgeistSubjectCache = {};

Use 'let' although 'const' will work here as well.

@@ +59,3 @@
+function ZeitgeistAsyncSearchProvider() {
+    this._init(interpretations);
+}

This should look like:

function ZeitgeistAsyncSearchProvider(title, interpretations) {
    this._init(title, interpretations);
}

Although you never use the constructor itself.

@@ +67,3 @@
+        Search.SearchProvider.prototype._init.call(this, title);
+        this._ZGFTS = new Zeitgeist.FTS();
+        this.templates = []

Missing semicolons.

@@ +111,3 @@
+            uri = GLib.uri_unescape_string(uri, '');
+            if (GLib.file_test(uri, GLib.FileTest.EXISTS)) {
+                if (ZeitgeistSubjectCache[subject.uri] == undefined) {

if (ZeitgeistSubjectCache.hasOwnProperty(subject.uri)) {

@@ +115,3 @@
+                    ZeitgeistSubjectCache[info.uri] = info;
+                }
+                items.push(event.subjects[0].uri);

items.push(subject);

@@ +131,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Documents", interpretations);

Missing semicolons, additionally you probably want to use gettext for "Documents" here.

@@ +144,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Videos", interpretations);

Ditto.

@@ +159,3 @@
+            'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio',
+            'http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Music", interpretations);

Ditto.

@@ +172,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Pictures", interpretations);

Ditto.

@@ +190,3 @@
+            '!http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio',
+            '!http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece']
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, "Other", interpretations);

Semis, gettext.

This is also confusing, because you call the parent's init and then override the template behavior below.

Not sure if it would be better to have a '_createTemplates' function in the parent prototype that you override here.

@@ +194,3 @@
+        // Here we construct an AND-like query instead of OR-like
+        this.templates = []
+        let subjects = []

Watch out for those semicolons.
Comment 20 Siegfried Gevatter (RainCT) 2011-01-29 12:37:17 UTC
Created attachment 179584 [details] [review]
Add support for asynchronous search providers

Thank you for your reviews.

> +        this.name = event.subjects[0].text;
> +        this._lowerName = event.subjects[0].text.toLowerCase();
> The private member looks a little ugly here, but personal preference.

It's just like in DocInfo. I think it makes sense to keep them together since they both are about the name, but I can move _lowerName to the end if you prefer.

> +var ZeitgeistSubjectCache = {};
> Use 'let' although 'const' will work here as well.

Changed it to const. Is there any information on when to use which of them?

I've only found http://svn.gnome.org/viewvc/gjs/trunk/doc/Style_Guide.txt?view=markup, which says «in particular we think you need "var" to define module variables»; is a «module» something else than a file? Also, some files are using var at the top (eg. js/ui/extensionSystem).
Comment 21 Siegfried Gevatter (RainCT) 2011-01-29 12:38:07 UTC
Created attachment 179585 [details] [review]
Add support for Zeitgeist search providers

(Argh, replaced the wrong patch.)
Comment 22 Jasper St. Pierre (not reading bugmail) 2011-01-31 03:49:00 UTC
Review of attachment 179557 [details] [review]:

::: js/misc/zeitgeist.js
@@ +197,3 @@
+    ],
+};
+

Just use the name "FullTextSearch" instead of FTS here.

@@ +222,3 @@
+        }
+        this.SearchRemote(query, [0, MAX_TIMESTAMP],
+                          eventTemplates.map(Event.toPlain), 0, 130, 4, handler);

What are the numbers "0, 130, 4"?
Comment 23 Jasper St. Pierre (not reading bugmail) 2011-01-31 04:04:29 UTC
Review of attachment 179585 [details] [review]:

Most of these comments are due to me not knowing about Zeitgeist, and I trust you on Zeitgeist more than me, but I'd like a bit more documentation.

::: js/misc/docInfo.js
@@ +60,3 @@
+    _init : function(event) {
+        this.event = event;
+        this.subject = event.subjects[0];

What happens when the event has more than one subject?

::: js/ui/docDisplay.js
@@ +6,1 @@
 const DocInfo = imports.misc.docInfo;

You remove here "_" but use it down below.

@@ +15,3 @@
+const ZeitgeistSubjectCache = {};
+
+// FIXME: Superseded by Zeitgeist. Can this be deleted?

Delete it if you don't use it or replace it. It's in git if we need it again.

@@ +69,3 @@
+
+    _buildTemplates: function(interpretations) {
+        this.templates = []

Semicolon.

@@ +72,3 @@
+        for (let i = 0; i < interpretations.length; i++) {
+            let subject = new Zeitgeist.Subject('', interpretations[i], '', '', '', '', '');
+            let event = new Zeitgeist.Event('', '', '', [subject], []);

This pattern of filling in half the parameters with blanks seems a bit odd.

Doing something like:

Zeitgeist.Event.templateFromInterpretation(interpretation);

would make this become this.templates = interpretations.map(Zeitgeist.Event.templateFromInterpretation);

But I trust that you know this a bit better than I.

@@ +82,3 @@
+
+    _asyncCancelled: function() {
+        // FIXME: Cancel pending D-Bus calls.

This needs to be filled in so that we don't rack up four or five D-Bus calls on every search.

@@ +197,3 @@
+    _buildTemplates: function(interpretations) {
+        // For this one we need to AND the interpretations instead
+        // of OR'ing them.

Why? The comment doesn't explain.

@@ +205,3 @@
+        }
+        let event = new Zeitgeist.Event('', '', '', subjects, []);
+        this.templates.push(event);

Similarly, something like:

this.templates = [Zeitgeist.Event.fromSubject(interpretations.map(Zeitgeist.Subject.templateFromInterpretation))];
Comment 24 Jasper St. Pierre (not reading bugmail) 2011-01-31 04:05:10 UTC
For the "const" question, the style guide doesn't say... the most recent copy is at http://git.gnome.org/browse/gjs/tree/doc/Style_Guide.txt and I edited the GnomeShell/StyleGuide page to link there.

I'm very sure the var limitation is gone, though that's a question for Colin Walters.

"const" is technically correct because the variable itself is never bound to another object, but it may be confusing because the cache itself is mutable.

One more thing: can you upload the newest "asynchronous" patch, because it's marked as obsolete here on git-bz.
Comment 25 Siegfried Gevatter (RainCT) 2011-02-01 22:29:57 UTC
> What happens when the event has more than one subject?

There isn't currently any data-source doing this. This could be
changed to add them all, but for now I'd just take the first one,
and reconsider this once events with more than one subject exist
(either having it take all subjects or changing the query to
avoid getting such results -eg. if they only happen for some
particular type of event-). Afaik this is what all existing GUIs do.


> This pattern of filling in half the parameters with blanks seems a bit odd.
> Doing something like:
> Zeitgeist.Event.templateFromInterpretation(interpretation);

Could be done (although in any case that'd have to be Event.templateFromSubjectInterpretation), but personally I'd see such a function as pretty arbitrary. Who says we won't be adding a condition other than the subject interpretations?

I agree that the constructors aren't that readable, though. Would you
prefer having the constructor take no arguments and assign the values
directly afterwards (as in "subject.interpretation = 'foo';")?

> This needs to be filled in so that we don't rack up four or five D-Bus calls on
> every search.

Yeah. Is there an example somewhere on how to do this from JavaScript? I
couldn't figure it out.

> +    _buildTemplates: function(interpretations) {
> +        // For this one we need to AND the interpretations instead
> +        // of OR'ing them.
> Why? The comment doesn't explain.

Most queries are like "get all sound AND music" (therefor we want stuff
matching any of the templats), however this one asks for everything not
matched by the queries above, so it's "get everything that *isn't* music
NOR image NOR document..." (that is, it must match ALL templates -which
are negated-).

> + [...] eventTemplates.map(Event.toPlain), 0, 130, 4, handler);
> What are the numbers "0, 130, 4"?

I'm not familiar with FTS, so I'll leave this one for Seif.
Comment 26 Siegfried Gevatter (RainCT) 2011-02-01 22:30:39 UTC
Created attachment 179842 [details] [review]
Add support for asynchronous search providers
Comment 27 Siegfried Gevatter (RainCT) 2011-02-01 22:30:52 UTC
Created attachment 179843 [details] [review]
Add Zeitgeist JS bindings
Comment 28 Siegfried Gevatter (RainCT) 2011-02-01 22:31:05 UTC
Created attachment 179844 [details] [review]
Add support for Zeitgeist search providers
Comment 29 Jasper St. Pierre (not reading bugmail) 2011-02-07 19:07:12 UTC
Review of attachment 179844 [details] [review]:

::: js/misc/docInfo.js
@@ +52,3 @@
 };
 
+

No blank line.

@@ +62,3 @@
+        this.subject = event.subjects[0];
+        this.timestamp = event.timestamp;
+        this.name = event.subjects[0].text;

this.name = this.subject.text;

@@ +94,3 @@
+        }
+        return mtype;
+    }

Comma or no comma?

@@ +99,1 @@
 var docManagerInstance = null;

You removed all usage of DocItemInfo and DocManager in docSearch.js

Remove DocItemInfo and DocManager here too.

::: js/ui/docDisplay.js
@@ +10,3 @@
 
+const Gettext = imports.gettext.domain('gnome-shell');
+const _ = Gettext.gettext;

No.

@@ +42,3 @@
+
+    _asyncCancelled: function() {
+        // FIXME: Cancel pending D-Bus calls.

This needs to be fixed.

@@ +93,3 @@
+    _init: function() {
+        let interpretations = ['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document'];
+        ZeitgeistAsyncSearchProvider.prototype._init.call(this, _("Documents"), interpretations);

Other search section titles are uppercase: use DOCUMENTS, MUSIC.
Comment 30 Jasper St. Pierre (not reading bugmail) 2011-02-07 19:07:23 UTC
Review of attachment 179843 [details] [review]:

Mostly comments relating to style and cleanup.

::: js/misc/zeitgeist.js
@@ +24,3 @@
+const DBus = imports.dbus;
+
+const SIG_EVENT = 'asaasay';

Might make sense to include the "(" and ")" that you seem to be using every time below.

@@ +117,3 @@
+/* Zeitgeist D-Bus Interface */
+
+const ZeitgeistLogIface = {

Drop the "Zeitgeist" prefix. Module namespaces are enough.

@@ +174,3 @@
+    },
+
+    findEvents: function(timeRange, eventTemplates, storageState, numEvents, resultType, callback) {

Drop this class, use DBus.makeProxyClass, and make this a wrapper function: Zeitgeist.findEvents

@@ +189,3 @@
+/* Zeitgeist Full-Text-Search extension D-Bus Interface */
+
+const ZeitgeistFTSIface = {

FullTextSearchIface

or IndexIface (because of org.gnome.zeitgeist.Index)

Drop the "Zeitgeist" prefix. Module namespaces are enough.

@@ +214,3 @@
+     * searches.
+     */
+    search: function(query, eventTemplates, callback) {

Drop this class, use DBus.makeProxyClass, and make this a wrapper function: Zeitgeist.fullTextSearch.

Docstring needs improvement:

/**
 * fullTextSearch:
 * 
 * Asynchronously search Zeitgeist's index for events relating to the query.
 * 
 * @param query The query string, using asterisks for wildcards. Wildcards must
 * be used at the start and/or end of a string to get relevant information.
 * @param eventTemplates Zeitgeist event templates, see
 * http://zeitgeist-project.com/unexisting-doc/event-templates.html for more information
 * @param callback The callback, takes a list containing Zeitgeist.Event objects
 */

@@ +222,3 @@
+        }
+        this.SearchRemote(query, [0, MAX_TIMESTAMP],
+                          eventTemplates.map(Event.toPlain), 0, 130, 4, handler);

As explained on IRC, the magic values are:

 0   - offset into the search result
 130 - maximum number of results, which is 130 due to a Zeitgeist and SQLite bug
 4   - sort by 'most used'

The 130 should definitely have a comment like

  // FIXME: we can only get 130 results due to http://bugs.launchpad.net/zeitgeist/12345678

and should maybe be a constant like

  const MAX_RESULTS = 130;

with the aforementioned comment.

'4' should be handled with a more complete enum, but
http://zeitgeist-project.com/docs/0.6/datamodel.html#resulttype
seem a bit on the crazy side, so something like

const ResultType = {
    MOST_POPULAR_SUBJECTS: 4,
};

should be fine for a stub, adding more as need be.
Comment 31 Siegfried Gevatter (RainCT) 2011-02-10 13:13:55 UTC
Created attachment 180575 [details] [review]
Add Zeitgeist JS bindings
Comment 32 Siegfried Gevatter (RainCT) 2011-02-10 13:14:11 UTC
Created attachment 180576 [details] [review]
Add support for Zeitgeist search providers
Comment 33 Siegfried Gevatter (RainCT) 2011-02-10 14:35:52 UTC
Created attachment 180585 [details] [review]
Add support for asynchronous search providers

Fix two space errors.
Comment 34 Siegfried Gevatter (RainCT) 2011-02-10 14:37:42 UTC
Created attachment 180586 [details] [review]
Add Zeitgeist JS bindings

Fix a couple whitespace mistakes.
Comment 35 Siegfried Gevatter (RainCT) 2011-02-10 14:39:23 UTC
Created attachment 180588 [details] [review]
Add support for asynchronous search providers

(Forgot to regenerate the patch).

By the way, magcius, are you taking care of this one? Because that's what I understood from your last comment on it (so I haven't really looked at the contents of this patch).
Comment 36 Siegfried Gevatter (RainCT) 2011-02-10 14:42:54 UTC
Created attachment 180590 [details] [review]
Add Zeitgeist JS bindings
Comment 37 Siegfried Gevatter (RainCT) 2011-02-10 15:10:41 UTC
Created attachment 180595 [details] [review]
Add support for Zeitgeist search providers

Updated to work apply correctly against HEAD.
Comment 38 Jasper St. Pierre (not reading bugmail) 2011-02-10 15:17:18 UTC
Review of attachment 180588 [details] [review]:

Yep, I'll take care of any problems with this patch.
Comment 39 Jasper St. Pierre (not reading bugmail) 2011-02-10 15:52:57 UTC
Review of attachment 180590 [details] [review]:

You need to add js/misc/zeitgeist.js to Makefile.am

Otherwise, good, and I'm going to ask for some more testing of these patches.

::: js/misc/zeitgeist.js
@@ +28,3 @@
+
+// FIXME: We can only get 130 results due to the 132 argument limit
+// set by Python's SQLite, workaround under development.

Bug link if possible.

@@ +32,3 @@
+
+const ResultType = {
+    MOST_POPULAR_SUBJECTS: 4,

Should have a comment explaining where this comes from

// http://zeitgeist-project.com/docs/0.6/datamodel.html#resulttype
// We only currently use MOST_POPULAR_SUBJECTS

@@ +176,3 @@
+const Log = DBus.makeProxyClass(LogIface);
+
+/* Currently not being used: */

I assume you're going to use it in the overview tabs, so it's best to keep this uncommented.

@@ +216,3 @@
+ *        be used at the start and/or end of a string to get relevant information.
+ * @param eventTemplates Zeitgeist event templates, see
+ *        http://zeitgeist-project.com/unexisting-doc/event-templates.html for more

Needs a real link.

@@ +229,3 @@
+    }
+    _index.SearchRemote(query, [0, MAX_TIMESTAMP],
+                      eventTemplates.map(Event.toPlain),

Align these with "query".
Comment 40 Jasper St. Pierre (not reading bugmail) 2011-02-10 15:56:07 UTC
Review of attachment 180595 [details] [review]:

Looks good to me.

::: js/misc/docInfo.js
@@ +16,2 @@
         this._lowerName = this.name.toLowerCase();
+        this.uri = event.subjects[0].uri;

this.uri = this.subject.uri;

::: js/misc/zeitgeistSearch.js
@@ +1,1 @@
+/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*-

This file goes in js/ui.
Comment 41 Siegfried Gevatter (RainCT) 2011-02-10 16:16:57 UTC
Created attachment 180599 [details] [review]
Add Zeitgeist JS bindings
Comment 42 Siegfried Gevatter (RainCT) 2011-02-10 16:17:27 UTC
Created attachment 180600 [details] [review]
Add support for Zeitgeist search providers
Comment 43 Siegfried Gevatter (RainCT) 2011-02-11 12:54:06 UTC
Created attachment 180650 [details] [review]
Add Zeitgeist JS bindings

Merged some changes by Federico into my patch.
Comment 44 Siegfried Gevatter (RainCT) 2011-02-11 12:54:29 UTC
Created attachment 180651 [details] [review]
Add support for Zeitgeist search providers
Comment 45 Federico Mena Quintero 2011-03-02 21:09:20 UTC
Created attachment 182302 [details] [review]
Add support for asynchronous search providers
Comment 46 Federico Mena Quintero 2011-03-02 21:10:31 UTC
Comment on attachment 180588 [details] [review]
Add support for asynchronous search providers

This new version is against the latest master from today; it handles the little change in updateSearch() to return a [] instead of an undefined value.
Comment 47 Federico Mena Quintero 2011-03-04 03:00:42 UTC
Siegfried's patches are settling down nicely, so I fixed up the last nits and pushed a "zeitgeist" branch to git.gnome.org.

We should take care of merging master periodically into zeitgeist so they stay in sync.  I can take care of this.

I'll start pushing the "Recent Activities" journal tab for the overview into that same branch - right now my commits are still unpolished; I'll push them up as they become clean.
Comment 48 Federico Mena Quintero 2011-03-04 03:19:16 UTC
I guess one remaining problem is that if Zeitgeist's full-text-search extension is not installed, then searching doesn't work at all.  You get an exception about a missing D-Bus method.  In that case, we should probably fall back to searching just by filename.
Comment 49 John Stowers 2011-06-30 04:58:31 UTC
Ping? Even if the Zg stuff is rejected, it would be good to have async support for search providers - can someone please review attachment 182302 [details] [review]
Comment 50 Jasper St. Pierre (not reading bugmail) 2011-06-30 05:26:23 UTC
Review of attachment 182302 [details] [review]:

I wrote the original version of this patch, and it was quite a while ago: I expect it would need at least a bit of effort put towards it to get it to apply properly.

John, do you want to clean this up? Here's some things to start with. Additionally, I'd like to get it to a place where all items could be asynchronous: a new application gets installed as you're staring at the results, a new contact comes online, etc.

::: js/ui/search.js
@@ +145,3 @@
+     * to the current search.
+     */
+    addItems: function( items) {

Remove space in front of " items".

@@ +262,3 @@
 Signals.addSignalMethods(SearchProvider.prototype);
 
+

No blank line.

@@ +398,3 @@
+            return;
+
+        results.push.apply(results, items);

I'm a horrible person -- this relies on modifying the list in-place.

@@ +399,3 @@
+
+        results.push.apply(results, items);
+        this.emit('results-updated', this._previousResults);

I think it might be better to only cause a re-display for one provider. Splitting this into two signals: 'search-updated' and 'search-completed' might be a bit less ugly. The former would have (provider, newItems) as arguments, and the latter would have (results).

@@ +425,3 @@
             }
+        } else {
+            terms = this._previousTerms;

We should probably bail out if this is the case: I doubt we should cancel and re-search with the same items.

@@ +430,3 @@
         let results = [];
         if (isSubSearch) {
+            for (let i = 0; i < this._providers.length; i++) {

Might be worth a comment why we loop through all providers. If I remember correctly, that could happen if results don't come back yet.
Comment 51 Philippe Normand 2011-07-24 10:36:29 UTC
Created attachment 192553 [details] [review]
search: support for asynchronous search providers

Original patch by Jasper St. Pierre and Seif Lofty.
I reworked this a bit to apply on master and did some adaptations
based on Jasper's review.
Comment 52 Philippe Normand 2011-07-24 10:37:28 UTC
(In reply to comment #50)
> Additionally, I'd like to get it to a place where all items could be
> asynchronous: a new application gets installed as you're staring at the
> results, a new contact comes online, etc.
> 

Can this be done in a follow-up patch?
Comment 53 Jasper St. Pierre (not reading bugmail) 2011-07-24 15:21:32 UTC
Given that the Zeitgeist search providers aren't going in the shell and Federico, Seif and such are working on an extension as a replacement, I'm going to close this bug. Can you file a new bug with the async patch?
Comment 54 Philippe Normand 2011-07-24 19:32:10 UTC
See Bug 655220