summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-05-13 12:30:26 -0400
committerDavid Zeuthen <davidz@redhat.com>2009-05-13 12:30:26 -0400
commit8e547a59a1fdac54329605f4b3576122f5236479 (patch)
tree0015c148ab5b528d37d830c298b71f79e33f06a3 /src/examples
parent7a9f7c1389befed09abc9d2187c213868f638c43 (diff)
downloadpolkit-8e547a59a1fdac54329605f4b3576122f5236479.tar.gz
Port examples and command-line tools to new API
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/cancel.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/examples/cancel.c b/src/examples/cancel.c
index 7191398..351f974 100644
--- a/src/examples/cancel.c
+++ b/src/examples/cancel.c
@@ -37,7 +37,7 @@ check_authorization_cb (PolkitAuthority *authority,
GMainLoop *loop)
{
GError *error;
- PolkitAuthorizationResult result;
+ PolkitAuthorizationResult *result;
error = NULL;
result = polkit_authority_check_authorization_finish (authority, res, &error);
@@ -48,27 +48,22 @@ check_authorization_cb (PolkitAuthority *authority,
}
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);