--- configure.ac.orig 2008-09-02 10:41:15.259043058 +0800
+++ configure.ac 2008-09-02 10:44:45.388537982 +0800
@@ -173,10 +173,8 @@
AC_MSG_CHECKING([whether to support PolicyKit])
have_polkit=no
if test x$enable_policykit = xyes ; then
- PKG_CHECK_MODULES(POLKIT, \
- polkit-grant >= $POLKIT_GNOME_REQUIRED\
- polkit-dbus >= $POLKIT_GNOME_REQUIRED)
AC_SUBST(POLKIT_CFLAGS)
+ POLKIT_LIBS="-lpolkit"
AC_SUBST(POLKIT_LIBS)
have_polkit=yes
AC_DEFINE(HAVE_POLKIT, 1, [Define if we use PolicyKit])
--- src/gpm-control.c.orig 2008-08-07 16:37:43.708754311 +0800
+++ src/gpm-control.c 2008-08-07 16:35:33.465521458 +0800
@@ -45,9 +45,14 @@
#include <libhal-gpower.h>
#ifdef HAVE_POLKIT
+#if defined(sun) && defined(__SVR4)
+#include <libpolkit/libpolkit.h>
+#include <pwd.h>
+#else
#include <polkit/polkit.h>
#include <polkit-dbus/polkit-dbus.h>
#endif
+#endif
#include "gpm-conf.h"
#include "gpm-screensaver.h"
@@ -101,6 +106,53 @@
{
gboolean ret = TRUE;
#ifdef HAVE_POLKIT
+#if defined(sun) && defined(__SVR4)
+ DBusConnection *connection = NULL;
+ LibPolKitContext *ctx = NULL;
+ struct passwd *pw = NULL;
+ gchar *uid = NULL;
+ const gchar *bus_unique_name = NULL;
+ const gchar *user = g_get_user_name ();
+ const gchar *myresource = NULL;
+ gboolean out_is_allowed;
+ gboolean out_is_temporary;
+ DBusError error;
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ egg_warning ("Cannot connect to system message bus");
+ return FALSE;
+ }
+ ctx = libpolkit_new_context (connection);
+ if (ctx == NULL) {
+ egg_warning ("Cannot get libpolkit context");
+ return FALSE;
+ }
+ pw = getpwnam(user);
+ uid = g_strdup_printf ("%d", pw->pw_uid);
+
+ if (libpolkit_is_uid_allowed_for_privilege (ctx,
+ bus_unique_name,
+ uid,
+ privilege,
+ myresource,
+ &out_is_allowed,
+ &out_is_temporary,
+ NULL)
+ != LIBPOLKIT_RESULT_OK) {
+ /* abort as calling libpolkit failed */
+ egg_warning ("Cannot lookup privilege from libpolkit\n");
+ }
+
+ if (out_is_allowed == FALSE) {
+ egg_debug ("The user don't possess privilege \"%s\"\n", privilege);
+ ret = FALSE;
+ }
+ if (ctx != NULL)
+ libpolkit_free_context (ctx);
+ g_free (uid);
+#else
polkit_uint64_t mask;
pid_t pid;
@@ -111,6 +163,7 @@
ret = FALSE;
}
#endif
+#endif
return ret;
}
@@ -170,7 +223,7 @@
*can = FALSE;
gpm_conf_get_bool (control->priv->conf, GPM_CONF_CAN_SUSPEND, &conf_ok);
hal_ok = hal_gpower_can_suspend (control->priv->hal_power);
- polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.hal.power-management.suspend");
+ polkit_ok = gpm_control_is_user_privileged (control, "hal-power-suspend");
fg = gpm_control_check_foreground_console (control);
if (conf_ok && hal_ok && polkit_ok && fg) {
*can = TRUE;
@@ -202,7 +255,7 @@
gpm_conf_get_bool (control->priv->conf, GPM_CONF_CAN_HIBERNATE, &conf_ok);
hal_ok = hal_gpower_can_hibernate (control->priv->hal_power);
fg = gpm_control_check_foreground_console (control);
- polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.hal.power-management.hibernate");
+ polkit_ok = gpm_control_is_user_privileged (control, "hal-power-hibernate");
if (conf_ok && hal_ok && polkit_ok && fg) {
*can = TRUE;
}
@@ -225,7 +278,7 @@
g_return_val_if_fail (can, FALSE);
*can = FALSE;
fg = gpm_control_check_foreground_console (control);
- polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.hal.power-management.shutdown");
+ polkit_ok = gpm_control_is_user_privileged (control, "hal-power-shutdown");
if (polkit_ok && fg) {
*can = TRUE;
}
@@ -249,7 +302,7 @@
g_return_val_if_fail (can, FALSE);
*can = FALSE;
fg = gpm_control_check_foreground_console (control);
- polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.hal.power-management.reboot");
+ polkit_ok = gpm_control_is_user_privileged (control, "hal-power-reboot");
if (polkit_ok && fg) {
*can = TRUE;
}
--- src/gpm-prefs-core.c.orig 2008-08-07 16:38:34.536599701 +0800
+++ src/gpm-prefs-core.c 2008-08-07 16:35:33.455754124 +0800
@@ -44,6 +44,9 @@
#include "gpm-stock-icons.h"
#include "gpm-screensaver.h"
#include "gpm-prefs-server.h"
+#if defined(sun) && defined(__SVR4)
+#include "gpm-control.h"
+#endif
#ifdef HAVE_GCONF_DEFAULTS
#include <polkit-gnome/polkit-gnome.h>
@@ -67,6 +70,10 @@
gboolean can_shutdown;
gboolean can_suspend;
gboolean can_hibernate;
+#if defined(sun) && defined(__SVR4)
+ gboolean can_cpufreq;
+ gboolean can_brightness;
+#endif
GpmConf *conf;
GpmScreensaver *screensaver;
#ifdef HAVE_GCONF_DEFAULTS
@@ -838,7 +845,11 @@
widget = glade_xml_get_widget (prefs->priv->glade_xml, "hbox_ac_lid");
gtk_widget_hide_all (widget);
}
+#if defined(sun) && defined(__SVR4)
+ if (prefs->priv->has_lcd == FALSE || prefs->priv->can_brightness == FALSE) {
+#else
if (prefs->priv->has_lcd == FALSE) {
+#endif
widget = glade_xml_get_widget (prefs->priv->glade_xml, "hbox_ac_brightness");
gtk_widget_hide_all (widget);
widget = glade_xml_get_widget (prefs->priv->glade_xml, "checkbutton_ac_display_dim");
@@ -923,7 +934,11 @@
widget = glade_xml_get_widget (prefs->priv->glade_xml, "hbox_battery_lid");
gtk_widget_hide_all (widget);
}
+#if defined(sun) && defined(__SVR4)
+ if (prefs->priv->has_lcd == FALSE || prefs->priv->can_brightness == FALSE) {
+#else
if (prefs->priv->has_lcd == FALSE) {
+#endif
widget = glade_xml_get_widget (prefs->priv->glade_xml, "checkbutton_battery_display_dim");
gtk_widget_hide_all (widget);
}
@@ -1142,6 +1157,19 @@
prefs->priv->can_hibernate = gpm_dbus_method_bool ("CanHibernate");
egg_debug ("caps=%i", caps);
+#if defined(sun) && defined(__SVR4)
+ GpmControl *control = gpm_control_new ();
+ if (control) {
+ prefs->priv->can_cpufreq = gpm_control_is_user_privileged (control, "hal-power-cpu");
+ prefs->priv->can_brightness = gpm_control_is_user_privileged (control, "hal-power-brightness");
+ g_object_unref (control);
+ } else {
+ prefs->priv->can_cpufreq = FALSE;
+ prefs->priv->can_brightness = FALSE;
+ }
+#endif
+
+
#ifdef HAVE_GCONF_DEFAULTS
/* use custom widgets */
glade_set_custom_handler (gpk_prefs_create_custom_widget, prefs);
--- src/gpm-control.h.orig 2008-08-07 16:47:31.320835919 +0800
+++ src/gpm-control.h 2008-08-07 16:48:52.620474383 +0800
@@ -74,6 +74,8 @@
GQuark gpm_control_error_quark (void);
GType gpm_control_get_type (void);
GpmControl *gpm_control_new (void);
+gboolean gpm_control_is_user_privileged (GpmControl *control,
+ const gchar *privilege);
gboolean gpm_control_allowed_suspend (GpmControl *control,
gboolean *can,
GError **error);
--- src/Makefile.am.orig 2008-08-07 17:09:19.740271490 +0800
+++ src/Makefile.am 2008-08-07 17:07:27.003203024 +0800
@@ -108,6 +108,12 @@
gpm-prefs-core.c \
gpm-marshal.h \
gpm-marshal.c \
+ gpm-control.h \
+ gpm-control.c \
+ gpm-networkmanager.h \
+ gpm-networkmanager.c \
+ gpm-button.c \
+ gpm-button.h \
gpm-common.h \
gpm-common.c \
gpm-screensaver.h \
@@ -119,7 +125,7 @@
$(GNOME_LIBS) \
$(HAL_LIBS) \
$(DBUS_LIBS) \
- $(POLKIT_GNOME_LIBS) \
+ $(POLKIT_LIBS) \
$(GPM_EXTRA_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
$(LOCAL_LIBDBUS_LIBS) \