From 6985934616b7ed03cdcf8ab7a4cfc749d85421c9 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Fri, 4 Dec 2009 20:05:22 +0200 Subject: [PATCH] tracker: Provide 'Years' hierarchy Enable user to browse pictures and videos by year of creation. --- src/plugins/tracker/Makefile.am | 1 + src/plugins/tracker/rygel-tracker-pictures.vala | 3 ++ src/plugins/tracker/rygel-tracker-videos.vala | 1 + src/plugins/tracker/rygel-tracker-years.vala | 60 +++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 src/plugins/tracker/rygel-tracker-years.vala diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am index ac36bcd..076cbf4 100644 --- a/src/plugins/tracker/Makefile.am +++ b/src/plugins/tracker/Makefile.am @@ -17,6 +17,7 @@ librygel_media_tracker_la_SOURCES = \ rygel-tracker-pictures.vala \ rygel-tracker-metadata-values.vala \ rygel-tracker-tags.vala \ + rygel-tracker-years.vala \ rygel-tracker-search-container.vala \ rygel-tracker-query.vala \ rygel-tracker-query-triplet.vala \ diff --git a/src/plugins/tracker/rygel-tracker-pictures.vala b/src/plugins/tracker/rygel-tracker-pictures.vala index 86222a0..dcba0ae 100644 --- a/src/plugins/tracker/rygel-tracker-pictures.vala +++ b/src/plugins/tracker/rygel-tracker-pictures.vala @@ -27,6 +27,8 @@ using Gee; * Container listing Pictures content hierarchy. */ public class Rygel.TrackerPictures : Rygel.SimpleContainer { + private const string[] KEY_CHAIN = { "nie:contentCreated", null }; + public TrackerPictures (string id, MediaContainer parent, string title) { @@ -35,6 +37,7 @@ public class Rygel.TrackerPictures : Rygel.SimpleContainer { var item_factory = new TrackerPictureItemFactory (); this.add_child (new TrackerTags ("19", this, item_factory)); + this.add_child (new TrackerYears ("22", this, item_factory)); } } diff --git a/src/plugins/tracker/rygel-tracker-videos.vala b/src/plugins/tracker/rygel-tracker-videos.vala index bc798de..0834aac 100644 --- a/src/plugins/tracker/rygel-tracker-videos.vala +++ b/src/plugins/tracker/rygel-tracker-videos.vala @@ -35,6 +35,7 @@ public class Rygel.TrackerVideos : Rygel.SimpleContainer { var item_factory = new TrackerVideoItemFactory (); this.add_child (new TrackerTags ("20", this, item_factory)); + this.add_child (new TrackerYears ("23", this, item_factory)); } } diff --git a/src/plugins/tracker/rygel-tracker-years.vala b/src/plugins/tracker/rygel-tracker-years.vala new file mode 100644 index 0000000..975fdd7 --- /dev/null +++ b/src/plugins/tracker/rygel-tracker-years.vala @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Nokia Corporation. + * + * Author: Zeeshan Ali (Khattak) + * + * + * This file is part of Rygel. + * + * Rygel is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Rygel 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +using Gee; + +/** + * Container listing content hierarchy by year of creation. + */ +public class Rygel.TrackerYears : Rygel.TrackerMetadataValues { + private const string[] KEY_CHAIN = { "nie:contentCreated", null }; + + public TrackerYears (string id, + MediaContainer parent, + TrackerItemFactory item_factory) { + base (id, + parent, + "Year", + item_factory, + KEY_CHAIN, + year_id_func, + year_id_func, + year_filter_func); + } + + private static string year_id_func (string value) { + return value.ndup (4); + } + + private static string year_filter_func (string variable, string value) { + var year = year_id_func (value); + var next_year = (year.to_int () + 1).to_string (); + + year += "-01-01T00:00:00Z"; + next_year += "-01-01T00:00:00Z"; + + return variable + " > \"" + year + "\" && " + + variable + " < \"" + next_year + "\""; + } +} + -- 2.7.4