[Xfce4-commits] [xfce/xfce4-power-manager] 01/01: Fix issues with FreeBSD

noreply at xfce.org noreply at xfce.org
Fri Jun 6 19:03:17 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit adbd1eac38243cc7b678d095073fd573e1b31691
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Fri Jun 6 19:57:43 2014 +0300

    Fix issues with FreeBSD
    
    This loweres the minimum upower version to support FreeBSD 10 out
    of the box and fixes a couple other issues. The get_string_sysctl
    function came from:
    http://cgit.freedesktop.org/upower/tree/src/freebsd/up-util.c
---
 configure.ac.in    |    2 +-
 src/xfpm-power.c   |    7 +++++--
 src/xfpm-suspend.c |   36 +++++++++++++++++++++++++++++++++++-
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index c07dda1..beb52f6 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -67,7 +67,7 @@ m4_define([libxfce4util_minimum_version],[4.10.0])
 m4_define([libxfce4panel_minimum_version],[4.10.0])
 
 m4_define([libnotify_minimum_version], [0.4.1])
-m4_define([upower_minimum_version], [0.9.8])
+m4_define([upower_minimum_version], [0.9.7])
 m4_define([xrandr_minimum_version], [1.2.0])
 m4_define([x11_minimum_version], [1.0.0])
 
diff --git a/src/xfpm-power.c b/src/xfpm-power.c
index b42210b..515ee6e 100644
--- a/src/xfpm-power.c
+++ b/src/xfpm-power.c
@@ -81,7 +81,9 @@ static void xfpm_power_change_presentation_mode (XfpmPower *power,
 static void xfpm_power_dbus_class_init (XfpmPowerClass * klass);
 static void xfpm_power_dbus_init (XfpmPower *power);
 
+#if UP_CHECK_VERSION(0, 99, 0)
 static gboolean xfpm_power_prompt_password (XfpmPower *power);
+#endif
 
 #define XFPM_POWER_GET_PRIVATE(o) \
 (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_POWER, XfpmPowerPrivate))
@@ -1341,7 +1343,8 @@ xfpm_power_is_in_presentation_mode (XfpmPower *power)
     return power->priv->presentation_mode;
 }
 
-
+/* ifdef this out to prevent an unused function warning */
+#if UP_CHECK_VERSION(0, 99, 0)
 static gboolean
 xfpm_power_prompt_password (XfpmPower *power)
 {
@@ -1397,7 +1400,7 @@ xfpm_power_prompt_password (XfpmPower *power)
 
     return state == PASSWORD_FAILED ? FALSE : TRUE;
 }
-
+#endif
 
 
 /*
diff --git a/src/xfpm-suspend.c b/src/xfpm-suspend.c
index d398799..63f4bf6 100644
--- a/src/xfpm-suspend.c
+++ b/src/xfpm-suspend.c
@@ -34,6 +34,9 @@
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
+#ifdef HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -515,6 +518,37 @@ xfpm_suspend_sudo_get_state (XfpmSuspend *suspend)
 
 
 #ifdef BACKEND_TYPE_FREEBSD
+static gchar *
+get_string_sysctl (GError **err, const gchar *format, ...)
+{
+        va_list args;
+        gchar *name;
+        size_t value_len;
+        gchar *str = NULL;
+
+        g_return_val_if_fail(format != NULL, FALSE);
+
+        va_start (args, format);
+        name = g_strdup_vprintf (format, args);
+        va_end (args);
+
+        if (sysctlbyname (name, NULL, &value_len, NULL, 0) == 0) {
+                str = g_new (char, value_len + 1);
+                if (sysctlbyname (name, str, &value_len, NULL, 0) == 0)
+                        str[value_len] = 0;
+                else {
+                        g_free (str);
+                        str = NULL;
+                }
+        }
+
+        if (!str)
+                g_set_error (err, 0, 0, "%s", g_strerror(errno));
+
+        g_free(name);
+        return str;
+}
+
 static gboolean
 freebsd_supports_sleep_state (const gchar *state)
 {
@@ -523,7 +557,7 @@ freebsd_supports_sleep_state (const gchar *state)
 
     XFPM_DEBUG("entering");
 
-    sleep_states = up_get_string_sysctl (NULL, "hw.acpi.supported_sleep_state");
+    sleep_states = get_string_sysctl (NULL, "hw.acpi.supported_sleep_state");
     if (sleep_states != NULL) {
         if (strstr (sleep_states, state) != NULL)
             ret = TRUE;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list