GMainLoop *loop)
{
GError *error;
- PolkitAuthorizationResult result;
+ PolkitAuthorizationResult *result;
error = NULL;
result = polkit_authority_check_authorization_finish (authority, res, &error);
}
else
{
- gchar *result_str;
- switch (result)
+ const gchar *result_str;
+ if (polkit_authorization_result_get_is_authorized (result))
{
- case POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED:
- result_str = g_strdup ("POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED");
- break;
-
- case POLKIT_AUTHORIZATION_RESULT_AUTHORIZED:
- result_str = g_strdup ("POLKIT_AUTHORIZATION_RESULT_AUTHORIZED");
- break;
-
- case POLKIT_AUTHORIZATION_RESULT_CHALLENGE:
- result_str = g_strdup ("POLKIT_AUTHORIZATION_RESULT_CHALLENGE");
- break;
-
- default:
- result_str = g_strdup_printf ("Unknown return code %d", result);
- break;
+ result_str = "authorized";
+ }
+ else if (polkit_authorization_result_get_is_challenge (result))
+ {
+ result_str = "challenge";
+ }
+ else
+ {
+ result_str = "not authorized";
}
+
g_print ("Authorization result: %s\n", result_str);
- g_free (result_str);
+ /* TODO: print details if authorized */
}
g_main_loop_quit (loop);
GAsyncReadyCallback callback,
gpointer user_data);
-static PolkitAuthorizationResult authority_check_authorization_finish (PolkitBackendAuthority *authority,
- GAsyncResult *res,
- GError **error);
+static PolkitAuthorizationResult *authority_check_authorization_finish (PolkitBackendAuthority *authority,
+ GAsyncResult *res,
+ GError **error);
G_DEFINE_DYNAMIC_TYPE (PolkitBackendNullAuthority, polkit_backend_null_authority,POLKIT_BACKEND_TYPE_AUTHORITY);
g_object_unref (simple);
}
-static PolkitAuthorizationResult
+static PolkitAuthorizationResult *
authority_check_authorization_finish (PolkitBackendAuthority *authority,
GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple;
- PolkitAuthorizationResult result;
+ PolkitAuthorizationResult *result;
simple = G_SIMPLE_ASYNC_RESULT (res);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == authority_check_authorization);
/* we always return NOT_AUTHORIZED, never an error */
- result = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
+ result = polkit_authorization_result_new (FALSE, FALSE, NULL);
if (g_simple_async_result_propagate_error (simple, error))
goto out;
static gboolean list_actions (void);
static gboolean list_users (void);
static gboolean list_groups (void);
-static gboolean list_authorizations (void);
+//static gboolean list_authorizations (void);
static gboolean list_explicit_authorizations (void);
-static gboolean do_check (void);
+//static gboolean do_check (void);
static gboolean do_add (void);
static gboolean do_remove (void);
}
else if (opt_list_authorizations)
{
- ret = list_authorizations ();
+ g_assert_not_reached ();
+ //ret = list_authorizations ();
}
else if (opt_list_explicit_authorizations)
{
goto out;
}
- ret = do_check ();
+ //ret = do_check ();
+ g_assert_not_reached ();
}
else if (opt_add)
{
/* ---------------------------------------------------------------------------------------------------- */
+#if 0
static gboolean
do_check (void)
{
g_main_loop_unref (authz_data_loop);
return ret;
}
+#endif
/* ---------------------------------------------------------------------------------------------------- */