[gnome-documents/wip/skydrive: 5/9] miner: Populate the database with Skydrive entries



commit c6d3be63c0327bda180fe042afb5c3bd9d813fc5
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed May 23 21:38:16 2012 +0200

    miner: Populate the database with Skydrive entries
    
    Currently the following properties are added:
      + nie:dataSource
      + nie:description
      + nie:contentLastModified
    
    Fixes: https://bugzilla.gnome.org/666535

 src/miner/gd-zpj-miner.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/src/miner/gd-zpj-miner.c b/src/miner/gd-zpj-miner.c
index e36c1e8..e240f36 100644
--- a/src/miner/gd-zpj-miner.c
+++ b/src/miner/gd-zpj-miner.c
@@ -24,6 +24,7 @@
 #include <unistd.h>
 
 #include "gd-zpj-miner.h"
+#include "gd-miner-tracker.h"
 #include "gd-utils.h"
 
 #define MINER_IDENTIFIER "gd:zpj:miner:30058620-777c-47a3-a19c-a6cdf4a315c4"
@@ -158,6 +159,70 @@ account_miner_job_process_entry (AccountMinerJob *job,
                                  ZpjSkydriveEntry *entry,
                                  GError **error)
 {
+  GDateTime *updated_time;
+  gchar *resource = NULL;
+  gchar *date, *datasource_urn, *identifier;
+  const gchar *class = NULL, *id;
+
+  id = zpj_skydrive_entry_get_id (entry);
+
+  identifier = g_strdup_printf ("%swindows-live:skydrive:%s",
+                                ZPJ_IS_SKYDRIVE_FOLDER (entry) ? "gd:collection:" : "",
+                                id);
+
+  /* remove from the list of the previous resources */
+  g_hash_table_remove (job->previous_resources, identifier);
+
+  if (ZPJ_IS_SKYDRIVE_FILE (entry))
+    class = "nfo:Document";
+
+  resource = gd_miner_tracker_sparql_connection_ensure_resource
+    (job->connection,
+     job->cancellable, error,
+     identifier, identifier,
+     "nfo:RemoteDataObject", class, NULL);
+
+  if (*error != NULL)
+    goto out;
+
+  datasource_urn = g_strdup_printf ("gd:goa-account:%s",
+                                    goa_account_get_id (job->account));
+  gd_miner_tracker_sparql_connection_set_triple
+     (job->connection, job->cancellable, error,
+      identifier, resource,
+      "nie:dataSource", datasource_urn);
+
+  g_free (datasource_urn);
+
+  gd_miner_tracker_sparql_connection_insert_or_replace_triple
+    (job->connection,
+     job->cancellable, error,
+     identifier, resource,
+     "nie:description", zpj_skydrive_entry_get_description (entry));
+
+  if (*error != NULL)
+    goto out;
+
+  updated_time = zpj_skydrive_entry_get_updated_time (entry);
+  date = gd_iso8601_from_timestamp (g_date_time_to_unix (updated_time));
+  gd_miner_tracker_sparql_connection_insert_or_replace_triple
+    (job->connection,
+     job->cancellable, error,
+     identifier, resource,
+     "nie:contentLastModified", date);
+  g_free (date);
+
+  if (*error != NULL)
+    goto out;
+
+ out:
+  g_free (resource);
+  g_free (identifier);
+
+  if (*error != NULL)
+    return FALSE;
+
+  return TRUE;
 }
 
 static void



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