polkitbackendauthority.h \
polkitbackendlocalauthority.h \
polkitbackendactionpool.h \
+ polkitbackendpendingcall.h \
polkitbackendserver.h \
$(NULL)
libpolkit_backend_1_la_SOURCES = \
polkitbackend.h \
polkitbackendtypes.h \
+ polkitbackendprivate.h \
polkitbackendauthority.h polkitbackendauthority.c \
polkitbackendlocalauthority.h polkitbackendlocalauthority.c \
polkitbackendactionpool.h polkitbackendactionpool.c \
+ polkitbackendpendingcall.h polkitbackendpendingcall.c \
polkitbackendserver.h polkitbackendserver.c \
$(NULL)
#define _POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H 1
#include <polkitbackend/polkitbackendtypes.h>
+#include <polkitbackend/polkitbackendpendingcall.h>
#include <polkitbackend/polkitbackendauthority.h>
#include <polkitbackend/polkitbackendlocalauthority.h>
#include <polkitbackend/polkitbackendactionpool.h>
{
}
-GList *
-polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
- const gchar *locale,
- GError **error)
+void
+polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
+ const gchar *locale,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendAuthorityClass *klass;
klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
- return klass->enumerate_actions (authority, locale, error);
+ klass->enumerate_actions (authority, locale, pending_call);
}
-GList *
-polkit_backend_authority_enumerate_users (PolkitBackendAuthority *authority,
- GError **error)
+void
+polkit_backend_authority_enumerate_users (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendAuthorityClass *klass;
klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
- return klass->enumerate_users (authority, error);
+ klass->enumerate_users (authority, pending_call);
}
-GList *
-polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
- GError **error)
+void
+polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendAuthorityClass *klass;
klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
- return klass->enumerate_groups (authority, error);
+ klass->enumerate_groups (authority, pending_call);
}
/*< public >*/
- GList * (*enumerate_actions) (PolkitBackendAuthority *authority,
- const gchar *locale,
- GError **error);
+ void (*enumerate_actions) (PolkitBackendAuthority *authority,
+ const gchar *locale,
+ PolkitBackendPendingCall *pending_call);
- GList * (*enumerate_users) (PolkitBackendAuthority *authority,
- GError **error);
+ void (*enumerate_users) (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call);
- GList * (*enumerate_groups) (PolkitBackendAuthority *authority,
- GError **error);
+ void (*enumerate_groups) (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call);
/*< private >*/
/* Padding for future expansion */
void (*_polkit_reserved8) (void);
};
-GType polkit_backend_authority_get_type (void) G_GNUC_CONST;
+GType polkit_backend_authority_get_type (void) G_GNUC_CONST;
-GList *polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
- const gchar *locale,
- GError **error);
+void polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
+ const gchar *locale,
+ PolkitBackendPendingCall *pending_call);
-GList *polkit_backend_authority_enumerate_users (PolkitBackendAuthority *authority,
- GError **error);
+void polkit_backend_authority_enumerate_users (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call);
-GList *polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
- GError **error);
+void polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call);
+
+void polkit_backend_authority_enumerate_actions_finish (PolkitBackendPendingCall *pending_call,
+ GList *actions);
+
+void polkit_backend_authority_enumerate_users_finish (PolkitBackendPendingCall *pending_call,
+ GList *users);
+
+void polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendingCall *pending_call,
+ GList *groups);
G_END_DECLS
#include <polkit/polkit.h>
#include "polkitbackendlocalauthority.h"
#include "polkitbackendactionpool.h"
+#include "polkitbackendpendingcall.h"
typedef struct
{
} PolkitBackendLocalAuthorityPrivate;
-static GList *polkit_backend_local_authority_enumerate_actions (PolkitBackendAuthority *authority,
- const gchar *locale,
- GError **error);
+static void polkit_backend_local_authority_enumerate_actions (PolkitBackendAuthority *authority,
+ const gchar *locale,
+ PolkitBackendPendingCall *pending_call);
-static GList *polkit_backend_local_authority_enumerate_users (PolkitBackendAuthority *authority,
- GError **error);
+static void polkit_backend_local_authority_enumerate_users (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call);
-static GList *polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority *authority,
- GError **error);
+static void polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call);
G_DEFINE_TYPE (PolkitBackendLocalAuthority, polkit_backend_local_authority, POLKIT_BACKEND_TYPE_AUTHORITY);
/* ---------------------------------------------------------------------------------------------------- */
-static GList *
-polkit_backend_local_authority_enumerate_actions (PolkitBackendAuthority *authority,
- const gchar *locale,
- GError **error)
+static void
+polkit_backend_local_authority_enumerate_actions (PolkitBackendAuthority *authority,
+ const gchar *locale,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendLocalAuthority *local_authority;
PolkitBackendLocalAuthorityPrivate *priv;
+ GList *actions;
local_authority = POLKIT_BACKEND_LOCAL_AUTHORITY (authority);
priv = POLKIT_BACKEND_LOCAL_AUTHORITY_GET_PRIVATE (local_authority);
- return polkit_backend_action_pool_get_all_actions (priv->action_pool, locale);
+ actions = polkit_backend_action_pool_get_all_actions (priv->action_pool, locale);
+
+ polkit_backend_authority_enumerate_actions_finish (pending_call,
+ actions);
}
-static GList *
-polkit_backend_local_authority_enumerate_users (PolkitBackendAuthority *authority,
- GError **error)
+static void
+polkit_backend_local_authority_enumerate_users (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendLocalAuthority *local_authority;
PolkitBackendLocalAuthorityPrivate *priv;
passwd = getpwent ();
if (passwd == NULL)
{
- g_set_error (error,
- POLKIT_ERROR,
- POLKIT_ERROR_FAILED,
- "getpwent failed: %s",
- strerror (errno));
+ polkit_backend_pending_call_return_error (pending_call,
+ POLKIT_ERROR,
+ POLKIT_ERROR_FAILED,
+ "getpwent failed: %s",
+ strerror (errno));
goto out;
}
list = g_list_reverse (list);
+ polkit_backend_authority_enumerate_users_finish (pending_call, list);
+
out:
- return list;
+ ;
}
-static GList *
-polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority *authority,
- GError **error)
+static void
+polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority *authority,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendLocalAuthority *local_authority;
PolkitBackendLocalAuthorityPrivate *priv;
group = getgrent ();
if (group == NULL)
{
- g_set_error (error,
- POLKIT_ERROR,
- POLKIT_ERROR_FAILED,
- "getgrent failed: %s",
- strerror (errno));
+ polkit_backend_pending_call_return_error (pending_call,
+ POLKIT_ERROR,
+ POLKIT_ERROR_FAILED,
+ "getpwent failed: %s",
+ strerror (errno));
goto out;
}
list = g_list_reverse (list);
- out:
- return list;
-}
-
-#if 0
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
-authority_iface_handle_say_hello (PolkitAuthority *authority,
- const gchar *message,
- EggDBusMethodInvocation *method_invocation)
-{
- gchar *result;
-
- result = g_strdup_printf ("You said '%s' to the AUTHORITY!", message);
-
- polkit_authority_handle_say_hello_finish (method_invocation,
- result);
-
- g_free (result);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
-authority_iface_handle_enumerate_users (PolkitAuthority *authority,
- EggDBusMethodInvocation *method_invocation)
-{
- struct passwd *passwd;
- GList *list;
-
- list = NULL;
-
- passwd = getpwent ();
- if (passwd == NULL)
- {
- egg_dbus_method_invocation_return_error (method_invocation,
- POLKIT_ERROR,
- POLKIT_ERROR_FAILED,
- "getpwent failed: %s",
- strerror (errno));
- goto out;
- }
-
- do
- {
- PolkitSubject *subject;
-
- subject = polkit_subject_new_for_unix_user (passwd->pw_uid);
-
- list = g_list_prepend (list, subject);
- }
- while ((passwd = getpwent ()) != NULL);
- endpwent ();
-
- list = g_list_reverse (list);
-
- polkit_authority_handle_enumerate_users_finish (method_invocation,
- list);
+ polkit_backend_authority_enumerate_groups_finish (pending_call, list);
out:
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ ;
}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
-authority_iface_handle_enumerate_actions (PolkitAuthority *authority,
- const gchar *locale,
- EggDBusMethodInvocation *method_invocation)
-{
- PolkitBackendLocalAuthority *local_authority;
- PolkitBackendLocalAuthorityPrivate *priv;
- GList *list;
-
- local_authority = POLKIT_BACKEND_LOCAL_AUTHORITY (authority);
- priv = POLKIT_BACKEND_LOCAL_AUTHORITY_GET_PRIVATE (local_authority);
-
- list = polkit_backend_action_pool_get_all_actions (priv->action_pool,
- locale);
-
- polkit_authority_handle_enumerate_actions_finish (method_invocation,
- list);
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
-authority_iface_init (PolkitAuthorityIface *authority_iface,
- gpointer iface_data)
-{
- authority_iface->handle_say_hello = authority_iface_handle_say_hello;
- authority_iface->handle_enumerate_users = authority_iface_handle_enumerate_users;
- authority_iface->handle_enumerate_actions = authority_iface_handle_enumerate_actions;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-#endif
--- /dev/null
+/*
+ * 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>
+ */
+
+#include "config.h"
+
+#include <polkit/polkit.h>
+#include "polkitbackendpendingcall.h"
+#include "polkitbackendprivate.h"
+
+typedef struct
+{
+ EggDBusMethodInvocation *method_invocation;
+ PolkitBackendServer *server;
+} PolkitBackendPendingCallPrivate;
+
+G_DEFINE_TYPE (PolkitBackendPendingCall, polkit_backend_pending_call, G_TYPE_OBJECT);
+
+#define POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_BACKEND_TYPE_PENDING_CALL, PolkitBackendPendingCallPrivate))
+
+static void
+polkit_backend_pending_call_init (PolkitBackendPendingCall *pending_call)
+{
+ PolkitBackendPendingCallPrivate *priv;
+
+ priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
+
+}
+
+static void
+polkit_backend_pending_call_finalize (GObject *object)
+{
+ PolkitBackendPendingCall *pending_call;
+ PolkitBackendPendingCallPrivate *priv;
+
+ pending_call = POLKIT_BACKEND_PENDING_CALL (object);
+ priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
+
+ g_object_unref (priv->method_invocation);
+ g_object_unref (priv->server);
+
+ G_OBJECT_CLASS (polkit_backend_pending_call_parent_class)->finalize (object);
+}
+
+static void
+polkit_backend_pending_call_class_init (PolkitBackendPendingCallClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = polkit_backend_pending_call_finalize;
+
+ g_type_class_add_private (klass, sizeof (PolkitBackendPendingCallPrivate));
+}
+
+PolkitBackendPendingCall *
+_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation,
+ PolkitBackendServer *server)
+{
+ PolkitBackendPendingCall *pending_call;
+ PolkitBackendPendingCallPrivate *priv;
+
+ pending_call = POLKIT_BACKEND_PENDING_CALL (g_object_new (POLKIT_BACKEND_TYPE_PENDING_CALL,
+ NULL));
+
+ priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
+
+ priv->method_invocation = g_object_ref (method_invocation);
+ priv->server = g_object_ref (server);
+
+ return pending_call;
+}
+
+PolkitBackendServer *
+polkit_backend_pending_call_get_server (PolkitBackendPendingCall *pending_call)
+{
+ PolkitBackendPendingCallPrivate *priv;
+ priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
+ return priv->server;
+}
+
+EggDBusMethodInvocation *
+_polkit_backend_pending_call_get_method_invocation (PolkitBackendPendingCall *pending_call)
+{
+ PolkitBackendPendingCallPrivate *priv;
+ priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
+ return priv->method_invocation;
+}
+
+
+PolkitSubject *
+polkit_backend_pending_call_get_caller (PolkitBackendPendingCall *pending_call)
+{
+ /* TODO: implement */
+ return NULL;
+}
+
+void
+polkit_backend_pending_call_return_gerror (PolkitBackendPendingCall *pending_call,
+ GError *error)
+{
+ PolkitBackendPendingCallPrivate *priv;
+
+ priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
+
+ egg_dbus_method_invocation_return_gerror (priv->method_invocation,
+ error);
+
+ g_object_unref (pending_call);
+}
+
+void
+polkit_backend_pending_call_return_error (PolkitBackendPendingCall *pending_call,
+ GQuark domain,
+ gint code,
+ const gchar *format,
+ ...)
+{
+ GError *error;
+ va_list va_args;
+ gchar *literal_message;
+
+ va_start (va_args, format);
+ literal_message = g_strdup_vprintf (format, va_args);
+
+ error = g_error_new_literal (domain,
+ code,
+ literal_message);
+
+ polkit_backend_pending_call_return_gerror (pending_call, error);
+
+ g_error_free (error);
+ g_free (literal_message);
+ va_end (va_args);
+}
+
--- /dev/null
+/*
+ * 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>
+ */
+
+#if !defined (_POLKIT_BACKEND_COMPILATION) && !defined(_POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H)
+#error "Only <polkitbackend/polkitbackend.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __POLKIT_BACKEND_PENDING_CALL_H
+#define __POLKIT_BACKEND_PENDING_CALL_H
+
+#include <glib-object.h>
+#include "polkitbackendtypes.h"
+
+G_BEGIN_DECLS
+
+#define POLKIT_BACKEND_TYPE_PENDING_CALL (polkit_backend_pending_call_get_type ())
+#define POLKIT_BACKEND_PENDING_CALL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_PENDING_CALL, PolkitBackendPendingCall))
+#define POLKIT_BACKEND_PENDING_CALL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_PENDING_CALL, PolkitBackendPendingCallClass))
+#define POLKIT_BACKEND_PENDING_CALL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_PENDING_CALL,PolkitBackendPendingCallClass))
+#define POLKIT_BACKEND_IS_PENDING_CALL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_PENDING_CALL))
+#define POLKIT_BACKEND_IS_PENDING_CALL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_PENDING_CALL))
+
+#if 0
+typedef struct _PolkitBackendPendingCall PolkitBackendPendingCall;
+#endif
+typedef struct _PolkitBackendPendingCallClass PolkitBackendPendingCallClass;
+
+struct _PolkitBackendPendingCall
+{
+ GObject parent_instance;
+};
+
+struct _PolkitBackendPendingCallClass
+{
+ GObjectClass parent_class;
+
+ /*< public >*/
+
+ /*< private >*/
+ /* Padding for future expansion */
+ void (*_polkit_reserved1) (void);
+ void (*_polkit_reserved2) (void);
+ void (*_polkit_reserved3) (void);
+ void (*_polkit_reserved4) (void);
+ void (*_polkit_reserved5) (void);
+ void (*_polkit_reserved6) (void);
+ void (*_polkit_reserved7) (void);
+ void (*_polkit_reserved8) (void);
+};
+
+GType polkit_backend_pending_call_get_type (void) G_GNUC_CONST;
+PolkitSubject *polkit_backend_pending_call_get_caller (PolkitBackendPendingCall *pending_call);
+PolkitBackendServer *polkit_backend_pending_call_get_server (PolkitBackendPendingCall *pending_call);
+void polkit_backend_pending_call_return_error (PolkitBackendPendingCall *pending_call,
+ GQuark domain,
+ gint code,
+ const gchar *format,
+ ...);
+void polkit_backend_pending_call_return_gerror (PolkitBackendPendingCall *pending_call,
+ GError *error);
+
+
+
+G_END_DECLS
+
+#endif /* __POLKIT_BACKEND_PENDING_CALL_H */
+
--- /dev/null
+/*
+ * 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_BACKEND_PRIVATE_H
+#define __POLKIT_BACKEND_PRIVATE_H
+
+#include <polkit/_polkitbindings.h>
+#include "polkitbackendpendingcall.h"
+#include "polkitbackendserver.h"
+
+PolkitBackendPendingCall *_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation,
+ PolkitBackendServer *server);
+
+EggDBusMethodInvocation *_polkit_backend_pending_call_get_method_invocation (PolkitBackendPendingCall *pending_call);
+
+#endif /* __POLKIT_BACKEND_PRIVATE_H */
#include "polkitbackendauthority.h"
#include "polkitbackendserver.h"
+#include "polkitbackendprivate.h"
struct _PolkitBackendServer
{
EggDBusMethodInvocation *method_invocation)
{
PolkitBackendServer *server = POLKIT_BACKEND_SERVER (instance);
- EggDBusArraySeq *array;
- GError *error;
- GList *actions;
- GList *l;
+ PolkitBackendPendingCall *pending_call;
- error = NULL;
- actions = polkit_backend_authority_enumerate_actions (server->authority, locale, &error);
+ pending_call = _polkit_backend_pending_call_new (method_invocation, server);
- if (error != NULL)
- {
- egg_dbus_method_invocation_return_gerror (method_invocation, error);
- g_error_free (error);
- goto out;
- }
+ polkit_backend_authority_enumerate_actions (server->authority, locale, pending_call);
+}
+
+void
+polkit_backend_authority_enumerate_actions_finish (PolkitBackendPendingCall *pending_call,
+ GList *actions)
+{
+ EggDBusArraySeq *array;
+ GList *l;
array = egg_dbus_array_seq_new (_POLKIT_TYPE_ACTION_DESCRIPTION, (GDestroyNotify) g_object_unref, NULL, NULL);
egg_dbus_array_seq_add (array, real);
}
- _polkit_authority_handle_enumerate_actions_finish (method_invocation, array);
+ _polkit_authority_handle_enumerate_actions_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
+ array);
g_object_unref (array);
g_list_foreach (actions, (GFunc) g_object_unref, NULL);
g_list_free (actions);
- out:
- ;
+ g_object_unref (pending_call);
}
static void
EggDBusMethodInvocation *method_invocation)
{
PolkitBackendServer *server = POLKIT_BACKEND_SERVER (instance);
- EggDBusArraySeq *array;
- GError *error;
- GList *subjects;
- GList *l;
+ PolkitBackendPendingCall *pending_call;
- error = NULL;
- subjects = polkit_backend_authority_enumerate_users (server->authority, &error);
+ pending_call = _polkit_backend_pending_call_new (method_invocation, server);
- if (error != NULL)
- {
- egg_dbus_method_invocation_return_gerror (method_invocation, error);
- g_error_free (error);
- goto out;
- }
+ polkit_backend_authority_enumerate_users (server->authority, pending_call);
+}
+
+void
+polkit_backend_authority_enumerate_users_finish (PolkitBackendPendingCall *pending_call,
+ GList *users)
+{
+ EggDBusArraySeq *array;
+ GList *l;
array = egg_dbus_array_seq_new (_POLKIT_TYPE_SUBJECT, (GDestroyNotify) g_object_unref, NULL, NULL);
- for (l = subjects; l != NULL; l = l->next)
+ for (l = users; l != NULL; l = l->next)
{
PolkitSubject *subject = POLKIT_SUBJECT (l->data);
_PolkitSubject *real;
egg_dbus_array_seq_add (array, real);
}
- _polkit_authority_handle_enumerate_users_finish (method_invocation, array);
+ _polkit_authority_handle_enumerate_users_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
+ array);
g_object_unref (array);
- g_list_foreach (subjects, (GFunc) g_object_unref, NULL);
- g_list_free (subjects);
-
- out:
- ;
+ g_list_foreach (users, (GFunc) g_object_unref, NULL);
+ g_list_free (users);
}
static void
EggDBusMethodInvocation *method_invocation)
{
PolkitBackendServer *server = POLKIT_BACKEND_SERVER (instance);
- EggDBusArraySeq *array;
- GError *error;
- GList *subjects;
- GList *l;
+ PolkitBackendPendingCall *pending_call;
- error = NULL;
- subjects = polkit_backend_authority_enumerate_groups (server->authority, &error);
+ pending_call = _polkit_backend_pending_call_new (method_invocation, server);
- if (error != NULL)
- {
- egg_dbus_method_invocation_return_gerror (method_invocation, error);
- g_error_free (error);
- goto out;
- }
+ polkit_backend_authority_enumerate_groups (server->authority, pending_call);
+}
+
+void
+polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendingCall *pending_call,
+ GList *groups)
+{
+ EggDBusArraySeq *array;
+ GList *l;
array = egg_dbus_array_seq_new (_POLKIT_TYPE_SUBJECT, (GDestroyNotify) g_object_unref, NULL, NULL);
- for (l = subjects; l != NULL; l = l->next)
+ for (l = groups; l != NULL; l = l->next)
{
PolkitSubject *subject = POLKIT_SUBJECT (l->data);
_PolkitSubject *real;
egg_dbus_array_seq_add (array, real);
}
- _polkit_authority_handle_enumerate_groups_finish (method_invocation, array);
+ _polkit_authority_handle_enumerate_groups_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
+ array);
g_object_unref (array);
- g_list_foreach (subjects, (GFunc) g_object_unref, NULL);
- g_list_free (subjects);
-
- out:
- ;
+ g_list_foreach (groups, (GFunc) g_object_unref, NULL);
+ g_list_free (groups);
}
static void
struct _PolkitBackendAuthority;
typedef struct _PolkitBackendAuthority PolkitBackendAuthority;
+struct _PolkitBackendPendingCall;
+typedef struct _PolkitBackendPendingCall PolkitBackendPendingCall;
+
struct _PolkitBackendServer;
typedef struct _PolkitBackendServer PolkitBackendServer;
static gboolean list_users (void);
static gboolean list_groups (void);
+static gboolean check (void);
+
static gboolean show_action (const gchar *action_id);
static void
}
else if (opt_check)
{
- g_print ("subject '%s' action-id '%s'\n", polkit_subject_to_string (subject), action_id);
- g_assert (FALSE);
+ if (subject == NULL || action_id == NULL)
+ {
+ usage (argc, argv);
+ goto out;
+ }
+
+ ret = check ();
}
else
{
out:
return ret;
}
+
+static gboolean
+check (void)
+{
+ PolkitAuthorizationResult result;
+ PolkitAuthorizationClaim *claim;
+ GError *error;
+
+ error = NULL;
+ claim = NULL;
+ result = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
+
+ claim = polkit_authorization_claim_new (subject,
+ action_id);
+
+ result = polkit_authority_check_claim_sync (authority,
+ claim,
+ NULL,
+ &error);
+ if (error != NULL)
+ {
+ g_printerr ("Error checking authorization claim: %s\n", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_debug ("result = %d", result);
+
+ out:
+ if (claim != NULL)
+ g_object_unref (claim);
+
+ return result == POLKIT_AUTHORIZATION_RESULT_AUTHORIZED;
+}
+