summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2021-09-26 09:43:41 +0000
committerMathieu Othacehe <othacehe@gnu.org>2021-10-02 10:54:39 +0000
commit96b755b42a7a3677b964be2f820b87458558c421 (patch)
treee792dcdf1bac053ac213e3530da7fa4958542e53
parent19ded2afe59595d342f9f1f885970fc10529f66b (diff)
downloadguix-96b755b42a7a3677b964be2f820b87458558c421.tar.gz
gnu: gnome-online-miners: Fix build.
* gnu/packages/patches/gnome-online-miners-tracker-3.patch: New file.
* gnu/local.mk (DIST_PATCH_DATA): Add it.
* gnu/packages/gnome.scm (gnome-online-miners)[source]: Use it.
[arguments]: Add a 'fix-configure and a 'autoreconf phase.
[inputs]: Add autoconf, automake and libtool.
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/gnome.scm22
-rw-r--r--gnu/packages/patches/gnome-online-miners-tracker-3.patch1505
3 files changed, 1526 insertions, 2 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 01665ecce8..620ac89548 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1158,6 +1158,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gmp-arm-asm-nothumb.patch		\
   %D%/packages/patches/gmp-faulty-test.patch			\
   %D%/packages/patches/gnash-fix-giflib-version.patch	        \
+  %D%/packages/patches/gnome-online-miners-tracker-3.patch	\
   %D%/packages/patches/gnome-shell-theme.patch			\
   %D%/packages/patches/gnome-shell-disable-test.patch		\
   %D%/packages/patches/gnome-shell-CVE-2020-17489.patch		\
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index d75f478539..0aa9b80aee 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -919,6 +919,7 @@ tomorrow, the rest of the week and for special occasions.")
        ("libdazzle" ,libdazzle)
        ("libgdata" ,libgdata)
        ("libgfbgraph" ,gfbgraph)
+       ("libhandy" ,libhandy)
        ("libjpeg" ,libjpeg-turbo)
        ("libpng" ,libpng)
        ("librest" ,rest)
@@ -1284,13 +1285,30 @@ in the GNOME desktop.")
                                   name "-" version ".tar.xz"))
               (sha256
                (base32
-                "1n2jz9i8a42zwxx5h8j2gdy6q1vyydh4vl00r0al7w8jzdh24p44"))))
+                "1n2jz9i8a42zwxx5h8j2gdy6q1vyydh4vl00r0al7w8jzdh24p44"))
+              (patches
+               (search-patches
+                "gnome-online-miners-tracker-3.patch"))))
     (build-system glib-or-gtk-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-configure
+           (lambda _
+             (substitute* "configure.ac"
+               (("AX_CHECK_ENABLE_DEBUG.*")
+                ""))))
+         (add-after 'fix-configure 'autoreconf
+           (lambda _
+             (invoke "autoreconf" "-vif"))))))
     (native-inputs
-     `(("gettext" ,gettext-minimal)
+     `(("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("gettext" ,gettext-minimal)
        ("glib:bin" ,glib "bin")
        ("gobject-introspection" ,gobject-introspection)
        ("gtk+:bin" ,gtk+ "bin")
+       ("libtool" ,libtool)
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("gnome-online-accounts" ,gnome-online-accounts)
diff --git a/gnu/packages/patches/gnome-online-miners-tracker-3.patch b/gnu/packages/patches/gnome-online-miners-tracker-3.patch
new file mode 100644
index 0000000000..0f89c56695
--- /dev/null
+++ b/gnu/packages/patches/gnome-online-miners-tracker-3.patch
@@ -0,0 +1,1505 @@
+Apply the following merge requests:
+
+https://gitlab.gnome.org/GNOME/gnome-online-miners/-/merge_requests/3
+https://gitlab.gnome.org/GNOME/gnome-online-miners/-/merge_requests/4
+
+to add tracker 3 support and fix a use after free error.
+
+diff --git a/src/gom-miner.c b/src/gom-miner.c
+index 7147b33..4fb4d80 100644
+--- a/src/gom-miner.c
++++ b/src/gom-miner.c
+@@ -221,6 +221,7 @@ gom_miner_check_pending_jobs (GTask *task)
+     return;
+ 
+   g_task_return_boolean (task, TRUE);
++  g_clear_object (&cleanup_job->self);
+   g_slice_free (CleanupJob, cleanup_job);
+ }
+ 
+@@ -461,7 +462,9 @@ miner_job_process_ready_cb (GObject *source,
+   cleanup_job->pending_jobs = g_list_remove (cleanup_job->pending_jobs,
+                                              account_miner_job);
+ 
++  /* This will free the cleanup job data if there are no more pending jobs. */
+   gom_miner_check_pending_jobs (account_miner_job->parent_task);
++
+   gom_account_miner_job_free (account_miner_job);
+ }
+ 
+@@ -520,10 +523,9 @@ cleanup_old_accounts_done (gpointer data)
+       job->old_datasources = NULL;
+     }
+ 
++  /* This will free the task data if there are no more pending jobs */
+   gom_miner_check_pending_jobs (task);
+ 
+-  g_clear_object (&job->self);
+-
+   return FALSE;
+ }
+ 
+@@ -690,6 +692,8 @@ gom_miner_cleanup_old_accounts (GomMiner *self,
+ {
+   CleanupJob *job = g_slice_new0 (CleanupJob);
+ 
++  g_return_if_fail (GOM_IS_MINER (self));
++
+   job->self = g_object_ref (self);
+   job->content_objects = content_objects;
+   job->acc_objects = acc_objects;
+
+diff --git a/src/gom-application.c b/src/gom-application.c
+index fadd388..9e558f5 100644
+--- a/src/gom-application.c
++++ b/src/gom-application.c
+@@ -229,10 +229,16 @@ gom_application_constructed (GObject *object)
+ {
+   GomApplication *self = GOM_APPLICATION (object);
+   const gchar *display_name;
++  GError *error = NULL;
+ 
+   G_OBJECT_CLASS (gom_application_parent_class)->constructed (object);
+ 
+-  self->miner = g_object_new (self->miner_type, NULL);
++  self->miner = g_initable_new (self->miner_type, NULL, &error, NULL);
++
++  if (self->miner == NULL) {
++    g_error (error->message);
++  }
++
+   display_name = gom_miner_get_display_name (self->miner);
+   gom_dbus_set_display_name (self->skeleton, display_name);
+ }
+diff --git a/src/gom-miner.c b/src/gom-miner.c
+index 7147b33..1dd9bb8 100644
+--- a/src/gom-miner.c
++++ b/src/gom-miner.c
+@@ -28,7 +28,11 @@
+ 
+ #include "gom-miner.h"
+ 
+-G_DEFINE_TYPE (GomMiner, gom_miner, G_TYPE_OBJECT)
++static void gom_miner_initable_interface_init (GInitableIface *iface);
++
++G_DEFINE_TYPE_WITH_CODE (GomMiner, gom_miner, G_TYPE_OBJECT,
++                         G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, gom_miner_initable_interface_init))
++
+ 
+ struct _GomMinerPrivate {
+   GoaClient *client;
+@@ -132,20 +136,21 @@ gom_miner_dispose (GObject *object)
+ }
+ 
+ static void
+-gom_miner_init_goa (GomMiner *self)
++gom_miner_init_goa (GomMiner  *self,
++                    GError   **error)
+ {
+   GoaAccount *account;
+   GoaObject *object;
+   const gchar *provider_type;
+   GList *accounts, *l;
+   GomMinerClass *miner_class = GOM_MINER_GET_CLASS (self);
++  GError *inner_error = NULL;
+ 
+-  self->priv->client = goa_client_new_sync (NULL, &self->priv->client_error);
++  self->priv->client = goa_client_new_sync (NULL, &inner_error);
+ 
+-  if (self->priv->client_error != NULL)
++  if (inner_error)
+     {
+-      g_critical ("Unable to create GoaClient: %s - indexing for %s will not work",
+-                  self->priv->client_error->message, miner_class->goa_provider_type);
++      g_propagate_error (error, inner_error);
+       return;
+     }
+ 
+@@ -170,16 +175,34 @@ gom_miner_init_goa (GomMiner *self)
+   g_list_free_full (accounts, g_object_unref);
+ }
+ 
+-static void
+-gom_miner_constructed (GObject *obj)
++static gboolean
++gom_miner_initable_init (GInitable     *initable,
++                         GCancellable  *cancellable,
++                         GError       **error)
+ {
+-  GomMiner *self = GOM_MINER (obj);
++  GError *inner_error = NULL;
++  GomMiner *self;
+ 
+-  G_OBJECT_CLASS (gom_miner_parent_class)->constructed (obj);
++  self = GOM_MINER (initable);
+ 
+-  gom_miner_init_goa (self);
++  self->priv->connection = tracker_sparql_connection_get (cancellable, &inner_error);
++  if (inner_error)
++    {
++      g_propagate_prefixed_error (error, inner_error, "Unable to connect to Tracker store: ");
++      return FALSE;
++    }
++
++  gom_miner_init_goa (self, &inner_error);
++  if (inner_error)
++    {
++      g_propagate_prefixed_error (error, inner_error, "Unable to connect to GNOME Online Accounts: ");
++      return FALSE;
++    }
++
++  return TRUE;
+ }
+ 
++
+ static void
+ gom_miner_init (GomMiner *self)
+ {
+@@ -187,14 +210,12 @@ gom_miner_init (GomMiner *self)
+ 
+   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GOM_TYPE_MINER, GomMinerPrivate);
+   self->priv->display_name = g_strdup ("");
++}
+ 
+-  self->priv->connection = tracker_sparql_connection_get (NULL, &self->priv->connection_error);
+-  if (self->priv->connection_error != NULL)
+-    {
+-      g_critical ("Unable to create TrackerSparqlConnection: %s - indexing for %s will not work",
+-                  self->priv->connection_error->message,
+-                  klass->goa_provider_type);
+-    }
++static void
++gom_miner_initable_interface_init (GInitableIface *iface)
++{
++  iface->init = gom_miner_initable_init;
+ }
+ 
+ static void
+@@ -202,7 +223,6 @@ gom_miner_class_init (GomMinerClass *klass)
+ {
+   GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ 
+-  oclass->constructed = gom_miner_constructed;
+   oclass->dispose = gom_miner_dispose;
+ 
+   cleanup_pool = g_thread_pool_new (cleanup_job, NULL, 1, FALSE, NULL);
+diff --git a/configure.ac b/configure.ac
+index 06cba71..6c61247 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -21,7 +21,7 @@ AC_HEADER_STDC
+ 
+ GDATA_MIN_VERSION=0.15.2
+ GFBGRAPH_MIN_VERSION=0.2.2
+-GLIB_MIN_VERSION=2.35.1
++GLIB_MIN_VERSION=2.56.0
+ GOA_MIN_VERSION=3.13.3
+ GRILO_MIN_VERSION=0.3.0
+ ZAPOJIT_MIN_VERSION=0.0.2
+@@ -36,7 +36,7 @@ PKG_CHECK_MODULES(GIO, [gio-2.0 gio-unix-2.0])
+ PKG_CHECK_MODULES(GOA, [goa-1.0 >= $GOA_MIN_VERSION])
+ AC_DEFINE([GOA_API_IS_SUBJECT_TO_CHANGE], [], [We are aware that GOA's API can change])
+ 
+-PKG_CHECK_MODULES(TRACKER, [tracker-miner-2.0 tracker-sparql-2.0])
++PKG_CHECK_MODULES(TRACKER, [tracker-sparql-3.0])
+ 
+ # Facebook
+ AC_ARG_ENABLE([facebook], [AS_HELP_STRING([--enable-facebook], [Enable Facebook miner])], [], [enable_facebook=yes])
+diff --git a/src/gom-application.c b/src/gom-application.c
+index 9e558f5..b435e26 100644
+--- a/src/gom-application.c
++++ b/src/gom-application.c
+@@ -233,7 +233,9 @@ gom_application_constructed (GObject *object)
+ 
+   G_OBJECT_CLASS (gom_application_parent_class)->constructed (object);
+ 
+-  self->miner = g_initable_new (self->miner_type, NULL, &error, NULL);
++  self->miner = g_initable_new (self->miner_type, NULL, &error,
++                                "bus-name", g_application_get_application_id (G_APPLICATION (self)),
++                                NULL);
+ 
+   if (self->miner == NULL) {
+     g_error (error->message);
+diff --git a/src/gom-miner.c b/src/gom-miner.c
+index 1dd9bb8..ba76ebb 100644
+--- a/src/gom-miner.c
++++ b/src/gom-miner.c
+@@ -33,12 +33,13 @@ static void gom_miner_initable_interface_init (GInitableIface *iface);
+ G_DEFINE_TYPE_WITH_CODE (GomMiner, gom_miner, G_TYPE_OBJECT,
+                          G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, gom_miner_initable_interface_init))
+ 
+-
+ struct _GomMinerPrivate {
+   GoaClient *client;
+   GError *client_error;
+ 
++  gchar *bus_name;
+   TrackerSparqlConnection *connection;
++  TrackerEndpointDBus *endpoint;
+   GError *connection_error;
+ 
+   gchar *display_name;
+@@ -62,6 +63,14 @@ typedef struct {
+   gpointer service;
+ } InsertSharedContentData;
+ 
++typedef enum
++{
++    PROP_BUS_NAME = 1,
++    N_PROPERTIES
++} GomMinerProperty;
++
++static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
++
+ static GThreadPool *cleanup_pool;
+ 
+ static void cleanup_job (gpointer data, gpointer user_data);
+@@ -135,6 +144,58 @@ gom_miner_dispose (GObject *object)
+   G_OBJECT_CLASS (gom_miner_parent_class)->dispose (object);
+ }
+ 
++static void
++gom_miner_init_database (GomMiner      *self,
++                         GCancellable  *cancellable,
++                         GError       **error)
++{
++  TrackerSparqlConnectionFlags flags;
++  g_autoptr (GFile) store_path = NULL;
++  g_autoptr (GDBusConnection) bus = NULL;
++  GError *inner_error = NULL;
++
++  flags = TRACKER_SPARQL_CONNECTION_FLAGS_FTS_ENABLE_STEMMER |
++          TRACKER_SPARQL_CONNECTION_FLAGS_FTS_ENABLE_UNACCENT |
++          TRACKER_SPARQL_CONNECTION_FLAGS_FTS_ENABLE_STOP_WORDS |
++          TRACKER_SPARQL_CONNECTION_FLAGS_FTS_IGNORE_NUMBERS;
++
++  store_path = g_file_new_build_filename (g_get_user_cache_dir (),
++                                          "gnome-online-miners",
++                                          self->priv->bus_name,
++                                          NULL);
++
++  self->priv->connection = tracker_sparql_connection_new (flags,
++                                                          store_path,
++                                                          tracker_sparql_get_ontology_nepomuk (),
++                                                          cancellable,
++                                                          &inner_error);
++
++  if (inner_error)
++    {
++      g_propagate_error (error, inner_error);
++      return;
++    }
++
++  bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &inner_error);
++
++  if (inner_error)
++    {
++      g_propagate_error (error, inner_error);
++      return;
++    }
++
++  self->priv->endpoint = tracker_endpoint_dbus_new (self->priv->connection,
++                                                    bus,
++                                                    NULL, /* object path */
++                                                    cancellable,
++                                                    &inner_error);
++  if (inner_error)
++    {
++      g_propagate_error (error, inner_error);
++      return;
++    }
++}
++
+ static void
+ gom_miner_init_goa (GomMiner  *self,
+                     GError   **error)
+@@ -185,10 +246,10 @@ gom_miner_initable_init (GInitable     *initable,
+ 
+   self = GOM_MINER (initable);
+ 
+-  self->priv->connection = tracker_sparql_connection_get (cancellable, &inner_error);
++  gom_miner_init_database (self, cancellable, &inner_error);
+   if (inner_error)
+     {
+-      g_propagate_prefixed_error (error, inner_error, "Unable to connect to Tracker store: ");
++      g_propagate_prefixed_error (error, inner_error, "Unable to set up Tracker database: ");
+       return FALSE;
+     }
+ 
+@@ -212,6 +273,47 @@ gom_miner_init (GomMiner *self)
+   self->priv->display_name = g_strdup ("");
+ }
+ 
++static void
++gom_miner_set_property (GObject      *object,
++                        guint         property_id,
++                        const GValue *value,
++                        GParamSpec   *pspec)
++{
++  GomMiner *self = GOM_MINER (object);
++
++  switch ((GomMinerProperty) property_id)
++    {
++      case PROP_BUS_NAME:
++        g_free (self->priv->bus_name);
++        self->priv->bus_name = g_value_dup_string (value);
++        break;
++
++      default:
++        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
++        break;
++    }
++}
++
++static void
++gom_miner_get_property (GObject    *object,
++                        guint       property_id,
++                        GValue     *value,
++                        GParamSpec *pspec)
++{
++  GomMiner *self = GOM_MINER (object);
++
++  switch ((GomMinerProperty) property_id)
++    {
++       case PROP_BUS_NAME:
++         g_value_set_string (value, self->priv->bus_name);
++         break;
++
++       default:
++         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
++         break;
++    }
++}
++
+ static void
+ gom_miner_initable_interface_init (GInitableIface *iface)
+ {
+@@ -224,6 +326,19 @@ gom_miner_class_init (GomMinerClass *klass)
+   GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ 
+   oclass->dispose = gom_miner_dispose;
++  oclass->set_property = gom_miner_set_property;
++  oclass->get_property = gom_miner_get_property;
++
++  obj_properties[PROP_BUS_NAME] = g_param_spec_string ("bus-name",
++                                                       "Bus Name",
++                                                       "D-Bus name of the miner",
++                                                       NULL  /* default value */,
++                                                       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
++                                                       G_PARAM_STATIC_STRINGS);
++
++  g_object_class_install_properties (oclass,
++                                     N_PROPERTIES,
++                                     obj_properties);
+ 
+   cleanup_pool = g_thread_pool_new (cleanup_job, NULL, 1, FALSE, NULL);
+ 
+diff --git a/src/gom-miner.h b/src/gom-miner.h
+index 8f83139..5dcfc8d 100644
+--- a/src/gom-miner.h
++++ b/src/gom-miner.h
+@@ -61,6 +61,7 @@ typedef struct _GomMinerPrivate GomMinerPrivate;
+ typedef struct {
+   GomMiner *miner;
+   TrackerSparqlConnection *connection;
++  gchar *bus_name;
+ 
+   GoaAccount *account;
+   GHashTable *services;
+diff --git a/src/gom-tracker.c b/src/gom-tracker.c
+index 68818c4..5666c16 100644
+--- a/src/gom-tracker.c
++++ b/src/gom-tracker.c
+@@ -408,7 +408,7 @@ gom_tracker_utils_ensure_equipment_resource (TrackerSparqlConnection *connection
+   gchar *retval = NULL;
+   gchar *select = NULL;
+ 
+-  g_return_val_if_fail (TRACKER_SPARQL_IS_CONNECTION (connection), NULL);
++  g_return_val_if_fail (TRACKER_IS_SPARQL_CONNECTION (connection), NULL);
+   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+   g_return_val_if_fail (make != NULL || model != NULL, NULL);
+
+diff --git a/src/gom-tracker.c b/src/gom-tracker.c
+index 5666c16..63a4c29 100644
+--- a/src/gom-tracker.c
++++ b/src/gom-tracker.c
+@@ -208,6 +208,6 @@ gom_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection
+   insert = g_string_new (NULL);
+   g_string_append_printf
+     (insert,
+-     "INSERT OR REPLACE %s { <%s> a nie:InformationElement ; %s %s }",
++     "INSERT OR REPLACE %s { <%s> a nie:InformationElement, nie:DataObject ; %s %s }",
+      graph_str, resource, property_name, quoted);
+   g_free (quoted);
+
+diff --git a/src/gom-facebook-miner.c b/src/gom-facebook-miner.c
+index ff42ca5..fc89096 100644
+--- a/src/gom-facebook-miner.c
++++ b/src/gom-facebook-miner.c
+@@ -70,7 +70,7 @@ account_miner_job_process_photo (GomAccountMinerJob *job,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_PICTURES_GRAPH, identifier,
+      "nfo:RemoteDataObject", class, NULL);
+ 
+   if (*error != NULL)
+@@ -239,7 +239,7 @@ account_miner_job_process_album (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:url", album_link);
+ 
+   if (*error != NULL)
+@@ -248,7 +248,7 @@ account_miner_job_process_album (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:description", album_description);
+ 
+   if (*error != NULL)
+@@ -257,7 +257,7 @@ account_miner_job_process_album (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:title", album_name);
+ 
+   if (*error != NULL)
+@@ -274,7 +274,7 @@ account_miner_job_process_album (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nco:creator", contact_resource);
+   g_free (contact_resource);
+ 
+@@ -284,7 +284,7 @@ account_miner_job_process_album (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:contentCreated", album_created_time);
+ 
+   if (*error != NULL)
+
+diff --git a/src/gom-flickr-miner.c b/src/gom-flickr-miner.c
+index 9ac338e..dc7349e 100644
+--- a/src/gom-flickr-miner.c
++++ b/src/gom-flickr-miner.c
+@@ -143,14 +143,14 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_PICTURES_GRAPH, identifier,
+      "nfo:RemoteDataObject", class, NULL);
+ 
+   if (*error != NULL)
+     goto out;
+ 
+   gom_tracker_update_datasource (connection, datasource_urn,
+-                                 resource_exists, identifier, resource,
++                                 resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                  cancellable, error);
+ 
+   if (*error != NULL)
+@@ -166,7 +166,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+       parent_resource_urn = gom_tracker_sparql_connection_ensure_resource
+         (connection, cancellable, error,
+          NULL,
+-         datasource_urn, parent_identifier,
++         TRACKER_PICTURES_GRAPH, parent_identifier,
+          "nfo:RemoteDataObject", "nfo:DataContainer", NULL);
+       g_free (parent_identifier);
+ 
+@@ -176,7 +176,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+       gom_tracker_sparql_connection_insert_or_replace_triple
+         (connection,
+          cancellable, error,
+-         datasource_urn, resource,
++         TRACKER_PICTURES_GRAPH, resource,
+          "nie:isPartOf", parent_resource_urn);
+       g_free (parent_resource_urn);
+ 
+@@ -187,7 +187,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:title", grl_media_get_title (entry->media));
+ 
+   if (*error != NULL)
+@@ -202,7 +202,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   created_time = modification_date = grl_media_get_creation_date (entry->media);
+   new_mtime = g_date_time_to_unix (modification_date);
+   mtime_changed = gom_tracker_update_mtime (connection, new_mtime,
+-                                            resource_exists, identifier, resource,
++                                            resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                             cancellable, error);
+ 
+   if (*error != NULL)
+@@ -221,7 +221,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+       gom_tracker_sparql_connection_insert_or_replace_triple
+         (connection,
+          cancellable, error,
+-         datasource_urn, resource,
++         TRACKER_PICTURES_GRAPH, resource,
+          "nie:contentCreated", date);
+       g_free (date);
+     }
+@@ -233,7 +233,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:url", url);
+ 
+   if (*error != NULL)
+@@ -242,7 +242,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:description", grl_media_get_description (entry->media));
+ 
+   if (*error != NULL)
+@@ -254,7 +254,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+       gom_tracker_sparql_connection_insert_or_replace_triple
+         (connection,
+          cancellable, error,
+-         datasource_urn, resource,
++         TRACKER_PICTURES_GRAPH, resource,
+          "nie:mimeType", mime);
+       g_free (mime);
+ 
+@@ -265,7 +265,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   contact_resource = gom_tracker_utils_ensure_contact_resource
+     (connection,
+      cancellable, error,
+-     datasource_urn, grl_media_get_author (entry->media));
++     TRACKER_PICTURES_GRAPH, grl_media_get_author (entry->media));
+ 
+   if (*error != NULL)
+     goto out;
+@@ -273,7 +273,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nco:creator", contact_resource);
+   g_free (contact_resource);
+ 
+diff --git a/src/gom-gdata-miner.c b/src/gom-gdata-miner.c
+index 7872431..d0deb80 100644
+--- a/src/gom-gdata-miner.c
++++ b/src/gom-gdata-miner.c
+@@ -120,7 +120,7 @@ account_miner_job_process_entry (TrackerSparqlConnection *connection,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_DOCUMENTS_GRAPH, identifier,
+      "nfo:RemoteDataObject", class, NULL);
+ 
+   if (*error != NULL)
+@@ -187,7 +187,7 @@ account_miner_job_process_entry (TrackerSparqlConnection *connection,
+       parent_resource_urn = gom_tracker_sparql_connection_ensure_resource
+         (connection, cancellable, error,
+          NULL,
+-         datasource_urn, parent_resource_id,
++         GOM_GRAPH, parent_resource_id,
+          "nfo:RemoteDataObject", "nfo:DataContainer", NULL);
+       g_free (parent_resource_id);
+ 
+@@ -219,7 +219,7 @@ account_miner_job_process_entry (TrackerSparqlConnection *connection,
+   gom_tracker_sparql_connection_toggle_favorite
+     (connection,
+      cancellable, error,
+-     resource, starred);
++     TRACKER_PICTURES_GRAPH, resource, starred);
+ 
+   if (*error != NULL)
+     goto out;
+@@ -400,14 +400,14 @@ account_miner_job_process_photo (TrackerSparqlConnection *connection,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_PICTURES_GRAPH, identifier,
+      "nfo:RemoteDataObject", "nmm:Photo", NULL);
+ 
+   if (*error != NULL)
+     goto out;
+ 
+   gom_tracker_update_datasource (connection, datasource_urn,
+-                                 resource_exists, identifier, resource,
++                                 resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                  cancellable, error);
+   if (*error != NULL)
+     goto out;
+@@ -566,6 +566,7 @@ account_miner_job_process_photo (TrackerSparqlConnection *connection,
+       equipment_resource = gom_tracker_utils_ensure_equipment_resource (connection,
+                                                                         cancellable,
+                                                                         error,
++                                                                        TRACKER_PICTURES_GRAPH,
+                                                                         make,
+                                                                         model);
+ 
+@@ -665,7 +666,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_PICTURES_GRAPH, identifier,
+      "nfo:RemoteDataObject", "nfo:DataContainer",
+      NULL);
+ 
+@@ -674,7 +675,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+ 
+   gom_tracker_update_datasource
+     (connection, datasource_urn,
+-     resource_exists, identifier, resource,
++     resource_exists, TRACKER_PICTURES_GRAPH, resource,
+      cancellable, error);
+ 
+   if (*error != NULL)
+@@ -685,7 +686,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+    */
+   new_mtime = gdata_entry_get_updated (GDATA_ENTRY (album));
+   mtime_changed = gom_tracker_update_mtime (connection, new_mtime,
+-                                            resource_exists, identifier, resource,
++                                            resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                             cancellable, error);
+ 
+   if (*error != NULL)
+@@ -703,7 +704,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:url", alternate_uri);
+ 
+   if (*error != NULL)
+@@ -713,7 +714,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:description", summary);
+ 
+   if (*error != NULL)
+@@ -723,7 +724,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:title", title);
+ 
+   if (*error != NULL)
+@@ -743,7 +744,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nco:creator", contact_resource);
+   g_free (contact_resource);
+ 
+@@ -755,7 +756,7 @@ account_miner_job_process_album (TrackerSparqlConnection *connection,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:contentCreated", date);
+   g_free (date);
+ 
+@@ -865,7 +866,7 @@ insert_shared_content_photos (TrackerSparqlConnection *connection,
+   if (!gom_tracker_sparql_connection_insert_or_replace_triple (connection,
+                                                                cancellable,
+                                                                &local_error,
+-                                                               datasource_urn,
++                                                               TRACKER_PICTURES_GRAPH,
+                                                                source_urn,
+                                                                "nie:relatedTo",
+                                                                photo_resource_urn))
+@@ -878,7 +879,7 @@ insert_shared_content_photos (TrackerSparqlConnection *connection,
+   if (!gom_tracker_sparql_connection_insert_or_replace_triple (connection,
+                                                                cancellable,
+                                                                &local_error,
+-                                                               datasource_urn,
++                                                               TRACKER_PICTURES_GRAPH,
+                                                                photo_resource_urn,
+                                                                "nie:links",
+                                                                source_urn))
+
+diff --git a/src/gom-media-server-miner.c b/src/gom-media-server-miner.c
+index 490869e..32e08c6 100644
+--- a/src/gom-media-server-miner.c
++++ b/src/gom-media-server-miner.c
+@@ -65,14 +65,14 @@ account_miner_job_process_photo (GomAccountMinerJob *job,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_PICTURES_GRAPH, identifier,
+      "nfo:RemoteDataObject", class, NULL);
+ 
+   if (*error != NULL)
+     goto out;
+ 
+   gom_tracker_update_datasource (connection, datasource_urn,
+-                                 resource_exists, identifier, resource,
++                                 resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                  cancellable, error);
+   if (*error != NULL)
+     goto out;
+@@ -81,7 +81,7 @@ account_miner_job_process_photo (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:url", photo->url);
+ 
+   if (*error != NULL)
+@@ -90,7 +90,7 @@ account_miner_job_process_photo (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:mimeType", photo->mimetype);
+ 
+   if (*error != NULL)
+@@ -99,7 +99,7 @@ account_miner_job_process_photo (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:title", photo->name);
+ 
+   if (*error != NULL)
+
+diff --git a/src/gom-miner.c b/src/gom-miner.c
+index ba76ebb..40b111d 100644
+--- a/src/gom-miner.c
++++ b/src/gom-miner.c
+@@ -375,7 +375,7 @@ gom_miner_ensure_datasource (GomMiner *self,
+                           "  <%s> a nie:DataSource ; nao:identifier \"%s\" . "
+                           "  <%s> a nie:InformationElement ; nie:rootElementOf <%s> ; nie:version \"%d\""
+                           "}",
+-                          datasource_urn,
++                          GOM_GRAPH,
+                           datasource_urn, klass->miner_identifier,
+                           root_element_urn, datasource_urn, klass->version);
+ 
+@@ -400,8 +400,8 @@ gom_account_miner_job_query_existing (GomAccountMinerJob *job,
+ 
+   select = g_string_new (NULL);
+   g_string_append_printf (select,
+-                          "SELECT ?urn nao:identifier(?urn) WHERE { ?urn nie:dataSource <%s> }",
+-                          job->datasource_urn);
++                          "SELECT ?urn ?id WHERE { GRAPH <%s> { ?urn nie:dataSource <%s> ; nao:identifier ?id . } }",
++                          GOM_GRAPH, job->datasource_urn);
+ 
+   cursor = tracker_sparql_connection_query (job->connection,
+                                             select->str,
+@@ -414,9 +414,21 @@ gom_account_miner_job_query_existing (GomAccountMinerJob *job,
+ 
+   while (tracker_sparql_cursor_next (cursor, cancellable, error))
+     {
+-      g_hash_table_insert (job->previous_resources,
+-                           g_strdup (tracker_sparql_cursor_get_string (cursor, 1, NULL)),
+-                           g_strdup (tracker_sparql_cursor_get_string (cursor, 0, NULL)));
++      const gchar *urn, *identifier;
++
++      urn = tracker_sparql_cursor_get_string (cursor, 0, NULL);
++      identifier = tracker_sparql_cursor_get_string (cursor, 1, NULL);
++
++      if (identifier != NULL)
++        {
++          g_hash_table_insert (job->previous_resources,
++                               g_strdup (identifier),
++                               g_strdup (urn));
++        }
++      else
++        {
++          g_warning ("Missing identifier for urn %s", urn);
++        }
+     }
+ 
+   g_object_unref (cursor);
+@@ -488,16 +500,19 @@ gom_account_miner_job (GTask *task,
+   if (error != NULL)
+     goto out;
+ 
++  g_debug ("account miner: Querying existing accounts stored in database");
+   gom_account_miner_job_query_existing (job, &error);
+ 
+   if (error != NULL)
+     goto out;
+ 
++  g_debug ("account miner: Querying remote server");
+   gom_account_miner_job_query (job, &error);
+ 
+   if (error != NULL)
+     goto out;
+ 
++  g_debug ("account miner: Removing stale accounts");
+   gom_account_miner_job_cleanup_previous (job, &error);
+ 
+   if (error != NULL)
+@@ -751,10 +766,15 @@ cleanup_job (gpointer data,
+ 
+   /* find all our datasources in the tracker DB */
+   select = g_string_new (NULL);
+-  g_string_append_printf (select, "SELECT ?datasource nie:version(?root) WHERE { "
+-                          "?datasource a nie:DataSource . "
+-                          "?datasource nao:identifier \"%s\" . "
+-                          "OPTIONAL { ?root nie:rootElementOf ?datasource } }",
++  g_string_append_printf (select,
++                          "SELECT ?datasource nie:version(?root) WHERE { "
++                          "  GRAPH <%s> { "
++                          "    ?datasource a nie:DataSource . "
++                          "    ?datasource nao:identifier \"%s\" . "
++                          "    OPTIONAL { ?root nie:rootElementOf ?datasource } "
++                          "  }"
++                          "}",
++                          GOM_GRAPH,
+                           klass->miner_identifier);
+ 
+   cursor = tracker_sparql_connection_query (self->priv->connection,
+
+diff --git a/src/gom-miner.h b/src/gom-miner.h
+index 5dcfc8d..8f83139 100644
+--- a/src/gom-miner.h
++++ b/src/gom-miner.h
+@@ -61,7 +61,6 @@ typedef struct _GomMinerPrivate GomMinerPrivate;
+ typedef struct {
+   GomMiner *miner;
+   TrackerSparqlConnection *connection;
+-  gchar *bus_name;
+ 
+   GoaAccount *account;
+   GHashTable *services;
+
+diff --git a/src/gom-owncloud-miner.c b/src/gom-owncloud-miner.c
+index 34d303b..623f2e1 100644
+--- a/src/gom-owncloud-miner.c
++++ b/src/gom-owncloud-miner.c
+@@ -100,14 +100,14 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_DOCUMENTS_GRAPH, identifier,
+      "nfo:RemoteDataObject", class, NULL);
+ 
+   if (*error != NULL)
+     goto out;
+ 
+   gom_tracker_update_datasource (connection, datasource_urn,
+-                                 resource_exists, identifier, resource,
++                                 resource_exists, TRACKER_DOCUMENTS_GRAPH, resource,
+                                  cancellable, error);
+ 
+   if (*error != NULL)
+@@ -117,7 +117,7 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+   modification_time = g_date_time_new_from_timeval_local (&tv);
+   new_mtime = g_date_time_to_unix (modification_time);
+   mtime_changed = gom_tracker_update_mtime (connection, new_mtime,
+-                                            resource_exists, identifier, resource,
++                                            resource_exists, TRACKER_DOCUMENTS_GRAPH, resource,
+                                             cancellable, error);
+ 
+   if (*error != NULL)
+@@ -133,7 +133,7 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_DOCUMENTS_GRAPH, resource,
+      "nie:url", uri);
+ 
+   if (*error != NULL)
+@@ -156,7 +156,7 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+           parent_resource_urn = gom_tracker_sparql_connection_ensure_resource
+             (connection, cancellable, error,
+              NULL,
+-             datasource_urn, parent_identifier,
++             GOM_GRAPH, parent_identifier,
+              "nfo:RemoteDataObject", "nfo:DataContainer", NULL);
+           g_checksum_reset (checksum);
+           g_free (parent_identifier);
+@@ -168,7 +168,7 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+           gom_tracker_sparql_connection_insert_or_replace_triple
+             (connection,
+              cancellable, error,
+-             datasource_urn, resource,
++             TRACKER_DOCUMENTS_GRAPH, resource,
+              "nie:isPartOf", parent_resource_urn);
+           g_free (parent_resource_urn);
+ 
+@@ -182,7 +182,7 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+           gom_tracker_sparql_connection_insert_or_replace_triple
+             (connection,
+              cancellable, error,
+-             datasource_urn, resource,
++             TRACKER_DOCUMENTS_GRAPH, resource,
+              "nie:mimeType", mime);
+ 
+           if (*error != NULL)
+@@ -194,7 +194,7 @@ account_miner_job_process_file (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_DOCUMENTS_GRAPH, resource,
+      "nfo:fileName", display_name);
+ 
+   if (*error != NULL)
+@@ -416,6 +416,11 @@ query_owncloud (GomAccountMinerJob *job,
+   mount = g_volume_get_mount (volume);
+   if (mount == NULL)
+     {
++      g_autofree gchar *volume_name;
++
++      volume_name = g_volume_get_name (volume);
++      g_debug ("Mounting Online Account volume %s", volume_name);
++
+       data.error = error;
+ 
+       context = g_main_context_new ();
+@@ -436,6 +441,7 @@ query_owncloud (GomAccountMinerJob *job,
+     }
+ 
+   root = g_mount_get_root (mount);
++  g_debug ("Got volume from gnome-online-accounts: root is %s", g_file_peek_path (root));
+   account_miner_job_traverse_dir (job, connection, previous_resources, datasource_urn, root, TRUE, cancellable, error);
+ 
+   g_object_unref (root);
+
+diff --git a/src/gom-tracker.c b/src/gom-tracker.c
+index 63a4c29..469583e 100644
+--- a/src/gom-tracker.c
++++ b/src/gom-tracker.c
+@@ -26,16 +26,11 @@
+ #include "gom-tracker.h"
+ #include "gom-utils.h"
+ 
+-static gchar *
+-_tracker_utils_format_into_graph (const gchar *graph)
+-{
+-  return (graph != NULL) ? g_strdup_printf ("INTO <%s> ", graph) : g_strdup ("");
+-}
+-
+ static gboolean
+ gom_tracker_sparql_connection_get_string_attribute (TrackerSparqlConnection *connection,
+                                                     GCancellable *cancellable,
+                                                     GError **error,
++                                                    const gchar *graph,
+                                                     const gchar *resource,
+                                                     const gchar *attribute,
+                                                     gchar **value)
+@@ -45,8 +40,8 @@ gom_tracker_sparql_connection_get_string_attribute (TrackerSparqlConnection *con
+   const gchar *string_value = NULL;
+   gboolean res;
+ 
+-  g_string_append_printf (select, "SELECT ?val { <%s> %s ?val }",
+-                          resource, attribute);
++  g_string_append_printf (select, "SELECT ?val { GRAPH <%s> { <%s> %s ?val } }",
++                          graph, resource, attribute);
+   cursor = tracker_sparql_connection_query (connection,
+                                             select->str,
+                                             cancellable, error);
+@@ -86,7 +81,8 @@ gom_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *connecti
+                                                const gchar *class,
+                                                ...)
+ {
+-  GString *select, *insert, *inner;
++  GString *select, *inner;
++  gchar *insert;
+   va_list args;
+   const gchar *arg;
+   TrackerSparqlCursor *cursor;
+@@ -98,6 +94,8 @@ gom_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *connecti
+   gchar *key = NULL, *val = NULL;
+   gboolean exists = FALSE;
+ 
++  g_return_val_if_fail (graph != NULL, NULL);
++
+   /* build the inner query with all the classes */
+   va_start (args, class);
+   inner = g_string_new (NULL);
+@@ -112,7 +110,7 @@ gom_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *connecti
+   /* query if such a resource is already in the DB */
+   select = g_string_new (NULL);
+   g_string_append_printf (select,
+-                          "SELECT ?urn WHERE { ?urn %s }", inner->str);
++                          "SELECT ?urn WHERE { GRAPH <%s> { ?urn %s } }", graph, inner->str);
+ 
+   cursor = tracker_sparql_connection_query (connection,
+                                             select->str,
+@@ -138,19 +136,12 @@ gom_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *connecti
+     }
+ 
+   /* not found, create the resource */
+-  insert = g_string_new (NULL);
+-  graph_str = _tracker_utils_format_into_graph (graph);
+-
+-  g_string_append_printf (insert, "INSERT %s { _:res %s }",
+-                          graph_str, inner->str);
+-  g_free (graph_str);
+-  g_string_free (inner, TRUE);
+-
++  insert = g_strdup_printf ("INSERT INTO <%s> { _:res %s }",
++                            graph, inner->str);
+   insert_res =
+-    tracker_sparql_connection_update_blank (connection, insert->str,
++    tracker_sparql_connection_update_blank (connection, insert,
+                                             G_PRIORITY_DEFAULT, NULL, error);
+-
+-  g_string_free (insert, TRUE);
++  g_free (insert);
+ 
+   if (*error != NULL)
+     goto out;
+@@ -194,10 +185,10 @@ gom_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection
+                                                         const gchar *property_value)
+ {
+   GString *insert;
+-  gchar *graph_str, *quoted;
++  gchar *quoted;
+   gboolean retval = TRUE;
+ 
+-  graph_str = _tracker_utils_format_into_graph (graph);
++  g_return_val_if_fail (graph != NULL, FALSE);
+ 
+   /* the "null" value must not be quoted */
+   if (property_value == NULL)
+@@ -208,8 +199,8 @@ gom_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection
+   insert = g_string_new (NULL);
+   g_string_append_printf
+     (insert,
+-     "INSERT OR REPLACE %s { <%s> a nie:InformationElement, nie:DataObject ; %s %s }",
+-     graph_str, resource, property_name, quoted);
++     "INSERT OR REPLACE INTO <%s> { <%s> a nie:InformationElement, nie:DataObject ; %s %s }",
++     graph, resource, property_name, quoted);
+   g_free (quoted);
+ 
+   g_debug ("Insert or replace triple: query %s", insert->str);
+@@ -223,8 +214,6 @@ gom_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection
+   if (*error != NULL)
+     retval = FALSE;
+ 
+-  g_free (graph_str);
+-
+   return retval;
+ }
+ 
+@@ -271,6 +260,7 @@ gboolean
+ gom_tracker_sparql_connection_toggle_favorite (TrackerSparqlConnection *connection,
+                                                GCancellable *cancellable,
+                                                GError **error,
++                                               const gchar *graph,
+                                                const gchar *resource,
+                                                gboolean favorite)
+ {
+@@ -279,15 +269,15 @@ gom_tracker_sparql_connection_toggle_favorite (TrackerSparqlConnection *connecti
+   gboolean retval = TRUE;
+ 
+   if (favorite)
+-    op_str = "INSERT OR REPLACE";
++    op_str = "INSERT OR REPLACE INTO";
+   else
+-    op_str = "DELETE";
++    op_str = "DELETE FROM";
+ 
+   update = g_string_new (NULL);
+   g_string_append_printf
+     (update,
+-     "%s { <%s> nao:hasTag nao:predefined-tag-favorite }",
+-     op_str, resource);
++     "%s <%s> { <%s> nao:hasTag nao:predefined-tag-favorite }",
++     op_str, graph, resource);
+ 
+   g_debug ("Toggle favorite: query %s", update->str);
+ 
+@@ -321,9 +311,13 @@ gom_tracker_utils_ensure_contact_resource (TrackerSparqlConnection *connection,
+   mail_uri = g_strconcat ("mailto:", email, NULL);
+   select = g_string_new (NULL);
+   g_string_append_printf (select,
+-                          "SELECT ?urn WHERE { ?urn a nco:Contact . "
+-                          "?urn nco:hasEmailAddress ?mail . "
+-                          "FILTER (fn:contains(?mail, \"%s\" )) }", mail_uri);
++                          "SELECT ?urn WHERE { "
++                          "  GRAPH <%s> { "
++                          "    ?urn a nco:Contact . "
++                          "    ?urn nco:hasEmailAddress ?mail . "
++                          "    FILTER (fn:contains(?mail, \"%s\" )) "
++                          "  }"
++                          "}", TRACKER_CONTACTS_GRAPH, mail_uri);
+ 
+   cursor = tracker_sparql_connection_query (connection,
+                                             select->str,
+@@ -351,8 +345,9 @@ gom_tracker_utils_ensure_contact_resource (TrackerSparqlConnection *connection,
+   insert = g_string_new (NULL);
+ 
+   g_string_append_printf (insert,
+-                          "INSERT { <%s> a nco:EmailAddress ; nco:emailAddress \"%s\" . "
++                          "INSERT INTO <%s> { <%s> a nco:EmailAddress ; nco:emailAddress \"%s\" . "
+                           "_:res a nco:Contact ; nco:hasEmailAddress <%s> ; nco:fullname \"%s\" . }",
++                          TRACKER_CONTACTS_GRAPH,
+                           mail_uri, email,
+                           mail_uri, fullname);
+ 
+@@ -397,6 +392,7 @@ gchar *
+ gom_tracker_utils_ensure_equipment_resource (TrackerSparqlConnection *connection,
+                                              GCancellable *cancellable,
+                                              GError **error,
++                                             const gchar *graph,
+                                              const gchar *make,
+                                              const gchar *model)
+ {
+@@ -416,7 +412,7 @@ gom_tracker_utils_ensure_equipment_resource (TrackerSparqlConnection *connection
+   equip_uri = tracker_sparql_escape_uri_printf ("urn:equipment:%s:%s:",
+                                                 make != NULL ? make : "",
+                                                 model != NULL ? model : "");
+-  select = g_strdup_printf ("SELECT <%s> WHERE { }", equip_uri);
++  select = g_strdup_printf ("SELECT <%s> WHERE { GRAPH <%s> { } }", equip_uri, graph);
+ 
+   local_error = NULL;
+   cursor = tracker_sparql_connection_query (connection, select, cancellable, &local_error);
+@@ -449,7 +445,8 @@ gom_tracker_utils_ensure_equipment_resource (TrackerSparqlConnection *connection
+     }
+ 
+   /* not found, create the resource */
+-  insert = g_strdup_printf ("INSERT { <%s> a nfo:Equipment ; nfo:manufacturer \"%s\" ; nfo:model \"%s\" }",
++  insert = g_strdup_printf ("INSERT INTO <%s> { <%s> a nfo:Equipment ; nfo:manufacturer \"%s\" ; nfo:model \"%s\" }",
++                            graph,
+                             equip_uri,
+                             make,
+                             model);
+@@ -480,7 +477,7 @@ void
+ gom_tracker_update_datasource (TrackerSparqlConnection  *connection,
+                                const gchar              *datasource_urn,
+                                gboolean                  resource_exists,
+-                               const gchar              *identifier,
++                               const gchar              *graph,
+                                const gchar              *resource,
+                                GCancellable             *cancellable,
+                                GError                  **error)
+@@ -498,7 +495,7 @@ gom_tracker_update_datasource (TrackerSparqlConnection  *connection,
+ 
+       res = gom_tracker_sparql_connection_get_string_attribute
+         (connection, cancellable, error,
+-         resource, "nie:dataSource", &old_value);
++         graph, resource, "nie:dataSource", &old_value);
+       g_clear_error (error);
+ 
+       if (res)
+@@ -514,7 +511,7 @@ gom_tracker_update_datasource (TrackerSparqlConnection  *connection,
+   if (set_datasource)
+     gom_tracker_sparql_connection_set_triple
+       (connection, cancellable, error,
+-       identifier, resource,
++       graph, resource,
+        "nie:dataSource", datasource_urn);
+ }
+ 
+@@ -522,7 +519,7 @@ gboolean
+ gom_tracker_update_mtime (TrackerSparqlConnection  *connection,
+                           gint64                    new_mtime,
+                           gboolean                  resource_exists,
+-                          const gchar              *identifier,
++                          const gchar              *graph,
+                           const gchar              *resource,
+                           GCancellable             *cancellable,
+                           GError                  **error)
+@@ -536,7 +533,7 @@ gom_tracker_update_mtime (TrackerSparqlConnection  *connection,
+     {
+       res = gom_tracker_sparql_connection_get_string_attribute
+         (connection, cancellable, error,
+-         resource, "nie:contentLastModified", &old_value);
++         graph, resource, "nie:contentLastModified", &old_value);
+       g_clear_error (error);
+ 
+       if (res)
+@@ -552,7 +549,7 @@ gom_tracker_update_mtime (TrackerSparqlConnection  *connection,
+   date = gom_iso8601_from_timestamp (new_mtime);
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection, cancellable, error,
+-     identifier, resource,
++     graph, resource,
+      "nie:contentLastModified", date);
+   g_free (date);
+ 
+diff --git a/src/gom-tracker.h b/src/gom-tracker.h
+index 94a39e8..a5ae6fd 100644
+--- a/src/gom-tracker.h
++++ b/src/gom-tracker.h
+@@ -29,6 +29,14 @@
+ 
+ G_BEGIN_DECLS
+ 
++/* The graph where we store account meta information */
++#define GOM_GRAPH "tracker.api.gnome.org/ontology/v3/gnome-online-miners"
++
++/* Graphs where we store content information */
++#define TRACKER_CONTACTS_GRAPH "http://tracker.api.gnome.org/ontology/v3/tracker#Contacts"
++#define TRACKER_DOCUMENTS_GRAPH "http://tracker.api.gnome.org/ontology/v3/tracker#Documents"
++#define TRACKER_PICTURES_GRAPH "http://tracker.api.gnome.org/ontology/v3/tracker#Pictures"
++
+ gchar *gom_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *connection,
+                                                       GCancellable *cancellable,
+                                                       GError **error,
+@@ -57,6 +65,7 @@ gboolean gom_tracker_sparql_connection_set_triple (TrackerSparqlConnection *conn
+ gboolean gom_tracker_sparql_connection_toggle_favorite (TrackerSparqlConnection *connection,
+                                                         GCancellable *cancellable,
+                                                         GError **error,
++                                                        const gchar *graph,
+                                                         const gchar *resource,
+                                                         gboolean favorite);
+ 
+@@ -69,20 +78,21 @@ gchar* gom_tracker_utils_ensure_contact_resource (TrackerSparqlConnection *conne
+ gchar *gom_tracker_utils_ensure_equipment_resource (TrackerSparqlConnection *connection,
+                                                     GCancellable *cancellable,
+                                                     GError **error,
++                                                    const gchar *graph,
+                                                     const gchar *make,
+                                                     const gchar *model);
+ 
+ void gom_tracker_update_datasource (TrackerSparqlConnection  *connection,
+                                     const gchar              *datasource_urn,
+                                     gboolean                  resource_exists,
+-                                    const gchar              *identifier,
++                                    const gchar              *graph,
+                                     const gchar              *resource,
+                                     GCancellable             *cancellable,
+                                     GError                  **error);
+ gboolean gom_tracker_update_mtime (TrackerSparqlConnection  *connection,
+                                    gint64                    new_mtime,
+                                    gboolean                  resource_exists,
+-                                   const gchar              *identifier,
++                                   const gchar              *graph,
+                                    const gchar              *resource,
+                                    GCancellable             *cancellable,
+                                    GError                  **error);
+diff --git a/src/gom-zpj-miner.c b/src/gom-zpj-miner.c
+index 6dff947..1372de5 100644
+--- a/src/gom-zpj-miner.c
++++ b/src/gom-zpj-miner.c
+@@ -70,14 +70,14 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+     (connection,
+      cancellable, error,
+      &resource_exists,
+-     datasource_urn, identifier,
++     TRACKER_PICTURES_GRAPH, identifier,
+      "nfo:RemoteDataObject", class, NULL);
+ 
+   if (*error != NULL)
+     goto out;
+ 
+   gom_tracker_update_datasource (connection, datasource_urn,
+-                                 resource_exists, identifier, resource,
++                                 resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                  cancellable, error);
+ 
+   if (*error != NULL)
+@@ -86,7 +86,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   updated_time = zpj_skydrive_entry_get_updated_time (entry);
+   new_mtime = g_date_time_to_unix (updated_time);
+   mtime_changed = gom_tracker_update_mtime (connection, new_mtime,
+-                                            resource_exists, identifier, resource,
++                                            resource_exists, TRACKER_PICTURES_GRAPH, resource,
+                                             cancellable, error);
+ 
+   if (*error != NULL)
+@@ -102,7 +102,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:url", identifier);
+ 
+   if (*error != NULL)
+@@ -119,7 +119,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+       parent_resource_urn = gom_tracker_sparql_connection_ensure_resource
+         (connection, cancellable, error,
+          NULL,
+-         datasource_urn, parent_identifier,
++         TRACKER_PICTURES_GRAPH, parent_identifier,
+          "nfo:RemoteDataObject", "nfo:DataContainer", NULL);
+       g_free (parent_identifier);
+ 
+@@ -129,7 +129,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+       gom_tracker_sparql_connection_insert_or_replace_triple
+         (connection,
+          cancellable, error,
+-         datasource_urn, resource,
++         TRACKER_PICTURES_GRAPH, resource,
+          "nie:isPartOf", parent_resource_urn);
+       g_free (parent_resource_urn);
+ 
+@@ -142,7 +142,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+           gom_tracker_sparql_connection_insert_or_replace_triple
+             (connection,
+              cancellable, error,
+-             datasource_urn, resource,
++             TRACKER_PICTURES_GRAPH, resource,
+              "nie:mimeType", mime);
+           g_free (mime);
+ 
+@@ -154,7 +154,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:description", zpj_skydrive_entry_get_description (entry));
+ 
+   if (*error != NULL)
+@@ -163,7 +163,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nfo:fileName", name);
+ 
+   if (*error != NULL)
+@@ -180,7 +180,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nco:creator", contact_resource);
+   g_free (contact_resource);
+ 
+@@ -192,6 +192,6 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
+   gom_tracker_sparql_connection_insert_or_replace_triple
+     (connection,
+      cancellable, error,
+-     datasource_urn, resource,
++     TRACKER_PICTURES_GRAPH, resource,
+      "nie:contentCreated", date);
+   g_free (date);
+
+diff --git a/src/gom-miner.c b/src/gom-miner.c
+index 40b111d..f9e4be0 100644
+--- a/src/gom-miner.c
++++ b/src/gom-miner.c
+@@ -381,7 +381,6 @@ gom_miner_ensure_datasource (GomMiner *self,
+ 
+   tracker_sparql_connection_update (self->priv->connection,
+                                     datasource_insert->str,
+-                                    G_PRIORITY_DEFAULT,
+                                     cancellable,
+                                     error);
+ 
+@@ -468,7 +467,6 @@ gom_account_miner_job_cleanup_previous (GomAccountMinerJob *job,
+ 
+   tracker_sparql_connection_update (job->connection,
+                                     delete->str,
+-                                    G_PRIORITY_DEFAULT,
+                                     cancellable,
+                                     error);
+ 
+@@ -708,7 +706,6 @@ cleanup_job_do_cleanup (CleanupJob *job, GCancellable *cancellable)
+ 
+   tracker_sparql_connection_update (self->priv->connection,
+                                     update->str,
+-                                    G_PRIORITY_DEFAULT,
+                                     cancellable,
+                                     &error);
+   g_string_free (update, TRUE);
+
+diff --git a/src/gom-tracker.c b/src/gom-tracker.c
+index 469583e..716fc14 100644
+--- a/src/gom-tracker.c
++++ b/src/gom-tracker.c
+@@ -138,9 +138,7 @@ gom_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *connecti
+   /* not found, create the resource */
+   insert = g_strdup_printf ("INSERT INTO <%s> { _:res %s }",
+                             graph, inner->str);
+-  insert_res =
+-    tracker_sparql_connection_update_blank (connection, insert,
+-                                            G_PRIORITY_DEFAULT, NULL, error);
++  insert_res = tracker_sparql_connection_update_blank (connection, insert, NULL, error);
+   g_free (insert);
+ 
+   if (*error != NULL)
+@@ -205,9 +203,7 @@ gom_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection
+ 
+   g_debug ("Insert or replace triple: query %s", insert->str);
+ 
+-  tracker_sparql_connection_update (connection, insert->str,
+-                                    G_PRIORITY_DEFAULT, cancellable,
+-                                    error);
++  tracker_sparql_connection_update (connection, insert->str, cancellable, error);
+ 
+   g_string_free (insert, TRUE);
+ 
+@@ -235,9 +231,7 @@ gom_tracker_sparql_connection_set_triple (TrackerSparqlConnection *connection,
+      "DELETE { <%s> %s ?val } WHERE { <%s> %s ?val }", resource,
+      property_name, resource, property_name);
+ 
+-  tracker_sparql_connection_update (connection, delete->str,
+-                                    G_PRIORITY_DEFAULT, cancellable,
+-                                    error);
++  tracker_sparql_connection_update (connection, delete->str, cancellable, error);
+ 
+   g_string_free (delete, TRUE);
+   if (*error != NULL)
+@@ -281,9 +275,7 @@ gom_tracker_sparql_connection_toggle_favorite (TrackerSparqlConnection *connecti
+ 
+   g_debug ("Toggle favorite: query %s", update->str);
+ 
+-  tracker_sparql_connection_update (connection, update->str,
+-                                    G_PRIORITY_DEFAULT, cancellable,
+-                                    error);
++  tracker_sparql_connection_update (connection, update->str, cancellable, error);
+ 
+   g_string_free (update, TRUE);
+ 
+@@ -351,9 +343,7 @@ gom_tracker_utils_ensure_contact_resource (TrackerSparqlConnection *connection,
+                           mail_uri, email,
+                           mail_uri, fullname);
+ 
+-  insert_res =
+-    tracker_sparql_connection_update_blank (connection, insert->str,
+-                                            G_PRIORITY_DEFAULT, cancellable, error);
++  insert_res = tracker_sparql_connection_update_blank (connection, insert->str, cancellable, error);
+ 
+   g_string_free (insert, TRUE);
+ 
+@@ -452,7 +442,7 @@ gom_tracker_utils_ensure_equipment_resource (TrackerSparqlConnection *connection
+                             model);
+ 
+   local_error = NULL;
+-  tracker_sparql_connection_update (connection, insert, G_PRIORITY_DEFAULT, cancellable, &local_error);
++  tracker_sparql_connection_update (connection, insert, cancellable, &local_error);
+   if (local_error != NULL)
+     {
+       g_propagate_error (error, local_error);