core,plugins: Support all types of devices
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 1 Jun 2009 12:00:09 +0000 (15:00 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 1 Jun 2009 12:00:09 +0000 (15:00 +0300)
Allow plugins to implement any kind of device rather than just MediaServer.
To not complicate the lives of plugin developers for this change, provide
a special constructor to easy create Plugin object for MediaServer.

src/plugins/dvb/rygel-dvb-plugin.vala
src/plugins/external/rygel-external-plugin.vala
src/plugins/folder/rygel-folder-plugin.vala
src/plugins/test/rygel-test-plugin.vala
src/plugins/tracker/rygel-tracker-plugin.vala
src/rygel/rygel-plugin.vala
src/rygel/rygel-root-device-factory.vala

index 86dc696..8b64ec6 100644 (file)
@@ -30,7 +30,7 @@ using CStuff;
 
 public class DVBPlugin : Plugin {
     public DVBPlugin () {
-        base ("DVB", "Digital TV");
+        base.MediaServer ("DVB", "Digital TV");
 
         // We only implement a ContentDirectory service
         var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
index 684f96e..ba54536 100644 (file)
@@ -45,7 +45,7 @@ public class ExternalPlugin : Plugin {
         props.Get (OBJECT_IFACE, "DisplayName", out value);
         var title = value.get_string ();
 
-        base (service_name, title);
+        base.MediaServer (service_name, title);
 
         this.service_name = service_name;
         this.root_object = root_object;
index 1c48f4e..179d365 100644 (file)
@@ -36,7 +36,7 @@ using GLib;
  */
 [ModuleInit]
 public void module_init (PluginLoader loader) {
-    Plugin plugin = new Plugin ("Folder", "@REALNAME@'s media");
+    Plugin plugin = new Plugin.MediaServer ("Folder", "@REALNAME@'s media");
 
     var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
                                           ContentDirectory.UPNP_TYPE,
index 6b17f52..a338902 100644 (file)
@@ -28,7 +28,7 @@ using CStuff;
 
 [ModuleInit]
 public void module_init (PluginLoader loader) {
-    Plugin plugin = new Plugin ("Test", "Test Streams");
+    Plugin plugin = new Plugin.MediaServer ("Test", "Test Streams");
 
     // We only implement a ContentDirectory service
     var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
index 498bf4a..71b1ede 100644 (file)
@@ -30,7 +30,7 @@ public class TrackerPlugin : Plugin {
                                 "/icons/hicolor/48x48/apps/tracker.png";
 
     public TrackerPlugin () {
-        base ("Tracker", "@REALNAME@'s media");
+        base.MediaServer ("Tracker", "@REALNAME@'s media");
 
         // We only implement a ContentDirectory service
         var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
index ee6f41b..48d108b 100644 (file)
 
 using Gee;
 using GUPnP;
+using CStuff;
 
 /**
  * Represents a Rygel plugin. Plugins are supposed to provide an object of this
  * class or a subclass.
  */
 public class Rygel.Plugin : GUPnP.ResourceFactory {
+    private static const string MEDIA_SERVER_DESC_PATH = BuildConfig.DATA_DIR +
+                                                         "/xml/description.xml";
+
     public string name;
     public string title;
 
+    // Path to description document
+    public string desc_path;
+
     public bool available { get; set; }
 
     public ArrayList<ResourceInfo> resource_infos;
     public ArrayList<IconInfo> icon_infos;
 
-    public Plugin (string  name,
+    public Plugin (string  desc_path,
+                   string  name,
                    string? title) {
+        this.desc_path = desc_path;
         this.name = name;
         this.title = title;
 
@@ -50,6 +59,11 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
 
         this.resource_infos = new ArrayList<ResourceInfo> ();
         this.icon_infos = new ArrayList<IconInfo> ();
+    }
+
+    public Plugin.MediaServer (string  name,
+                               string? title) {
+        this (MEDIA_SERVER_DESC_PATH, name, title);
 
         /* Register Rygel.ConnectionManager */
         var resource_info = new ResourceInfo
index 5898617..556b358 100644 (file)
@@ -35,7 +35,6 @@ public errordomain RootDeviceFactoryError {
  * Root device for that.
  */
 public class Rygel.RootDeviceFactory {
-    public static const string DESC_DOC = "xml/description.xml";
     public static const string DESC_PREFIX = "Rygel";
 
     private Configuration config;
@@ -81,7 +80,7 @@ public class Rygel.RootDeviceFactory {
             path = desc_path;
         } else {
             /* Use the template */
-            path = Path.build_filename (BuildConfig.DATA_DIR, DESC_DOC);
+            path = plugin.desc_path;
         }
 
         Xml.Doc *doc = Xml.Parser.parse_file (path);