[rygel] media-export: Expose default virtual folders
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Expose default virtual folders
- Date: Sat, 14 Aug 2010 23:32:36 +0000 (UTC)
commit 9207d4833c057e47a0b6de784291aee069af1780
Author: Jens Georg <mail jensge org>
Date: Sat Aug 14 11:34:29 2010 +0300
media-export: Expose default virtual folders
Expose a similar default virtual folder tree as tracker.
There are no "Tags" folders since we don't support tags.
Pictures
-> Year dc:date,?
-> All upnp:class,object.item.ImageItem
Music
-> Year dc:date,?
-> Artist
-> Album upnp:artist,?,upnp:album,?
-> Album upnp:album,?
-> Genre upnp:genre,?
-> All upnp:class,object.item.audioIte
Videos
-> Year dc:date,?
-> All upnp:class,object.item.videoItem
.../rygel-media-export-media-cache.vala | 2 +-
.../rygel-media-export-root-container.vala | 70 ++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 270cf77..5b67a8f 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -652,7 +652,7 @@ public class Rygel.MediaExport.MediaCache : Object {
column = "m.author";
break;
case "dc:date":
- column = "m.date";
+ column = "strftime(\"%Y\", m.date)";
break;
case "upnp:album":
column = "m.album";
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 0920a4b..a907306 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -21,6 +21,22 @@
using Gee;
using GUPnP;
+internal struct Rygel.MediaExport.FolderDefinition {
+ string title;
+ string definition;
+}
+
+const Rygel.MediaExport.FolderDefinition[] virtual_folders_default = {
+ { N_("Year"), "dc:date,?" },
+ { N_("All"), "" }
+};
+
+const Rygel.MediaExport.FolderDefinition[] virtual_folders_music = {
+ { N_("Artist"), "upnp:artist,?,upnp:album,?" },
+ { N_("Album"), "upnp:album,?" },
+ { N_("Genre"), "dc:genre,?" }
+};
+
/**
* Represents the root container.
*/
@@ -332,7 +348,61 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
}
}
+ this.add_default_virtual_folders ();
+
this.updated ();
}
+ private void add_default_virtual_folders () {
+ try {
+ this.add_virtual_containers_for_class (_("Music"),
+ "object.item.audioItem",
+ virtual_folders_music);
+ this.add_virtual_containers_for_class (_("Pictures"),
+ "object.item.imageItem");
+ this.add_virtual_containers_for_class (_("Videos"),
+ "object.item.videoItem");
+ } catch (Error error) {};
+ }
+
+ private void add_folder_definition (MediaContainer container,
+ string item_class,
+ FolderDefinition definition)
+ throws Error {
+ var id = "%supnp:class,%s,%s".printf (QueryContainer.PREFIX,
+ item_class,
+ definition.definition);
+ if (id.has_suffix (",")) {
+ id = id.slice (0,-1);
+ }
+
+ QueryContainer.register_id (ref id);
+ var query_container = new QueryContainer (this.media_db,
+ id,
+ definition.title);
+ query_container.parent = container;
+ this.media_db.save_container (query_container);
+ }
+
+ private void add_virtual_containers_for_class (
+ string parent,
+ string item_class,
+ FolderDefinition[]? definitions = null)
+ throws Error {
+ var container = new NullContainer ();
+ container.parent = this;
+ container.title = parent;
+ container.id = "virtual-parent:" + item_class;
+ this.media_db.save_container (container);
+
+ foreach (var definition in virtual_folders_default) {
+ this.add_folder_definition (container, item_class, definition);
+ }
+
+ if (definitions != null) {
+ foreach (var definition in definitions) {
+ this.add_folder_definition (container, item_class, definition);
+ }
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]