[grilo-plugins] tracker: add support for specific upnp ontology



commit fe5d6e2b3cb17be59f089645374d09896b1fdfd1
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Wed Mar 30 11:43:40 2011 +0100

    tracker: add support for specific upnp ontology
    
    Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>

 src/media/tracker/grl-tracker-media-priv.h |    1 +
 src/media/tracker/grl-tracker-utils.c      |    7 +++
 src/media/tracker/grl-tracker.c            |   59 ++++++++++++++++++++++++----
 3 files changed, 59 insertions(+), 8 deletions(-)
---
diff --git a/src/media/tracker/grl-tracker-media-priv.h b/src/media/tracker/grl-tracker-media-priv.h
index 965c270..a1210fc 100644
--- a/src/media/tracker/grl-tracker-media-priv.h
+++ b/src/media/tracker/grl-tracker-media-priv.h
@@ -76,6 +76,7 @@ extern const GrlPluginInfo *grl_tracker_plugin;
 /* shared data across  */
 extern GrlTrackerCache *grl_tracker_item_cache;
 extern GHashTable *grl_tracker_media_sources_modified;
+extern gboolean grl_tracker_upnp_present;
 
 /* tracker plugin config */
 extern gboolean grl_tracker_per_device_source;
diff --git a/src/media/tracker/grl-tracker-utils.c b/src/media/tracker/grl-tracker-utils.c
index 14eecee..974b81b 100644
--- a/src/media/tracker/grl-tracker-utils.c
+++ b/src/media/tracker/grl-tracker-utils.c
@@ -279,6 +279,13 @@ grl_tracker_setup_key_mappings (void)
                       "nfo:lastPlayedPosition",
                       "nfo:lastPlayedPosition(?urn)",
                       "media");
+
+  if (grl_tracker_upnp_present) {
+    insert_key_mapping (GRL_METADATA_KEY_THUMBNAIL,
+                        "upnp:thumbnail",
+                        "upnp:thumbnail(?urn)",
+                        "media");
+  }
 }
 
 tracker_grl_sparql_t *
diff --git a/src/media/tracker/grl-tracker.c b/src/media/tracker/grl-tracker.c
index 11a4e66..e48dbd4 100644
--- a/src/media/tracker/grl-tracker.c
+++ b/src/media/tracker/grl-tracker.c
@@ -52,6 +52,13 @@ GRL_LOG_DOMAIN_STATIC(tracker_general_log_domain);
   "FILTER(fn:ends-with(?urn,\"nfo#Folder\")) " \
   "}"
 
+#define TRACKER_UPNP_CLASS_REQUEST                      \
+  "SELECT ?urn WHERE "                                  \
+  "{ "                                                  \
+  "?urn a rdfs:Class . "                                \
+  "FILTER(fn:ends-with(?urn,\"upnp#UPnPDataObject\")) " \
+  "}"
+
 #define TRACKER_NOTIFY_FOLDER_UPDATE            \
   "INSERT "                                     \
   "{ "                                          \
@@ -68,6 +75,7 @@ gboolean grl_tracker_plugin_init (GrlPluginRegistry *registry,
 
 TrackerSparqlConnection *grl_tracker_connection = NULL;
 const GrlPluginInfo *grl_tracker_plugin;
+gboolean grl_tracker_upnp_present = FALSE;
 
 /* tracker plugin config */
 gboolean grl_tracker_per_device_source = FALSE;
@@ -78,6 +86,8 @@ gboolean grl_tracker_browse_filesystem = FALSE;
 static void
 init_sources (void)
 {
+  grl_tracker_setup_key_mappings ();
+
   if (grl_tracker_connection != NULL) {
     grl_tracker_media_dbus_start_watch ();
 
@@ -133,15 +143,30 @@ tracker_get_folder_class_cb (GObject      *object,
 }
 
 static void
-tracker_get_connection_cb (GObject             *object,
-                           GAsyncResult        *res,
-                           const GrlPluginInfo *plugin)
+tracker_get_upnp_class_cb (GObject      *object,
+                           GAsyncResult *result,
+                           gpointer      data)
 {
-  /* GrlTrackerMedia *source; */
+  GError *error = NULL;
+  TrackerSparqlCursor *cursor;
 
-  GRL_DEBUG ("%s", __FUNCTION__);
+  GRL_DEBUG ("%s", G_STRFUNC);
 
-  grl_tracker_connection = tracker_sparql_connection_get_finish (res, NULL);
+  cursor = tracker_sparql_connection_query_finish (grl_tracker_connection,
+                                                   result, &error);
+  if (error) {
+    GRL_WARNING ("Could not execute sparql query for upnp class: %s",
+                 error->message);
+    g_error_free (error);
+  } else {
+    if (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+      GRL_DEBUG ("\tUPnP ontology present");
+      grl_tracker_upnp_present = TRUE;
+    }
+  }
+
+  if (cursor)
+    g_object_unref (cursor);
 
   if (grl_tracker_browse_filesystem)
     tracker_sparql_connection_query_async (grl_tracker_connection,
@@ -153,6 +178,26 @@ tracker_get_connection_cb (GObject             *object,
     init_sources ();
 }
 
+static void
+tracker_get_connection_cb (GObject             *object,
+                           GAsyncResult        *res,
+                           const GrlPluginInfo *plugin)
+{
+  /* GrlTrackerMedia *source; */
+
+  GRL_DEBUG ("%s", __FUNCTION__);
+
+  grl_tracker_connection = tracker_sparql_connection_get_finish (res, NULL);
+
+  GRL_DEBUG ("\trequest : '%s'", TRACKER_UPNP_CLASS_REQUEST);
+
+  tracker_sparql_connection_query_async (grl_tracker_connection,
+                                         TRACKER_UPNP_CLASS_REQUEST,
+                                         NULL,
+                                         tracker_get_upnp_class_cb,
+                                         NULL);
+}
+
 gboolean
 grl_tracker_plugin_init (GrlPluginRegistry *registry,
                          const GrlPluginInfo *plugin,
@@ -166,8 +211,6 @@ grl_tracker_plugin_init (GrlPluginRegistry *registry,
   grl_tracker_media_init_requests ();
   grl_tracker_metadata_init_requests ();
 
-  grl_tracker_setup_key_mappings ();
-
   grl_tracker_plugin = plugin;
 
   if (!configs) {



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