[Xfce4-commits] <xfce4-power-manager:master> Okay, since udisks/upower both now have releases with no API break (in xfpm pov), i'm going to rely just on these two daemons, since having xfpm handling devkit/upower presence on runtime was a bad idea, because xfpm needs to be always connected to these daemons, so there is no easy way to do it.
Ali Abdallah
noreply at xfce.org
Thu Mar 18 11:16:01 CET 2010
Updating branch refs/heads/master
to 9e00d74faf9a7757adaf3a407977e1eccc539bb8 (commit)
from c15f43c16010d394c494d9fbe7136c1d12e62662 (commit)
commit 9e00d74faf9a7757adaf3a407977e1eccc539bb8
Author: Ali Abdallah <aliov at xfce.org>
Date: Thu Mar 18 11:07:40 2010 +0100
Okay, since udisks/upower both now have releases with no API break (in xfpm pov), i'm going
to rely just on these two daemons, since having xfpm handling devkit/upower presence on runtime
was a bad idea, because xfpm needs to be always connected to these daemons, so there is no easy way
to do it.
Xfpm, requires now upower and udisks in order to work, consolekit (optional) dependeny will be
removed also.
Hopefully things will go stable in the regard of upower/udisk, so we can finally concentrate on
usuability issues.
src/xfpm-disks.c | 34 ++---------
src/xfpm-power-common.h | 25 +++-----
src/xfpm-power-info.c | 69 ++++-----------------
src/xfpm-power.c | 153 ++++------------------------------------------
4 files changed, 40 insertions(+), 241 deletions(-)
diff --git a/src/xfpm-disks.c b/src/xfpm-disks.c
index 5fc31f4..3f9f986 100644
--- a/src/xfpm-disks.c
+++ b/src/xfpm-disks.c
@@ -51,9 +51,6 @@ struct XfpmDisksPrivate
gchar *cookie;
gboolean set;
gboolean can_spin;
-
-
- gboolean is_udisks;
};
G_DEFINE_TYPE (XfpmDisks, xfpm_disks, G_TYPE_OBJECT)
@@ -165,7 +162,7 @@ xfpm_disks_get_is_auth_to_spin (XfpmDisks *disks)
{
const gchar *action_id;
- action_id = disks->priv->is_udisks ? "org.freedesktop.udisks.drive-set-spindown" : "org.freedesktop.devicekit.disks.drive-set-spindown";
+ action_id = "org.freedesktop.udisks.drive-set-spindown";
disks->priv->can_spin = xfpm_polkit_check_auth (disks->priv->polkit,
action_id);
@@ -188,7 +185,6 @@ xfpm_disks_init (XfpmDisks *disks)
disks->priv->cookie = NULL;
disks->priv->polkit = NULL;
- disks->priv->is_udisks = FALSE;
disks->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -199,31 +195,11 @@ xfpm_disks_init (XfpmDisks *disks)
goto out;
}
- disks->priv->proxy = dbus_g_proxy_new_for_name_owner (disks->priv->bus,
- "org.freedesktop.UDisks",
- "/org/freedesktop/UDisks",
- "org.freedesktop.UDisks",
- NULL);
+ disks->priv->proxy = dbus_g_proxy_new_for_name (disks->priv->bus,
+ "org.freedesktop.UDisks",
+ "/org/freedesktop/UDisks",
+ "org.freedesktop.UDisks");
- if ( !disks->priv->proxy )
- {
- g_message ("UDisks not found, trying devkit-disks");
- disks->priv->proxy = dbus_g_proxy_new_for_name_owner (disks->priv->bus,
- "org.freedesktop.DeviceKit.Disks",
- "/org/freedesktop/DeviceKit/Disks",
- "org.freedesktop.DeviceKit.Disks",
- NULL);
- }
- else
- {
- disks->priv->is_udisks = TRUE;
- }
-
- if ( !disks->priv->proxy )
- {
- g_warning ("Unable to create proxy for 'org.freedesktop.DeviceKit.Disks'");
- goto out;
- }
disks->priv->conf = xfpm_xfconf_new ();
disks->priv->power = xfpm_power_get ();
diff --git a/src/xfpm-power-common.h b/src/xfpm-power-common.h
index 914441c..d5b5518 100644
--- a/src/xfpm-power-common.h
+++ b/src/xfpm-power-common.h
@@ -23,26 +23,19 @@
#include <dbus/dbus-glib.h>
-#define DKP_NAME "org.freedesktop.DeviceKit.Power"
-#define DKP_PATH "/org/freedesktop/DeviceKit/Power"
+#define UPOWER_NAME "org.freedesktop.UPower"
+#define UPOWER_PATH "/org/freedesktop/UPower"
-#define DKP_IFACE "org.freedesktop.DeviceKit.Power"
-#define DKP_IFACE_DEVICE "org.freedesktop.DeviceKit.Power.Device"
-#define DKP_PATH_DEVICE "/org/freedesktop/DeviceKit/Power/devices/"
+#define UPOWER_IFACE "org.freedesktop.UPower"
+#define UPOWER_IFACE_DEVICE "org.freedesktop.UPower.Device"
+#define UPOWER_PATH_DEVICE "/org/freedesktop/UPower/devices/"
-#define DKP_PATH_WAKEUPS "/org/freedesktop/DeviceKit/Power/Wakeups"
-#define DKP_IFACE_WAKEUPS "org.freedesktop.DeviceKit.Power.Wakeups"
+#define UPOWER_PATH_WAKEUPS "/org/freedesktop/UPower/Wakeups"
+#define UPOWER_IFACE_WAKEUPS "org.freedesktop.UPower.Wakeups"
+#define POLKIT_AUTH_SUSPEND "org.freedesktop.upower.suspend"
+#define POLKIT_AUTH_HIBERNATE "org.freedesktop.upower.hibernate"
-#define UPOWER_NAME "org.freedesktop.UPower"
-#define UPOWER_PATH "/org/freedesktop/UPower"
-
-#define UPOWER_IFACE "org.freedesktop.UPower"
-#define UPOWER_IFACE_DEVICE "org.freedesktop.UPower.Device"
-#define UPOWER_PATH_DEVICE "/org/freedesktop/UPower/devices/"
-
-#define UPOWER_PATH_WAKEUPS "/org/freedesktop/UPower/Wakeups"
-#define UPOWER_IFACE_WAKEUPS "org.freedesktop.UPower.Wakeups"
GPtrArray *xfpm_power_enumerate_devices (DBusGProxy *proxy);
diff --git a/src/xfpm-power-info.c b/src/xfpm-power-info.c
index cfd533c..b2f6ea2 100644
--- a/src/xfpm-power-info.c
+++ b/src/xfpm-power-info.c
@@ -46,14 +46,6 @@
#include "xfpm-unique.h"
-static const gchar *BACKEND_NAME;
-static const gchar *BACKEND_PATH;
-static const gchar *BACKEND_IFACE;
-static const gchar *BACKEND_IFACE_DEVICE;
-static const gchar *BACKEND_PATH_DEVICE;
-static const gchar *BACKEND_IFACE_WAKEUPS;
-static const gchar *BACKEND_PATH_WAKEUPS;
-
typedef struct
{
DBusGConnection *bus;
@@ -354,7 +346,7 @@ xfpm_info_add_device_view (XfpmInfo *info, GHashTable *props, const gchar *objec
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
XFPM_DEVICE_INFO_NAME, _("Device"),
- XFPM_DEVICE_INFO_VALUE, g_str_has_prefix (object_path, BACKEND_PATH_DEVICE) ? object_path + strlen (BACKEND_PATH_DEVICE) : object_path,
+ XFPM_DEVICE_INFO_VALUE, g_str_has_prefix (object_path, UPOWER_PATH_DEVICE) ? object_path + strlen (UPOWER_PATH_DEVICE) : object_path,
-1);
i++;
@@ -521,7 +513,7 @@ xfpm_info_add_device (XfpmInfo *info, const gchar *object_path)
GHashTable *props;
proxy_prop = dbus_g_proxy_new_for_name (info->bus,
- BACKEND_NAME,
+ UPOWER_NAME,
object_path,
DBUS_INTERFACE_PROPERTIES);
@@ -531,7 +523,7 @@ xfpm_info_add_device (XfpmInfo *info, const gchar *object_path)
return;
}
- props = xfpm_power_get_interface_properties (proxy_prop, BACKEND_IFACE_DEVICE);
+ props = xfpm_power_get_interface_properties (proxy_prop, UPOWER_IFACE_DEVICE);
if ( props )
{
@@ -548,48 +540,11 @@ xfpm_info_power_devices (XfpmInfo *info)
/*Check for upower/devkit power here*/
- info->power_proxy = dbus_g_proxy_new_for_name_owner (info->bus,
- UPOWER_NAME,
- UPOWER_PATH,
- UPOWER_IFACE,
- NULL);
+ info->power_proxy = dbus_g_proxy_new_for_name (info->bus,
+ UPOWER_NAME,
+ UPOWER_PATH,
+ UPOWER_IFACE);
- if ( info->power_proxy )
- {
- BACKEND_NAME = UPOWER_NAME;
- BACKEND_PATH = UPOWER_PATH;
- BACKEND_IFACE = UPOWER_IFACE;
- BACKEND_IFACE_DEVICE = UPOWER_IFACE_DEVICE;
- BACKEND_PATH_DEVICE = UPOWER_PATH_DEVICE;
- BACKEND_IFACE_WAKEUPS = UPOWER_IFACE_WAKEUPS;
- BACKEND_PATH_WAKEUPS = UPOWER_PATH_WAKEUPS;
- }
- else
- {
- g_message ("Unable to create proxy for UPower, trying DeviceKit Power...");
- info->power_proxy = dbus_g_proxy_new_for_name_owner (info->bus,
- DKP_NAME,
- DKP_PATH,
- DKP_IFACE,
- NULL);
- if ( info->power_proxy )
- {
- g_message ("Devkit Power found in the system");
-
- BACKEND_NAME = DKP_NAME;
- BACKEND_PATH = DKP_PATH;
- BACKEND_IFACE = DKP_IFACE;
- BACKEND_IFACE_DEVICE = DKP_IFACE_DEVICE;
- BACKEND_PATH_DEVICE = DKP_PATH_DEVICE;
- BACKEND_IFACE_WAKEUPS = DKP_IFACE_WAKEUPS;
- BACKEND_PATH_WAKEUPS = DKP_PATH_WAKEUPS;
- }
- else
- {
- g_error ("UPower and DevkitPower are not found");
- }
- }
-
array = xfpm_power_enumerate_devices (info->power_proxy);
if ( array )
@@ -652,7 +607,7 @@ xfpm_info_update_wakeups (XfpmInfo *info)
if ( !ret )
{
- g_warning ("GetData Failed on %s : %s", BACKEND_PATH_WAKEUPS, error->message);
+ g_warning ("GetData Failed on %s : %s", UPOWER_PATH_WAKEUPS, error->message);
g_error_free (error);
return;
}
@@ -753,13 +708,13 @@ xfpm_info_cpu_wakeups (XfpmInfo *info)
GtkCellRenderer *renderer;
info->wakeups_proxy = dbus_g_proxy_new_for_name (info->bus,
- BACKEND_NAME,
- BACKEND_PATH_WAKEUPS,
- BACKEND_IFACE_WAKEUPS);
+ UPOWER_NAME,
+ UPOWER_PATH_WAKEUPS,
+ UPOWER_IFACE_WAKEUPS);
if ( !info->wakeups_proxy )
{
- g_warning ("Unable to create proxy for %s", BACKEND_PATH_WAKEUPS);
+ g_warning ("Unable to create proxy for %s", UPOWER_PATH_WAKEUPS);
return;
}
diff --git a/src/xfpm-power.c b/src/xfpm-power.c
index 116f0f6..4bc31d1 100644
--- a/src/xfpm-power.c
+++ b/src/xfpm-power.c
@@ -50,17 +50,6 @@
#include "xfpm-debug.h"
#include "xfpm-enum-types.h"
-
-static const gchar *BACKEND_NAME;
-static const gchar *BACKEND_PATH;
-static const gchar *BACKEND_IFACE;
-static const gchar *BACKEND_IFACE_DEVICE;
-static const gchar *BACKEND_PATH_DEVICE;
-#ifdef ENABLE_POLKIT
-static const gchar *POLKIT_AUTH_SUSPEND;
-static const gchar *POLKIT_AUTH_HIBERNATE;
-#endif /*ENABLE_POLKIT*/
-
static void xfpm_power_finalize (GObject *object);
static void xfpm_power_get_property (GObject *object,
@@ -99,8 +88,6 @@ struct XfpmPowerPrivate
gboolean auth_suspend;
gboolean auth_hibernate;
- gboolean dkp_is_upower;
-
/* Properties */
gboolean on_low_battery;
gboolean lid_is_present;
@@ -264,70 +251,6 @@ xfpm_power_check_lid (XfpmPower *power, GHashTable *props)
}
}
-static void
-xfpm_power_check_daemon_version (XfpmPower *power, GHashTable *props)
-{
- GValue *value;
- gint power_version;
-
- if ( power->priv->dkp_is_upower)
- return;
-
- 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;
- }
- }
-
- power->priv->daemon_version = g_strdup (g_value_get_string (value));
- XFPM_DEBUG ("Dkp daemon version %s", power->priv->daemon_version);
- power_version = strtol (power->priv->daemon_version, NULL, 10);
-
- if ( power_version < 11)
- {
- XfconfChannel *channel;
- gboolean show_error;
-
- channel = xfpm_xfconf_get_channel (power->priv->conf);
-
- show_error = xfconf_channel_get_bool (channel, PROPERTIES_PREFIX "show-power-version-error", TRUE);
-
- XFPM_WARNING ("Dkp version %d is less than the required minimum version 011", power_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"),
- power->priv->daemon_version);
-
- g_set_error (&error, 0, 0, "%s", message);
- xfce_dialog_show_error (NULL, error, "%s", _("Devicekit-power version 011 or above not found"));
- xfconf_channel_set_bool (channel, PROPERTIES_PREFIX "show-power-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
*
@@ -344,16 +267,12 @@ xfpm_power_get_properties (XfpmPower *power)
{
GHashTable *props;
- props = xfpm_power_get_interface_properties (power->priv->proxy_prop, BACKEND_IFACE);
+ props = xfpm_power_get_interface_properties (power->priv->proxy_prop, UPOWER_IFACE);
xfpm_power_check_pm (power, props);
xfpm_power_check_lid (power, props);
xfpm_power_check_power (power, props);
- if ( power->priv->daemon_version == NULL )
- {
- xfpm_power_check_daemon_version (power, props);
- }
g_hash_table_destroy (props);
}
@@ -961,7 +880,7 @@ xfpm_power_add_device (XfpmPower *power, const gchar *object_path)
GValue value;
proxy_prop = dbus_g_proxy_new_for_name (power->priv->bus,
- BACKEND_NAME,
+ UPOWER_NAME,
object_path,
DBUS_INTERFACE_PROPERTIES);
@@ -971,7 +890,7 @@ xfpm_power_add_device (XfpmPower *power, const gchar *object_path)
return;
}
- value = xfpm_power_get_interface_property (proxy_prop, BACKEND_IFACE_DEVICE, "Type");
+ value = xfpm_power_get_interface_property (proxy_prop, UPOWER_IFACE_DEVICE, "Type");
device_type = g_value_get_uint (&value);
@@ -986,15 +905,15 @@ xfpm_power_add_device (XfpmPower *power, const gchar *object_path)
XFPM_DEBUG_ENUM (device_type, XFPM_TYPE_DEVICE_TYPE,
"Battery device detected at : %s", object_path);
proxy = dbus_g_proxy_new_for_name (power->priv->bus,
- BACKEND_NAME,
+ UPOWER_NAME,
object_path,
- BACKEND_IFACE_DEVICE);
+ UPOWER_IFACE_DEVICE);
battery = xfpm_battery_new ();
gtk_status_icon_set_visible (battery, FALSE);
xfpm_battery_monitor_device (XFPM_BATTERY (battery),
proxy,
proxy_prop,
- BACKEND_IFACE_DEVICE,
+ UPOWER_IFACE_DEVICE,
device_type);
g_hash_table_insert (power->priv->hash, g_strdup (object_path), battery);
@@ -1328,63 +1247,19 @@ xfpm_power_init (XfpmPower *power)
goto out;
}
- power->priv->proxy = dbus_g_proxy_new_for_name_owner (power->priv->bus,
- UPOWER_NAME,
- UPOWER_PATH,
- UPOWER_IFACE,
- NULL);
-
- if ( power->priv->proxy )
- {
- power->priv->dkp_is_upower = TRUE;
-
- BACKEND_NAME = UPOWER_NAME;
- BACKEND_PATH = UPOWER_PATH;
- BACKEND_IFACE = UPOWER_IFACE;
- BACKEND_IFACE_DEVICE = UPOWER_IFACE_DEVICE;
- BACKEND_PATH_DEVICE = UPOWER_PATH_DEVICE;
-#ifdef ENABLE_POLKIT
- POLKIT_AUTH_SUSPEND = "org.freedesktop.upower.suspend";
- POLKIT_AUTH_HIBERNATE = "org.freedesktop.upower.hibernate";
-#endif
- }
- else
- {
- g_message ("Unable to create proxy for UPower, trying DeviceKit Power...");
- power->priv->proxy = dbus_g_proxy_new_for_name_owner (power->priv->bus,
- DKP_NAME,
- DKP_PATH,
- DKP_IFACE,
- NULL);
- if ( power->priv->proxy )
- {
- g_message ("Devkit Power found in the system");
- power->priv->dkp_is_upower = FALSE;
-
- BACKEND_NAME = DKP_NAME;
- BACKEND_PATH = DKP_PATH;
- BACKEND_IFACE = DKP_IFACE;
- BACKEND_IFACE_DEVICE = DKP_IFACE_DEVICE;
- BACKEND_PATH_DEVICE = DKP_PATH_DEVICE;
-#ifdef ENABLE_POLKIT
- POLKIT_AUTH_SUSPEND = "org.freedesktop.devicekit.power.suspend";
- POLKIT_AUTH_HIBERNATE = "org.freedesktop.devicekit.power.hibernate";
-#endif
- }
- else
- {
- g_critical ("UPower and DevkitPower are not found");
- goto out;
- }
- }
+ power->priv->proxy = dbus_g_proxy_new_for_name (power->priv->bus,
+ UPOWER_NAME,
+ UPOWER_PATH,
+ UPOWER_IFACE);
+
power->priv->proxy_prop = dbus_g_proxy_new_for_name (power->priv->bus,
- BACKEND_NAME,
- BACKEND_PATH,
+ UPOWER_NAME,
+ UPOWER_PATH,
DBUS_INTERFACE_PROPERTIES);
if (power->priv->proxy_prop == NULL)
{
- g_critical ("Unable to create proxy for %s", BACKEND_NAME);
+ g_critical ("Unable to create proxy for %s", UPOWER_NAME);
goto out;
}
More information about the Xfce4-commits
mailing list