[gnome-documents/wip/skydrive: 5/24] miner: populate the database with Skydrive entries
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/skydrive: 5/24] miner: populate the database with Skydrive entries
- Date: Wed, 30 May 2012 21:57:15 +0000 (UTC)
commit dba58f54ff3a0cbaa9107354d7b2e94e2cf3acc9
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 | 67 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/src/miner/gd-zpj-miner.c b/src/miner/gd-zpj-miner.c
index e36c1e8..1721fe8 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,72 @@ 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";
+ else if (ZPJ_IS_SKYDRIVE_FOLDER (entry))
+ class = "nfo:DataContainer";
+
+ 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]