[rygel] Let PluginFactory handle the NameOwnerChange signal



commit 53547bb76c242cd7cc74cf0bb1bd55372fc0acb3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue May 12 20:46:36 2009 +0300

    Let PluginFactory handle the NameOwnerChange signal
    
    Let PluginFactory handle the org.freedesktop.DBus.NameOwnerChange signal.
---
 src/plugins/external/rygel-external-plugin.vala |   40 ++++++++++++-----------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/plugins/external/rygel-external-plugin.vala b/src/plugins/external/rygel-external-plugin.vala
index affeba2..9cd8b05 100644
--- a/src/plugins/external/rygel-external-plugin.vala
+++ b/src/plugins/external/rygel-external-plugin.vala
@@ -78,6 +78,27 @@ public class ExternalPluginFactory {
                                                        service));
             }
         }
+
+        dbus_obj.NameOwnerChanged += this.name_owner_changed;
+    }
+
+    private void name_owner_changed (dynamic DBus.Object dbus_obj,
+                                     string              name,
+                                     string              old_owner,
+                                     string              new_owner) {
+        var plugin = this.loader.get_plugin_by_name (name);
+
+        if (plugin != null) {
+            if (old_owner != "" && new_owner == "") {
+                debug ("Service '%s' going down, marking it as unavailable",
+                        name);
+                plugin.available = false;
+            } else if (old_owner == "" && new_owner != "") {
+                debug ("Service '%s' up again, marking it as available",
+                        name);
+                plugin.available = true;
+            }
+        }
     }
 }
 
@@ -115,24 +136,5 @@ public class ExternalPlugin : Plugin {
                                               typeof (ExternalContentDir));
 
         this.add_resource (resource_info);
-
-        dbus_obj.NameOwnerChanged += this.name_owner_changed;
-    }
-
-    private void name_owner_changed (dynamic DBus.Object dbus_obj,
-                                     string              name,
-                                     string              old_owner,
-                                     string              new_owner) {
-        if (name == this.service_name) {
-            if (old_owner != "" && new_owner == "") {
-                debug ("Service '%s' going down, marking it as unavailable",
-                        name);
-                this.available = false;
-            } else if (old_owner == "" && new_owner != "") {
-                debug ("Service '%s' up again, marking it as available",
-                        name);
-                this.available = true;
-            }
-        }
     }
 }



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