[tracker/writeback: 1/7] Added skeleton for playlist writeback support



commit 63b5479e83bdab807d7125945a07a79c8f217e69
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Dec 15 12:59:39 2009 +0100

    Added skeleton for playlist writeback support

 data/ontologies/33-nfo.ontology                    |   16 ++-
 src/tracker-extract/tracker-extract-playlist.c     |   10 ++
 src/tracker-writeback/Makefile.am                  |   11 ++-
 src/tracker-writeback/tracker-writeback-playlist.c |  155 ++++++++++++++++++++
 4 files changed, 186 insertions(+), 6 deletions(-)
---
diff --git a/data/ontologies/33-nfo.ontology b/data/ontologies/33-nfo.ontology
index 44a4344..9bbe644 100644
--- a/data/ontologies/33-nfo.ontology
+++ b/data/ontologies/33-nfo.ontology
@@ -419,20 +419,23 @@ nfo:hasMediaFileListEntry a rdf:Property ;
 	rdfs:label "hasMediaFileListEntry" ;
 	rdfs:comment "This property is intended to point to an RDF list of MediaFiles." ;
 	rdfs:domain nfo:MediaList ;
-	rdfs:range nfo:MediaFileListEntry .
+	rdfs:range nfo:MediaFileListEntry ;
+	tracker:writeback true .
 
 # Propose in nepomuk
 nfo:entryCounter a rdf:Property ;
         rdfs:label "entry Counter" ;
 	rdfs:comment "Number of entries in the list. Optimize some common queries" ;
 	rdfs:domain nfo:MediaList ;
-	rdfs:range xsd:integer .
+	rdfs:range xsd:integer ;
+	tracker:writeback true .
 
 nfo:listDuration a rdf:Property ;
 	rdfs:label "List duration" ;
 	rdfs:comment "Sum of the duration of all items in the list. Optimize some common queries. In seconds";
         rdfs:domain nfo:MediaList ;
-	rdfs:range xsd:integer .
+	rdfs:range xsd:integer ;
+	tracker:writeback true .
 
 # Propose in nepomuk
 nfo:listPosition a rdf:Property ;
@@ -440,7 +443,9 @@ nfo:listPosition a rdf:Property ;
 	rdfs:comment "Position of an entry in a list. Double, to optimize the poor insertions" ;
  	nrl:maxCardinality 1 ;
 	rdfs:domain nfo:MediaFileListEntry ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
+
 
 # Propose in nepomuk
 nfo:entryContent a rdf:Property ;
@@ -448,7 +453,8 @@ nfo:entryContent a rdf:Property ;
 	rdfs:comment "URI to the element in certain position of the list" ;
         nrl:maxCardinality 1 ;
 	rdfs:domain nfo:MediaFileListEntry ;
-	rdfs:range nie:InformationElement .
+	rdfs:range nie:InformationElement ;
+	tracker:writeback true .
 
 nfo:height a rdf:Property ;
 	rdfs:label "height" ;
diff --git a/src/tracker-extract/tracker-extract-playlist.c b/src/tracker-extract/tracker-extract-playlist.c
index f6d2eb3..8bfb299 100644
--- a/src/tracker-extract/tracker-extract-playlist.c
+++ b/src/tracker-extract/tracker-extract-playlist.c
@@ -88,6 +88,16 @@ entry_parsed (TotemPlParser *parser, const gchar *to_uri, GHashTable *to_metadat
 	tracker_sparql_builder_predicate (data->metadata, "a");
 	tracker_sparql_builder_object (data->metadata, "nfo:MediaFileListEntry");
 
+	/* The DO for the entries is needed for writeback, which depends on nie:isStoredAs
+	 * being set. You can see it as "is stored in" instead of as ;) */
+
+	tracker_sparql_builder_predicate (data->metadata, "a");
+	tracker_sparql_builder_object (data->metadata, "nie:DataObject");
+	tracker_sparql_builder_predicate (data->metadata, "nie:isStoredAs");
+	tracker_sparql_builder_object_unvalidated (data->metadata, data->uri);
+	tracker_sparql_builder_predicate (data->metadata, "nie:url");
+	tracker_sparql_builder_object_unvalidated (data->metadata, data->uri);
+
 	tracker_sparql_builder_predicate (data->metadata, "nfo:entryContent");
 	tracker_sparql_builder_object_unvalidated (data->metadata, to_uri);
 
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index 7e535ec..4655653 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -17,7 +17,8 @@ INCLUDES = 								\
 	$(GMODULE_CFLAGS) 						\
 	$(DBUS_CFLAGS)							\
 	$(ID3LIB_CFLAGS)						\
-	$(EXEMPI_CFLAGS)
+	$(EXEMPI_CFLAGS)						\
+	$(TOTEM_PL_PARSER_CFLAGS)
 
 modules_LTLIBRARIES =
 
@@ -37,6 +38,14 @@ libwriteback_xmp_la_LDFLAGS = $(module_flags)
 libwriteback_xmp_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(EXEMPI_LIBS)
 endif
 
+# Playlists
+if HAVE_TOTEM_PL_PARSER
+modules_LTLIBRARIES += libwriteback-playlist.la
+libwriteback_playlist_la_SOURCES = tracker-writeback-playlist.c
+libwriteback_playlist_la_LDFLAGS = $(module_flags)
+libwriteback_playlist_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(TOTEM_PL_PARSER_LIBS)
+endif
+
 #
 # Binaries
 #
diff --git a/src/tracker-writeback/tracker-writeback-playlist.c b/src/tracker-writeback/tracker-writeback-playlist.c
new file mode 100644
index 0000000..18335b0
--- /dev/null
+++ b/src/tracker-writeback/tracker-writeback-playlist.c
@@ -0,0 +1,155 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Authors: Philip Van Hoof <philip codeminded be>
+ */
+
+#include "config.h"
+
+
+#include <libtracker-common/tracker-ontology.h>
+
+#include "tracker-writeback-file.h"
+
+#define TRACKER_TYPE_WRITEBACK_PLAYLIST (tracker_writeback_playlist_get_type ())
+
+typedef struct TrackerWritebackPlaylist TrackerWritebackPlaylist;
+typedef struct TrackerWritebackPlaylistClass TrackerWritebackPlaylistClass;
+
+struct TrackerWritebackPlaylist {
+	TrackerWritebackFile parent_instance;
+};
+
+struct TrackerWritebackPlaylistClass {
+	TrackerWritebackFileClass parent_class;
+};
+
+static GType                tracker_writeback_playlist_get_type     (void) G_GNUC_CONST;
+static gboolean             writeback_playlist_update_file_metadata (TrackerWritebackFile *wbf,
+                                                                     GFile                *file,
+                                                                     GPtrArray            *values,
+                                                                     TrackerClient        *client);
+static const gchar * const *writeback_playlist_content_types        (TrackerWritebackFile *wbf);
+
+G_DEFINE_DYNAMIC_TYPE (TrackerWritebackPlaylist, tracker_writeback_playlist, TRACKER_TYPE_WRITEBACK_FILE);
+
+static void
+tracker_writeback_playlist_class_init (TrackerWritebackPlaylistClass *klass)
+{
+	TrackerWritebackFileClass *writeback_file_class = TRACKER_WRITEBACK_FILE_CLASS (klass);
+
+	writeback_file_class->update_file_metadata = writeback_playlist_update_file_metadata;
+	writeback_file_class->content_types = writeback_playlist_content_types;
+}
+
+static void
+tracker_writeback_playlist_class_finalize (TrackerWritebackPlaylistClass *klass)
+{
+}
+
+static void
+tracker_writeback_playlist_init (TrackerWritebackPlaylist *wbm)
+{
+}
+
+static const gchar * const *
+writeback_playlist_content_types (TrackerWritebackFile *wbf)
+{
+	static const gchar *content_types[] = {
+		"audio/x-mpegurl",
+		"audio/mpegurl",
+		"audio/x-scpls",
+		"audio/x-pn-realaudio",
+		"application/ram",
+		"application/vnd.ms-wpl",
+		"application/smil",
+		"audio/x-ms-asx",
+		NULL
+	};
+
+	return content_types;
+}
+
+static gboolean
+writeback_playlist_update_file_metadata (TrackerWritebackFile *writeback_file,
+                                         GFile                *file,
+                                         GPtrArray            *values,
+                                         TrackerClient        *client)
+{
+	gchar *path;
+	guint n;
+
+	path = g_file_get_path (file);
+
+	for (n = 0; n < values->len; n++) {
+		const GStrv row = g_ptr_array_index (values, n);
+
+		/* nfo:MediaList */
+
+		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "title") == 0) {
+			/* TODO */
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "hasMediaFileListEntry") == 0) {
+			/* TODO */
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "entryCounter") == 0) {
+			/* TODO */
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "listDuration") == 0) {
+			/* TODO */
+		}
+
+		/* nfo:MediaFileListEntry */
+
+		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "entryContent") == 0) {
+			/* TODO */
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "listPosition") == 0) {
+			/* TODO */
+		}
+	}
+
+	g_free (path);
+
+	return TRUE;
+}
+
+TrackerWriteback *
+writeback_module_create (GTypeModule *module)
+{
+	tracker_writeback_playlist_register_type (module);
+
+	return g_object_new (TRACKER_TYPE_WRITEBACK_PLAYLIST, NULL);
+}
+
+const gchar * const *
+writeback_module_get_rdf_types (void)
+{
+	static const gchar *rdftypes[] = {
+		TRACKER_NFO_PREFIX "MediaList",
+		TRACKER_NFO_PREFIX "MediaFileListEntry",
+		NULL
+	};
+
+	return rdftypes;
+}



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