3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/clock.c.polkit1 gnome-panel-2.27.4/applets/clock/clock.c
3e0d02c
--- gnome-panel-2.27.4/applets/clock/clock.c.polkit1	2009-07-01 09:06:23.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/clock.c	2009-08-13 14:09:17.734209990 -0400
3e0d02c
@@ -1617,7 +1617,7 @@ update_set_time_button (ClockData *cd)
fa93d27
 {
fa93d27
 	gint can_set;
fa93d27
 
fa93d27
-	can_set = can_set_system_time (); /* this can return 0, 1, 2 */
fa93d27
+	can_set = can_set_system_time ();
fa93d27
 
fa93d27
 	if (cd->time_settings_button)
fa93d27
 		gtk_widget_set_sensitive (cd->time_settings_button, can_set);
3e0d02c
@@ -1680,7 +1680,7 @@ set_time (GtkWidget *widget, ClockData *
fa93d27
 
fa93d27
 	tim = mktime (&t);
fa93d27
 
fa93d27
-	set_system_time_async (tim, GDK_WINDOW_XWINDOW (cd->applet->window), (GFunc)set_time_callback, cd, NULL);
fa93d27
+	set_system_time_async (tim, (GFunc)set_time_callback, cd, NULL);
fa93d27
 }
fa93d27
 
fa93d27
 static void
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/clock-location.c.polkit1 gnome-panel-2.27.4/applets/clock/clock-location.c
3e0d02c
--- gnome-panel-2.27.4/applets/clock/clock-location.c.polkit1	2009-08-13 14:09:17.708956705 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/clock-location.c	2009-08-13 14:09:17.737208766 -0400
fa93d27
@@ -537,8 +537,7 @@ clock_location_make_current (ClockLocati
fa93d27
 
fa93d27
         filename = g_build_filename (SYSTEM_ZONEINFODIR, priv->timezone, NULL);
fa93d27
         set_system_timezone_async (filename,
fa93d27
-				   transient_parent_xid,
fa93d27
-                                   (GFunc)make_current_cb, 
fa93d27
+                                   (GFunc)make_current_cb,
fa93d27
 				   mcdata,
fa93d27
                                    free_make_current_data);
fa93d27
         g_free (filename);
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.c.polkit1 gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.c
3e0d02c
--- gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.c.polkit1	2009-04-19 13:45:09.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.c	2009-08-13 14:09:17.739206856 -0400
fa93d27
@@ -37,7 +37,7 @@
fa93d27
 #include <dbus/dbus-glib.h>
fa93d27
 #include <dbus/dbus-glib-lowlevel.h>
fa93d27
 
fa93d27
-#include <polkit-dbus/polkit-dbus.h>
fa93d27
+#include <polkit/polkit.h>
fa93d27
 
fa93d27
 #include "system-timezone.h"
fa93d27
 
fa93d27
@@ -68,7 +68,7 @@ struct GnomeClockAppletMechanismPrivate
fa93d27
 {
fa93d27
         DBusGConnection *system_bus_connection;
fa93d27
         DBusGProxy      *system_bus_proxy;
fa93d27
-        PolKitContext   *pol_ctx;
fa93d27
+        PolkitAuthority *auth;
fa93d27
 };
fa93d27
 
fa93d27
 static void     gnome_clock_applet_mechanism_finalize    (GObject     *object);
fa93d27
@@ -172,50 +172,11 @@ gnome_clock_applet_mechanism_finalize (G
fa93d27
 }
fa93d27
 
fa93d27
 static gboolean
fa93d27
-pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
fa93d27
-{
fa93d27
-        int fd;
fa93d27
-        PolKitContext *pk_context = user_data;
fa93d27
-        fd = g_io_channel_unix_get_fd (channel);
fa93d27
-        polkit_context_io_func (pk_context, fd);
fa93d27
-        return TRUE;
fa93d27
-}
fa93d27
-
fa93d27
-static int 
fa93d27
-pk_io_add_watch (PolKitContext *pk_context, int fd)
fa93d27
-{
fa93d27
-        guint id = 0;
fa93d27
-        GIOChannel *channel;
fa93d27
-        channel = g_io_channel_unix_new (fd);
fa93d27
-        if (channel == NULL)
fa93d27
-                goto out;
fa93d27
-        id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context);
fa93d27
-        if (id == 0) {
fa93d27
-                g_io_channel_unref (channel);
fa93d27
-                goto out;
fa93d27
-        }
fa93d27
-        g_io_channel_unref (channel);
fa93d27
-out:
fa93d27
-        return id;
fa93d27
-}
fa93d27
-
fa93d27
-static void 
fa93d27
-pk_io_remove_watch (PolKitContext *pk_context, int watch_id)
fa93d27
-{
fa93d27
-        g_source_remove (watch_id);
fa93d27
-}
fa93d27
-
fa93d27
-static gboolean
fa93d27
 register_mechanism (GnomeClockAppletMechanism *mechanism)
fa93d27
 {
fa93d27
         GError *error = NULL;
fa93d27
 
fa93d27
-        mechanism->priv->pol_ctx = polkit_context_new ();
fa93d27
-        polkit_context_set_io_watch_functions (mechanism->priv->pol_ctx, pk_io_add_watch, pk_io_remove_watch);
fa93d27
-        if (!polkit_context_init (mechanism->priv->pol_ctx, NULL)) {
fa93d27
-                g_critical ("cannot initialize libpolkit");
fa93d27
-                goto error;
fa93d27
-        }
fa93d27
+        mechanism->priv->auth = polkit_authority_get ();
fa93d27
 
fa93d27
         error = NULL;
fa93d27
         mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
fa93d27
@@ -266,49 +227,36 @@ _check_polkit_for_action (GnomeClockAppl
fa93d27
 {
fa93d27
         const char *sender;
fa93d27
         GError *error;
fa93d27
-        DBusError dbus_error;
fa93d27
-        PolKitCaller *pk_caller;
fa93d27
-        PolKitAction *pk_action;
fa93d27
-        PolKitResult pk_result;
fa93d27
+        PolkitSubject *subject;
fa93d27
+        PolkitAuthorizationResult *result;
fa93d27
 
fa93d27
         error = NULL;
fa93d27
 
fa93d27
         /* Check that caller is privileged */
fa93d27
         sender = dbus_g_method_get_sender (context);
fa93d27
-        dbus_error_init (&dbus_error);
fa93d27
-        pk_caller = polkit_caller_new_from_dbus_name (
fa93d27
-                dbus_g_connection_get_connection (mechanism->priv->system_bus_connection),
fa93d27
-                sender, 
fa93d27
-                &dbus_error);
fa93d27
-        if (pk_caller == NULL) {
fa93d27
-                error = g_error_new (GNOME_CLOCK_APPLET_MECHANISM_ERROR,
fa93d27
-                                     GNOME_CLOCK_APPLET_MECHANISM_ERROR_GENERAL,
fa93d27
-                                     "Error getting information about caller: %s: %s",
fa93d27
-                                     dbus_error.name, dbus_error.message);
fa93d27
-                dbus_error_free (&dbus_error);
fa93d27
-                dbus_g_method_return_error (context, error);
fa93d27
-                g_error_free (error);
fa93d27
-                return FALSE;
fa93d27
-        }
fa93d27
+        subject = polkit_system_bus_name_new (sender);
fa93d27
 
fa93d27
-        pk_action = polkit_action_new ();
fa93d27
-        polkit_action_set_action_id (pk_action, action);
fa93d27
-        pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, pk_action, pk_caller, FALSE, NULL);
fa93d27
-        polkit_caller_unref (pk_caller);
fa93d27
-        polkit_action_unref (pk_action);
fa93d27
+        result = polkit_authority_check_authorization_sync (mechanism->priv->auth,
fa93d27
+                                                            subject,
fa93d27
+                                                            action,
fa93d27
+                                                            NULL,
fa93d27
+                                                            POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
fa93d27
+                                                            NULL, NULL);
fa93d27
+        g_object_unref (subject);
fa93d27
 
fa93d27
-        if (pk_result != POLKIT_RESULT_YES) {
fa93d27
+        if (!polkit_authorization_result_get_is_authorized (result)) {
fa93d27
                 error = g_error_new (GNOME_CLOCK_APPLET_MECHANISM_ERROR,
fa93d27
                                      GNOME_CLOCK_APPLET_MECHANISM_ERROR_NOT_PRIVILEGED,
fa93d27
-                                     "%s %s <-- (action, result)",
fa93d27
-                                     action,
fa93d27
-                                     polkit_result_to_string_representation (pk_result));
fa93d27
-                dbus_error_free (&dbus_error);
fa93d27
+                                     "Not Authorized for action %s", action);
fa93d27
                 dbus_g_method_return_error (context, error);
fa93d27
                 g_error_free (error);
fa93d27
+		g_object_unref (result);
fa93d27
+
fa93d27
                 return FALSE;
fa93d27
         }
fa93d27
 
fa93d27
+	g_object_unref (result);
fa93d27
+
fa93d27
         return TRUE;
fa93d27
 }
fa93d27
 
fa93d27
@@ -607,5 +555,61 @@ gnome_clock_applet_mechanism_set_hardwar
fa93d27
         }
fa93d27
         dbus_g_method_return (context);
fa93d27
         return TRUE;
fa93d27
+}
fa93d27
+
fa93d27
+static void
fa93d27
+check_can_do (GnomeClockAppletMechanism *mechanism,
fa93d27
+              const char                *action,
fa93d27
+              DBusGMethodInvocation     *context)
fa93d27
+{
fa93d27
+        const char *sender;
fa93d27
+        PolkitSubject *subject;
fa93d27
+        PolkitAuthorizationResult *result;
fa93d27
+
fa93d27
+        /* Check that caller is privileged */
fa93d27
+        sender = dbus_g_method_get_sender (context);
fa93d27
+        subject = polkit_system_bus_name_new (sender);
fa93d27
+
fa93d27
+        result = polkit_authority_check_authorization_sync (mechanism->priv->auth,
fa93d27
+                                                            subject,
fa93d27
+                                                            action,
fa93d27
+                                                            NULL,
fa93d27
+                                                            0,
fa93d27
+                                                            NULL, NULL);
fa93d27
+        g_object_unref (subject);
fa93d27
+
fa93d27
+        if (polkit_authorization_result_get_is_authorized (result)) {
fa93d27
+		dbus_g_method_return (context, 2);
fa93d27
+	}
fa93d27
+	else if (polkit_authorization_result_get_is_challenge (result)) {
fa93d27
+		dbus_g_method_return (context, 1);
fa93d27
+	}
fa93d27
+	else {
fa93d27
+		dbus_g_method_return (context, 0);
fa93d27
+	}
fa93d27
+
fa93d27
+	g_object_unref (result);
fa93d27
+}
fa93d27
+
fa93d27
+
fa93d27
+gboolean
fa93d27
+gnome_clock_applet_mechanism_can_set_time (GnomeClockAppletMechanism    *mechanism,
fa93d27
+                                           DBusGMethodInvocation        *context)
fa93d27
+{
fa93d27
+        check_can_do (mechanism,
fa93d27
+                      "org.gnome.clockapplet.mechanism.settime",
fa93d27
+                      context);
fa93d27
+
fa93d27
+	return TRUE;
fa93d27
+}
fa93d27
+
fa93d27
+gboolean
fa93d27
+gnome_clock_applet_mechanism_can_set_timezone (GnomeClockAppletMechanism    *mechanism,
fa93d27
+                                               DBusGMethodInvocation        *context)
fa93d27
+{
fa93d27
+        check_can_do (mechanism,
fa93d27
+                      "org.gnome.clockapplet.mechanism.settimezone",
fa93d27
+                      context);
fa93d27
 
fa93d27
+	return TRUE;
fa93d27
 }
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.h.polkit1 gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.h
3e0d02c
--- gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.h.polkit1	2009-04-19 13:45:09.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.h	2009-08-13 14:09:17.740206913 -0400
fa93d27
@@ -69,9 +69,14 @@ gboolean            gnome_clock_applet_m
fa93d27
                                                                const char                   *zone_file,
fa93d27
                                                                DBusGMethodInvocation        *context);
fa93d27
 
fa93d27
+gboolean            gnome_clock_applet_mechanism_can_set_timezone (GnomeClockAppletMechanism    *mechanism,
fa93d27
+                                                                   DBusGMethodInvocation        *context);
fa93d27
+
fa93d27
 gboolean            gnome_clock_applet_mechanism_set_time     (GnomeClockAppletMechanism    *mechanism,
fa93d27
                                                                gint64                        seconds_since_epoch,
fa93d27
                                                                DBusGMethodInvocation        *context);
fa93d27
+gboolean            gnome_clock_applet_mechanism_can_set_time (GnomeClockAppletMechanism    *mechanism,
fa93d27
+                                                               DBusGMethodInvocation        *context);
fa93d27
 
fa93d27
 gboolean            gnome_clock_applet_mechanism_adjust_time  (GnomeClockAppletMechanism    *mechanism,
fa93d27
                                                                gint64                        seconds_to_add,
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.xml.polkit1 gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.xml
3e0d02c
--- gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.xml.polkit1	2009-04-19 13:45:09.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/gnome-clock-applet-mechanism.xml	2009-08-13 14:09:17.741205993 -0400
fa93d27
@@ -5,10 +5,18 @@
fa93d27
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
fa93d27
       <arg name="zonefile" direction="in" type="s"/>
fa93d27
     </method>
fa93d27
+    <method name="CanSetTimezone">
fa93d27
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
fa93d27
+      <arg name="value" direction="out" type="i"/>
fa93d27
+    </method>
fa93d27
     <method name="SetTime">
fa93d27
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
fa93d27
       <arg name="seconds_since_epoch" direction="in" type="x"/>
fa93d27
     </method>
fa93d27
+    <method name="CanSetTime">
fa93d27
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
fa93d27
+      <arg name="value" direction="out" type="i"/>
fa93d27
+    </method>
fa93d27
     <method name="AdjustTime">
fa93d27
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
fa93d27
       <arg name="seconds_to_add" direction="in" type="x"/>
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/Makefile.am.polkit1 gnome-panel-2.27.4/applets/clock/Makefile.am
3e0d02c
--- gnome-panel-2.27.4/applets/clock/Makefile.am.polkit1	2009-07-01 09:06:23.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/Makefile.am	2009-08-13 14:09:17.742205491 -0400
3e0d02c
@@ -9,7 +9,7 @@ INCLUDES =							\
fa93d27
 	$(GNOME_INCLUDEDIR)					\
fa93d27
 	$(WARN_CFLAGS)						\
fa93d27
 	$(CLOCK_CFLAGS)						\
fa93d27
-	$(POLKIT_GNOME_CFLAGS)					\
fa93d27
+	$(POLKIT_CFLAGS)					\
fa93d27
 	$(LIBPANEL_APPLET_CFLAGS)				\
fa93d27
 	-DDATADIR=\""$(datadir)"\"				\
fa93d27
 	-DGLADEDIR=\""$(datadir)/gnome-panel/glade"\"		\
3e0d02c
@@ -67,7 +67,7 @@ CLOCK_LDADD =						\
fa93d27
 	../../libpanel-applet/libpanel-applet-2.la	\
fa93d27
 	$(CLOCK_LIBS)					\
fa93d27
 	$(LIBPANEL_APPLET_LIBS)				\
fa93d27
-	$(POLKIT_GNOME_LIBS)				\
fa93d27
+	$(POLKIT_LIBS)				\
fa93d27
 	-lgweather
fa93d27
 
fa93d27
 BUILT_SOURCES =					\
3e0d02c
@@ -132,11 +132,11 @@ endif
fa93d27
 
fa93d27
 gnome_clock_applet_mechanism_INCLUDES =	\
fa93d27
 	$(CLOCK_MECHANISM_CFLAGS) 	\
fa93d27
-	$(POLKIT_GNOME_CFLAGS)
fa93d27
+	$(POLKIT_CFLAGS)
fa93d27
 
fa93d27
 gnome_clock_applet_mechanism_LDADD =	\
fa93d27
 	$(CLOCK_MECHANISM_LIBS)		\
fa93d27
-	$(POLKIT_GNOME_LIBS)
fa93d27
+	$(POLKIT_LIBS)
fa93d27
 
fa93d27
 if CLOCK_INPROCESS
fa93d27
 APPLET_TYPE     = shlib
3e0d02c
@@ -206,7 +206,7 @@ endif
fa93d27
 
fa93d27
 dbus_servicesdir = $(datadir)/dbus-1/system-services
fa93d27
 dbus_confdir = $(sysconfdir)/dbus-1/system.d
fa93d27
-polkitdir = $(datadir)/PolicyKit/policy
fa93d27
+polkitdir = $(datadir)/polkit-1/actions
fa93d27
 
fa93d27
 dbus_services_in_files = org.gnome.ClockApplet.Mechanism.service.in
fa93d27
 polkit_in_files = org.gnome.clockapplet.mechanism.policy.in
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/org.gnome.clockapplet.mechanism.policy.in.polkit1 gnome-panel-2.27.4/applets/clock/org.gnome.clockapplet.mechanism.policy.in
3e0d02c
--- gnome-panel-2.27.4/applets/clock/org.gnome.clockapplet.mechanism.policy.in.polkit1	2009-04-19 13:45:09.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/org.gnome.clockapplet.mechanism.policy.in	2009-08-13 14:21:10.175979956 -0400
fa93d27
@@ -13,7 +13,7 @@
fa93d27
     <_message>Privileges are required to change the system time zone.</_message>
fa93d27
     <defaults>
fa93d27
       <allow_inactive>no</allow_inactive>
fa93d27
-      <allow_active>auth_self_keep_always</allow_active>
3e0d02c
+      <allow_active>auth_admin_keep</allow_active>
fa93d27
     </defaults>
fa93d27
   </action>
fa93d27
 
fa93d27
@@ -22,7 +22,7 @@
fa93d27
     <_message>Privileges are required to change the system time.</_message>
fa93d27
     <defaults>
fa93d27
       <allow_inactive>no</allow_inactive>
fa93d27
-      <allow_active>auth_self_keep_always</allow_active>
3e0d02c
+      <allow_active>auth_admin_keep</allow_active>
fa93d27
     </defaults>
fa93d27
   </action>
fa93d27
 
fa93d27
@@ -31,7 +31,7 @@
fa93d27
     <_message>Privileges are required to configure the hardware clock.</_message>
fa93d27
     <defaults>
fa93d27
       <allow_inactive>no</allow_inactive>
fa93d27
-      <allow_active>auth_self_keep_always</allow_active>
3e0d02c
+      <allow_active>auth_admin_keep</allow_active>
fa93d27
     </defaults>
fa93d27
   </action>
fa93d27
 
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/set-timezone.c.polkit1 gnome-panel-2.27.4/applets/clock/set-timezone.c
3e0d02c
--- gnome-panel-2.27.4/applets/clock/set-timezone.c.polkit1	2009-04-19 13:45:09.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/set-timezone.c	2009-08-13 14:09:17.744960941 -0400
fa93d27
@@ -32,31 +32,8 @@
fa93d27
 #include <dbus/dbus-glib.h>
fa93d27
 #include <dbus/dbus-glib-lowlevel.h>
fa93d27
 
fa93d27
-#include <polkit/polkit.h>
fa93d27
-#include <polkit-dbus/polkit-dbus.h>
fa93d27
-
fa93d27
 #include "set-timezone.h"
fa93d27
 
fa93d27
-#define CACHE_VALIDITY_SEC 2
fa93d27
-
fa93d27
-static DBusGConnection *
fa93d27
-get_session_bus (void)
fa93d27
-{
fa93d27
-        GError          *error;
fa93d27
-        static DBusGConnection *bus = NULL;
fa93d27
-
fa93d27
-	if (bus == NULL) {
fa93d27
-        	error = NULL;
fa93d27
-        	bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
fa93d27
-        	if (bus == NULL) {
fa93d27
-               		g_warning ("Couldn't connect to session bus: %s", 
fa93d27
-				   error->message);
fa93d27
-                	g_error_free (error);
fa93d27
-        	}
fa93d27
-	}
fa93d27
-
fa93d27
-        return bus;
fa93d27
-}
fa93d27
 
fa93d27
 static DBusGConnection *
fa93d27
 get_system_bus (void)
fa93d27
@@ -77,148 +54,96 @@ get_system_bus (void)
fa93d27
         return bus;
fa93d27
 }
fa93d27
 
fa93d27
-static gboolean
fa93d27
-pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
fa93d27
-{
fa93d27
-        int fd;
fa93d27
-        PolKitContext *pk_context = user_data;
fa93d27
-        fd = g_io_channel_unix_get_fd (channel);
fa93d27
-        polkit_context_io_func (pk_context, fd);
fa93d27
-        return TRUE;
fa93d27
-}
fa93d27
-
fa93d27
-static int 
fa93d27
-pk_io_add_watch_fn (PolKitContext *pk_context, int fd)
fa93d27
-{
fa93d27
-        guint id = 0;
fa93d27
-        GIOChannel *channel;
fa93d27
-        channel = g_io_channel_unix_new (fd);
fa93d27
-        if (channel == NULL)
fa93d27
-                goto out;
fa93d27
-        id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context);
fa93d27
-        if (id == 0) {
fa93d27
-                g_io_channel_unref (channel);
fa93d27
-                goto out;
fa93d27
-        }
fa93d27
-        g_io_channel_unref (channel);
fa93d27
-out:
fa93d27
-        return id;
fa93d27
-}
fa93d27
+#define CACHE_VALIDITY_SEC 2
fa93d27
 
fa93d27
-static void 
fa93d27
-pk_io_remove_watch_fn (PolKitContext *pk_context, int watch_id)
fa93d27
-{
fa93d27
-        g_source_remove (watch_id);
fa93d27
-}
fa93d27
+typedef  void (*CanDoFunc) (gint value);
fa93d27
 
fa93d27
-static PolKitContext *
fa93d27
-get_pk_context (void)
fa93d27
+static void
fa93d27
+can_do_notify (DBusGProxy     *proxy,
fa93d27
+	       DBusGProxyCall *call,
fa93d27
+	       void           *user_data)
fa93d27
 {
fa93d27
-	static PolKitContext *pk_context = NULL;
fa93d27
+        CanDoFunc callback = user_data;
fa93d27
+	GError *error = NULL;
fa93d27
+	gint value;
fa93d27
 
fa93d27
-	if (pk_context == NULL) {
fa93d27
-		pk_context = polkit_context_new ();
fa93d27
-                polkit_context_set_io_watch_functions (pk_context,
fa93d27
-                                                       pk_io_add_watch_fn,
fa93d27
-                                                       pk_io_remove_watch_fn);
fa93d27
-		if (!polkit_context_init (pk_context, NULL)) {
fa93d27
-			polkit_context_unref (pk_context);
fa93d27
-			pk_context = NULL;
fa93d27
-		}
fa93d27
+	if (dbus_g_proxy_end_call (proxy, call,
fa93d27
+                                   &error,
fa93d27
+                                   G_TYPE_INT, &value,
fa93d27
+                                   G_TYPE_INVALID)) {
fa93d27
+        	callback (value);
fa93d27
 	}
fa93d27
-
fa93d27
-	return pk_context;
fa93d27
 }
fa93d27
 
fa93d27
-static gint
fa93d27
-can_do (const gchar *pk_action_id)
fa93d27
+static void
fa93d27
+can_do_refresh (const gchar *action, CanDoFunc callback)
fa93d27
 {
fa93d27
-	DBusConnection *system_bus;
fa93d27
-	PolKitCaller *pk_caller;
fa93d27
-        PolKitAction *pk_action;
fa93d27
-        PolKitResult pk_result;
fa93d27
-	PolKitContext *pk_context;
fa93d27
-        DBusError dbus_error;
fa93d27
-	gint res = 0;
fa93d27
-
fa93d27
-        pk_caller = NULL;
fa93d27
-        pk_action = NULL;
fa93d27
-
fa93d27
-	system_bus = dbus_g_connection_get_connection (get_system_bus ());
fa93d27
-	if (system_bus == NULL)
fa93d27
-		goto out;
fa93d27
-	
fa93d27
-	pk_context = get_pk_context ();
fa93d27
-	if (pk_context == NULL)
fa93d27
-		goto out;
fa93d27
-	
fa93d27
-        pk_action = polkit_action_new ();
fa93d27
-        polkit_action_set_action_id (pk_action, pk_action_id);
fa93d27
-
fa93d27
-        dbus_error_init (&dbus_error);
fa93d27
-        pk_caller = polkit_caller_new_from_pid (system_bus, getpid (), &dbus_error);
fa93d27
-        if (pk_caller == NULL) {
fa93d27
-                fprintf (stderr, "cannot get caller from dbus name\n");
fa93d27
-                goto out;
fa93d27
-        }
fa93d27
+        DBusGConnection *bus;
fa93d27
+        DBusGProxy      *proxy;
fa93d27
 
fa93d27
-        pk_result = polkit_context_is_caller_authorized (pk_context, pk_action, pk_caller, FALSE, NULL);
fa93d27
+        bus = get_system_bus ();
fa93d27
+        if (bus == NULL)
fa93d27
+                return;
fa93d27
 
fa93d27
-	switch (pk_result) {
fa93d27
-        case POLKIT_RESULT_UNKNOWN:
fa93d27
-        case POLKIT_RESULT_NO:
fa93d27
- 		res = 0;
fa93d27
-		break;
fa93d27
-        case POLKIT_RESULT_YES:
fa93d27
-		res = 2;
fa93d27
-		break;
fa93d27
-        default:
fa93d27
-                /* This covers all the POLKIT_RESULT_ONLY_VIA_[SELF|ADMIN]_AUTH_* cases as more of these
fa93d27
-                 * may be added in the future.
fa93d27
-                 */
fa93d27
-		res = 1;
fa93d27
-		break;
fa93d27
-	}
fa93d27
-	
fa93d27
-out:
fa93d27
-        if (pk_action != NULL)
fa93d27
-                polkit_action_unref (pk_action);
fa93d27
-        if (pk_caller != NULL)
fa93d27
-                polkit_caller_unref (pk_caller);
fa93d27
+	proxy = dbus_g_proxy_new_for_name (bus,
fa93d27
+					   "org.gnome.ClockApplet.Mechanism",
fa93d27
+					   "/",
fa93d27
+					   "org.gnome.ClockApplet.Mechanism");
fa93d27
+
fa93d27
+	dbus_g_proxy_begin_call_with_timeout (proxy,
fa93d27
+					      action,
fa93d27
+					      can_do_notify,
fa93d27
+					      callback, NULL,
fa93d27
+					      INT_MAX,
fa93d27
+					      G_TYPE_INVALID);
fa93d27
+}
fa93d27
 
fa93d27
-	return res;
fa93d27
+static gint   settimezone_cache = 0;
fa93d27
+static time_t settimezone_stamp = 0;
fa93d27
+
fa93d27
+static void
fa93d27
+update_can_settimezone (gint res)
fa93d27
+{
fa93d27
+	settimezone_cache = res;
fa93d27
+	time (&settimezone_stamp);
fa93d27
 }
fa93d27
 
fa93d27
 gint
fa93d27
 can_set_system_timezone (void)
fa93d27
 {
fa93d27
-	static gboolean cache = FALSE;
fa93d27
-	static time_t   last_refreshed = 0;
fa93d27
 	time_t          now;
fa93d27
 
fa93d27
 	time (&now;;
fa93d27
-	if (ABS (now - last_refreshed) > CACHE_VALIDITY_SEC) {
fa93d27
-		cache = can_do ("org.gnome.clockapplet.mechanism.settimezone");
fa93d27
-		last_refreshed = now;
fa93d27
+	if (ABS (now - settimezone_stamp) > CACHE_VALIDITY_SEC) {
fa93d27
+		can_do_refresh ("CanSetTimezone", update_can_settimezone);
fa93d27
+		settimezone_stamp = now;
fa93d27
 	}
fa93d27
 
fa93d27
-	return cache;
fa93d27
+	return settimezone_cache;
fa93d27
+}
fa93d27
+
fa93d27
+static gint   settime_cache = 0;
fa93d27
+static time_t settime_stamp = 0;
fa93d27
+
fa93d27
+static void
fa93d27
+update_can_settime (gint res)
fa93d27
+{
fa93d27
+	settime_cache = res;
fa93d27
+	time (&settime_stamp);
fa93d27
 }
fa93d27
 
fa93d27
 gint
fa93d27
 can_set_system_time (void)
fa93d27
 {
fa93d27
-	static gboolean cache = FALSE;
fa93d27
-	static time_t   last_refreshed = 0;
fa93d27
-	time_t          now;
fa93d27
+	time_t now;
fa93d27
 
fa93d27
 	time (&now;;
fa93d27
-	if (ABS (now - last_refreshed) > CACHE_VALIDITY_SEC) {
fa93d27
-		cache = can_do ("org.gnome.clockapplet.mechanism.settime");
fa93d27
-		last_refreshed = now;
fa93d27
+	if (ABS (now - settime_stamp) > CACHE_VALIDITY_SEC) {
fa93d27
+		can_do_refresh ("CanSetTime", update_can_settime);
fa93d27
+		settime_stamp = now;
fa93d27
 	}
fa93d27
 
fa93d27
-	return cache;
fa93d27
+	return settime_cache;
fa93d27
 }
fa93d27
 
fa93d27
 typedef struct {
fa93d27
@@ -226,7 +151,6 @@ typedef struct {
fa93d27
         gchar *call;
fa93d27
 	gint64 time;
fa93d27
 	gchar *filename;
fa93d27
-        guint transient_parent_xid;
fa93d27
 	GFunc callback;
fa93d27
 	gpointer data;
fa93d27
 	GDestroyNotify notify;
fa93d27
@@ -246,61 +170,6 @@ free_data (gpointer d)
fa93d27
 	}
fa93d27
 }
fa93d27
 
fa93d27
-static void set_time_async (SetTimeCallbackData *data);
fa93d27
-
fa93d27
-static void 
fa93d27
-auth_notify (DBusGProxy     *proxy,
fa93d27
-             DBusGProxyCall *call,
fa93d27
-             void           *user_data)
fa93d27
-{
fa93d27
-	SetTimeCallbackData *data = user_data;
fa93d27
-	GError *error = NULL;
fa93d27
-	gboolean gained_privilege;
fa93d27
-
fa93d27
-	if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &gained_privilege, G_TYPE_INVALID)) {
fa93d27
-		if (gained_privilege)
fa93d27
-			set_time_async (data);
fa93d27
-	}
fa93d27
-	else {
fa93d27
-		if (data->callback) 
fa93d27
-			data->callback (data->data, error);
fa93d27
-		else
fa93d27
-			g_error_free (error);
fa93d27
-	}
fa93d27
-}
fa93d27
-
fa93d27
-static void
fa93d27
-do_auth_async (const gchar         *action, 
fa93d27
-               const gchar         *result, 
fa93d27
-               SetTimeCallbackData *data)
fa93d27
-{
fa93d27
-        DBusGConnection *bus;
fa93d27
-	DBusGProxy *proxy;
fa93d27
-
fa93d27
-	g_debug ("helper refused; returned polkit_result='%s' and polkit_action='%s'",
fa93d27
-		 result, action);
fa93d27
-
fa93d27
-	/* Now ask the user for auth... */
fa93d27
-        bus = get_session_bus ();
fa93d27
-	if (bus == NULL)
fa93d27
-		return;
fa93d27
-
fa93d27
-	proxy = dbus_g_proxy_new_for_name (bus,
fa93d27
-					"org.gnome.PolicyKit",
fa93d27
-					"/org/gnome/PolicyKit/Manager",
fa93d27
-					"org.gnome.PolicyKit.Manager");
fa93d27
-	
fa93d27
-	data->ref_count++;
fa93d27
-	dbus_g_proxy_begin_call_with_timeout (proxy,
fa93d27
-					      "ShowDialog",
fa93d27
-					      auth_notify,
fa93d27
-					      data, free_data,
fa93d27
-					      INT_MAX,
fa93d27
-					      G_TYPE_STRING, action,
fa93d27
-					      G_TYPE_UINT, data->transient_parent_xid,
fa93d27
-					      G_TYPE_INVALID);
fa93d27
-}
fa93d27
-
fa93d27
 static void
fa93d27
 set_time_notify (DBusGProxy     *proxy,
fa93d27
 		 DBusGProxyCall *call,
fa93d27
@@ -324,17 +193,6 @@ set_time_notify (DBusGProxy     *proxy,
fa93d27
 			if (data->callback)
fa93d27
 				data->callback (data->data, NULL);
fa93d27
 		}
fa93d27
-		else if (dbus_g_error_has_name (error, "org.gnome.ClockApplet.Mechanism.NotPrivileged")) {
fa93d27
-			gchar **tokens;
fa93d27
-
fa93d27
-			tokens = g_strsplit (error->message, " ", 2);
fa93d27
-			g_error_free (error);                            
fa93d27
-			if (g_strv_length (tokens) == 2) 
fa93d27
-				do_auth_async (tokens[0], tokens[1], data);
fa93d27
-			else
fa93d27
-				g_warning ("helper return string malformed");
fa93d27
-			g_strfreev (tokens);
fa93d27
-		}
fa93d27
 		else {
fa93d27
 			if (data->callback)
fa93d27
 				data->callback (data->data, error);
fa93d27
@@ -386,9 +244,8 @@ set_time_async (SetTimeCallbackData *dat
fa93d27
 
fa93d27
 void
fa93d27
 set_system_time_async (gint64         time,
fa93d27
-                       guint          transient_parent_xid,
fa93d27
-		       GFunc          callback, 
fa93d27
-		       gpointer       d, 
fa93d27
+		       GFunc          callback,
fa93d27
+		       gpointer       d,
fa93d27
 		       GDestroyNotify notify)
fa93d27
 {
fa93d27
 	SetTimeCallbackData *data;
fa93d27
@@ -401,7 +258,6 @@ set_system_time_async (gint64         ti
fa93d27
 	data->call = "SetTime";
fa93d27
 	data->time = time;
fa93d27
 	data->filename = NULL;
fa93d27
-        data->transient_parent_xid = transient_parent_xid;
fa93d27
 	data->callback = callback;
fa93d27
 	data->data = d;
fa93d27
 	data->notify = notify;
fa93d27
@@ -412,9 +268,8 @@ set_system_time_async (gint64         ti
fa93d27
 
fa93d27
 void
fa93d27
 set_system_timezone_async (const gchar    *filename,
fa93d27
-                           guint           transient_parent_xid,
fa93d27
-	             	   GFunc           callback, 
fa93d27
-		           gpointer        d, 
fa93d27
+	             	   GFunc           callback,
fa93d27
+		           gpointer        d,
fa93d27
 		           GDestroyNotify  notify)
fa93d27
 {
fa93d27
 	SetTimeCallbackData *data;
fa93d27
@@ -427,7 +282,6 @@ set_system_timezone_async (const gchar  
fa93d27
 	data->call = "SetTimezone";
fa93d27
 	data->time = -1;
fa93d27
 	data->filename = g_strdup (filename);
fa93d27
-        data->transient_parent_xid = transient_parent_xid;
fa93d27
 	data->callback = callback;
fa93d27
 	data->data = d;
fa93d27
 	data->notify = notify;
3e0d02c
diff -up gnome-panel-2.27.4/applets/clock/set-timezone.h.polkit1 gnome-panel-2.27.4/applets/clock/set-timezone.h
3e0d02c
--- gnome-panel-2.27.4/applets/clock/set-timezone.h.polkit1	2009-04-19 13:45:09.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/applets/clock/set-timezone.h	2009-08-13 14:09:17.745957855 -0400
fa93d27
@@ -28,13 +28,11 @@ gint     can_set_system_timezone (void);
fa93d27
 gint     can_set_system_time     (void);
fa93d27
 
fa93d27
 void     set_system_time_async   (gint64         time,
fa93d27
-                                  guint          transient_parent_xid,
fa93d27
                                   GFunc          callback,
fa93d27
                                   gpointer       data,
fa93d27
                                   GDestroyNotify notify);
fa93d27
 
fa93d27
 void     set_system_timezone_async   (const gchar    *filename,
fa93d27
-                                      guint           transient_parent_xid,
fa93d27
                                       GFunc           callback,
fa93d27
                                       gpointer        data,
fa93d27
                                       GDestroyNotify  notify);
3e0d02c
diff -up gnome-panel-2.27.4/configure.in.polkit1 gnome-panel-2.27.4/configure.in
3e0d02c
--- gnome-panel-2.27.4/configure.in.polkit1	2009-07-15 11:05:33.000000000 -0400
3e0d02c
+++ gnome-panel-2.27.4/configure.in	2009-08-13 14:09:17.746976770 -0400
fa93d27
@@ -129,24 +129,21 @@ PKG_CHECK_MODULES(CLOCK_MECHANISM, [ gth
fa93d27
 AC_SUBST(CLOCK_MECHANISM_CFLAGS)
fa93d27
 AC_SUBST(CLOCK_MECHANISM_LIBS)
fa93d27
 
fa93d27
-POLKIT_GNOME_REQUIRED=0.7
fa93d27
-POLKIT_DBUS_REQUIRED=0.7
fa93d27
+POLKIT_REQUIRED=0.91
fa93d27
 DBUS_GLIB_REQUIRED=0.71
fa93d27
 DBUS_REQUIRED=1.1.2
fa93d27
 NETWORK_MANAGER_REQUIRED=0.6
fa93d27
  
fa93d27
 # PolicyKit detection; defaults to 'auto' (use it if it's available)
fa93d27
 #
fa93d27
-POLKIT_GNOME_CFLAGS=
fa93d27
-POLKIT_GNOME_LIBS=
fa93d27
-POLKIT_DBUS_CFLAGS=
fa93d27
-POLKIT_DBUS_LIBS=
fa93d27
+POLKIT_CFLAGS=
fa93d27
+POLKIT_LIBS=
fa93d27
 AC_ARG_ENABLE(polkit, AS_HELP_STRING([--enable-polkit],[Enable PolicyKit support (auto)]),enable_polkit=$enableval,enable_polkit=auto)
fa93d27
 if test "x$enable_polkit" = "xno" ; then
fa93d27
   HAVE_POLKIT=no
fa93d27
 else
fa93d27
   HAVE_POLKIT=no
fa93d27
-  PKG_CHECK_MODULES(POLKIT_GNOME, polkit-gnome >= $POLKIT_GNOME_REQUIRED dbus-1 >= $DBUS_REQUIRED, HAVE_POLKIT=yes, HAVE_POLKIT=no)
fa93d27
+  PKG_CHECK_MODULES(POLKIT, polkit-gobject-1 >= $POLKIT_REQUIRED dbus-1 >= $DBUS_REQUIRED, HAVE_POLKIT=yes, HAVE_POLKIT=no)
fa93d27
  
fa93d27
   if test "x$enable_polkit" = "xyes" -a "x$HAVE_POLKIT" = "xno" ; then
fa93d27
     AC_MSG_ERROR(PolicyKit support explicity enabled but not available)
fa93d27
@@ -154,16 +151,11 @@ else
fa93d27
 
fa93d27
   if test "x$HAVE_POLKIT" = "xyes" ; then
fa93d27
     AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled])
fa93d27
-    PKG_CHECK_MODULES(POLKIT_DBUS, polkit-dbus >= $POLKIT_DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gobject-2.0)
fa93d27
-    AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
fa93d27
-                  [polkit-policy-file-validate], [polkit-policy-file-validate])
fa93d27
   fi
fa93d27
 fi
fa93d27
 AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes")
fa93d27
-AC_SUBST(POLKIT_GNOME_CFLAGS)
fa93d27
-AC_SUBST(POLKIT_GNOME_LIBS)
fa93d27
-AC_SUBST(POLKIT_DBUS_CFLAGS)
fa93d27
-AC_SUBST(POLKIT_DBUS_LIBS)
fa93d27
+AC_SUBST(POLKIT_CFLAGS)
fa93d27
+AC_SUBST(POLKIT_LIBS)
fa93d27
 
fa93d27
 AC_ARG_ENABLE(network_manager, AS_HELP_STRING([--enable-network-manager],[Enable NetworkManager support (auto)]),enable_network_manager=$enableval,enable_network_manager=auto)
fa93d27
 if test "x$enable_network_manager" = "xno" ; then