rygel r283 - in trunk: . src/media-providers/tracker



Author: zeeshanak
Date: Tue Nov 11 17:41:56 2008
New Revision: 283
URL: http://svn.gnome.org/viewvc/rygel?rev=283&view=rev

Log:
Refactor: Put common Tracker item code into a separate abstract class.

All Tracker item classes now inherit from this class.

Added:
   trunk/src/media-providers/tracker/rygel-tracker-item.vala
Modified:
   trunk/ChangeLog
   trunk/src/media-providers/tracker/Makefile.am
   trunk/src/media-providers/tracker/rygel-tracker-image-item.vala
   trunk/src/media-providers/tracker/rygel-tracker-music-item.vala
   trunk/src/media-providers/tracker/rygel-tracker-video-item.vala

Modified: trunk/src/media-providers/tracker/Makefile.am
==============================================================================
--- trunk/src/media-providers/tracker/Makefile.am	(original)
+++ trunk/src/media-providers/tracker/Makefile.am	Tue Nov 11 17:41:56 2008
@@ -12,6 +12,8 @@
 		rygel-media-tracker.c \
 		rygel-tracker-container.h \
 		rygel-tracker-container.c \
+		rygel-tracker-item.h \
+		rygel-tracker-item.c \
 		rygel-tracker-video-item.h \
 		rygel-tracker-video-item.c \
 		rygel-tracker-music-item.h \
@@ -27,6 +29,9 @@
 				    rygel-tracker-container.h \
 			            rygel-tracker-container.c \
 				    rygel-tracker-container.vala \
+                                    rygel-tracker-item.h \
+                                    rygel-tracker-item.c \
+                                    rygel-tracker-item.vala \
                                     rygel-tracker-video-item.h \
                                     rygel-tracker-video-item.c \
                                     rygel-tracker-video-item.vala \

Modified: trunk/src/media-providers/tracker/rygel-tracker-image-item.vala
==============================================================================
--- trunk/src/media-providers/tracker/rygel-tracker-image-item.vala	(original)
+++ trunk/src/media-providers/tracker/rygel-tracker-image-item.vala	Tue Nov 11 17:41:56 2008
@@ -27,28 +27,13 @@
 using GUPnP;
 using DBus;
 
-public class Rygel.TrackerImageItem : MediaItem {
-    private TrackerContainer parent;
-    private string path;
-    private GUPnP.Context context;
-
-    private dynamic DBus.Object metadata;
-
-    string[] keys;
-
+public class Rygel.TrackerImageItem : TrackerItem {
     public TrackerImageItem (string              id,
                              string              path,
                              TrackerContainer    parent,
                              dynamic DBus.Object metadata,
                              GUPnP.Context       context) {
-        this.id = id;
-        this.path = path;
-        this.parent = parent;
-        this.parent_id = parent.id;
-        this.upnp_class = parent.child_class;
-
-        this.metadata = metadata;
-        this.context = context;
+        base (id, path, parent, metadata, context);
 
         keys = new string[] {"File:Name",
                              "File:Mime",
@@ -100,30 +85,5 @@
 
         base.serialize (didl_writer);
     }
-
-    private string seconds_to_iso8601 (string seconds) {
-        string date;
-
-        if (seconds != "") {
-            TimeVal tv;
-
-            tv.tv_sec = seconds.to_int ();
-            tv.tv_usec = 0;
-
-            date = tv.to_iso8601 ();
-        } else {
-            date = "";
-        }
-
-        return date;
-    }
-
-    private string uri_from_path (string path) {
-        string escaped_path = Uri.escape_string (path, "/", true);
-
-        return "http://%s:%u%s".printf (this.context.host_ip,
-                                        this.context.port,
-                                        escaped_path);
-    }
 }
 

Added: trunk/src/media-providers/tracker/rygel-tracker-item.vala
==============================================================================
--- (empty file)
+++ trunk/src/media-providers/tracker/rygel-tracker-item.vala	Tue Nov 11 17:41:56 2008
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali <zeenix gmail com>
+ *
+ * This program 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 program 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+using Rygel;
+using GUPnP;
+using DBus;
+
+public abstract class Rygel.TrackerItem : MediaItem {
+    protected TrackerContainer parent;
+    protected string path;
+    protected GUPnP.Context context;
+
+    protected dynamic DBus.Object metadata;
+
+    protected string[] keys;
+
+    public TrackerItem (string              id,
+                        string              path,
+                        TrackerContainer    parent,
+                        dynamic DBus.Object metadata,
+                        GUPnP.Context       context) {
+        this.id = id;
+        this.path = path;
+        this.parent = parent;
+        this.parent_id = parent.id;
+        this.upnp_class = parent.child_class;
+
+        this.metadata = metadata;
+        this.context = context;
+    }
+
+    protected string seconds_to_iso8601 (string seconds) {
+        string date;
+
+        if (seconds != "") {
+            TimeVal tv;
+
+            tv.tv_sec = seconds.to_int ();
+            tv.tv_usec = 0;
+
+            date = tv.to_iso8601 ();
+        } else {
+            date = "";
+        }
+
+        return date;
+    }
+
+    protected string uri_from_path (string path) {
+        string escaped_path = Uri.escape_string (path, "/", true);
+
+        return "http://%s:%u%s".printf (this.context.host_ip,
+                                        this.context.port,
+                                        escaped_path);
+    }
+}
+

Modified: trunk/src/media-providers/tracker/rygel-tracker-music-item.vala
==============================================================================
--- trunk/src/media-providers/tracker/rygel-tracker-music-item.vala	(original)
+++ trunk/src/media-providers/tracker/rygel-tracker-music-item.vala	Tue Nov 11 17:41:56 2008
@@ -27,28 +27,13 @@
 using GUPnP;
 using DBus;
 
-public class Rygel.TrackerMusicItem : MediaItem {
-    private TrackerContainer parent;
-    private string path;
-    private GUPnP.Context context;
-
-    private dynamic DBus.Object metadata;
-
-    string[] keys;
-
+public class Rygel.TrackerMusicItem : TrackerItem {
     public TrackerMusicItem (string              id,
                              string              path,
                              TrackerContainer    parent,
                              dynamic DBus.Object metadata,
                              GUPnP.Context       context) {
-        this.id = id;
-        this.path = path;
-        this.parent = parent;
-        this.parent_id = parent.id;
-        this.upnp_class = parent.child_class;
-
-        this.metadata = metadata;
-        this.context = context;
+        base (id, path, parent, metadata, context);
 
         keys = new string[] {"File:Name",
                              "File:Mime",
@@ -99,30 +84,5 @@
 
         base.serialize (didl_writer);
     }
-
-    private string seconds_to_iso8601 (string seconds) {
-        string date;
-
-        if (seconds != "") {
-            TimeVal tv;
-
-            tv.tv_sec = seconds.to_int ();
-            tv.tv_usec = 0;
-
-            date = tv.to_iso8601 ();
-        } else {
-            date = "";
-        }
-
-        return date;
-    }
-
-    private string uri_from_path (string path) {
-        string escaped_path = Uri.escape_string (path, "/", true);
-
-        return "http://%s:%u%s".printf (this.context.host_ip,
-                                        this.context.port,
-                                        escaped_path);
-    }
 }
 

Modified: trunk/src/media-providers/tracker/rygel-tracker-video-item.vala
==============================================================================
--- trunk/src/media-providers/tracker/rygel-tracker-video-item.vala	(original)
+++ trunk/src/media-providers/tracker/rygel-tracker-video-item.vala	Tue Nov 11 17:41:56 2008
@@ -27,28 +27,13 @@
 using GUPnP;
 using DBus;
 
-public class Rygel.TrackerVideoItem : MediaItem {
-    private TrackerContainer parent;
-    private string path;
-    private GUPnP.Context context;
-
-    private dynamic DBus.Object metadata;
-
-    string[] keys;
-
+public class Rygel.TrackerVideoItem : TrackerItem {
     public TrackerVideoItem (string              id,
                              string              path,
                              TrackerContainer    parent,
                              dynamic DBus.Object metadata,
                              GUPnP.Context       context) {
-        this.id = id;
-        this.path = path;
-        this.parent = parent;
-        this.parent_id = parent.id;
-        this.upnp_class = parent.child_class;
-
-        this.metadata = metadata;
-        this.context = context;
+        base (id, path, parent, metadata, context);
 
         keys = new string[] {"File:Name",
                              "File:Mime",
@@ -92,30 +77,5 @@
 
         base.serialize (didl_writer);
     }
-
-    private string seconds_to_iso8601 (string seconds) {
-        string date;
-
-        if (seconds != "") {
-            TimeVal tv;
-
-            tv.tv_sec = seconds.to_int ();
-            tv.tv_usec = 0;
-
-            date = tv.to_iso8601 ();
-        } else {
-            date = "";
-        }
-
-        return date;
-    }
-
-    private string uri_from_path (string path) {
-        string escaped_path = Uri.escape_string (path, "/", true);
-
-        return "http://%s:%u%s".printf (this.context.host_ip,
-                                        this.context.port,
-                                        escaped_path);
-    }
 }
 



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