[tracker/writeback: 30/30] Filled in some functions in the playlist skeleton, squashme
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/writeback: 30/30] Filled in some functions in the playlist skeleton, squashme
- Date: Fri, 18 Dec 2009 12:04:04 +0000 (UTC)
commit c8262ec886c950f9afa0eff42502e404ccbe7877
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Dec 18 13:02:13 2009 +0100
Filled in some functions in the playlist skeleton, squashme
src/tracker-writeback/Makefile.am | 12 +-
src/tracker-writeback/tracker-writeback-playlist.c | 97 +++++++++++++------
2 files changed, 72 insertions(+), 37 deletions(-)
---
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index 0d67a81..857287c 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -39,12 +39,12 @@ 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
+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
index 18335b0..9f18b62 100644
--- a/src/tracker-writeback/tracker-writeback-playlist.c
+++ b/src/tracker-writeback/tracker-writeback-playlist.c
@@ -22,6 +22,7 @@
#include "config.h"
+#include <totem-pl-parser.h>
#include <libtracker-common/tracker-ontology.h>
@@ -86,51 +87,85 @@ writeback_playlist_content_types (TrackerWritebackFile *wbf)
return content_types;
}
-static gboolean
-writeback_playlist_update_file_metadata (TrackerWritebackFile *writeback_file,
- GFile *file,
- GPtrArray *values,
- TrackerClient *client)
+static void
+rewrite_playlist (TrackerClient *client, GFile *file, const gchar *subject)
{
gchar *path;
- guint n;
+ GPtrArray *array;
+ GError *error = NULL;
+ gchar *query;
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 */
+ query = g_strdup_printf ("SELECT ?entry { ?unknown a nfo:MediaFileListEntry ; "
+ "nie:isStoredAs <%s> ; "
+ "nfo:entryContent ?entry"
+ "}", subject);
+
+ array = tracker_resources_sparql_query (client, query, &error);
+
+ g_free (query);
+
+ if (!error) {
+ if (array && array->len > 0) {
+ guint i;
+#if 0
+ TotemPlPlaylist *playlist;
+
+ playlist = totem_pl_playlist_new ();
+#endif
+ for (i = 0; i < array->len; i++) {
+ GStrv row;
+
+ row = g_ptr_array_index (array, i);
+
+ if (row && row[0]) {
+#if 0
+ TotemPlPlaylistIter iter;
+
+ totem_pl_playlist_append (playlist, &iter);
+ totem_pl_playlist_set_value (playlist, &iter,
+ TOTEM_PL_PARSER_FIELD_DOWNLOAD_URI,
+ row[0]);
+#endif
+ }
+ }
+#if 0
+ /* TODO: write to path as same type as path */
+ g_object_unref (playlist);
+#endif
+ } else {
+ /* TODO: Empty the file in @path */
}
- if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "entryCounter") == 0) {
- /* TODO */
- }
+ } else {
+ g_clear_error (&error);
+ }
- if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "listDuration") == 0) {
- /* TODO */
- }
+ if (array) {
+ g_ptr_array_foreach (array, (GFunc) g_strfreev, NULL);
+ g_ptr_array_free (array, TRUE);
+ }
- /* nfo:MediaFileListEntry */
+ g_free (path);
+}
- if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "entryContent") == 0) {
- /* TODO */
- }
+static gboolean
+writeback_playlist_update_file_metadata (TrackerWritebackFile *writeback_file,
+ GFile *file,
+ GPtrArray *values,
+ TrackerClient *client)
+{
+ guint n;
- if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "listPosition") == 0) {
- /* TODO */
+ for (n = 0; n < values->len; n++) {
+ const GStrv row = g_ptr_array_index (values, n);
+ if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "entryCounter") == 0) {
+ rewrite_playlist (client, file, row[0]);
+ break;
}
}
- g_free (path);
-
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]