[grilo-plugins] tracker: provide filesystem exploration through browsing
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] tracker: provide filesystem exploration through browsing
- Date: Tue, 8 Mar 2011 08:40:15 +0000 (UTC)
commit 57aae5910dc1533ea7b8a92b76cac315a5a9a7ae
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date: Tue Feb 22 17:10:05 2011 +0000
tracker: provide filesystem exploration through browsing
Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>
src/media/tracker/grl-tracker-api.c | 96 +++++++++++++++++++++++++++++++-
src/media/tracker/grl-tracker-priv.h | 1 +
src/media/tracker/grl-tracker-utils.c | 2 +
src/media/tracker/grl-tracker-utils.h | 1 +
src/media/tracker/grl-tracker.c | 4 +-
5 files changed, 100 insertions(+), 4 deletions(-)
---
diff --git a/src/media/tracker/grl-tracker-api.c b/src/media/tracker/grl-tracker-api.c
index d13c04b..a3be157 100644
--- a/src/media/tracker/grl-tracker-api.c
+++ b/src/media/tracker/grl-tracker-api.c
@@ -81,6 +81,36 @@ GRL_LOG_DOMAIN_STATIC(tracker_request_log_domain);
"OFFSET %i " \
"LIMIT %i"
+#define TRACKER_BROWSE_FILESYSTEM_ROOT_REQUEST \
+ "SELECT rdf:type(?urn) %s " \
+ "WHERE " \
+ "{ " \
+ "{ ?urn a nfo:Folder } UNION " \
+ "{ ?urn a nfo:Audio } UNION " \
+ "{ ?urn a nmm:Photo } UNION " \
+ "{ ?urn a nmm:Video } . " \
+ "%s " \
+ "FILTER (!bound(nfo:belongsToContainer(?urn))) " \
+ "} " \
+ "ORDER BY DESC(nfo:fileLastModified(?urn)) " \
+ "OFFSET %i " \
+ "LIMIT %i"
+
+#define TRACKER_BROWSE_FILESYSTEM_REQUEST \
+ "SELECT rdf:type(?urn) %s " \
+ "WHERE " \
+ "{ " \
+ "{ ?urn a nfo:Folder } UNION " \
+ "{ ?urn a nfo:Audio } UNION " \
+ "{ ?urn a nmm:Photo } UNION " \
+ "{ ?urn a nmm:Video } . " \
+ "%s " \
+ "FILTER(tracker:id(nfo:belongsToContainer(?urn)) = %s) " \
+ "} " \
+ "ORDER BY DESC(nfo:fileLastModified(?urn)) " \
+ "OFFSET %i " \
+ "LIMIT %i"
+
#define TRACKER_METADATA_REQUEST \
"SELECT %s " \
"WHERE " \
@@ -601,9 +631,9 @@ grl_tracker_source_search (GrlMediaSource *source, GrlMediaSourceSearchSpec *ss)
g_free (sparql_final);
}
-void
-grl_tracker_source_browse (GrlMediaSource *source,
- GrlMediaSourceBrowseSpec *bs)
+static void
+grl_tracker_source_browse_category (GrlMediaSource *source,
+ GrlMediaSourceBrowseSpec *bs)
{
GrlTrackerSourcePriv *priv = GRL_TRACKER_SOURCE_GET_PRIVATE (source);
gchar *constraint;
@@ -673,6 +703,66 @@ grl_tracker_source_browse (GrlMediaSource *source,
g_free (sparql_final);
}
+static void
+grl_tracker_source_browse_filesystem (GrlMediaSource *source,
+ GrlMediaSourceBrowseSpec *bs)
+{
+ GrlTrackerSourcePriv *priv = GRL_TRACKER_SOURCE_GET_PRIVATE (source);
+ gchar *constraint;
+ gchar *sparql_select;
+ gchar *sparql_final;
+ struct OperationSpec *os;
+
+ GRL_DEBUG ("%s: id=%u", __FUNCTION__, bs->browse_id);
+
+ sparql_select = grl_tracker_source_get_select_string (bs->source, bs->keys);
+ constraint = grl_tracker_source_get_device_constraint (priv);
+
+ if (bs->container == NULL ||
+ !grl_media_get_id (bs->container)) {
+ sparql_final = g_strdup_printf (TRACKER_BROWSE_FILESYSTEM_ROOT_REQUEST,
+ sparql_select,
+ constraint,
+ bs->skip, bs->count);
+
+ } else {
+ sparql_final = g_strdup_printf (TRACKER_BROWSE_FILESYSTEM_REQUEST,
+ sparql_select,
+ constraint,
+ grl_media_get_id (bs->container),
+ bs->skip, bs->count);
+ }
+
+ GRL_DEBUG ("\tselect: '%s'", sparql_final);
+
+ os = tracker_operation_initiate (source, priv, bs->browse_id);
+ os->keys = bs->keys;
+ os->skip = bs->skip;
+ os->count = bs->count;
+ os->callback = bs->callback;
+ os->user_data = bs->user_data;
+
+ tracker_sparql_connection_query_async (priv->tracker_connection,
+ sparql_final,
+ os->cancel_op,
+ (GAsyncReadyCallback) tracker_query_cb,
+ os);
+
+ g_free (constraint);
+ g_free (sparql_select);
+ g_free (sparql_final);
+}
+
+void
+grl_tracker_source_browse (GrlMediaSource *source,
+ GrlMediaSourceBrowseSpec *bs)
+{
+ if (grl_tracker_browse_filesystem)
+ grl_tracker_source_browse_filesystem (source, bs);
+ else
+ grl_tracker_source_browse_category (source, bs);
+}
+
void
grl_tracker_source_cancel (GrlMediaSource *source, guint operation_id)
{
diff --git a/src/media/tracker/grl-tracker-priv.h b/src/media/tracker/grl-tracker-priv.h
index b6c5a18..8b9bbe0 100644
--- a/src/media/tracker/grl-tracker-priv.h
+++ b/src/media/tracker/grl-tracker-priv.h
@@ -81,5 +81,6 @@ extern GHashTable *grl_tracker_modified_sources;
/* tracker plugin config */
extern gboolean grl_tracker_per_device_source;
+extern gboolean grl_tracker_browse_filesystem;
#endif /* _GRL_TRACKER_PRIV_H_ */
diff --git a/src/media/tracker/grl-tracker-utils.c b/src/media/tracker/grl-tracker-utils.c
index 01fcf98..7f07583 100644
--- a/src/media/tracker/grl-tracker-utils.c
+++ b/src/media/tracker/grl-tracker-utils.c
@@ -233,6 +233,8 @@ grl_tracker_build_grilo_media (const gchar *rdf_type)
media = grl_media_box_new ();
} else if (g_str_has_suffix (rdf_single_type[i], RDF_TYPE_BOX)) {
media = grl_media_box_new ();
+ } else if (g_str_has_suffix (rdf_single_type[i], RDF_TYPE_FOLDER)) {
+ media = grl_media_box_new ();
}
i--;
}
diff --git a/src/media/tracker/grl-tracker-utils.h b/src/media/tracker/grl-tracker-utils.h
index 9522381..1fc8819 100644
--- a/src/media/tracker/grl-tracker-utils.h
+++ b/src/media/tracker/grl-tracker-utils.h
@@ -35,6 +35,7 @@
#define RDF_TYPE_MUSIC "nmm#MusicPiece"
#define RDF_TYPE_IMAGE "nmm#Photo"
#define RDF_TYPE_VIDEO "nmm#Video"
+#define RDF_TYPE_FOLDER "nfo#Folder"
#define RDF_TYPE_BOX "grilo#Box"
#define RDF_TYPE_VOLUME "tracker#Volume"
diff --git a/src/media/tracker/grl-tracker.c b/src/media/tracker/grl-tracker.c
index 01a4dd5..77980d1 100644
--- a/src/media/tracker/grl-tracker.c
+++ b/src/media/tracker/grl-tracker.c
@@ -82,7 +82,7 @@ GHashTable *grl_tracker_modified_sources;
/* tracker plugin config */
gboolean grl_tracker_per_device_source = FALSE;
-
+gboolean grl_tracker_browse_filesystem = FALSE;
/* =================== Tracker Plugin =============== */
@@ -295,6 +295,8 @@ grl_tracker_plugin_init (GrlPluginRegistry *registry,
grl_tracker_per_device_source =
grl_config_get_boolean (config, "per-device-source");
+ grl_tracker_browse_filesystem =
+ grl_config_get_boolean (config, "browse-filesystem");
}
tracker_sparql_connection_get_async (NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]