[rygel] core: Add ENERGY_MANAGEMENT capability



commit b3389fcdd49462d5cb0d77cd9c66583268676add
Author: Jens Georg <mail jensge org>
Date:   Thu Nov 13 18:16:56 2014 +0100

    core: Add ENERGY_MANAGEMENT capability
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/librygel-core/rygel-description-file.vala |    4 ++
 src/librygel-core/rygel-plugin.vala           |   45 +++++++++++++++----------
 2 files changed, 31 insertions(+), 18 deletions(-)
---
diff --git a/src/librygel-core/rygel-description-file.vala b/src/librygel-core/rygel-description-file.vala
index 4c1e82d..ece1e50 100644
--- a/src/librygel-core/rygel-description-file.vala
+++ b/src/librygel-core/rygel-description-file.vala
@@ -235,6 +235,10 @@ public class Rygel.DescriptionFile : Object {
             flags += "+DIAGE+";
         }
 
+        if (PluginCapabilities.ENERGY_MANAGEMENT in capabilities) {
+            flags += "+LPE+";
+        }
+
         // Set the flags we found; otherwise remove whatever is in the
         // template.
         if (flags.length > 0) {
diff --git a/src/librygel-core/rygel-plugin.vala b/src/librygel-core/rygel-plugin.vala
index abd8fa9..4cb51a1 100644
--- a/src/librygel-core/rygel-plugin.vala
+++ b/src/librygel-core/rygel-plugin.vala
@@ -53,8 +53,13 @@ public enum Rygel.PluginCapabilities {
 
     /* Renderer caps */
 
+    /// General capabilities
+
     /* Diagnostics (DIAGE) support */
     DIAGNOSTICS,
+
+    /* EnergyManagement (LPE) support */
+    ENERGY_MANAGEMENT
 }
 
 /**
@@ -162,7 +167,28 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
 
                 this.capabilities |= PluginCapabilities.DIAGNOSTICS;
             }
-        } catch (GLib.Error error) {}
+        } catch (GLib.Error error) {
+            if (!(error is ConfigurationError.NO_VALUE_SET))
+                warning ("Failed to read configuration: %s", error.message);
+        }
+
+        /* Enable EnergyManagement service on this device if needed */
+        config = MetaConfig.get_default ();
+        try {
+            if (config.get_bool (this.name, "energy-management")) {
+                var resource = new ResourceInfo (EnergyManagement.UPNP_ID,
+                                                 EnergyManagement.UPNP_TYPE,
+                                                 EnergyManagement.DESCRIPTION_PATH,
+                                                 typeof (EnergyManagement));
+                this.add_resource (resource);
+
+                this.capabilities |= PluginCapabilities.ENERGY_MANAGEMENT;
+
+            }
+        } catch (GLib.Error error) {
+            if (!(error is ConfigurationError.NO_VALUE_SET))
+                warning ("Failed to read configuration: %s", error.message);
+        }
 
         this.icon_infos = new ArrayList<IconInfo> ();
         this.default_icons = new ArrayList<IconInfo> ();
@@ -194,23 +220,6 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
                                ICON_SMALL_WIDTH,
                                ICON_SMALL_HEIGHT,
                                ICON_JPG_DEPTH);
-
-        /* Enable EnergyManagement service on this device if needed */
-        config = MetaConfig.get_default ();
-        try {
-            if (config.get_bool (this.name, "energy-management")) {
-                var resource = new ResourceInfo (EnergyManagement.UPNP_ID,
-                                                 EnergyManagement.UPNP_TYPE,
-                                                 EnergyManagement.DESCRIPTION_PATH,
-                                                 typeof (EnergyManagement));
-                this.add_resource (resource);
-
-            }
-        } catch (GLib.Error error) {
-            if (!(error is ConfigurationError.NO_VALUE_SET))
-                warning ("Failed to read configuration: %s", error.message);
-        }
-
     }
 
     public void add_resource (ResourceInfo resource_info) {


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