[gnome-settings-daemon/wip/datetime-service] Add optional dependency on PolicyKit and install datetime service



commit 7d2e3195b9e836eebd0c0a3b7a1e02edfd3c025f
Author: Thomas Wood <thomas wood intel com>
Date:   Wed Jun 23 14:32:08 2010 +0100

    Add optional dependency on PolicyKit and install datetime service

 configure.ac                                       |   42 ++++++++++++++++++++
 plugins/Makefile.am                                |    1 +
 plugins/datetime/gsd-datetime-mechanism-main.c     |    2 +-
 plugins/datetime/gsd-datetime-mechanism.c          |   15 ++++---
 ...org.gnome.SettingsDaemon.DateTimeMechanism.conf |   19 +++++++++
 ...nome.settingsdaemon.datetimemechanism.policy.in |   38 ++++++++++++++++++
 6 files changed, 109 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a6a4ec1..3169b17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -297,6 +297,46 @@ fi
 
 AC_SUBST(NSS_DATABASE)
 
+
+# ---------------------------------------------------------------------------
+# PolicyKit
+# ---------------------------------------------------------------------------
+
+POLKIT_REQUIRED=0.91
+DBUS_GLIB_REQUIRED=0.71
+DBUS_REQUIRED=1.1.2
+NETWORK_MANAGER_REQUIRED=0.6
+
+# PolicyKit detection; defaults to 'auto' (use it if it's available)
+#
+POLKIT_CFLAGS=
+POLKIT_LIBS=
+AC_ARG_ENABLE(polkit,
+              AS_HELP_STRING([--enable-polkit],
+                             [Enable PolicyKit support (auto)]),
+              enable_polkit=$enableval,
+              enable_polkit=auto)
+
+if test "x$enable_polkit" = "xno" ; then
+  HAVE_POLKIT=no
+else
+  HAVE_POLKIT=no
+  PKG_CHECK_MODULES(POLKIT, polkit-gobject-1 >= $POLKIT_REQUIRED dbus-1 >= $DBUS_REQUIRED, HAVE_POLKIT=yes, HAVE_POLKIT=no)
+
+  if test "x$enable_polkit" = "xyes" -a "x$HAVE_POLKIT" = "xno" ; then
+    AC_MSG_ERROR(PolicyKit support explicity enabled but not available)
+  fi
+
+  if test "x$HAVE_POLKIT" = "xyes" ; then
+    AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled])
+  fi
+fi
+AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes")
+AC_SUBST(POLKIT_CFLAGS)
+AC_SUBST(POLKIT_LIBS)
+
+
+
 # ---------------------------------------------------------------------------
 # Enable Profiling
 # ---------------------------------------------------------------------------
@@ -388,6 +428,7 @@ plugins/a11y-keyboard/Makefile
 plugins/background/Makefile
 plugins/clipboard/Makefile
 plugins/common/Makefile
+plugins/datetime/Makefile
 plugins/dummy/Makefile
 plugins/font/Makefile
 plugins/housekeeping/Makefile
@@ -434,6 +475,7 @@ echo "
         Maintainer mode:          ${USE_MAINTAINER_MODE}
 
         dbus-1 system.d dir:      ${DBUS_SYS_DIR}
+        PolicyKit support:        ${HAVE_POLKIT}
 
         Libnotify support:        ${have_libnotify}
         PulseAudio support:       ${have_pulse}
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index ef82aa0..f84cdf9 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -4,6 +4,7 @@ enabled_plugins =	\
 	a11y-keyboard	\
 	background	\
 	clipboard	\
+	datetime	\
 	dummy		\
 	font		\
 	housekeeping    \
diff --git a/plugins/datetime/gsd-datetime-mechanism-main.c b/plugins/datetime/gsd-datetime-mechanism-main.c
index 6aae463..b1f580a 100644
--- a/plugins/datetime/gsd-datetime-mechanism-main.c
+++ b/plugins/datetime/gsd-datetime-mechanism-main.c
@@ -39,7 +39,7 @@
 #include <dbus/dbus-glib-lowlevel.h>
 
 
-#include "gnome-clock-applet-mechanism.h"
+#include "gsd-datetime-mechanism.h"
 
 static DBusGProxy *
 get_bus_proxy (DBusGConnection *connection)
diff --git a/plugins/datetime/gsd-datetime-mechanism.c b/plugins/datetime/gsd-datetime-mechanism.c
index a465542..f1bc363 100644
--- a/plugins/datetime/gsd-datetime-mechanism.c
+++ b/plugins/datetime/gsd-datetime-mechanism.c
@@ -41,8 +41,8 @@
 
 #include "system-timezone.h"
 
-#include "gnome-clock-applet-mechanism.h"
-#include "gnome-clock-applet-mechanism-glue.h"
+#include "gsd-datetime-mechanism.h"
+#include "gsd-datetime-mechanism-glue.h"
 
 static gboolean
 do_exit (gpointer user_data)
@@ -275,7 +275,7 @@ _set_time (GsdDatetimeMechanism    *mechanism,
 {
         GError *error;
 
-        if (!_check_polkit_for_action (mechanism, context, "org.gnome.clockapplet.mechanism.settime"))
+        if (!_check_polkit_for_action (mechanism, context, "org.gnome.settingsdaemon.datetimemechanism.settime"))
                 return FALSE;
 
         if (settimeofday (tv, NULL) != 0) {
@@ -433,7 +433,7 @@ gsd_datetime_mechanism_set_timezone (GsdDatetimeMechanism *mechanism,
         reset_killtimer ();
         g_debug ("SetTimezone('%s') called", zone_file);
 
-        if (!_check_polkit_for_action (mechanism, context, "org.gnome.clockapplet.mechanism.settimezone"))
+        if (!_check_polkit_for_action (mechanism, context, "org.gnome.settingsdaemon.datetimemechanism.settimezone"))
                 return FALSE;
 
         error = NULL;
@@ -527,7 +527,8 @@ gsd_datetime_mechanism_set_hardware_clock_using_utc  (GsdDatetimeMechanism    *m
 
         error = NULL;
 
-        if (!_check_polkit_for_action (mechanism, context, "org.gnome.clockapplet.mechanism.configurehwclock"))
+        if (!_check_polkit_for_action (mechanism, context,
+                                       "org.gnome.settingsdaemon.datetimemechanism.configurehwclock"))
                 return FALSE;
 
         if (g_file_test ("/sbin/hwclock", 
@@ -613,7 +614,7 @@ gsd_datetime_mechanism_can_set_time (GsdDatetimeMechanism    *mechanism,
                                            DBusGMethodInvocation        *context)
 {
         check_can_do (mechanism,
-                      "org.gnome.clockapplet.mechanism.settime",
+                      "org.gnome.settingsdaemon.datetimemechanism.settime",
                       context);
 
         return TRUE;
@@ -624,7 +625,7 @@ gsd_datetime_mechanism_can_set_timezone (GsdDatetimeMechanism    *mechanism,
                                                DBusGMethodInvocation        *context)
 {
         check_can_do (mechanism,
-                      "org.gnome.clockapplet.mechanism.settimezone",
+                      "org.gnome.settingsdaemon.datetimemechanism.settimezone",
                       context);
 
         return TRUE;
diff --git a/plugins/datetime/org.gnome.SettingsDaemon.DateTimeMechanism.conf b/plugins/datetime/org.gnome.SettingsDaemon.DateTimeMechanism.conf
new file mode 100644
index 0000000..bdb7554
--- /dev/null
+++ b/plugins/datetime/org.gnome.SettingsDaemon.DateTimeMechanism.conf
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
+
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";>
+<busconfig>
+
+  <!-- Only root can own the service -->
+  <policy user="root">
+    <allow own="org.gnome.SettingsDaemon.DateTimeMechanism"/>
+    <allow send_destination="org.gnome.SettingsDaemon.DateTimeMechanism"/>
+  </policy>
+
+  <!-- Allow anyone to invoke methods on the interfaces -->
+  <policy context="default">
+    <allow send_destination="org.gnome.SettingsDaemon.DateTimeMechanism"/>
+  </policy>
+
+</busconfig>
diff --git a/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in b/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in
new file mode 100644
index 0000000..5fdb8d8
--- /dev/null
+++ b/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd";>
+
+<policyconfig>
+  <vendor>The GNOME Project</vendor>
+  <vendor_url>http://www.gnome.org/</vendor_url>
+  <icon_name>gnome-panel-clock</icon_name>
+
+  <action id="org.gnome.settingsdaemon.datetimemechanism.settimezone">
+    <_description>Change system time zone</_description>
+    <_message>Privileges are required to change the system time zone.</_message>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>auth_self_keep</allow_active>
+    </defaults>
+  </action>
+
+  <action id="org.gnome.settingsdaemon.datetimemechanism.settime">
+    <_description>Change system time</_description>
+    <_message>Privileges are required to change the system time.</_message>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>auth_admin_keep</allow_active>
+    </defaults>
+  </action>
+
+  <action id="org.gnome.settingsdaemon.datetimemechanism.configurehwclock">
+    <_description>Configure hardware clock</_description>
+    <_message>Privileges are required to configure the hardware clock.</_message>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>auth_admin_keep</allow_active>
+    </defaults>
+  </action>
+
+</policyconfig>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]