[rygel] Plugin is made (un)available when it's backend goes down/up
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] Plugin is made (un)available when it's backend goes down/up
- Date: Mon, 11 May 2009 18:35:29 -0400 (EDT)
commit 55340a6e3142a8b07cf28fe06469e4ffc7bf5082
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon May 11 19:51:54 2009 +0300
Plugin is made (un)available when it's backend goes down/up
---
src/plugins/external/rygel-external-plugin.vala | 31 ++++++++++++++++++++--
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/plugins/external/rygel-external-plugin.vala b/src/plugins/external/rygel-external-plugin.vala
index f5d9ac4..4f8415b 100644
--- a/src/plugins/external/rygel-external-plugin.vala
+++ b/src/plugins/external/rygel-external-plugin.vala
@@ -46,7 +46,9 @@ public void module_init (PluginLoader loader) {
string[] services = dbus_obj.ListNames ();
foreach (var service in services) {
if (service.has_prefix (SERVICE_PREFIX)) {
- loader.add_plugin (new ExternalPlugin (connection, service));
+ loader.add_plugin (new ExternalPlugin (connection,
+ dbus_obj,
+ service));
}
}
} catch (DBus.Error error) {
@@ -60,8 +62,11 @@ public class ExternalPlugin : Plugin {
public string service_name;
public string root_object;
- public ExternalPlugin (DBus.Connection connection,
- string service_name) {
+ private dynamic DBus.Object dbus_obj;
+
+ public ExternalPlugin (DBus.Connection connection,
+ dynamic DBus.Object dbus_obj,
+ string service_name) {
// org.Rygel.MediaServer1.NAME => /org/Rygel/MediaServer1/NAME
var root_object = "/" + service_name.replace (".", "/");
@@ -75,6 +80,7 @@ public class ExternalPlugin : Plugin {
base (service_name, title);
+ this.dbus_obj = dbus_obj;
this.service_name = service_name;
this.root_object = root_object;
@@ -85,5 +91,24 @@ 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]