[gnome-documents] miner: store the alternate view uri in nie:url



commit 3cf45e8059a2765aa418788d9042aee762f10fbc
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Aug 28 16:52:18 2011 -0400

    miner: store the alternate view uri in nie:url
    
    So we can have a 'Open in Google Docs' entry in the open with context
    menu.

 src/documents.js           |   16 ++++++++++------
 src/miner/gd-gdata-miner.c |   20 ++++++++++++++++----
 2 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 538341b..7922b7c 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -39,6 +39,7 @@ function DocCommon(cursor) {
 DocCommon.prototype = {
     _init: function(cursor) {
         this.urn = null;
+        this.uri = null;
         this.title = null;
         this.author = null;
         this.mtime = null;
@@ -86,6 +87,7 @@ DocCommon.prototype = {
     },
 
     _populateFromCursor: function(cursor) {
+        this.uri = cursor.get_string(Query.QueryColumns.URI)[0];
         this.urn = cursor.get_string(Query.QueryColumns.URN)[0];
         this.title = cursor.get_string(Query.QueryColumns.TITLE)[0];
         this.author = cursor.get_string(Query.QueryColumns.AUTHOR)[0];
@@ -99,6 +101,8 @@ DocCommon.prototype = {
         // sanitize
         if (!this.author)
             this.author = '';
+        if (!this.uri)
+            this.uri = '';
 
         this.refreshIcon();
     },
@@ -148,10 +152,10 @@ LocalDocument.prototype = {
     __proto__: DocCommon.prototype,
 
     _init: function(cursor) {
-        // overridden
-        this.uri = cursor.get_string(Query.QueryColumns.URI)[0];
-
         DocCommon.prototype._init.call(this, cursor);
+
+        // overridden
+        this.identifier = cursor.get_string(Query.QueryColumns.URI)[0];
     },
 
     refreshIcon: function() {
@@ -247,10 +251,10 @@ GoogleDocument.prototype = {
     __proto__: DocCommon.prototype,
 
     _init: function(cursor) {
-        // overridden
-        this.uri = cursor.get_string(Query.QueryColumns.IDENTIFIER)[0];
-
         DocCommon.prototype._init.call(this, cursor);
+
+        // overridden
+        this.identifier = cursor.get_string(Query.QueryColumns.IDENTIFIER)[0];
     }
 };
 
diff --git a/src/miner/gd-gdata-miner.c b/src/miner/gd-gdata-miner.c
index dac73b3..2a6f012 100644
--- a/src/miner/gd-gdata-miner.c
+++ b/src/miner/gd-gdata-miner.c
@@ -342,10 +342,8 @@ gd_gdata_miner_process_entry (GdGDataMiner *self,
   TrackerSparqlBuilder *builder;
   gint64 mtime;
 
-  identifier = gdata_entry_get_id (entry);
-  resource_url = g_strdup_printf 
-    ("google:docs:%s", 
-     gdata_documents_entry_get_path (doc_entry));
+  GDataLink *alternate;
+  const gchar *alternate_uri;
 
   if (!GDATA_IS_DOCUMENTS_DOCUMENT (doc_entry))
     {
@@ -354,6 +352,11 @@ gd_gdata_miner_process_entry (GdGDataMiner *self,
       return;
     }
 
+  identifier = gdata_entry_get_id (entry);
+  resource_url = g_strdup_printf 
+    ("google:docs:%s", 
+     gdata_documents_entry_get_path (doc_entry));
+
   if (GDATA_IS_DOCUMENTS_PRESENTATION (doc_entry))
     class = "nfo:Presentation";
   else if (GDATA_IS_DOCUMENTS_SPREADSHEET (doc_entry))
@@ -372,6 +375,15 @@ gd_gdata_miner_process_entry (GdGDataMiner *self,
   if (*error != NULL)
     goto out;
 
+  alternate = gdata_entry_look_up_link (entry, GDATA_LINK_ALTERNATE);
+  alternate_uri = gdata_link_get_uri (alternate);
+
+  _tracker_sparql_connection_insert_or_replace_triple
+    (self->priv->connection, 
+     self->priv->cancellable, error,
+     identifier, resource,
+     "nie:url", alternate_uri);
+
   _tracker_sparql_connection_insert_or_replace_triple
     (self->priv->connection, 
      self->priv->cancellable, error,



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