[PolicyKit-gnome] Use new API in polkit 0.95 for lock down
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [PolicyKit-gnome] Use new API in polkit 0.95 for lock down
- Date: Wed, 11 Nov 2009 22:13:34 +0000 (UTC)
commit fa5e2491081fb0a24d795fdcefe2d01f9bd0759f
Author: David Zeuthen <davidz redhat com>
Date: Wed Nov 11 17:11:59 2009 -0500
Use new API in polkit 0.95 for lock down
These polkit commits explain the new API
http://cgit.freedesktop.org/PolicyKit/commit/?id=00c00948004b605d424d1e74c91dea5521042571
http://cgit.freedesktop.org/PolicyKit/commit/?id=8f7727e1df53e9eaa2a36fd6ee8eaf41b209a3f0
http://cgit.freedesktop.org/PolicyKit/commit/?id=49de132d4ed313926f7e7f92da22cd6a3e50da18
configure.ac | 4 +-
polkitgtk/example.c | 4 +-
polkitgtk/polkitlockbutton.c | 68 ++++++++++++++++++++++++++++++++++-------
3 files changed, 60 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 767d5b0..97c10bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,8 +119,8 @@ GNOME_MAINTAINER_MODE_DEFINES
# ***************************
GTK_REQUIRED=2.17.1
-POLKIT_AGENT_REQUIRED=0.93
-POLKIT_GOBJECT_REQUIRED=0.93
+POLKIT_AGENT_REQUIRED=0.95
+POLKIT_GOBJECT_REQUIRED=0.95
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(GTK_CFLAGS)
diff --git a/polkitgtk/example.c b/polkitgtk/example.c
index 79ddc91..23e2c79 100644
--- a/polkitgtk/example.c
+++ b/polkitgtk/example.c
@@ -61,12 +61,12 @@ update_one (PolkitSubject *subject,
else
{
g_string_append_printf (s,
- "authorized=%d challenge=%d retains=%d temporary=%d lockdown=%d",
+ "authorized=%d challenge=%d retains=%d temporary=%d locked_down=%d",
polkit_authorization_result_get_is_authorized (result),
polkit_authorization_result_get_is_challenge (result),
polkit_authorization_result_get_retains_authorization (result),
polkit_authorization_result_get_temporary_authorization_id (result) != NULL,
- polkit_authorization_result_get_local_authority_lock_down (result));
+ polkit_authorization_result_get_locked_down (result));
g_object_unref (result);
}
diff --git a/polkitgtk/polkitlockbutton.c b/polkitgtk/polkitlockbutton.c
index 5348773..be81b02 100644
--- a/polkitgtk/polkitlockbutton.c
+++ b/polkitgtk/polkitlockbutton.c
@@ -809,8 +809,8 @@ process_result (PolkitLockButton *button,
old_authorized = button->priv->authorized;
button->priv->can_obtain = polkit_authorization_result_get_is_challenge (result);
button->priv->authorized = polkit_authorization_result_get_is_authorized (result);
- button->priv->can_lock_down = TRUE; /* TODO: check if we're using the Local Authority */
- button->priv->locked_down = polkit_authorization_result_get_local_authority_lock_down (result);
+ button->priv->can_lock_down = polkit_authority_get_backend_features (button->priv->authority) & POLKIT_AUTHORITY_FEATURES_LOCKDOWN;
+ button->priv->locked_down = polkit_authorization_result_get_locked_down (result);
/* save the temporary authorization id */
g_free (button->priv->tmp_authz_id);
@@ -968,6 +968,28 @@ interactive_check_cb (GObject *source_object,
}
}
+static void
+remove_lockdown_cb (PolkitAuthority *authority,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data);
+ GError *error;
+
+ error = NULL;
+ if (!polkit_authority_remove_lockdown_for_action_finish (button->priv->authority,
+ res,
+ &error))
+ {
+ g_warning ("Error removing lockdown for action %s: %s",
+ button->priv->action_id,
+ error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (button);
+}
+
static gboolean
on_button_press_event (GtkWidget *widget,
GdkEventButton *event,
@@ -980,12 +1002,11 @@ on_button_press_event (GtkWidget *widget,
if (event->button == 3 && button->priv->locked_down)
{
- gchar *command_line;
-
- command_line = g_strdup_printf ("pklalockdown --remove-lockdown %s", button->priv->action_id);
- g_spawn_command_line_async (command_line, NULL);
- g_free (command_line);
-
+ polkit_authority_remove_lockdown_for_action (button->priv->authority,
+ button->priv->action_id,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback) remove_lockdown_cb,
+ g_object_ref (button));
/* eat this event */
ret = TRUE;
}
@@ -994,6 +1015,28 @@ on_button_press_event (GtkWidget *widget,
}
static void
+add_lockdown_cb (PolkitAuthority *authority,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data);
+ GError *error;
+
+ error = NULL;
+ if (!polkit_authority_add_lockdown_for_action_finish (button->priv->authority,
+ res,
+ &error))
+ {
+ g_warning ("Error adding lockdown for action %s: %s",
+ button->priv->action_id,
+ error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (button);
+}
+
+static void
on_clicked (GtkButton *_button,
gpointer user_data)
{
@@ -1027,10 +1070,11 @@ on_clicked (GtkButton *_button,
else if (button->priv->authorized && button->priv->tmp_authz_id == NULL &&
button->priv->can_lock_down && !button->priv->locked_down)
{
- gchar *command_line;
- command_line = g_strdup_printf ("pklalockdown --lockdown %s", button->priv->action_id);
- g_spawn_command_line_async (command_line, NULL);
- g_free (command_line);
+ polkit_authority_add_lockdown_for_action (button->priv->authority,
+ button->priv->action_id,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback) add_lockdown_cb,
+ g_object_ref (button));
}
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]