[gnome-panel] [clock] Port to PolicyKit 1



commit 51d89b59fa52553224dc846a2de8312b94851695
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 11 20:08:54 2009 +0200

    [clock] Port to PolicyKit 1

 applets/clock/Makefile.am                          |   10 +-
 applets/clock/clock-location.c                     |    3 +-
 applets/clock/clock.c                              |    4 +-
 applets/clock/gnome-clock-applet-mechanism.c       |  146 ++++++-----
 applets/clock/gnome-clock-applet-mechanism.h       |    5 +
 applets/clock/gnome-clock-applet-mechanism.xml     |    8 +
 .../org.gnome.clockapplet.mechanism.policy.in      |    6 +-
 applets/clock/set-timezone.c                       |  276 +++++---------------
 applets/clock/set-timezone.h                       |    2 -
 configure.in                                       |   20 +-
 10 files changed, 170 insertions(+), 310 deletions(-)
---
diff --git a/applets/clock/Makefile.am b/applets/clock/Makefile.am
index 5af69d4..6896aba 100644
--- a/applets/clock/Makefile.am
+++ b/applets/clock/Makefile.am
@@ -7,7 +7,7 @@ INCLUDES =							\
 	$(GNOME_INCLUDEDIR)					\
 	$(WARN_CFLAGS)						\
 	$(CLOCK_CFLAGS)						\
-	$(POLKIT_GNOME_CFLAGS)					\
+	$(POLKIT_CFLAGS)					\
 	$(LIBPANEL_APPLET_CFLAGS)				\
 	-DDATADIR=\""$(datadir)"\"				\
 	-DBUILDERDIR=\""$(uidir)"\"				\
@@ -65,7 +65,7 @@ CLOCK_LDADD =						\
 	../../libpanel-applet/libpanel-applet-2.la	\
 	$(CLOCK_LIBS)					\
 	$(LIBPANEL_APPLET_LIBS)				\
-	$(POLKIT_GNOME_LIBS)				\
+	$(POLKIT_LIBS)				\
 	-lgweather
 
 BUILT_SOURCES =					\
@@ -130,11 +130,11 @@ endif
 
 gnome_clock_applet_mechanism_INCLUDES =	\
 	$(CLOCK_MECHANISM_CFLAGS) 	\
-	$(POLKIT_GNOME_CFLAGS)
+	$(POLKIT_CFLAGS)
 
 gnome_clock_applet_mechanism_LDADD =	\
 	$(CLOCK_MECHANISM_LIBS)		\
-	$(POLKIT_GNOME_LIBS)
+	$(POLKIT_LIBS)
 
 if CLOCK_INPROCESS
 APPLET_TYPE     = shlib
@@ -203,7 +203,7 @@ endif
 
 dbus_servicesdir = $(datadir)/dbus-1/system-services
 dbus_confdir = $(sysconfdir)/dbus-1/system.d
-polkitdir = $(datadir)/PolicyKit/policy
+polkitdir = $(datadir)/polkit-1/actions
 
 dbus_services_in_files = org.gnome.ClockApplet.Mechanism.service.in
 polkit_in_files = org.gnome.clockapplet.mechanism.policy.in
diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c
index a297c9f..20d58f3 100644
--- a/applets/clock/clock-location.c
+++ b/applets/clock/clock-location.c
@@ -534,8 +534,7 @@ clock_location_make_current (ClockLocation *loc,
 
         filename = g_build_filename (SYSTEM_ZONEINFODIR, priv->timezone, NULL);
         set_system_timezone_async (filename,
-				   transient_parent_xid,
-                                   (GFunc)make_current_cb, 
+                                   (GFunc)make_current_cb,
 				   mcdata,
                                    free_make_current_data);
         g_free (filename);
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 70b95ed..7ce582c 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -1628,7 +1628,7 @@ update_set_time_button (ClockData *cd)
 {
 	gint can_set;
 
-	can_set = can_set_system_time (); /* this can return 0, 1, 2 */
+	can_set = can_set_system_time ();
 
 	if (cd->time_settings_button)
 		gtk_widget_set_sensitive (cd->time_settings_button, can_set);
@@ -1691,7 +1691,7 @@ set_time (GtkWidget *widget, ClockData *cd)
 
 	tim = mktime (&t);
 
-	set_system_time_async (tim, GDK_WINDOW_XWINDOW (cd->applet->window), (GFunc)set_time_callback, cd, NULL);
+	set_system_time_async (tim, (GFunc)set_time_callback, cd, NULL);
 }
 
 static void
diff --git a/applets/clock/gnome-clock-applet-mechanism.c b/applets/clock/gnome-clock-applet-mechanism.c
index 3027ca6..10a254d 100644
--- a/applets/clock/gnome-clock-applet-mechanism.c
+++ b/applets/clock/gnome-clock-applet-mechanism.c
@@ -37,7 +37,7 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include <polkit-dbus/polkit-dbus.h>
+#include <polkit/polkit.h>
 
 #include "system-timezone.h"
 
@@ -68,7 +68,7 @@ struct GnomeClockAppletMechanismPrivate
 {
         DBusGConnection *system_bus_connection;
         DBusGProxy      *system_bus_proxy;
-        PolKitContext   *pol_ctx;
+        PolkitAuthority *auth;
 };
 
 static void     gnome_clock_applet_mechanism_finalize    (GObject     *object);
@@ -172,50 +172,11 @@ gnome_clock_applet_mechanism_finalize (GObject *object)
 }
 
 static gboolean
-pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
-{
-        int fd;
-        PolKitContext *pk_context = user_data;
-        fd = g_io_channel_unix_get_fd (channel);
-        polkit_context_io_func (pk_context, fd);
-        return TRUE;
-}
-
-static int 
-pk_io_add_watch (PolKitContext *pk_context, int fd)
-{
-        guint id = 0;
-        GIOChannel *channel;
-        channel = g_io_channel_unix_new (fd);
-        if (channel == NULL)
-                goto out;
-        id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context);
-        if (id == 0) {
-                g_io_channel_unref (channel);
-                goto out;
-        }
-        g_io_channel_unref (channel);
-out:
-        return id;
-}
-
-static void 
-pk_io_remove_watch (PolKitContext *pk_context, int watch_id)
-{
-        g_source_remove (watch_id);
-}
-
-static gboolean
 register_mechanism (GnomeClockAppletMechanism *mechanism)
 {
         GError *error = NULL;
 
-        mechanism->priv->pol_ctx = polkit_context_new ();
-        polkit_context_set_io_watch_functions (mechanism->priv->pol_ctx, pk_io_add_watch, pk_io_remove_watch);
-        if (!polkit_context_init (mechanism->priv->pol_ctx, NULL)) {
-                g_critical ("cannot initialize libpolkit");
-                goto error;
-        }
+        mechanism->priv->auth = polkit_authority_get ();
 
         error = NULL;
         mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -266,49 +227,36 @@ _check_polkit_for_action (GnomeClockAppletMechanism *mechanism, DBusGMethodInvoc
 {
         const char *sender;
         GError *error;
-        DBusError dbus_error;
-        PolKitCaller *pk_caller;
-        PolKitAction *pk_action;
-        PolKitResult pk_result;
+        PolkitSubject *subject;
+        PolkitAuthorizationResult *result;
 
         error = NULL;
 
         /* Check that caller is privileged */
         sender = dbus_g_method_get_sender (context);
-        dbus_error_init (&dbus_error);
-        pk_caller = polkit_caller_new_from_dbus_name (
-                dbus_g_connection_get_connection (mechanism->priv->system_bus_connection),
-                sender, 
-                &dbus_error);
-        if (pk_caller == NULL) {
-                error = g_error_new (GNOME_CLOCK_APPLET_MECHANISM_ERROR,
-                                     GNOME_CLOCK_APPLET_MECHANISM_ERROR_GENERAL,
-                                     "Error getting information about caller: %s: %s",
-                                     dbus_error.name, dbus_error.message);
-                dbus_error_free (&dbus_error);
-                dbus_g_method_return_error (context, error);
-                g_error_free (error);
-                return FALSE;
-        }
+        subject = polkit_system_bus_name_new (sender);
 
-        pk_action = polkit_action_new ();
-        polkit_action_set_action_id (pk_action, action);
-        pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, pk_action, pk_caller, FALSE, NULL);
-        polkit_caller_unref (pk_caller);
-        polkit_action_unref (pk_action);
+        result = polkit_authority_check_authorization_sync (mechanism->priv->auth,
+                                                            subject,
+                                                            action,
+                                                            NULL,
+                                                            POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+                                                            NULL, NULL);
+        g_object_unref (subject);
 
-        if (pk_result != POLKIT_RESULT_YES) {
+        if (!polkit_authorization_result_get_is_authorized (result)) {
                 error = g_error_new (GNOME_CLOCK_APPLET_MECHANISM_ERROR,
                                      GNOME_CLOCK_APPLET_MECHANISM_ERROR_NOT_PRIVILEGED,
-                                     "%s %s <-- (action, result)",
-                                     action,
-                                     polkit_result_to_string_representation (pk_result));
-                dbus_error_free (&dbus_error);
+                                     "Not Authorized for action %s", action);
                 dbus_g_method_return_error (context, error);
                 g_error_free (error);
+		g_object_unref (result);
+
                 return FALSE;
         }
 
+	g_object_unref (result);
+
         return TRUE;
 }
 
@@ -607,5 +555,61 @@ gnome_clock_applet_mechanism_set_hardware_clock_using_utc  (GnomeClockAppletMech
         }
         dbus_g_method_return (context);
         return TRUE;
+}
+
+static void
+check_can_do (GnomeClockAppletMechanism *mechanism,
+              const char                *action,
+              DBusGMethodInvocation     *context)
+{
+        const char *sender;
+        PolkitSubject *subject;
+        PolkitAuthorizationResult *result;
+
+        /* Check that caller is privileged */
+        sender = dbus_g_method_get_sender (context);
+        subject = polkit_system_bus_name_new (sender);
+
+        result = polkit_authority_check_authorization_sync (mechanism->priv->auth,
+                                                            subject,
+                                                            action,
+                                                            NULL,
+                                                            0,
+                                                            NULL, NULL);
+        g_object_unref (subject);
+
+        if (polkit_authorization_result_get_is_authorized (result)) {
+		dbus_g_method_return (context, 2);
+	}
+	else if (polkit_authorization_result_get_is_challenge (result)) {
+		dbus_g_method_return (context, 1);
+	}
+	else {
+		dbus_g_method_return (context, 0);
+	}
+
+	g_object_unref (result);
+}
+
+
+gboolean
+gnome_clock_applet_mechanism_can_set_time (GnomeClockAppletMechanism    *mechanism,
+                                           DBusGMethodInvocation        *context)
+{
+        check_can_do (mechanism,
+                      "org.gnome.clockapplet.mechanism.settime",
+                      context);
+
+	return TRUE;
+}
+
+gboolean
+gnome_clock_applet_mechanism_can_set_timezone (GnomeClockAppletMechanism    *mechanism,
+                                               DBusGMethodInvocation        *context)
+{
+        check_can_do (mechanism,
+                      "org.gnome.clockapplet.mechanism.settimezone",
+                      context);
 
+	return TRUE;
 }
diff --git a/applets/clock/gnome-clock-applet-mechanism.h b/applets/clock/gnome-clock-applet-mechanism.h
index 90b8cf3..cccc584 100644
--- a/applets/clock/gnome-clock-applet-mechanism.h
+++ b/applets/clock/gnome-clock-applet-mechanism.h
@@ -69,9 +69,14 @@ gboolean            gnome_clock_applet_mechanism_set_timezone (GnomeClockAppletM
                                                                const char                   *zone_file,
                                                                DBusGMethodInvocation        *context);
 
+gboolean            gnome_clock_applet_mechanism_can_set_timezone (GnomeClockAppletMechanism    *mechanism,
+                                                                   DBusGMethodInvocation        *context);
+
 gboolean            gnome_clock_applet_mechanism_set_time     (GnomeClockAppletMechanism    *mechanism,
                                                                gint64                        seconds_since_epoch,
                                                                DBusGMethodInvocation        *context);
+gboolean            gnome_clock_applet_mechanism_can_set_time (GnomeClockAppletMechanism    *mechanism,
+                                                               DBusGMethodInvocation        *context);
 
 gboolean            gnome_clock_applet_mechanism_adjust_time  (GnomeClockAppletMechanism    *mechanism,
                                                                gint64                        seconds_to_add,
diff --git a/applets/clock/gnome-clock-applet-mechanism.xml b/applets/clock/gnome-clock-applet-mechanism.xml
index fb604f0..9845fa8 100644
--- a/applets/clock/gnome-clock-applet-mechanism.xml
+++ b/applets/clock/gnome-clock-applet-mechanism.xml
@@ -5,10 +5,18 @@
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
       <arg name="zonefile" direction="in" type="s"/>
     </method>
+    <method name="CanSetTimezone">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg name="value" direction="out" type="i"/>
+    </method>
     <method name="SetTime">
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
       <arg name="seconds_since_epoch" direction="in" type="x"/>
     </method>
+    <method name="CanSetTime">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg name="value" direction="out" type="i"/>
+    </method>
     <method name="AdjustTime">
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
       <arg name="seconds_to_add" direction="in" type="x"/>
diff --git a/applets/clock/org.gnome.clockapplet.mechanism.policy.in b/applets/clock/org.gnome.clockapplet.mechanism.policy.in
index ecba073..4d34e71 100644
--- a/applets/clock/org.gnome.clockapplet.mechanism.policy.in
+++ b/applets/clock/org.gnome.clockapplet.mechanism.policy.in
@@ -13,7 +13,7 @@
     <_message>Privileges are required to change the system time zone.</_message>
     <defaults>
       <allow_inactive>no</allow_inactive>
-      <allow_active>auth_self_keep_always</allow_active>
+      <allow_active>auth_self_keep</allow_active>
     </defaults>
   </action>
 
@@ -22,7 +22,7 @@
     <_message>Privileges are required to change the system time.</_message>
     <defaults>
       <allow_inactive>no</allow_inactive>
-      <allow_active>auth_self_keep_always</allow_active>
+      <allow_active>auth_self_keep</allow_active>
     </defaults>
   </action>
 
@@ -31,7 +31,7 @@
     <_message>Privileges are required to configure the hardware clock.</_message>
     <defaults>
       <allow_inactive>no</allow_inactive>
-      <allow_active>auth_self_keep_always</allow_active>
+      <allow_active>auth_self_keep</allow_active>
     </defaults>
   </action>
 
diff --git a/applets/clock/set-timezone.c b/applets/clock/set-timezone.c
index f2a5259..daecab9 100644
--- a/applets/clock/set-timezone.c
+++ b/applets/clock/set-timezone.c
@@ -32,31 +32,8 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include <polkit/polkit.h>
-#include <polkit-dbus/polkit-dbus.h>
-
 #include "set-timezone.h"
 
-#define CACHE_VALIDITY_SEC 2
-
-static DBusGConnection *
-get_session_bus (void)
-{
-        GError          *error;
-        static DBusGConnection *bus = NULL;
-
-	if (bus == NULL) {
-        	error = NULL;
-        	bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-        	if (bus == NULL) {
-               		g_warning ("Couldn't connect to session bus: %s", 
-				   error->message);
-                	g_error_free (error);
-        	}
-	}
-
-        return bus;
-}
 
 static DBusGConnection *
 get_system_bus (void)
@@ -77,148 +54,96 @@ get_system_bus (void)
         return bus;
 }
 
-static gboolean
-pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
-{
-        int fd;
-        PolKitContext *pk_context = user_data;
-        fd = g_io_channel_unix_get_fd (channel);
-        polkit_context_io_func (pk_context, fd);
-        return TRUE;
-}
+#define CACHE_VALIDITY_SEC 2
 
-static int 
-pk_io_add_watch_fn (PolKitContext *pk_context, int fd)
-{
-        guint id = 0;
-        GIOChannel *channel;
-        channel = g_io_channel_unix_new (fd);
-        if (channel == NULL)
-                goto out;
-        id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context);
-        if (id == 0) {
-                g_io_channel_unref (channel);
-                goto out;
-        }
-        g_io_channel_unref (channel);
-out:
-        return id;
-}
+typedef  void (*CanDoFunc) (gint value);
 
-static void 
-pk_io_remove_watch_fn (PolKitContext *pk_context, int watch_id)
+static void
+can_do_notify (DBusGProxy     *proxy,
+	       DBusGProxyCall *call,
+	       void           *user_data)
 {
-        g_source_remove (watch_id);
+        CanDoFunc callback = user_data;
+	GError *error = NULL;
+	gint value;
+
+	if (dbus_g_proxy_end_call (proxy, call,
+                                   &error,
+                                   G_TYPE_INT, &value,
+                                   G_TYPE_INVALID)) {
+        	callback (value);
+	}
 }
 
-static PolKitContext *
-get_pk_context (void)
+static void
+can_do_refresh (const gchar *action, CanDoFunc callback)
 {
-	static PolKitContext *pk_context = NULL;
-
-	if (pk_context == NULL) {
-		pk_context = polkit_context_new ();
-                polkit_context_set_io_watch_functions (pk_context,
-                                                       pk_io_add_watch_fn,
-                                                       pk_io_remove_watch_fn);
-		if (!polkit_context_init (pk_context, NULL)) {
-			polkit_context_unref (pk_context);
-			pk_context = NULL;
-		}
-	}
+        DBusGConnection *bus;
+        DBusGProxy      *proxy;
 
-	return pk_context;
+        bus = get_system_bus ();
+        if (bus == NULL)
+                return;
+
+	proxy = dbus_g_proxy_new_for_name (bus,
+					   "org.gnome.ClockApplet.Mechanism",
+					   "/",
+					   "org.gnome.ClockApplet.Mechanism");
+
+	dbus_g_proxy_begin_call_with_timeout (proxy,
+					      action,
+					      can_do_notify,
+					      callback, NULL,
+					      INT_MAX,
+					      G_TYPE_INVALID);
 }
 
-static gint
-can_do (const gchar *pk_action_id)
-{
-	DBusConnection *system_bus;
-	PolKitCaller *pk_caller;
-        PolKitAction *pk_action;
-        PolKitResult pk_result;
-	PolKitContext *pk_context;
-        DBusError dbus_error;
-	gint res = 0;
-
-        pk_caller = NULL;
-        pk_action = NULL;
-
-	system_bus = dbus_g_connection_get_connection (get_system_bus ());
-	if (system_bus == NULL)
-		goto out;
-	
-	pk_context = get_pk_context ();
-	if (pk_context == NULL)
-		goto out;
-	
-        pk_action = polkit_action_new ();
-        polkit_action_set_action_id (pk_action, pk_action_id);
-
-        dbus_error_init (&dbus_error);
-        pk_caller = polkit_caller_new_from_pid (system_bus, getpid (), &dbus_error);
-        if (pk_caller == NULL) {
-                fprintf (stderr, "cannot get caller from dbus name\n");
-                goto out;
-        }
+static gint   settimezone_cache = 0;
+static time_t settimezone_stamp = 0;
 
-        pk_result = polkit_context_is_caller_authorized (pk_context, pk_action, pk_caller, FALSE, NULL);
-
-	switch (pk_result) {
-        case POLKIT_RESULT_UNKNOWN:
-        case POLKIT_RESULT_NO:
- 		res = 0;
-		break;
-        case POLKIT_RESULT_YES:
-		res = 2;
-		break;
-        default:
-                /* This covers all the POLKIT_RESULT_ONLY_VIA_[SELF|ADMIN]_AUTH_* cases as more of these
-                 * may be added in the future.
-                 */
-		res = 1;
-		break;
-	}
-	
-out:
-        if (pk_action != NULL)
-                polkit_action_unref (pk_action);
-        if (pk_caller != NULL)
-                polkit_caller_unref (pk_caller);
-
-	return res;
+static void
+update_can_settimezone (gint res)
+{
+	settimezone_cache = res;
+	time (&settimezone_stamp);
 }
 
 gint
 can_set_system_timezone (void)
 {
-	static gboolean cache = FALSE;
-	static time_t   last_refreshed = 0;
 	time_t          now;
 
 	time (&now);
-	if (ABS (now - last_refreshed) > CACHE_VALIDITY_SEC) {
-		cache = can_do ("org.gnome.clockapplet.mechanism.settimezone");
-		last_refreshed = now;
+	if (ABS (now - settimezone_stamp) > CACHE_VALIDITY_SEC) {
+		can_do_refresh ("CanSetTimezone", update_can_settimezone);
+		settimezone_stamp = now;
 	}
 
-	return cache;
+	return settimezone_cache;
+}
+
+static gint   settime_cache = 0;
+static time_t settime_stamp = 0;
+
+static void
+update_can_settime (gint res)
+{
+	settime_cache = res;
+	time (&settime_stamp);
 }
 
 gint
 can_set_system_time (void)
 {
-	static gboolean cache = FALSE;
-	static time_t   last_refreshed = 0;
-	time_t          now;
+	time_t now;
 
 	time (&now);
-	if (ABS (now - last_refreshed) > CACHE_VALIDITY_SEC) {
-		cache = can_do ("org.gnome.clockapplet.mechanism.settime");
-		last_refreshed = now;
+	if (ABS (now - settime_stamp) > CACHE_VALIDITY_SEC) {
+		can_do_refresh ("CanSetTime", update_can_settime);
+		settime_stamp = now;
 	}
 
-	return cache;
+	return settime_cache;
 }
 
 typedef struct {
@@ -226,7 +151,6 @@ typedef struct {
         gchar *call;
 	gint64 time;
 	gchar *filename;
-        guint transient_parent_xid;
 	GFunc callback;
 	gpointer data;
 	GDestroyNotify notify;
@@ -246,61 +170,6 @@ free_data (gpointer d)
 	}
 }
 
-static void set_time_async (SetTimeCallbackData *data);
-
-static void 
-auth_notify (DBusGProxy     *proxy,
-             DBusGProxyCall *call,
-             void           *user_data)
-{
-	SetTimeCallbackData *data = user_data;
-	GError *error = NULL;
-	gboolean gained_privilege;
-
-	if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &gained_privilege, G_TYPE_INVALID)) {
-		if (gained_privilege)
-			set_time_async (data);
-	}
-	else {
-		if (data->callback) 
-			data->callback (data->data, error);
-		else
-			g_error_free (error);
-	}
-}
-
-static void
-do_auth_async (const gchar         *action, 
-               const gchar         *result, 
-               SetTimeCallbackData *data)
-{
-        DBusGConnection *bus;
-	DBusGProxy *proxy;
-
-	g_debug ("helper refused; returned polkit_result='%s' and polkit_action='%s'",
-		 result, action);
-
-	/* Now ask the user for auth... */
-        bus = get_session_bus ();
-	if (bus == NULL)
-		return;
-
-	proxy = dbus_g_proxy_new_for_name (bus,
-					"org.gnome.PolicyKit",
-					"/org/gnome/PolicyKit/Manager",
-					"org.gnome.PolicyKit.Manager");
-	
-	data->ref_count++;
-	dbus_g_proxy_begin_call_with_timeout (proxy,
-					      "ShowDialog",
-					      auth_notify,
-					      data, free_data,
-					      INT_MAX,
-					      G_TYPE_STRING, action,
-					      G_TYPE_UINT, data->transient_parent_xid,
-					      G_TYPE_INVALID);
-}
-
 static void
 set_time_notify (DBusGProxy     *proxy,
 		 DBusGProxyCall *call,
@@ -324,17 +193,6 @@ set_time_notify (DBusGProxy     *proxy,
 			if (data->callback)
 				data->callback (data->data, NULL);
 		}
-		else if (dbus_g_error_has_name (error, "org.gnome.ClockApplet.Mechanism.NotPrivileged")) {
-			gchar **tokens;
-
-			tokens = g_strsplit (error->message, " ", 2);
-			g_error_free (error);                            
-			if (g_strv_length (tokens) == 2) 
-				do_auth_async (tokens[0], tokens[1], data);
-			else
-				g_warning ("helper return string malformed");
-			g_strfreev (tokens);
-		}
 		else {
 			if (data->callback)
 				data->callback (data->data, error);
@@ -386,9 +244,8 @@ set_time_async (SetTimeCallbackData *data)
 
 void
 set_system_time_async (gint64         time,
-                       guint          transient_parent_xid,
-		       GFunc          callback, 
-		       gpointer       d, 
+		       GFunc          callback,
+		       gpointer       d,
 		       GDestroyNotify notify)
 {
 	SetTimeCallbackData *data;
@@ -401,7 +258,6 @@ set_system_time_async (gint64         time,
 	data->call = "SetTime";
 	data->time = time;
 	data->filename = NULL;
-        data->transient_parent_xid = transient_parent_xid;
 	data->callback = callback;
 	data->data = d;
 	data->notify = notify;
@@ -412,9 +268,8 @@ set_system_time_async (gint64         time,
 
 void
 set_system_timezone_async (const gchar    *filename,
-                           guint           transient_parent_xid,
-	             	   GFunc           callback, 
-		           gpointer        d, 
+	             	   GFunc           callback,
+		           gpointer        d,
 		           GDestroyNotify  notify)
 {
 	SetTimeCallbackData *data;
@@ -427,7 +282,6 @@ set_system_timezone_async (const gchar    *filename,
 	data->call = "SetTimezone";
 	data->time = -1;
 	data->filename = g_strdup (filename);
-        data->transient_parent_xid = transient_parent_xid;
 	data->callback = callback;
 	data->data = d;
 	data->notify = notify;
diff --git a/applets/clock/set-timezone.h b/applets/clock/set-timezone.h
index db8f4ae..5280b07 100644
--- a/applets/clock/set-timezone.h
+++ b/applets/clock/set-timezone.h
@@ -28,13 +28,11 @@ gint     can_set_system_timezone (void);
 gint     can_set_system_time     (void);
 
 void     set_system_time_async   (gint64         time,
-                                  guint          transient_parent_xid,
                                   GFunc          callback,
                                   gpointer       data,
                                   GDestroyNotify notify);
 
 void     set_system_timezone_async   (const gchar    *filename,
-                                      guint           transient_parent_xid,
                                       GFunc           callback,
                                       gpointer        data,
                                       GDestroyNotify  notify);
diff --git a/configure.in b/configure.in
index 91d61ad..09dd990 100644
--- a/configure.in
+++ b/configure.in
@@ -129,24 +129,21 @@ PKG_CHECK_MODULES(CLOCK_MECHANISM, [ gthread-2.0 gio-2.0 dbus-glib-1 ])
 AC_SUBST(CLOCK_MECHANISM_CFLAGS)
 AC_SUBST(CLOCK_MECHANISM_LIBS)
 
-POLKIT_GNOME_REQUIRED=0.7
-POLKIT_DBUS_REQUIRED=0.7
+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_GNOME_CFLAGS=
-POLKIT_GNOME_LIBS=
-POLKIT_DBUS_CFLAGS=
-POLKIT_DBUS_LIBS=
+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_GNOME, polkit-gnome >= $POLKIT_GNOME_REQUIRED dbus-1 >= $DBUS_REQUIRED, HAVE_POLKIT=yes, 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)
@@ -154,16 +151,11 @@ else
 
   if test "x$HAVE_POLKIT" = "xyes" ; then
     AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled])
-    PKG_CHECK_MODULES(POLKIT_DBUS, polkit-dbus >= $POLKIT_DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gobject-2.0)
-    AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
-                  [polkit-policy-file-validate], [polkit-policy-file-validate])
   fi
 fi
 AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes")
-AC_SUBST(POLKIT_GNOME_CFLAGS)
-AC_SUBST(POLKIT_GNOME_LIBS)
-AC_SUBST(POLKIT_DBUS_CFLAGS)
-AC_SUBST(POLKIT_DBUS_LIBS)
+AC_SUBST(POLKIT_CFLAGS)
+AC_SUBST(POLKIT_LIBS)
 
 AC_ARG_ENABLE(network_manager, AS_HELP_STRING([--enable-network-manager],[Enable NetworkManager support (auto)]),enable_network_manager=$enableval,enable_network_manager=auto)
 if test "x$enable_network_manager" = "xno" ; then



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