From b06d4ae63fc95f50870510ca0acbaf049ba6dbb2 Mon Sep 17 00:00:00 2001 From: infirit Date: Sat, 12 Sep 2015 12:03:15 +0200 Subject: Return error when authentication dialog is dismissed This allows PolicyKit applications to disambiguate between when the authentication dialog is dismissed versus when authentication fails (e.g. the wrong password has been entered). From polkit-gnome, commit: 2511afae6b72fe3b4714d07ab6373c93c2923a5e From: David Zeuthen Gnome bug: https://bugs.freedesktop.org/show_bug.cgi?id=30653 --- src/Makefile.am | 2 ++ src/polkitmateauthenticator.c | 11 ++++++++--- src/polkitmatelistener.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index d1d8136..eb2fcfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ polkit_mate_authentication_agent_1_CPPFLAGS = \ polkit_mate_authentication_agent_1_CFLAGS = \ $(GTK_CFLAGS) \ + $(GLIB_CFLAGS) \ $(POLKIT_AGENT_CFLAGS) \ $(POLKIT_GOBJECT_CFLAGS) \ $(WARN_CFLAGS) \ @@ -40,6 +41,7 @@ polkit_mate_authentication_agent_1_LDFLAGS = \ polkit_mate_authentication_agent_1_LDADD = \ $(GTK_LIBS) \ + $(GLIB_LIBS) \ $(POLKIT_AGENT_LIBS) \ $(POLKIT_GOBJECT_LIBS) \ $(INTLLIBS) diff --git a/src/polkitmateauthenticator.c b/src/polkitmateauthenticator.c index e5fd4c4..93440cd 100644 --- a/src/polkitmateauthenticator.c +++ b/src/polkitmateauthenticator.c @@ -127,6 +127,7 @@ polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass) * PolkitMateAuthenticator::completed: * @authenticator: A #PolkitMateAuthenticator. * @gained_authorization: Whether the authorization was gained. + * @dismissed: Whether the dialog was dismissed. * * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator * upon receiving this signal. @@ -137,9 +138,10 @@ polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass) 0, /* class offset */ NULL, /* accumulator */ NULL, /* accumulator data */ - g_cclosure_marshal_VOID__BOOLEAN, + g_cclosure_marshal_generic, G_TYPE_NONE, - 1, + 2, + G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); } @@ -473,7 +475,10 @@ do_initiate (gpointer user_data) } out: - g_signal_emit_by_name (authenticator, "completed", authenticator->gained_authorization); + g_signal_emit_by_name (authenticator, + "completed", + authenticator->gained_authorization, + authenticator->was_cancelled); g_object_unref (authenticator); diff --git a/src/polkitmatelistener.c b/src/polkitmatelistener.c index 1b7c486..926fccd 100644 --- a/src/polkitmatelistener.c +++ b/src/polkitmatelistener.c @@ -23,6 +23,7 @@ #include "config.h" #include +#include #include "polkitmatelistener.h" #include "polkitmateauthenticator.h" @@ -153,8 +154,9 @@ maybe_initiate_next_authenticator (PolkitMateListener *listener) static void authenticator_completed (PolkitMateAuthenticator *authenticator, - gboolean gained_authorization, - gpointer user_data) + gboolean gained_authorization, + gboolean dismissed, + gpointer user_data) { AuthData *data = user_data; @@ -164,6 +166,14 @@ authenticator_completed (PolkitMateAuthenticator *authenticator, g_object_unref (authenticator); + if (dismissed) + { + g_simple_async_result_set_error (data->simple, + POLKIT_ERROR, + POLKIT_ERROR_CANCELLED, + _("Authentication dialog was dismissed by the user")); + } + g_simple_async_result_complete (data->simple); g_object_unref (data->simple); -- cgit v1.2.1