[rygel] tracker: Base class for category containers



commit 2a852ade5cc6980173c6fe662ec99aeead8017fc
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Feb 3 16:00:29 2010 +0200

    tracker: Base class for category containers

 src/plugins/tracker/Makefile.am                    |    1 +
 .../tracker/rygel-tracker-category-container.vala  |   47 ++++++++++++++++++++
 src/plugins/tracker/rygel-tracker-music.vala       |   16 ++-----
 src/plugins/tracker/rygel-tracker-pictures.vala    |   16 ++-----
 src/plugins/tracker/rygel-tracker-videos.vala      |   16 ++-----
 5 files changed, 63 insertions(+), 33 deletions(-)
---
diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am
index ba18233..503a75e 100644
--- a/src/plugins/tracker/Makefile.am
+++ b/src/plugins/tracker/Makefile.am
@@ -12,6 +12,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 librygel_media_tracker_la_SOURCES = \
 				    rygel-media-tracker.vala \
 				    rygel-tracker-root-container.vala \
+				    rygel-tracker-category-container.vala \
 				    rygel-tracker-music.vala \
 				    rygel-tracker-videos.vala \
 				    rygel-tracker-pictures.vala \
diff --git a/src/plugins/tracker/rygel-tracker-category-container.vala b/src/plugins/tracker/rygel-tracker-category-container.vala
new file mode 100644
index 0000000..5dbfc7c
--- /dev/null
+++ b/src/plugins/tracker/rygel-tracker-category-container.vala
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * 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 for a specific category.
+ */
+public class Rygel.TrackerCategoryContainer : Rygel.SimpleContainer {
+    public TrackerCategoryContainer (string         id,
+                                     MediaContainer parent,
+                                     string         title,
+                                     string         upload_dir) {
+        base (id, parent, title);
+
+        try {
+            var uri = Filename.to_uri (upload_dir, null);
+
+            this.uris.add (uri);
+        } catch (ConvertError error) {
+            warning ("Failed to contstruct URI for directory '%s': %s",
+                     upload_dir,
+                     error.message);
+        }
+    }
+}
+
diff --git a/src/plugins/tracker/rygel-tracker-music.vala b/src/plugins/tracker/rygel-tracker-music.vala
index 8363ab7..9656fb8 100644
--- a/src/plugins/tracker/rygel-tracker-music.vala
+++ b/src/plugins/tracker/rygel-tracker-music.vala
@@ -26,11 +26,14 @@ using Gee;
 /**
  * Container listing Music content hierarchy.
  */
-public class Rygel.TrackerMusic : Rygel.SimpleContainer {
+public class Rygel.TrackerMusic : Rygel.TrackerCategoryContainer {
     public TrackerMusic (string         id,
                          MediaContainer parent,
                          string         title) {
-        base (id, parent, title);
+        base (id,
+              parent,
+              title,
+              Environment.get_user_special_dir (UserDirectory.MUSIC));
 
         var item_factory = new TrackerMusicItemFactory ();
         var key_chain = new string[] { "nmm:performer",
@@ -53,15 +56,6 @@ public class Rygel.TrackerMusic : Rygel.SimpleContainer {
                                                     this,
                                                     "All",
                                                     item_factory));
-        try {
-            var dir = Environment.get_user_special_dir (UserDirectory.MUSIC);
-            var uri = Filename.to_uri (dir, null);
-
-            this.uris.add (uri);
-        } catch (ConvertError error) {
-            warning ("Failed to get URI for music directory: %s",
-                     error.message);
-        }
     }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-pictures.vala b/src/plugins/tracker/rygel-tracker-pictures.vala
index 2d34919..5340f7b 100644
--- a/src/plugins/tracker/rygel-tracker-pictures.vala
+++ b/src/plugins/tracker/rygel-tracker-pictures.vala
@@ -26,13 +26,16 @@ using Gee;
 /**
  * Container listing Pictures content hierarchy.
  */
-public class Rygel.TrackerPictures : Rygel.SimpleContainer {
+public class Rygel.TrackerPictures : Rygel.TrackerCategoryContainer {
     private const string[] KEY_CHAIN = { "nie:contentCreated", null };
 
     public TrackerPictures (string         id,
                             MediaContainer parent,
                             string         title) {
-        base (id, parent, title);
+        base (id,
+              parent,
+              title,
+              Environment.get_user_special_dir (UserDirectory.PICTURES));
 
         var item_factory = new TrackerPictureItemFactory ();
 
@@ -42,15 +45,6 @@ public class Rygel.TrackerPictures : Rygel.SimpleContainer {
                                                     this,
                                                     "All",
                                                     item_factory));
-        try {
-            var dir = Environment.get_user_special_dir (UserDirectory.PICTURES);
-            var uri = Filename.to_uri (dir, null);
-
-            this.uris.add (uri);
-        } catch (ConvertError error) {
-            warning ("Failed to get URI for pictures directory: %s",
-                     error.message);
-        }
     }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-videos.vala b/src/plugins/tracker/rygel-tracker-videos.vala
index 20dc771..2e2a664 100644
--- a/src/plugins/tracker/rygel-tracker-videos.vala
+++ b/src/plugins/tracker/rygel-tracker-videos.vala
@@ -26,11 +26,14 @@ using Gee;
 /**
  * Container listing video content hierarchy.
  */
-public class Rygel.TrackerVideos : Rygel.SimpleContainer {
+public class Rygel.TrackerVideos : Rygel.TrackerCategoryContainer {
     public TrackerVideos (string         id,
                           MediaContainer parent,
                           string         title) {
-        base (id, parent, title);
+        base (id,
+              parent,
+              title,
+              Environment.get_user_special_dir (UserDirectory.VIDEOS));
 
         var item_factory = new TrackerVideoItemFactory ();
 
@@ -40,15 +43,6 @@ public class Rygel.TrackerVideos : Rygel.SimpleContainer {
                                                     this,
                                                     "All",
                                                     item_factory));
-        try {
-            var dir = Environment.get_user_special_dir (UserDirectory.VIDEOS);
-            var uri = Filename.to_uri (dir, null);
-
-            this.uris.add (uri);
-        } catch (ConvertError error) {
-            warning ("Failed to get URI for videos directory: %s",
-                     error.message);
-        }
     }
 }
 



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