[grilo-plugins/tracker-notification: 10/17] tracker: avoid relaying on UPnP ontology



commit c4ac76f768bb4c65cc523e702580896fdb36c119
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Mon Feb 21 10:35:47 2011 +0000

    tracker: avoid relaying on UPnP ontology
    
    As we don't know whether or not the UPnP ontology is installed (unless
    we check the rdf classes), we can't refer to UPnP classes or
    properties, otherwise we will generate invalid SparQL requests.
    
    Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>

 src/media/tracker/grl-tracker-notif.c |   23 ++++++++++-------------
 src/media/tracker/grl-tracker-notif.h |   18 ++++++++++++++----
 src/media/tracker/grl-tracker.c       |   15 +++++++--------
 3 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/src/media/tracker/grl-tracker-notif.c b/src/media/tracker/grl-tracker-notif.c
index b7eecd8..f14d0bc 100644
--- a/src/media/tracker/grl-tracker-notif.c
+++ b/src/media/tracker/grl-tracker-notif.c
@@ -428,7 +428,7 @@ tracker_evt_preupdate_sources_item_cb (GObject              *object,
                                        tracker_evt_update_t *evt)
 {
   const gchar *type, *datasource, *uri, *datasource_name;
-  gboolean volume_mounted, upnp_available, source_available;
+  gboolean source_available;
   GrlTrackerSource *source;
   GError *error = NULL;
 
@@ -454,16 +454,12 @@ tracker_evt_preupdate_sources_item_cb (GObject              *object,
   datasource = tracker_sparql_cursor_get_string (evt->cursor, 1, NULL);
   datasource_name = tracker_sparql_cursor_get_string (evt->cursor, 2, NULL);
   uri = tracker_sparql_cursor_get_string (evt->cursor, 3, NULL);
-  volume_mounted = tracker_sparql_cursor_get_boolean (evt->cursor, 4);
-  upnp_available = tracker_sparql_cursor_get_boolean (evt->cursor, 5);
-
-  source_available = volume_mounted | upnp_available;
+  source_available = tracker_sparql_cursor_get_boolean (evt->cursor, 4);
 
   source = grl_tracker_source_find (datasource);
 
-  GRL_DEBUG ("\tdatasource=%s uri=%s volume/mounted=%i "
-             "upnp/available=%i source=%p",
-             datasource, uri, volume_mounted, upnp_available, source);
+  GRL_DEBUG ("\tdatasource=%s uri=%s available=%i source=%p",
+             datasource, uri, source_available, source);
 
   if (source_available) {
     if (source == NULL) {
@@ -536,8 +532,6 @@ tracker_dbus_signal_cb (GDBusConnection *connection,
   GVariantIter *iter1, *iter2;
   tracker_evt_update_t *evt = tracker_evt_update_new ();
 
-  GRL_DEBUG ("%s: evt=%p", __FUNCTION__, evt);
-
   g_variant_get (parameters, "(&sa(iiii)a(iiii))", &class_name, &iter1, &iter2);
 
   GRL_DEBUG ("\tTracker update event for class=%s ins=%lu del=%lu evt=%p",
@@ -562,7 +556,8 @@ tracker_dbus_signal_cb (GDBusConnection *connection,
       /* GRL_DEBUG ("\tdelete=> subject=%i", subject); */
 
       if (source) {
-        g_hash_table_insert (evt->deleted_items, psubject, source);
+        g_hash_table_insert (evt->deleted_items, psubject,
+                             g_object_ref (source));
       } else {
         g_hash_table_insert (evt->orphan_items, psubject,
                              GSIZE_TO_POINTER (GRL_CONTENT_REMOVED));
@@ -582,9 +577,11 @@ tracker_dbus_signal_cb (GDBusConnection *connection,
         /* 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);
+          g_hash_table_insert (evt->updated_items, psubject,
+                               g_object_ref (source));
         } else if (!g_hash_table_lookup (evt->updated_items, psubject)) {
-          g_hash_table_insert (evt->inserted_items, psubject, source);
+          g_hash_table_insert (evt->inserted_items, psubject,
+                               g_object_ref (source));
         }
       } else {
         gpointer state;
diff --git a/src/media/tracker/grl-tracker-notif.h b/src/media/tracker/grl-tracker-notif.h
index 7317f43..a288fc3 100644
--- a/src/media/tracker/grl-tracker-notif.h
+++ b/src/media/tracker/grl-tracker-notif.h
@@ -30,10 +30,20 @@
 /* ------- Definitions ------- */
 
 #define TRACKER_DATASOURCES_REQUEST                                     \
-  "SELECT rdf:type(?urn) ?urn nie:title(?urn) "				\
-  "nie:url(tracker:mountPoint(?urn)) "					\
-  "tracker:isMounted(?urn) upnp:available(?urn) "			\
-  "WHERE { ?urn a nie:DataSource . }"
+  "SELECT "                                                             \
+  "(SELECT GROUP_CONCAT(rdf:type(?source), \":\") "                     \
+  " WHERE { ?urn nie:dataSource ?source }) "                            \
+  "nie:dataSource(?urn) "                                               \
+  "(SELECT GROUP_CONCAT(nie:title(?source), \":\") "                    \
+  " WHERE { ?urn nie:dataSource ?source }) "                            \
+  "(SELECT GROUP_CONCAT(nie:url(tracker:mountPoint(?source)), \":\") "  \
+  " WHERE { ?urn nie:dataSource ?source }) "                            \
+  "tracker:available(?urn) "                                            \
+  "WHERE "                                                              \
+  "{ "                                                                  \
+  "?urn a nfo:FileDataObject . FILTER (bound(nie:dataSource(?urn)))"    \
+  "} "                                                                  \
+  "GROUP BY (nie:dataSource(?urn))"
 
 /**/
 
diff --git a/src/media/tracker/grl-tracker.c b/src/media/tracker/grl-tracker.c
index 62b26a7..66e183b 100644
--- a/src/media/tracker/grl-tracker.c
+++ b/src/media/tracker/grl-tracker.c
@@ -150,11 +150,13 @@ grl_tracker_source_find (const gchar *id)
   source = grl_plugin_registry_lookup_source (grl_plugin_registry_get_default (),
 					      id);
 
-  if (source && GRL_IS_TRACKER_SOURCE (source))
+  if (source && GRL_IS_TRACKER_SOURCE (source)) {
     return (GrlTrackerSource *) source;
+  }
 
-  return (GrlTrackerSource *) g_hash_table_lookup (grl_tracker_modified_sources,
-                                                   id);
+  return
+    (GrlTrackerSource *) g_hash_table_lookup (grl_tracker_modified_sources,
+                                              id);
 }
 
 static void
@@ -163,7 +165,7 @@ tracker_get_datasource_cb (GObject             *object,
                            TrackerSparqlCursor *cursor)
 {
   const gchar *type, *datasource, *datasource_name, *uri;
-  gboolean volume_mounted, upnp_available, source_available;
+  gboolean source_available;
   GError *error = NULL;
   GrlTrackerSource *source;
 
@@ -184,10 +186,7 @@ tracker_get_datasource_cb (GObject             *object,
   datasource = tracker_sparql_cursor_get_string (cursor, 1, NULL);
   datasource_name = tracker_sparql_cursor_get_string (cursor, 2, NULL);
   uri = tracker_sparql_cursor_get_string (cursor, 3, NULL);
-  volume_mounted = tracker_sparql_cursor_get_boolean (cursor, 4);
-  upnp_available = tracker_sparql_cursor_get_boolean (cursor, 5);
-
-  source_available = volume_mounted | upnp_available;
+  source_available = tracker_sparql_cursor_get_boolean (cursor, 4);
 
   source = grl_tracker_source_find (datasource);
 



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