core: Introducing SourceConnectionManager
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sun, 4 Oct 2009 17:58:17 +0000 (20:58 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 5 Oct 2009 12:42:54 +0000 (15:42 +0300)
Separate ConnectionManager implemenation for MediaServer usage.

src/rygel/Makefile.am
src/rygel/rygel-connection-manager.vala
src/rygel/rygel-plugin.vala
src/rygel/rygel-source-connection-manager.vala [new file with mode: 0644]

index b7a2661..2804256 100644 (file)
@@ -47,6 +47,7 @@ VAPI_SOURCE_FILES = rygel-configuration.vala \
                    rygel-cmdline-config.vala \
                    rygel-content-directory.vala \
                    rygel-connection-manager.vala \
+                   rygel-source-connection-manager.vala \
                    rygel-transcode-manager.vala \
                    rygel-http-server.vala \
                    rygel-state-machine.vala \
index f378131..980a332 100644 (file)
@@ -36,15 +36,11 @@ public class Rygel.ConnectionManager : Service {
 
     protected string sink_protocol_info;
     protected string connection_ids;
-
-    protected string source_protocol_info {
-        owned get {
-            return this.get_http_server ().get_protocol_info ();
-        }
-    }
+    protected string source_protocol_info;
 
     public override void constructed () {
         this.sink_protocol_info   = "";
+        this.source_protocol_info = "";
         this.connection_ids       = "0";
 
         this.query_variable["SourceProtocolInfo"] +=
@@ -118,20 +114,4 @@ public class Rygel.ConnectionManager : Service {
 
         action.return ();
     }
-
-    private HTTPServer get_http_server () {
-        HTTPServer server = null;
-
-        var root_device = (Rygel.RootDevice) this.root_device;
-
-        // Find the ContentDirectory service attached to this root device.
-        foreach (var service in root_device.services) {
-            if (service.get_type().is_a (typeof (Rygel.ContentDirectory))) {
-                var content_directory = (Rygel.ContentDirectory) service;
-                server = content_directory.http_server;
-            }
-        }
-
-        return server;
-    }
 }
index a433e77..fa7dc8d 100644 (file)
@@ -77,7 +77,7 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
         resource_info = new ResourceInfo (ConnectionManager.UPNP_ID,
                                           ConnectionManager.UPNP_TYPE,
                                           ConnectionManager.DESCRIPTION_PATH,
-                                          typeof (ConnectionManager));
+                                          typeof (SourceConnectionManager));
         this.add_resource (resource_info);
     }
 
diff --git a/src/rygel/rygel-source-connection-manager.vala b/src/rygel/rygel-source-connection-manager.vala
new file mode 100644 (file)
index 0000000..aabbbbb
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 Nokia Corporation.
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
+ *
+ * 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 GUPnP;
+
+/**
+ * UPnP ConnectionManager service for serving end-points (MediaServer).
+ */
+public class Rygel.SourceConnectionManager : Rygel.ConnectionManager {
+    public override void constructed () {
+        base.constructed ();
+
+        var server = this.get_http_server ();
+        this.source_protocol_info = server.get_protocol_info ();
+    }
+
+    private HTTPServer get_http_server () {
+        HTTPServer server = null;
+
+        var root_device = (Rygel.RootDevice) this.root_device;
+
+        // Find the ContentDirectory service attached to this root device.
+        foreach (var service in root_device.services) {
+            if (service.get_type().is_a (typeof (Rygel.ContentDirectory))) {
+                var content_directory = (Rygel.ContentDirectory) service;
+                server = content_directory.http_server;
+            }
+        }
+
+        return server;
+    }
+}