[gnome-documents] gdata-miner: set a drawing mimetype for Google Drawings



commit 17e2efc270069601a3a4301874fb0adede2cb3c9
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Mar 27 16:36:49 2013 -0400

    gdata-miner: set a drawing mimetype for Google Drawings
    
    So that code in Documents can use it to fetch the correct icon for
    those.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689153

 src/miner/gd-gdata-miner.c   |   14 ++++++++++++++
 src/miner/gd-miner-tracker.c |   13 ++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/src/miner/gd-gdata-miner.c b/src/miner/gd-gdata-miner.c
index 73b1a40..508cf54 100644
--- a/src/miner/gd-gdata-miner.c
+++ b/src/miner/gd-gdata-miner.c
@@ -39,6 +39,7 @@ account_miner_job_process_entry (GdAccountMinerJob *job,
   gchar *resource = NULL;
   gchar *date, *resource_url, *identifier;
   const gchar *class = NULL;
+  const gchar *mimetype_override = NULL;
   gboolean mtime_changed, resource_exists;
   gint64 new_mtime;
 
@@ -131,6 +132,19 @@ account_miner_job_process_entry (GdAccountMinerJob *job,
   if (*error != NULL)
     goto out;
 
+  /* fake a drawing mimetype, so Documents can get the correct icon */
+  if (GDATA_IS_DOCUMENTS_DRAWING (doc_entry))
+    mimetype_override = "application/vnd.sun.xml.draw";
+
+  gd_miner_tracker_sparql_connection_insert_or_replace_triple
+    (job->connection,
+     job->cancellable, error,
+     identifier, resource,
+     "nie:mimeType", mimetype_override);
+
+  if (*error != NULL)
+    goto out;
+
   parents = gdata_entry_look_up_links (entry, PARENT_LINK_REL);
   for (l = parents; l != NULL; l = l->next)
     {
diff --git a/src/miner/gd-miner-tracker.c b/src/miner/gd-miner-tracker.c
index 75960ca..7fa4428 100644
--- a/src/miner/gd-miner-tracker.c
+++ b/src/miner/gd-miner-tracker.c
@@ -192,16 +192,23 @@ gd_miner_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnec
                                                              const gchar *property_value)
 {
   GString *insert;
-  gchar *graph_str;
+  gchar *graph_str, *quoted;
   gboolean retval = TRUE;
 
   graph_str = _tracker_utils_format_into_graph (graph);
 
+  /* the "null" value must not be quoted */
+  if (property_value == NULL)
+    quoted = g_strdup ("null");
+  else
+    quoted = g_strdup_printf ("\"%s\"", property_value);
+
   insert = g_string_new (NULL);
   g_string_append_printf
     (insert,
-     "INSERT OR REPLACE %s { <%s> a nie:InformationElement ; %s \"%s\" }",
-     graph_str, resource, property_name, property_value);
+     "INSERT OR REPLACE %s { <%s> a nie:InformationElement ; %s %s }",
+     graph_str, resource, property_name, quoted);
+  g_free (quoted);
 
   g_debug ("Insert or replace triple: query %s", insert->str);
 


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