{
GObject parent_instance;
+ EggDBusConnection *system_bus;
EggDBusObjectProxy *authority_object_proxy;
_PolkitAuthority *real;
static void
polkit_authority_init (PolkitAuthority *authority)
{
- EggDBusConnection *system_bus;
-
- system_bus = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
+ authority->system_bus = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
- authority->authority_object_proxy = egg_dbus_connection_get_object_proxy (system_bus,
+ authority->authority_object_proxy = egg_dbus_connection_get_object_proxy (authority->system_bus,
"org.freedesktop.PolicyKit1",
"/org/freedesktop/PolicyKit1/Authority");
authority->real = _POLKIT_QUERY_INTERFACE_AUTHORITY (authority->authority_object_proxy);
-
- g_object_unref (system_bus);
}
static void
authority = POLKIT_AUTHORITY (object);
g_object_unref (authority->authority_object_proxy);
+ g_object_unref (authority->system_bus);
the_authority = NULL;
return the_authority;
}
+static void
+generic_cb (GObject *source_obj,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GAsyncResult **target_res = user_data;
+
+ *target_res = g_object_ref (res);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static guint
+polkit_authority_enumerate_actions_async (PolkitAuthority *authority,
+ const gchar *locale,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ guint call_id;
+
+ call_id = _polkit_authority_enumerate_actions (authority->real,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ locale,
+ cancellable,
+ callback,
+ user_data);
+
+ return call_id;
+}
+
+void
+polkit_authority_enumerate_actions (PolkitAuthority *authority,
+ const gchar *locale,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ polkit_authority_enumerate_actions_async (authority, locale, cancellable, callback, user_data);
+}
+
GList *
-polkit_authority_enumerate_actions_sync (PolkitAuthority *authority,
- const gchar *locale,
- GCancellable *cancellable,
- GError **error)
+polkit_authority_enumerate_actions_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error)
{
EggDBusArraySeq *array_seq;
GList *result;
result = NULL;
- if (!_polkit_authority_enumerate_actions_sync (authority->real,
- EGG_DBUS_CALL_FLAGS_NONE,
- locale,
- &array_seq,
- cancellable,
- error))
+ if (!_polkit_authority_enumerate_actions_finish (authority->real,
+ &array_seq,
+ res,
+ error))
goto out;
for (n = 0; n < array_seq->size; n++)
return result;
}
+
GList *
-polkit_authority_enumerate_users_sync (PolkitAuthority *authority,
- GCancellable *cancellable,
- GError **error)
+polkit_authority_enumerate_actions_sync (PolkitAuthority *authority,
+ const gchar *locale,
+ GCancellable *cancellable,
+ GError **error)
+{
+ guint call_id;
+ GAsyncResult *res;
+ GList *result;
+
+ call_id = polkit_authority_enumerate_actions_async (authority, locale, cancellable, generic_cb, &res);
+
+ egg_dbus_connection_pending_call_block (authority->system_bus, call_id);
+
+ result = polkit_authority_enumerate_actions_finish (authority, res, error);
+
+ g_object_unref (res);
+
+ return result;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static guint
+polkit_authority_enumerate_users_async (PolkitAuthority *authority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ guint call_id;
+
+ call_id = _polkit_authority_enumerate_users (authority->real,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ cancellable,
+ callback,
+ user_data);
+
+ return call_id;
+}
+
+void
+polkit_authority_enumerate_users (PolkitAuthority *authority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ polkit_authority_enumerate_users_async (authority, cancellable, callback, user_data);
+}
+
+GList *
+polkit_authority_enumerate_users_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error)
{
EggDBusArraySeq *array_seq;
GList *result;
result = NULL;
- if (!_polkit_authority_enumerate_users_sync (authority->real,
- EGG_DBUS_CALL_FLAGS_NONE,
- &array_seq,
- cancellable,
- error))
+ if (!_polkit_authority_enumerate_users_finish (authority->real,
+ &array_seq,
+ res,
+ error))
goto out;
for (n = 0; n < array_seq->size; n++)
}
GList *
-polkit_authority_enumerate_groups_sync (PolkitAuthority *authority,
- GCancellable *cancellable,
- GError **error)
+polkit_authority_enumerate_users_sync (PolkitAuthority *authority,
+ GCancellable *cancellable,
+ GError **error)
+{
+ guint call_id;
+ GAsyncResult *res;
+ GList *result;
+
+ call_id = polkit_authority_enumerate_users_async (authority, cancellable, generic_cb, &res);
+
+ egg_dbus_connection_pending_call_block (authority->system_bus, call_id);
+
+ result = polkit_authority_enumerate_users_finish (authority, res, error);
+
+ g_object_unref (res);
+
+ return result;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static guint
+polkit_authority_enumerate_groups_async (PolkitAuthority *authority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ guint call_id;
+
+ call_id = _polkit_authority_enumerate_groups (authority->real,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ cancellable,
+ callback,
+ user_data);
+
+ return call_id;
+}
+
+void
+polkit_authority_enumerate_groups (PolkitAuthority *authority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ polkit_authority_enumerate_groups_async (authority, cancellable, callback, user_data);
+}
+
+GList *
+polkit_authority_enumerate_groups_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error)
{
EggDBusArraySeq *array_seq;
GList *result;
result = NULL;
- if (!_polkit_authority_enumerate_groups_sync (authority->real,
- EGG_DBUS_CALL_FLAGS_NONE,
- &array_seq,
- cancellable,
- error))
+ if (!_polkit_authority_enumerate_groups_finish (authority->real,
+ &array_seq,
+ res,
+ error))
goto out;
for (n = 0; n < array_seq->size; n++)
return result;
}
-PolkitAuthorizationResult
-polkit_authority_check_claim_sync (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GError **error)
+GList *
+polkit_authority_enumerate_groups_sync (PolkitAuthority *authority,
+ GCancellable *cancellable,
+ GError **error)
{
- _PolkitAuthorizationResult result;
- _PolkitAuthorizationClaim *real_claim;
- EggDBusHashMap *result_attributes;
+ guint call_id;
+ GAsyncResult *res;
+ GList *result;
- result = _POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
- real_claim = NULL;
+ call_id = polkit_authority_enumerate_groups_async (authority, cancellable, generic_cb, &res);
+
+ egg_dbus_connection_pending_call_block (authority->system_bus, call_id);
+
+ result = polkit_authority_enumerate_groups_finish (authority, res, error);
+
+ g_object_unref (res);
+
+ return result;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static guint
+polkit_authority_check_claim_async (PolkitAuthority *authority,
+ PolkitAuthorizationClaim *claim,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ _PolkitAuthorizationClaim *real_claim;
+ guint call_id;
real_claim = polkit_authorization_claim_get_real (claim);
- if (!_polkit_authority_check_claim_sync (authority->real,
+ call_id = _polkit_authority_check_claim (authority->real,
EGG_DBUS_CALL_FLAGS_NONE,
real_claim,
- &result,
- &result_attributes,
cancellable,
- error))
+ callback,
+ user_data);
+
+ g_object_unref (real_claim);
+
+ return call_id;
+}
+
+void
+polkit_authority_check_claim (PolkitAuthority *authority,
+ PolkitAuthorizationClaim *claim,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ polkit_authority_check_claim_async (authority, claim, cancellable, callback, user_data);
+}
+
+PolkitAuthorizationResult
+polkit_authority_check_claim_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error)
+{
+ _PolkitAuthorizationResult result;
+ EggDBusHashMap *result_attributes;
+
+ result = _POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
+
+ if (!_polkit_authority_check_claim_finish (authority->real,
+ &result,
+ &result_attributes,
+ res,
+ error))
goto out;
/* TODO: pass these back */
g_object_unref (result_attributes);
out:
- if (real_claim != NULL)
- g_object_unref (real_claim);
return result;
}
+PolkitAuthorizationResult
+polkit_authority_check_claim_sync (PolkitAuthority *authority,
+ PolkitAuthorizationClaim *claim,
+ GCancellable *cancellable,
+ GError **error)
+{
+ guint call_id;
+ GAsyncResult *res;
+ PolkitAuthorizationResult result;
+
+ call_id = polkit_authority_check_claim_async (authority, claim, cancellable, generic_cb, &res);
+
+ egg_dbus_connection_pending_call_block (authority->system_bus, call_id);
+
+ result = polkit_authority_check_claim_finish (authority, res, error);
+
+ g_object_unref (res);
+
+ return result;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */