[grilo-plugins/tracker-notification: 3/4] tracker: avoid parsing items unrelated to grilo's data types



commit 7d1de9a2a49df30f7b7d7c81fb446ab1408fb92e
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Mon Feb 14 10:37:18 2011 +0000

    tracker: avoid parsing items unrelated to grilo's data types
    
    Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>

 src/tracker/grl-tracker-notif.c |   91 +++++++++++++++++++++------------------
 src/tracker/grl-tracker-utils.c |   13 ------
 src/tracker/grl-tracker-utils.h |   15 ++++++
 3 files changed, 64 insertions(+), 55 deletions(-)
---
diff --git a/src/tracker/grl-tracker-notif.c b/src/tracker/grl-tracker-notif.c
index 7f509f2..52f061d 100644
--- a/src/tracker/grl-tracker-notif.c
+++ b/src/tracker/grl-tracker-notif.c
@@ -263,8 +263,7 @@ tracker_evt_update_orphans_cb (GObject              *object,
     GRL_WARNING ("Could not execute sparql query: %s", tracker_error->message);
 
     g_error_free (tracker_error);
-    tracker_evt_update_free (evt); /* TODO: change order with
-                                      sources/items parsing */
+    tracker_evt_postupdate_sources (evt);
     return;
   }
 
@@ -550,55 +549,63 @@ tracker_dbus_signal_cb (GDBusConnection *connection,
              (unsigned long) g_variant_iter_n_children (iter2),
 	     evt);
 
-  /* Process deleted items */
-  while (g_variant_iter_loop (iter1, "(iiii)", &graph,
-                              &subject, &predicate, &object)) {
-    gpointer psubject = GSIZE_TO_POINTER (subject);
-    GrlTrackerSource *source =
-      grl_tracker_item_cache_get_source (grl_tracker_item_cache, subject);
+  /* Avoid processing item from uninteresting classes */
+  if (g_str_has_suffix (class_name, RDF_TYPE_MUSIC) ||
+      g_str_has_suffix (class_name, RDF_TYPE_AUDIO) ||
+      g_str_has_suffix (class_name, RDF_TYPE_VIDEO) ||
+      g_str_has_suffix (class_name, RDF_TYPE_IMAGE)) {
 
-    /* GRL_DEBUG ("\tdelete=> subject=%i", subject); */
+    /* Process deleted items */
+    while (g_variant_iter_loop (iter1, "(iiii)", &graph,
+                                &subject, &predicate, &object)) {
+      gpointer psubject = GSIZE_TO_POINTER (subject);
+      GrlTrackerSource *source =
+        grl_tracker_item_cache_get_source (grl_tracker_item_cache, subject);
 
-    if (source) {
-      g_hash_table_insert (evt->deleted_items, psubject, source);
-    } else {
-      g_hash_table_insert (evt->orphan_items, psubject,
-                           GSIZE_TO_POINTER (GRL_CONTENT_REMOVED));
-    }
-  }
-  g_variant_iter_free (iter1);
+      /* GRL_DEBUG ("\tdelete=> subject=%i", subject); */
 
-  /* Process inserted items */
-  while (g_variant_iter_loop (iter2, "(iiii)", &graph,
-                              &subject, &predicate, &object)) {
-    gpointer psubject = GSIZE_TO_POINTER (subject);
-    GrlTrackerSource *source =
-      grl_tracker_item_cache_get_source (grl_tracker_item_cache, subject);
-
-    /* GRL_DEBUG ("\tinsert=> subject=%i", subject); */
-
-    if (source) {
-      /* Removed & inserted items are probably just renamed items... */
-      if (g_hash_table_lookup (evt->deleted_items, psubject)) {
-        g_hash_table_remove (evt->deleted_items, psubject);
-        g_hash_table_insert (evt->updated_items, psubject, source);
-      } else if (!g_hash_table_lookup (evt->updated_items, psubject)) {
-        g_hash_table_insert (evt->inserted_items, psubject, source);
+      if (source) {
+        g_hash_table_insert (evt->deleted_items, psubject, source);
+      } else {
+        g_hash_table_insert (evt->orphan_items, psubject,
+                             GSIZE_TO_POINTER (GRL_CONTENT_REMOVED));
       }
-    } else {
-      gpointer state;
+    }
 
-      if (g_hash_table_lookup_extended (evt->orphan_items, psubject,
-                                        NULL, &state) &&
-	  (GPOINTER_TO_INT (state) == GRL_CONTENT_REMOVED)) {
-        g_hash_table_insert (evt->orphan_items, psubject,
-                             GSIZE_TO_POINTER (GRL_CONTENT_CHANGED));
+    /* Process inserted items */
+    while (g_variant_iter_loop (iter2, "(iiii)", &graph,
+                              &subject, &predicate, &object)) {
+      gpointer psubject = GSIZE_TO_POINTER (subject);
+      GrlTrackerSource *source =
+        grl_tracker_item_cache_get_source (grl_tracker_item_cache, subject);
+
+      /* GRL_DEBUG ("\tinsert=> subject=%i", subject); */
+
+      if (source) {
+        /* Removed & inserted items are probably just renamed items... */
+        if (g_hash_table_lookup (evt->deleted_items, psubject)) {
+          g_hash_table_remove (evt->deleted_items, psubject);
+          g_hash_table_insert (evt->updated_items, psubject, source);
+        } else if (!g_hash_table_lookup (evt->updated_items, psubject)) {
+          g_hash_table_insert (evt->inserted_items, psubject, source);
+        }
       } else {
-        g_hash_table_insert (evt->orphan_items, psubject,
-                             GSIZE_TO_POINTER (GRL_CONTENT_ADDED));
+        gpointer state;
+
+        if (g_hash_table_lookup_extended (evt->orphan_items, psubject,
+                                          NULL, &state) &&
+            (GPOINTER_TO_INT (state) == GRL_CONTENT_REMOVED)) {
+          g_hash_table_insert (evt->orphan_items, psubject,
+                               GSIZE_TO_POINTER (GRL_CONTENT_CHANGED));
+        } else {
+          g_hash_table_insert (evt->orphan_items, psubject,
+                               GSIZE_TO_POINTER (GRL_CONTENT_ADDED));
+        }
       }
     }
   }
+
+  g_variant_iter_free (iter1);
   g_variant_iter_free (iter2);
 
   GRL_DEBUG ("\tinserted=%i deleted=%i updated=%i orphan=%i",
diff --git a/src/tracker/grl-tracker-utils.c b/src/tracker/grl-tracker-utils.c
index 1c1d741..01fcf98 100644
--- a/src/tracker/grl-tracker-utils.c
+++ b/src/tracker/grl-tracker-utils.c
@@ -25,19 +25,6 @@
 #include "grl-tracker-utils.h"
 #include "grl-tracker-priv.h"
 
-/* ------- Definitions ------- */
-
-#define RDF_TYPE_ALBUM  "nmm#MusicAlbum"
-#define RDF_TYPE_ARTIST "nmm#Artist"
-#define RDF_TYPE_AUDIO  "nfo#Audio"
-#define RDF_TYPE_MUSIC  "nmm#MusicPiece"
-#define RDF_TYPE_IMAGE  "nmm#Photo"
-#define RDF_TYPE_VIDEO  "nmm#Video"
-#define RDF_TYPE_BOX    "grilo#Box"
-
-#define RDF_TYPE_VOLUME "tracker#Volume"
-#define RDF_TYPE_UPNP   "upnp#ContentDirectory"
-
 /**/
 
 static GHashTable *grl_to_sparql_mapping = NULL;
diff --git a/src/tracker/grl-tracker-utils.h b/src/tracker/grl-tracker-utils.h
index b73fca0..9522381 100644
--- a/src/tracker/grl-tracker-utils.h
+++ b/src/tracker/grl-tracker-utils.h
@@ -27,6 +27,21 @@
 
 #include "grl-tracker.h"
 
+/* ------- Definitions ------- */
+
+#define RDF_TYPE_ALBUM  "nmm#MusicAlbum"
+#define RDF_TYPE_ARTIST "nmm#Artist"
+#define RDF_TYPE_AUDIO  "nfo#Audio"
+#define RDF_TYPE_MUSIC  "nmm#MusicPiece"
+#define RDF_TYPE_IMAGE  "nmm#Photo"
+#define RDF_TYPE_VIDEO  "nmm#Video"
+#define RDF_TYPE_BOX    "grilo#Box"
+
+#define RDF_TYPE_VOLUME "tracker#Volume"
+#define RDF_TYPE_UPNP   "upnp#ContentDirectory"
+
+/**/
+
 typedef struct {
   GrlKeyID     grl_key;
   const gchar *sparql_key_name;



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