[Xfce4-commits] <xfce4-power-manager:devkit-power> Check dkp daemon version as the minimum allowed version is 011 since earlier versions of devkit-power uses dash-dash property names while newer version uses FirstLetterCaps.

Ali Abdallah noreply at xfce.org
Fri Nov 6 21:02:01 CET 2009


Updating branch refs/heads/devkit-power
         to 13c68f4148f2ffd91a3c562bc5588c42a3d3219d (commit)
       from 4ab79e4744caf4a5649407d44df025d1122451dd (commit)

commit 13c68f4148f2ffd91a3c562bc5588c42a3d3219d
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 20:58:02 2009 +0100

    Check dkp daemon version as the minimum allowed version is 011 since
    earlier versions of devkit-power uses dash-dash property names
    while newer version uses FirstLetterCaps.

 src/xfpm-dkp.c    |   77 +++++++++++++++++++++++++++++++++++++++++++++-------
 src/xfpm-xfconf.c |    7 +++-
 src/xfpm-xfconf.h |    3 ++
 3 files changed, 74 insertions(+), 13 deletions(-)

diff --git a/src/xfpm-dkp.c b/src/xfpm-dkp.c
index 69a6343..9397869 100644
--- a/src/xfpm-dkp.c
+++ b/src/xfpm-dkp.c
@@ -242,6 +242,67 @@ xfpm_dkp_check_lid (XfpmDkp *dkp, GHashTable *props)
     }
 }
 
+static void
+xfpm_dkp_check_daemon_version (XfpmDkp *dkp, GHashTable *props)
+{
+    GValue *value;
+    gint dkp_version;
+	
+    value = g_hash_table_lookup (props, "DaemonVersion");
+
+    if (value == NULL) 
+    {
+	g_warning ("No 'DaemonVersion' property");
+	/*
+	 * Version less than 011 uses dash-dash
+	 */
+	value = g_hash_table_lookup (props, "daemon-version");
+	
+	if (value == NULL) 
+	{
+	    g_warning ("No 'daemon-version' property");
+	    goto out;
+	}
+    }
+    
+    dkp->priv->daemon_version = g_strdup (g_value_get_string (value));
+    XFPM_DEBUG ("Dkp daemon version %s", dkp->priv->daemon_version);
+    dkp_version = strtol (dkp->priv->daemon_version, NULL, 10);
+    
+    if ( dkp_version < 15)
+    {
+	XfconfChannel *channel;
+	gboolean show_error;
+	
+	channel = xfpm_xfconf_get_channel (dkp->priv->conf);
+	
+	show_error = xfconf_channel_get_bool (channel, PROPERTIES_PREFIX "show-dkp-version-error", TRUE);
+	
+	XFPM_WARNING ("Dkp version %d is less than the required minimum version 011", dkp_version);
+	
+	
+	if ( show_error )
+	{
+	    GError *error = NULL;
+	    gchar *message;
+	    message = g_strdup_printf ("%s %s", 
+				   _("Xfce Power Manager requires version 011 of devicekit-power " 
+				   "to work properly while the version found is"), 
+				   dkp->priv->daemon_version);
+		
+	    g_set_error (&error, 0, 0, message);
+	    xfce_dialog_show_error (NULL, error, "%s", _("Devicekit-power version 011 or above not found"));
+	    xfconf_channel_set_bool (channel, PROPERTIES_PREFIX "show-dkp-version-error", FALSE);
+	    g_free (message);
+	    g_error_free (error);
+	}
+	
+	g_error (_("Devicekit-power version 011 or above not found"));
+    }
+out:
+    ;
+}
+
 /*
  * Get the properties on org.freedesktop.DeviceKit.Power
  * 
@@ -263,20 +324,12 @@ xfpm_dkp_get_properties (XfpmDkp *dkp)
     xfpm_dkp_check_pm (dkp, props);
     xfpm_dkp_check_lid (dkp, props);
     xfpm_dkp_check_power (dkp, props);
-    /*
+
     if ( dkp->priv->daemon_version == NULL )
     {
-	value = g_hash_table_lookup (props, "DaemonVersion");
-    
-	if (value == NULL) 
-	{
-	    g_warning ("No 'DaemonVersion' property");
-	    goto out;
-	}
-	//FIXME: Check daemon version
-	client->priv->daemon_version = g_strdup (g_value_get_string (value));
+	xfpm_dkp_check_daemon_version (dkp, props);
     }
-    */
+out:
     g_hash_table_destroy (props);
 }
 
@@ -1268,6 +1321,8 @@ xfpm_dkp_finalize (GObject *object)
 
     dkp = XFPM_DKP (object);
     
+    g_free (dkp->priv->daemon_version);
+    
     g_object_unref (dkp->priv->inhibit);
     g_object_unref (dkp->priv->notify);
     g_object_unref (dkp->priv->conf);
diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
index e1b8366..3ac3a46 100644
--- a/src/xfpm-xfconf.c
+++ b/src/xfpm-xfconf.c
@@ -29,8 +29,6 @@
 #include <glib.h>
 #include <libxfce4util/libxfce4util.h>
 
-#include <xfconf/xfconf.h>
-
 #include "xfpm-xfconf.h"
 #include "xfpm-config.h"
 #include "xfpm-enum-glib.h"
@@ -578,3 +576,8 @@ xfpm_xfconf_new (void)
     }
     return XFPM_XFCONF (xfpm_xfconf_object);
 }
+
+XfconfChannel *xfpm_xfconf_get_channel (XfpmXfconf *conf)
+{
+    return conf->priv->channel;
+}
diff --git a/src/xfpm-xfconf.h b/src/xfpm-xfconf.h
index 1fb4af1..15eccc5 100644
--- a/src/xfpm-xfconf.h
+++ b/src/xfpm-xfconf.h
@@ -22,6 +22,7 @@
 #define __XFPM_XFCONF_H
 
 #include <glib-object.h>
+#include <xfconf/xfconf.h>
 
 G_BEGIN_DECLS
 
@@ -48,6 +49,8 @@ GType        		  xfpm_xfconf_get_type           	(void) G_GNUC_CONST;
 
 XfpmXfconf       	 *xfpm_xfconf_new                 	(void);
 
+XfconfChannel 		 *xfpm_xfconf_get_channel		(XfpmXfconf *conf);
+
 G_END_DECLS
 
 #endif /* __XFPM_XFCONF_H */



More information about the Xfce4-commits mailing list