summaryrefslogtreecommitdiff
path: root/src/polkit
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-01-18 16:14:39 -0500
committerDavid Zeuthen <davidz@redhat.com>2009-01-18 16:14:39 -0500
commit4653150b07c83d9140893b115699bdc1c238ee1a (patch)
treea9168a2effd0e3f3b2552cc091f667ec5cb5e2bb /src/polkit
parentf8ce12a6cb950073fab66f6dccbfff4eed85849a (diff)
downloadpolkit-4653150b07c83d9140893b115699bdc1c238ee1a.tar.gz
rename CheckClaim() to CheckAuthorization()
Also get rid of AuthorizationClaim type and add D-Bus prototypes for a couple of other methods.
Diffstat (limited to 'src/polkit')
-rw-r--r--src/polkit/Makefile.am7
-rw-r--r--src/polkit/polkit.h2
-rw-r--r--src/polkit/polkitauthority.c87
-rw-r--r--src/polkit/polkitauthority.h30
-rw-r--r--src/polkit/polkitcheckauthorizationflags.c35
-rw-r--r--src/polkit/polkitcheckauthorizationflags.h50
-rw-r--r--src/polkit/polkitprivate.h2
7 files changed, 162 insertions, 51 deletions
diff --git a/src/polkit/Makefile.am b/src/polkit/Makefile.am
index 3a62076..0dc1af7 100644
--- a/src/polkit/Makefile.am
+++ b/src/polkit/Makefile.am
@@ -18,8 +18,9 @@ INCLUDES = \
BUILT_SOURCES = \
_polkitactiondescription.c _polkitactiondescription.h \
_polkitauthority.c _polkitauthority.h \
- _polkitauthorizationclaim.c _polkitauthorizationclaim.h \
+ _polkitauthorization.c _polkitauthorization.h \
_polkitauthorizationresult.c _polkitauthorizationresult.h \
+ _polkitcheckauthorizationflags.c _polkitcheckauthorizationflags.h \
_polkitbindings.c _polkitbindings.h \
_polkitbindingsmarshal.c _polkitbindingsmarshal.h \
_polkitbindingstypes.h \
@@ -49,8 +50,8 @@ libpolkit_gobject_1include_HEADERS = \
polkitunixprocess.h \
polkitunixsession.h \
polkitsystembusname.h \
- polkitauthorizationclaim.h \
polkitauthorizationresult.h \
+ polkitcheckauthorizationflags.h \
$(NULL)
libpolkit_gobject_1_la_SOURCES = \
@@ -65,8 +66,8 @@ libpolkit_gobject_1_la_SOURCES = \
polkitunixprocess.c polkitunixprocess.h \
polkitunixsession.c polkitunixsession.h \
polkitsystembusname.c polkitsystembusname.h \
- polkitauthorizationclaim.c polkitauthorizationclaim.h \
polkitauthorizationresult.c polkitauthorizationresult.h \
+ polkitcheckauthorizationflags.c polkitcheckauthorizationflags.h \
$(NULL)
libpolkit_gobject_1_la_CFLAGS = \
diff --git a/src/polkit/polkit.h b/src/polkit/polkit.h
index 40df617..d872d54 100644
--- a/src/polkit/polkit.h
+++ b/src/polkit/polkit.h
@@ -32,8 +32,8 @@
#include <polkit/polkitunixprocess.h>
#include <polkit/polkitunixsession.h>
#include <polkit/polkitsystembusname.h>
-#include <polkit/polkitauthorizationclaim.h>
#include <polkit/polkitauthorizationresult.h>
+#include <polkit/polkitcheckauthorizationflags.h>
#include <polkit/polkitauthority.h>
#undef _POLKIT_INSIDE_POLKIT_H
diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c
index 1646467..60f5017 100644
--- a/src/polkit/polkitauthority.c
+++ b/src/polkit/polkitauthority.c
@@ -24,6 +24,7 @@
#endif
#include "polkitauthorizationresult.h"
+#include "polkitcheckauthorizationflags.h"
#include "polkitauthority.h"
#include "polkitprivate.h"
@@ -519,51 +520,61 @@ polkit_authority_enumerate_sessions_sync (PolkitAuthority *authority,
/* ---------------------------------------------------------------------------------------------------- */
static guint
-polkit_authority_check_claim_async (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+polkit_authority_check_authorization_async (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- _PolkitAuthorizationClaim *real_claim;
+ _PolkitSubject *real_subject;
guint call_id;
GSimpleAsyncResult *simple;
- real_claim = polkit_authorization_claim_get_real (claim);
+ real_subject = polkit_subject_get_real (subject);
simple = g_simple_async_result_new (G_OBJECT (authority),
callback,
user_data,
- polkit_authority_check_claim_async);
+ polkit_authority_check_authorization_async);
- g_object_set_data_full (G_OBJECT (simple), "claim", g_object_ref (claim), (GDestroyNotify) g_object_unref);
+ call_id = _polkit_authority_check_authorization (authority->real,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ real_subject,
+ action_id,
+ flags,
+ cancellable,
+ generic_async_cb,
+ simple);
- call_id = _polkit_authority_check_claim (authority->real,
- EGG_DBUS_CALL_FLAGS_NONE,
- real_claim,
- cancellable,
- generic_async_cb,
- simple);
-
- g_object_unref (real_claim);
+ g_object_unref (real_subject);
return call_id;
}
void
-polkit_authority_check_claim (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+polkit_authority_check_authorization (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- polkit_authority_check_claim_async (authority, claim, cancellable, callback, user_data);
+ polkit_authority_check_authorization_async (authority,
+ subject,
+ action_id,
+ flags,
+ cancellable,
+ callback,
+ user_data);
}
PolkitAuthorizationResult
-polkit_authority_check_claim_finish (PolkitAuthority *authority,
- GAsyncResult *res,
- GError **error)
+polkit_authority_check_authorization_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error)
{
_PolkitAuthorizationResult result;
GSimpleAsyncResult *simple;
@@ -572,11 +583,11 @@ polkit_authority_check_claim_finish (PolkitAuthority *authority,
simple = G_SIMPLE_ASYNC_RESULT (res);
real_res = G_ASYNC_RESULT (g_simple_async_result_get_op_res_gpointer (simple));
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_check_claim_async);
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_check_authorization_async);
result = _POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
- if (!_polkit_authority_check_claim_finish (authority->real,
+ if (!_polkit_authority_check_authorization_finish (authority->real,
&result,
real_res,
error))
@@ -588,20 +599,28 @@ polkit_authority_check_claim_finish (PolkitAuthority *authority,
}
PolkitAuthorizationResult
-polkit_authority_check_claim_sync (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GError **error)
+polkit_authority_check_authorization_sync (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GError **error)
{
guint call_id;
GAsyncResult *res;
PolkitAuthorizationResult result;
- call_id = polkit_authority_check_claim_async (authority, claim, cancellable, generic_cb, &res);
+ call_id = polkit_authority_check_authorization_async (authority,
+ subject,
+ action_id,
+ flags,
+ cancellable,
+ generic_cb,
+ &res);
egg_dbus_connection_pending_call_block (authority->system_bus, call_id);
- result = polkit_authority_check_claim_finish (authority, res, error);
+ result = polkit_authority_check_authorization_finish (authority, res, error);
g_object_unref (res);
diff --git a/src/polkit/polkitauthority.h b/src/polkit/polkitauthority.h
index 85b1a51..2b69a4e 100644
--- a/src/polkit/polkitauthority.h
+++ b/src/polkit/polkitauthority.h
@@ -63,10 +63,12 @@ GList *polkit_authority_enumerate_sessions_sync (PolkitAutho
GCancellable *cancellable,
GError **error);
-PolkitAuthorizationResult polkit_authority_check_claim_sync (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GError **error);
+PolkitAuthorizationResult polkit_authority_check_authorization_sync (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GError **error);
/* ---------------------------------------------------------------------------------------------------- */
@@ -107,15 +109,17 @@ GList * polkit_authority_enumerate_sessions_finish (PolkitAut
GAsyncResult *res,
GError **error);
-void polkit_authority_check_claim (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-PolkitAuthorizationResult polkit_authority_check_claim_finish (PolkitAuthority *authority,
- GAsyncResult *res,
- GError **error);
+void polkit_authority_check_authorization (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+PolkitAuthorizationResult polkit_authority_check_authorization_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error);
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/polkit/polkitcheckauthorizationflags.c b/src/polkit/polkitcheckauthorizationflags.c
new file mode 100644
index 0000000..f6e1e23
--- /dev/null
+++ b/src/polkit/polkitcheckauthorizationflags.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "polkitcheckauthorizationflags.h"
+#include "polkitprivate.h"
+
+GType
+polkit_check_authorization_flags_get_type (void)
+{
+ return _polkit_check_authorization_flags_get_type ();
+}
+
+
diff --git a/src/polkit/polkitcheckauthorizationflags.h b/src/polkit/polkitcheckauthorizationflags.h
new file mode 100644
index 0000000..8d284f5
--- /dev/null
+++ b/src/polkit/polkitcheckauthorizationflags.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_CHECK_AUTHORIZATION_FLAGS_H
+#define __POLKIT_CHECK_AUTHORIZATION_FLAGS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+GType polkit_check_authorization_flags_get_type (void) G_GNUC_CONST;
+
+#define POLKIT_TYPE_CHECK_AUTHORIZATION_FLAGS (polkit_check_authorization_flags_get_type ())
+
+/**
+ * PolkitCheckAuthorizationFlags:
+ * @POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE: No flags set.
+ * @POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION: If the subject can obtain the authorization
+ * through authentication, and an authentication agent is available, then attempt to do so. Note, this
+ * means that the method used for checking authorization is likely to block for a long time.
+ *
+ * Possible flags when checking authorizations.
+ */
+typedef enum
+{
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE = 0x0000, /*< nick=none >*/
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION = 0x0001,
+} PolkitCheckAuthorizationFlags;
+
+G_END_DECLS
+
+#endif /* __POLKIT_CHECK_AUTHORIZATION_FLAGS_H */
diff --git a/src/polkit/polkitprivate.h b/src/polkit/polkitprivate.h
index 6aca70e..526de6a 100644
--- a/src/polkit/polkitprivate.h
+++ b/src/polkit/polkitprivate.h
@@ -40,7 +40,9 @@ _PolkitActionDescription *polkit_action_description_get_real (PolkitActionDe
PolkitSubject *polkit_subject_new_for_real (_PolkitSubject *real);
_PolkitSubject *polkit_subject_get_real (PolkitSubject *subject);
+#if 0
PolkitAuthorizationClaim *polkit_authorization_claim_new_for_real (_PolkitAuthorizationClaim *real);
_PolkitAuthorizationClaim *polkit_authorization_claim_get_real (PolkitAuthorizationClaim *claim);
+#endif
#endif /* __POLKIT_PRIVATE_H */