Attach the availability of MediaServer and Plugin
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sun, 10 May 2009 01:12:27 +0000 (04:12 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sun, 10 May 2009 01:12:27 +0000 (04:12 +0300)
Attach the availability of the Plugin to it's associated MediaServer.

src/rygel/rygel-main.vala

index ff453b9..70fbd08 100644 (file)
@@ -72,10 +72,11 @@ public class Rygel.Main : Object {
         try {
             var server = this.ms_factory.create_media_server (plugin);
 
-            /* Make our device available */
-            server.available = true;
+            server.available = plugin.available;
 
             media_servers.add (server);
+
+            plugin.notify["available"] += this.on_plugin_notify;
         } catch (GLib.Error error) {
             warning ("Failed to create MediaServer for %s. Reason: %s\n",
                      plugin.name,
@@ -83,6 +84,15 @@ public class Rygel.Main : Object {
         }
     }
 
+    private void on_plugin_notify (Plugin    plugin,
+                                   ParamSpec spec) {
+        foreach (var server in this.media_servers) {
+            if (server.resource_factory == plugin) {
+                server.available = plugin.available;
+            }
+        }
+    }
+
     public static int main (string[] args) {
         Main main;