[rygel] core: Keep empty MediaServer plugins, inactivate



commit 5c7c2e12107661e8c0eed20fe753594bb3266008
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Dec 24 04:22:29 2010 +0200

    core: Keep empty MediaServer plugins, inactivate
    
    If the root container of a MediaServer plugin is empty, deactivate the plugin
    until the situation changes.

 src/rygel/rygel-media-server-plugin.vala |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/rygel/rygel-media-server-plugin.vala b/src/rygel/rygel-media-server-plugin.vala
index b5e347f..2090f08 100644
--- a/src/rygel/rygel-media-server-plugin.vala
+++ b/src/rygel/rygel-media-server-plugin.vala
@@ -49,8 +49,34 @@ public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
                                  MediaReceiverRegistrar.DESCRIPTION_PATH,
                                  typeof (MediaReceiverRegistrar));
         this.add_resource (info);
+
+        var root_container = this.get_root_container ();
+        if (root_container.child_count == 0) {
+            debug ("Deactivating plugin '%s' until it provides content.",
+                   this.name);
+
+            this.active = false;
+
+            root_container.container_updated.connect
+                                        (this.on_container_updated);
+        }
     }
 
     public abstract MediaContainer get_root_container ();
+
+    private void on_container_updated (MediaContainer root_container,
+                                       MediaContainer updated) {
+        if (updated != root_container || updated.child_count == 0) {
+            return;
+        }
+
+        root_container.container_updated.disconnect
+                                        (this.on_container_updated);
+
+        debug ("Activating plugin '%s' since it now provides content.",
+               this.name);
+
+        this.active = true;
+    }
 }
 



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