1
--- indicator-session-0.1.4/configure.ac 2009-09-22 09:12:00.000000000 +0200
2
+++ indicator-session-0.1.4.new/configure.ac 2009-09-22 09:11:42.000000000 +0200
4
GTK_REQUIRED_VERSION=2.12
5
INDICATOR_REQUIRED_VERSION=0.2.0
6
DBUSMENUGTK_REQUIRED_VERSION=0.1.1
7
+POLKIT_REQUIRED_VERSION=0.92
9
PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
10
indicator >= $INDICATOR_REQUIRED_VERSION
12
AC_SUBST(SESSIONERVICE_LIBS)
14
PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-2.0 >= $GTK_REQUIRED_VERSION
16
+ polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
19
AC_SUBST(GTKLOGOUTHELPER_CFLAGS)
20
AC_SUBST(GTKLOGOUTHELPER_LIBS)
21
diff -ur indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.c indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.c
22
--- indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.c 2009-09-22 09:12:00.000000000 +0200
23
+++ indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.c 2009-09-22 09:11:43.000000000 +0200
27
#include <dbus/dbus-glib.h>
28
-#include <polkit-gnome/polkit-gnome.h>
29
+#include <polkit/polkit.h>
31
#include "logout-dialog.h"
32
#include "ck-pk-helper.h"
37
- PolKitResult polres;
38
+ PolkitAuthorizationResult *polres = NULL;
39
+ gboolean ret = FALSE;
40
if (pk_can_do_action(pk_action, &polres)) {
41
- if (polres == POLKIT_RESULT_YES) {
43
+ if (polkit_authorization_result_get_is_challenge (polres)) {
47
+ g_debug ("pk_require_auth(%s): authorized, is_challenge: %i", pk_action, ret);
49
+ g_debug ("pk_require_auth(%s): not authorized", pk_action);
52
+ g_object_unref (polres);
59
-pk_can_do_action (const gchar *action_id, PolKitResult * pol_result)
60
+pk_can_do_action (const gchar *action_id, PolkitAuthorizationResult ** pol_result)
62
- PolKitGnomeContext *gnome_context;
63
- PolKitAction *action;
64
- PolKitCaller *caller;
65
- DBusError dbus_error;
67
- PolKitResult result;
69
- gnome_context = polkit_gnome_context_get (NULL);
71
- if (gnome_context == NULL) {
75
- if (gnome_context->pk_tracker == NULL) {
79
- dbus_error_init (&dbus_error);
80
- caller = polkit_tracker_get_caller_from_pid (gnome_context->pk_tracker,
83
- dbus_error_free (&dbus_error);
85
- if (caller == NULL) {
89
- action = polkit_action_new ();
90
- if (!polkit_action_set_action_id (action, action_id)) {
91
- polkit_action_unref (action);
92
- polkit_caller_unref (caller);
96
- result = POLKIT_RESULT_UNKNOWN;
98
- result = polkit_context_is_caller_authorized (gnome_context->pk_context,
99
- action, caller, FALSE,
101
- if (polkit_error_is_set (error)) {
102
- polkit_error_free (error);
104
- polkit_action_unref (action);
105
- polkit_caller_unref (caller);
106
+ PolkitAuthority *authority;
107
+ PolkitSubject *subject;
108
+ PolkitAuthorizationResult *result;
111
+ authority = polkit_authority_get();
113
+ g_warning ("Could not get PolicyKit authority instance");
116
+ subject = polkit_unix_process_new (getpid());
118
- if (pol_result != NULL) {
119
- *pol_result = result;
121
+ result = polkit_authority_check_authorization_sync (authority, subject, action_id, NULL, 0, NULL, NULL);
122
+ g_object_unref (authority);
124
- return result != POLKIT_RESULT_NO && result != POLKIT_RESULT_UNKNOWN;
127
+ ret = polkit_authorization_result_get_is_authorized (result) ||
128
+ polkit_authorization_result_get_is_challenge (result);
129
+ g_debug ("pk_can_do_action(%s): %i", action_id, ret);
131
+ g_warning ("pk_can_do_action(%s): check_authorization returned NULL", action_id);
134
+ *pol_result = result;
136
+ g_object_unref (result);
141
diff -ur indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.h indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.h
142
--- indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.h 2009-09-22 09:12:00.000000000 +0200
143
+++ indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.h 2009-09-22 09:11:43.000000000 +0200
145
#ifndef __CK_PK_HELPER_H__
146
#define __CK_PK_HELPER_H__ 1
148
-#include <polkit-gnome/polkit-gnome.h>
149
+#include <polkit/polkit.h>
151
gboolean pk_require_auth (LogoutDialogAction action);
152
-gboolean pk_can_do_action (const gchar *action_id, PolKitResult * pol_result);
153
+gboolean pk_can_do_action (const gchar *action_id, PolkitAuthorizationResult ** pol_result);
155
#endif /* __CK_PK_HELPER__ */