diff options
author | David Zeuthen <davidz@redhat.com> | 2009-05-13 12:30:26 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2009-05-13 12:30:26 -0400 |
commit | 8e547a59a1fdac54329605f4b3576122f5236479 (patch) | |
tree | 0015c148ab5b528d37d830c298b71f79e33f06a3 /src/examples | |
parent | 7a9f7c1389befed09abc9d2187c213868f638c43 (diff) | |
download | polkit-8e547a59a1fdac54329605f4b3576122f5236479.tar.gz |
Port examples and command-line tools to new API
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/cancel.c | 33 |
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); |