Hello community,
here is the log from the commit of package wmpowersave
checked in at Sat Oct 14 19:27:34 CEST 2006.
--------
--- arch/i386/wmpowersave/wmpowersave.changes 2006-09-19 15:47:18.000000000 +0200
+++ /mounts/work_src_done/STABLE/wmpowersave/wmpowersave.changes 2006-10-14 12:49:09.000000000 +0200
@@ -1,0 +2,8 @@
+Fri Oct 13 16:49:18 CEST 2006 - hmacht@suse.de
+
+- remove dependency to powersave_dbus library
+- remove generic D-Bus functions, use liblazy instead
+- remove dependency to libpolkit, use liblazy instead
+- define own battery limits
+
+-------------------------------------------------------------------
Old:
----
wmpowersave-0.2.7.tar.bz2
New:
----
wmpowersave-0.2.8.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ wmpowersave.spec ++++++
--- /var/tmp/diff_new_pack.laZgHB/_old 2006-10-14 19:27:19.000000000 +0200
+++ /var/tmp/diff_new_pack.laZgHB/_new 2006-10-14 19:27:19.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package wmpowersave (Version 0.2.7)
+# spec file for package wmpowersave (Version 0.2.8)
#
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -11,9 +11,9 @@
# norootforbuild
Name: wmpowersave
-BuildRequires: WindowMaker-devel hal-devel powersave-devel xorg-x11
+BuildRequires: WindowMaker-devel dbus-1-glib-devel liblazy powersave-devel xorg-x11
URL: ftp://ftp.suse.com/pub/people/seife/powersave
-Version: 0.2.7
+Version: 0.2.8
Release: 1
Summary: DockApp GUI frontend for powersave
License: GPL
@@ -56,6 +56,11 @@
/usr/share/icons/wmpowersave
%changelog -n wmpowersave
+* Fri Oct 13 2006 - hmacht@suse.de
+- remove dependency to powersave_dbus library
+- remove generic D-Bus functions, use liblazy instead
+- remove dependency to libpolkit, use liblazy instead
+- define own battery limits
* Tue Sep 19 2006 - hmacht@suse.de
- remove some dependencies to powersave:
use brightness methods from HAL
++++++ wmpowersave-0.2.7.tar.bz2 -> wmpowersave-0.2.8.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/wmpowersave-0.2.7/configure new/wmpowersave-0.2.8/configure
--- old/wmpowersave-0.2.7/configure 2006-09-19 15:45:27.000000000 +0200
+++ new/wmpowersave-0.2.8/configure 2006-10-14 12:35:27.000000000 +0200
@@ -3156,7 +3156,7 @@
GLIB_REQUIRED=2.0.3
-pkg_modules="glib-2.0 >= 2.2.2, dbus-1 >= 0.33, dbus-glib-1 >= 0.33, polkit >= 0.2_git20060822"
+pkg_modules="glib-2.0 >= 2.2.2, dbus-1 >= 0.33, dbus-glib-1 >= 0.33, powersave >= 0.15.3"
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
@@ -4359,13 +4359,13 @@
fi
-{ echo "$as_me:$LINENO: checking for dbusSendSimpleMessage in -lpowersave_dbus" >&5
-echo $ECHO_N "checking for dbusSendSimpleMessage in -lpowersave_dbus... $ECHO_C" >&6; }
-if test "${ac_cv_lib_powersave_dbus_dbusSendSimpleMessage+set}" = set; then
+{ echo "$as_me:$LINENO: checking for liblazy_dbus_system_send_method_call in -llazy" >&5
+echo $ECHO_N "checking for liblazy_dbus_system_send_method_call in -llazy... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lazy_liblazy_dbus_system_send_method_call+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpowersave_dbus $LIBS"
+LIBS="-llazy $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -4379,11 +4379,11 @@
#ifdef __cplusplus
extern "C"
#endif
-char dbusSendSimpleMessage ();
+char liblazy_dbus_system_send_method_call ();
int
main ()
{
-return dbusSendSimpleMessage ();
+return liblazy_dbus_system_send_method_call ();
;
return 0;
}
@@ -4422,287 +4422,26 @@
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_lib_powersave_dbus_dbusSendSimpleMessage=yes
+ ac_cv_lib_lazy_liblazy_dbus_system_send_method_call=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_powersave_dbus_dbusSendSimpleMessage=no
+ ac_cv_lib_lazy_liblazy_dbus_system_send_method_call=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_powersave_dbus_dbusSendSimpleMessage" >&5
-echo "${ECHO_T}$ac_cv_lib_powersave_dbus_dbusSendSimpleMessage" >&6; }
-if test $ac_cv_lib_powersave_dbus_dbusSendSimpleMessage = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lazy_liblazy_dbus_system_send_method_call" >&5
+echo "${ECHO_T}$ac_cv_lib_lazy_liblazy_dbus_system_send_method_call" >&6; }
+if test $ac_cv_lib_lazy_liblazy_dbus_system_send_method_call = yes; then
cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPOWERSAVE_DBUS 1
+#define HAVE_LIBLAZY 1
_ACEOF
- LIBS="-lpowersave_dbus $LIBS"
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for checkACPI in -lpowersave" >&5
-echo $ECHO_N "checking for checkACPI in -lpowersave... $ECHO_C" >&6; }
-if test "${ac_cv_lib_powersave_checkACPI+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpowersave $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char checkACPI ();
-int
-main ()
-{
-return checkACPI ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_powersave_checkACPI=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_powersave_checkACPI=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_powersave_checkACPI" >&5
-echo "${ECHO_T}$ac_cv_lib_powersave_checkACPI" >&6; }
-if test $ac_cv_lib_powersave_checkACPI = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPOWERSAVE 1
-_ACEOF
-
- LIBS="-lpowersave $LIBS"
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for send_Action in -lpowersave_daemon" >&5
-echo $ECHO_N "checking for send_Action in -lpowersave_daemon... $ECHO_C" >&6; }
-if test "${ac_cv_lib_powersave_daemon_send_Action+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpowersave_daemon $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char send_Action ();
-int
-main ()
-{
-return send_Action ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_powersave_daemon_send_Action=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_powersave_daemon_send_Action=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_powersave_daemon_send_Action" >&5
-echo "${ECHO_T}$ac_cv_lib_powersave_daemon_send_Action" >&6; }
-if test $ac_cv_lib_powersave_daemon_send_Action = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPOWERSAVE_DAEMON 1
-_ACEOF
-
- LIBS="-lpowersave_daemon $LIBS"
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for dbusSendSimpleMessage in -lpowersave_dbus" >&5
-echo $ECHO_N "checking for dbusSendSimpleMessage in -lpowersave_dbus... $ECHO_C" >&6; }
-if test "${ac_cv_lib_powersave_dbus_dbusSendSimpleMessage+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpowersave_dbus $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dbusSendSimpleMessage ();
-int
-main ()
-{
-return dbusSendSimpleMessage ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_powersave_dbus_dbusSendSimpleMessage=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_powersave_dbus_dbusSendSimpleMessage=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_powersave_dbus_dbusSendSimpleMessage" >&5
-echo "${ECHO_T}$ac_cv_lib_powersave_dbus_dbusSendSimpleMessage" >&6; }
-if test $ac_cv_lib_powersave_dbus_dbusSendSimpleMessage = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPOWERSAVE_DBUS 1
-_ACEOF
-
- LIBS="-lpowersave_dbus $LIBS"
+ LIBS="-llazy $LIBS"
fi
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/wmpowersave-0.2.7/configure.in new/wmpowersave-0.2.8/configure.in
--- old/wmpowersave-0.2.7/configure.in 2006-09-19 15:45:27.000000000 +0200
+++ new/wmpowersave-0.2.8/configure.in 2006-10-14 12:35:27.000000000 +0200
@@ -12,7 +12,7 @@
GLIB_REQUIRED=2.0.3
AC_SUBST(GLIB_REQUIRED)
-pkg_modules="glib-2.0 >= 2.2.2, dbus-1 >= 0.33, dbus-glib-1 >= 0.33, polkit >= 0.2_git20060822"
+pkg_modules="glib-2.0 >= 2.2.2, dbus-1 >= 0.33, dbus-glib-1 >= 0.33, powersave >= 0.15.3"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS)
@@ -35,10 +35,7 @@
dnl AC_CHECK_LIB(apm, apm_read)
AC_CHECK_LIB(m, roundf)
AC_CHECK_LIB(dbus-1, dbus_error_init)
-AC_CHECK_LIB(powersave_dbus, dbusSendSimpleMessage)
-AC_CHECK_LIB(powersave, checkACPI)
-AC_CHECK_LIB(powersave_daemon, send_Action)
-AC_CHECK_LIB(powersave_dbus, dbusSendSimpleMessage)
+AC_CHECK_LIB(lazy, liblazy_dbus_system_send_method_call)
dnl Checks for header files.
AC_HEADER_STDC
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/wmpowersave-0.2.7/wmpowersave.c new/wmpowersave-0.2.8/wmpowersave.c
--- old/wmpowersave-0.2.7/wmpowersave.c 2006-09-19 15:45:27.000000000 +0200
+++ new/wmpowersave-0.2.8/wmpowersave.c 2006-10-14 12:35:27.000000000 +0200
@@ -19,11 +19,10 @@
#include
#include
-#include
+#include
#include
#include
#include
-#include
#define POLKIT_CPUFREQ_PRIVILEGE "hal-power-cpufreq"
#define POLKIT_SUSPEND_TO_DISK_PRIVILEGE "hal-power-hibernate"
@@ -35,6 +34,10 @@
#define HAL_UDI_COMPUTER "/org/freedesktop/Hal/devices/computer"
#define HAL_DEVICE_LAPTOP_PANEL "org.freedesktop.Hal.Device.LaptopPanel"
+#define BATTERY_LIMIT_WARNING 12
+#define BATTERY_LIMIT_LOW 7
+#define BATTERY_LIMIT_CRITICAL 2
+
#ifdef HAVE_GETOPT_H
#include
#endif
@@ -71,160 +74,6 @@
DBusHandlerResult filter_function (DBusConnection *, DBusMessage *, void *);
-static int sendMethodCall(const char *interface, const char *path,
- const char *object, const char *method,
- int first_arg_type, ...)
-{
- DBusConnection *connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-
- if (connection == NULL) {
- pDebug(DBG_INFO, "Connection to dbus not ready, skipping method call %s",
- method);
- return -1;
- }
-
- DBusError dbus_error;
- DBusMessage *message;
- DBusMessage *reply;
- va_list var_args;
-
- dbus_error_init(&dbus_error);
-
- message = dbus_message_new_method_call( interface, path, object, method );
-
- va_start(var_args, first_arg_type);
- dbus_message_append_args_valist(message, first_arg_type, var_args);
- va_end(var_args);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message, -1, &dbus_error);
-
- if (dbus_error_is_set(&dbus_error)) {
- pDebug (DBG_ERR, "Could not send method call: %s\n", dbus_error.message);
- dbus_message_unref(message);
- dbus_error_free(&dbus_error);
- return -1;
- }
-
- dbus_message_unref(message);
- dbus_message_unref(reply);
- dbus_connection_flush(connection);
-
- return 0;
-}
-
-static int sendMethodCallWithReturn(const char *interface, const char *path,
- const char *object ,const char *method,
- int arg_type, void *value)
-{
- DBusConnection *connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-
- if (connection == NULL) {
- pDebug(DBG_INFO, "Connection to dbus not ready, skipping method call %s",
- method);
- return -1;
- }
-
- DBusMessage *message;
- DBusError dbus_error;
- DBusMessage *reply;
-
- dbus_error_init(&dbus_error);
-
- message = dbus_message_new_method_call(interface, path, object, method);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message, -1, &dbus_error);
- if (dbus_error_is_set(&dbus_error)) {
- pDebug (DBG_WARN, "Could not send method call to D-BUS system bus: %s\n",
- dbus_error.message);
- goto Error;
- }
-
- if (!dbus_message_get_args(reply, &dbus_error, arg_type, value, DBUS_TYPE_INVALID)){
- if (dbus_error_is_set(&dbus_error))
- pDebug(DBG_WARN, "Could not get argument from reply: %s",
- dbus_error.message);
- goto NoReply;
- }
-
- dbus_connection_flush(connection);
- return 0;
-
-NoReply:
- dbus_message_unref(reply);
-Error:
- dbus_message_unref(message);
- dbus_error_free(&dbus_error);
-
- return -1;
-}
-
-/** checks if caller of message possesses the CPUFREQ_POLKIT_PRIVILGE */
-static gboolean dbus_is_privileged(char *privilege)
-{
- LibPolKitContext *polctx = NULL;
- char *caller_unix_user_str;
- const char *caller_dbus_name;
- unsigned long caller_unix_user;
- gboolean out_is_allowed;
- gboolean out_is_temporary;
- LibPolKitResult res;
- DBusConnection *connection;
- DBusError error;
-
- dbus_error_init(&error);
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (dbus_error_is_set(&error)) {
- fprintf(stderr, "Cannot get connection to system bus: %s\n", error.message);
- dbus_error_free(&error);
- return FALSE;
- }
-
- polctx = libpolkit_new_context(connection);
- if (polctx == NULL) {
- fprintf(stderr, "Cannot get PolicyKit context\n");
- return FALSE;
- }
-
- caller_dbus_name = dbus_bus_get_unique_name(connection);
- caller_unix_user = dbus_bus_get_unix_user(connection, caller_dbus_name, &error);
- printf("Connection name of caller: %s\n", caller_dbus_name);
- printf("Unix user id of caller: %ld\n", caller_unix_user);
- if (dbus_error_is_set(&error)) {
- fprintf(stderr, "Cannot get unix user of caller");
- dbus_error_free(&error);
- goto Error;
- }
-
- caller_unix_user_str = g_strdup_printf("%ld", caller_unix_user);
- res = libpolkit_is_uid_allowed_for_privilege(polctx,
- caller_dbus_name,
- caller_unix_user_str,
- privilege,
- getenv("UDI"),
- &out_is_allowed,
- &out_is_temporary,
- NULL);
- g_free(caller_unix_user_str);
-
- if (res != LIBPOLKIT_RESULT_OK) {
- fprintf(stderr, "Cannot lookup privilege: %d\n", res);
- goto Error;
- }
-
- if (!out_is_allowed) {
- printf(("caller don't possess privilege\n"));
- fprintf(stderr, "%s refused uid %lu\n", privilege, caller_unix_user);
- goto Error;
- }
-
- printf("Caller is privileged for %s\n", privilege);
- return out_is_allowed;
-
-Error:
- libpolkit_free_context(polctx);
- return FALSE;
-}
void error(const char *fmt, ...) {
va_list arglist;
@@ -506,9 +355,6 @@
case SCHEME_ACOUSTIC:
draw_image(ACOUSTIC);
break;
- case SCHEME_PRESENTATION:
- draw_image(PRESENTATION);
- break;
case SCHEME_POWERSAVE:
draw_image(POWERSAVE);
break;
@@ -658,40 +504,22 @@
}
int get_battery_status(){
- DBusMessage *reply;
- char *state;
int ret = -1;
+ BatteryGeneral bg;
- ret = dbusSendSimpleMessageWithReply( REQUEST_MESSAGE,
- &reply,
- "BatteryState" );
-
- if ( ret != REPLY_SUCCESS ) {
- return -1;
- }
-
-
+ if (getBatteriesInfo(&bg) < 0)
+ return BATTERY_STATUS_UNKNOWN;
- if ( !dbusGetMessageString( reply, &state, 0 ) ) {
- if ( !strcmp( state, "normal" ) )
- ret = BATTERY_STATUS_NORMAL;
- else if ( !strcmp( state, "low" ) )
- ret = BATTERY_STATUS_LOW;
- else if ( !strcmp( state, "warning" ) )
- ret = BATTERY_STATUS_WARNING;
- else if ( !strcmp( state, "critical" ) )
- ret = BATTERY_STATUS_CRITICAL;
- else if ( !strcmp( state, "no battery" ) )
- ret = BATTERY_STATUS_ABSENT;
- else
- ret = BATTERY_STATUS_UNKNOWN;
+ if (bg.remaining_percent <= BATTERY_LIMIT_CRITICAL)
+ ret = BATTERY_STATUS_CRITICAL;
+ else if (bg.remaining_percent <= BATTERY_LIMIT_LOW)
+ ret = BATTERY_STATUS_LOW;
+ else if (bg.remaining_percent <= BATTERY_LIMIT_WARNING)
+ ret = BATTERY_STATUS_WARNING;
+ else
+ ret = BATTERY_STATUS_UNKNOWN;
- dbus_message_unref( reply );
- return ret;
- }
- else {
- return -1;
- }
+ return ret;
}
int get_battery_percentage(){
@@ -714,33 +542,38 @@
int get_ps_cpufreq() {
char *governor = NULL;
- int ret = -1;
+ DBusMessage *reply = NULL;
- if (!dbus_is_privileged(POLKIT_CPUFREQ_PRIVILEGE))
- return ret;
+ if (liblazy_polkit_is_user_allowed_by_uid(getuid(), "hal-power-cpufreq", NULL) != 1) {
+ fprintf(stderr, "Caller doesn't possess privilege hal-power-cpufreq\n");
+ return -1;
+ }
- if (sendMethodCallWithReturn(DBUS_HAL_INTERFACE,
- HAL_UDI_COMPUTER,
- DBUS_HAL_CPUFREQ_INTERFACE,
- "GetCPUFreqGovernor",
- DBUS_TYPE_STRING,
- &governor)) {
+ if (liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE,
+ HAL_UDI_COMPUTER,
+ DBUS_HAL_CPUFREQ_INTERFACE,
+ "GetCPUFreqGovernor",
+ &reply,
+ DBUS_TYPE_INVALID)) {
fprintf(stderr, "Could not get current CPUFreq policy.\n");
- ret = -1;
- } else if (governor != NULL) {
+ return -1;
+ }
+
+ liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_STRING, &governor, 0);
+ if (governor != NULL) {
+ printf("gov: %s\n", governor);
if (!strcmp(governor, "ondemand") || !strcmp(governor, "userspace"))
- ret = PS_CPU_AUTO;
+ return PS_CPU_AUTO;
else if (!strcmp(governor, "powersave"))
- ret = PS_CPU_LOW;
+ return PS_CPU_LOW;
else if (!strcmp(governor, "performance"))
- ret = PS_CPU_HIGH;
+ return PS_CPU_HIGH;
else
- ret = -1;
+ return -1;
} else {
- ret = -1;
fprintf(stderr, "governor is NULL\n");
+ return -1;
}
- return ret;
}
int get_ac_line_status(){
@@ -765,13 +598,17 @@
int get_ps_capability() {
int ps_capability = 0;
- if (!dbus_is_privileged(POLKIT_SUSPEND_TO_DISK_PRIVILEGE))
+ if (liblazy_polkit_is_user_allowed_by_uid(getuid(),
+ POLKIT_SUSPEND_TO_DISK_PRIVILEGE,
+ NULL) != 1)
fprintf(stderr, "Caller doesn't possess privilege %s\n", POLKIT_SUSPEND_TO_DISK_PRIVILEGE);
else
ps_capability |= PS_SUSP_TO_DISK_ENA;
- if (!dbus_is_privileged(POLKIT_SUSPEND_TO_RAM_PRIVILEGE))
+ if (liblazy_polkit_is_user_allowed_by_uid(getuid(),
+ POLKIT_SUSPEND_TO_RAM_PRIVILEGE,
+ NULL) != 1)
fprintf(stderr, "Caller doesn't possess privilege %s\n", POLKIT_SUSPEND_TO_RAM_PRIVILEGE);
else
ps_capability |= PS_SUSP_TO_RAM_ENA;
@@ -785,16 +622,20 @@
char *scheme;
int ret = -1;
- ret = dbusSendSimpleMessageWithReply(REQUEST_MESSAGE,
- &reply,
- "SchemesGet");
-
+ ret = liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesGet",
+ &reply,
+ DBUS_TYPE_INVALID);
+ liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_UINT16, &ret, 0);
if (ret != REPLY_SUCCESS){
return 0;
}
- if ( !dbusGetMessageInteger( reply, &active, 0 ) ) {
- if ( !dbusGetMessageString( reply, &scheme, active ) ) {
+ if ( !liblazy_dbus_message_get_basic_arg( reply, DBUS_TYPE_INT32, &active, 0 ) ) {
+ if ( !liblazy_dbus_message_get_basic_arg( reply, DBUS_TYPE_STRING, &scheme, active ) ) {
+ printf("sceme: %s\n", scheme);
if ( !strcmp( scheme, "Acoustic" ) ) {
ret = SCHEME_ACOUSTIC;
}
@@ -804,9 +645,6 @@
else if ( !strcmp( scheme, "Powersave" ) ) {
ret = SCHEME_POWERSAVE;
}
- else if ( !strcmp( scheme, "Presentation" ) ) {
- ret = SCHEME_PRESENTATION;
- }
else {
ret = -1;
}
@@ -827,10 +665,13 @@
int ret = -1;
DBusMessage *reply;
- ret = dbusSendMessageWithReply( REQUEST_MESSAGE,
- &reply,
- "SchemesGet",
- DBUS_TYPE_INVALID );
+ ret = liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesGet",
+ &reply,
+ DBUS_TYPE_INVALID);
+ liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_UINT16, &ret, 0);
if ( ret != REPLY_SUCCESS ) {
return -1;
@@ -840,15 +681,16 @@
int battery_scheme;
int ac_scheme;
- if ( dbusGetMessageInteger(reply, ¤t_scheme, 0)
- || dbusGetMessageInteger(reply, &battery_scheme, 1)
- || dbusGetMessageInteger(reply, &ac_scheme, 2)) {
+ if (liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_STRING, ¤t_scheme, 0)
+ || liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_INT32, &battery_scheme, 1)
+ || liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_INT32, &ac_scheme, 2)) {
dbus_message_unref( reply );
ret = -1;
}
- if ( dbusGetMessageString( reply, &info->ac_scheme, ac_scheme ) < 0
- || dbusGetMessageString( reply, &info->battery_scheme, battery_scheme ) < 0 ) {
+ if ( liblazy_dbus_message_get_basic_arg( reply, DBUS_TYPE_STRING, &info->ac_scheme, ac_scheme ) < 0
+ || liblazy_dbus_message_get_basic_arg( reply, DBUS_TYPE_STRING, &info->battery_scheme,
+ battery_scheme ) < 0 ) {
ret = -1;
}
@@ -860,8 +702,14 @@
int powersave_read (powersave_info *info) {
- int ret = dbusSendSimpleMessage( ACTION_MESSAGE,
- "Ping" );
+ DBusMessage *reply;
+ int ret = liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "Ping",
+ &reply,
+ DBUS_TYPE_INVALID);
+ liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_UINT16, &ret, 0);
if ( ret != REPLY_SUCCESS ) {
info->battery_status = REPLY_HW_NOT_SUPPORTED;
@@ -945,26 +793,28 @@
break;
}
- if (sendMethodCall(DBUS_HAL_INTERFACE,
- HAL_UDI_COMPUTER,
- DBUS_HAL_CPUFREQ_INTERFACE,
- "SetCPUFreqGovernor",
- DBUS_TYPE_STRING,
- &governor,
- DBUS_TYPE_INVALID)) {
+ if (liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE,
+ HAL_UDI_COMPUTER,
+ DBUS_HAL_CPUFREQ_INTERFACE,
+ "SetCPUFreqGovernor",
+ NULL,
+ DBUS_TYPE_STRING,
+ &governor,
+ DBUS_TYPE_INVALID)) {
/* try userspace if ondemand does not work */
if (!strcmp(governor,"ondemand")) {
printf("Kernel ondemand governor not working, "
"trying userspace instead\n");
strcpy(governor, "userspace");
- if (sendMethodCall(DBUS_HAL_INTERFACE,
- HAL_UDI_COMPUTER,
- DBUS_HAL_CPUFREQ_INTERFACE,
- "SetCPUFreqGovernor",
- DBUS_TYPE_STRING,
- &governor,
- DBUS_TYPE_INVALID)) {
+ if (liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE,
+ HAL_UDI_COMPUTER,
+ DBUS_HAL_CPUFREQ_INTERFACE,
+ "SetCPUFreqGovernor",
+ NULL,
+ DBUS_TYPE_STRING,
+ &governor,
+ DBUS_TYPE_INVALID)) {
printf("Neither ondemand nor userspace governor working\n");
} else
printf("CPUFreq policy set\n");
@@ -978,77 +828,83 @@
break;
}
case ARROW_RIGHT:
+ printf("arrao right: %s, %s\n", cur_info.battery_scheme, cur_info.ac_scheme);
switch (cur_info.current_scheme) {
case SCHEME_PERFORMANCE: {
char *scheme = "Acoustic";
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &scheme,
- DBUS_TYPE_INVALID);
+ liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesSet",
+ NULL,
+ DBUS_TYPE_STRING,
+ &scheme,
+ DBUS_TYPE_INVALID);
break;
}
case SCHEME_ACOUSTIC: {
- char *scheme = "Presentation";
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &scheme,
- DBUS_TYPE_INVALID);
+ liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesSet",
+ NULL,
+ DBUS_TYPE_STRING,
+ &(cur_info.battery_scheme),
+ DBUS_TYPE_INVALID);
+ printf("set scheme %s\n", cur_info.battery_scheme);
break;
}
- case SCHEME_PRESENTATION:
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &(cur_info.battery_scheme),
- DBUS_TYPE_INVALID);
- break;
- case SCHEME_POWERSAVE:
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &(cur_info.ac_scheme),
- DBUS_TYPE_INVALID);
+ case SCHEME_POWERSAVE: {
+ liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesSet",
+ NULL,
+ DBUS_TYPE_STRING,
+ &(cur_info.ac_scheme),
+ DBUS_TYPE_INVALID);
break;
}
+ }
break;
case ARROW_LEFT:
switch (cur_info.current_scheme) {
- case SCHEME_PERFORMANCE:
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &(cur_info.battery_scheme),
- DBUS_TYPE_INVALID);
- break;
- case SCHEME_ACOUSTIC:
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &(cur_info.ac_scheme),
- DBUS_TYPE_INVALID);
- break;
- case SCHEME_PRESENTATION: {
+ case SCHEME_PERFORMANCE: {
char *scheme = "Acoustic";
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &scheme,
- DBUS_TYPE_INVALID);
+ liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesSet",
+ NULL,
+ DBUS_TYPE_STRING,
+ &scheme,
+ DBUS_TYPE_INVALID);
break;
}
+ case SCHEME_ACOUSTIC:
+ liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesSet",
+ NULL,
+ DBUS_TYPE_STRING,
+ &(cur_info.ac_scheme),
+ DBUS_TYPE_INVALID);
+ break;
case SCHEME_POWERSAVE: {
- char *scheme = "Presentation";
- dbusSendMessage(ACTION_MESSAGE,
- "SchemesSet",
- DBUS_TYPE_STRING,
- &scheme,
- DBUS_TYPE_INVALID);
+ char *scheme = "Performance";
+ liblazy_dbus_system_send_method_call(PS_DBUS_SERVICE,
+ PS_DBUS_PATH,
+ PS_DBUS_INTERFACE,
+ "SchemesSet",
+ NULL,
+ DBUS_TYPE_STRING,
+ &scheme,
+ DBUS_TYPE_INVALID);
break;
}
- break;
}
+ break;
}}
case Button2:
button = whichButton(ev.xbutton.x, ev.xbutton.y);
@@ -1056,11 +912,13 @@
if ( pressed2 == button) {
switch (pressed2) {
case SUSP_TO_DISK:
- if (sendMethodCall(DBUS_HAL_INTERFACE,
- HAL_UDI_COMPUTER,
- DBUS_HAL_SYSTEM_POWER_INTERFACE,
- "Hibernate",
- DBUS_TYPE_INVALID)) {
+ if (liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE,
+ HAL_UDI_COMPUTER,
+ DBUS_HAL_SYSTEM_POWER_INTERFACE,
+ "Hibernate",
+ NULL,
+ DBUS_TYPE_INVALID)) {
+
fprintf(stderr, "Could not send suspend to disk request to HAL\n");
} else
printf("Suspend to disk request sent.\n");
@@ -1068,10 +926,11 @@
break;
case SUSP_TO_RAM: {
int wake_up = 0;
- if (sendMethodCall(DBUS_HAL_INTERFACE,
+ if (liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE,
HAL_UDI_COMPUTER,
DBUS_HAL_SYSTEM_POWER_INTERFACE,
"Suspend",
+ NULL,
DBUS_TYPE_INT32,
&wake_up,
DBUS_TYPE_INVALID)) {
@@ -1142,6 +1001,11 @@
"interface='com.novell.powersave.manager',"
"path='/com/novell/powersave',", NULL);
+ dbus_bus_add_match(connection,
+ "type='signal',"
+ "interface=org.freedesktop.Hal.Device,"
+ "member=PropertyModified", NULL);
+
make_window(parse_commandline(argc, argv), argc ,argv);
load_images();
@@ -1169,18 +1033,21 @@
DBusError error;
dbus_error_init( &error );
+ const char *path;
if ( dbus_message_get_type( message ) != DBUS_MESSAGE_TYPE_SIGNAL ) {
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+ path = dbus_message_get_path(message);
+
/* the argument received */
char *value;
/* get the name of the signal */
const char *signal = dbus_message_get_member( message );
- if ( dbusGetMessageString( message, &value, 0 ) < 0 ) {
+ if (liblazy_dbus_message_get_basic_arg(message, DBUS_TYPE_STRING, &value, 0) < 0 ) {
printf( " Warning: Received signal %s, but no string argument\n",
error.message );
return DBUS_HANDLER_RESULT_HANDLED;
@@ -1193,6 +1060,10 @@
value );*/
return DBUS_HANDLER_RESULT_HANDLED;
}
+ else if ( ! strcmp( path, "/org/freedesktop/Hal/devices/acpi_AC") ) {
+ cur_info.ac_line_status = get_ac_line_status();
+ recalc_window(cur_info);
+ }
/* powersave event received */
else if ( ! strcmp( signal, "PowersaveEvent" ) ) {
// printf( "Received powersave event. Value: %s\n", value );
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/wmpowersave-0.2.7/wmpowersave.h new/wmpowersave-0.2.8/wmpowersave.h
--- old/wmpowersave-0.2.7/wmpowersave.h 2006-09-19 15:45:27.000000000 +0200
+++ new/wmpowersave-0.2.8/wmpowersave.h 2006-10-14 12:35:27.000000000 +0200
@@ -43,8 +43,7 @@
/* define the schemes */
#define SCHEME_PERFORMANCE (1)
#define SCHEME_ACOUSTIC (2)
-#define SCHEME_PRESENTATION (3)
-#define SCHEME_POWERSAVE (4)
+#define SCHEME_POWERSAVE (3)
typedef struct {
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org