[PolicyKit-gnome] Return error when authentication dialog is dismissed



commit 2511afae6b72fe3b4714d07ab6373c93c2923a5e
Author: David Zeuthen <davidz redhat com>
Date:   Tue Feb 22 19:33:39 2011 -0500

    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).
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=30653 for more
    information.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/Makefile.am                |   14 ++++++++++++--
 src/polkitgnomeauthenticator.c |   12 +++++++++---
 src/polkitgnomelistener.c      |    9 +++++++++
 src/polkitgnomemarshal.list    |    1 +
 4 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index be8420e..909624e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,14 +1,24 @@
 
+NULL =
+
 FULL_LIBEXECDIR=$(libexecdir)
 
 libexec_PROGRAMS = polkit-gnome-authentication-agent-1
 
+polkitgnomemarshal.h polkitgnomemarshal.c : Makefile.am $(srcdir)/polkitgnomemarshal.list
+	glib-genmarshal --prefix=_polkit_gnome_marshal $(srcdir)/polkitgnomemarshal.list --header > polkitgnomemarshal.h.tmp && mv polkitgnomemarshal.h.tmp polkitgnomemarshal.h
+	(echo "#include \"polkitgnomemarshal.h\""; glib-genmarshal --prefix=_polkit_gnome_marshal $(srcdir)/polkitgnomemarshal.list --body) > polkitgnomemarshal.c.tmp && mv polkitgnomemarshal.c.tmp polkitgnomemarshal.c
+	touch polkitgnomemarshal.stamp
+
+BUILT_SOURCES = polkitgnomemarshal.h polkitgnomemarshal.c
+
 polkit_gnome_authentication_agent_1_SOURCES = 						\
 	polkitgnomelistener.h			polkitgnomelistener.c			\
 	polkitgnomeauthenticator.h		polkitgnomeauthenticator.c		\
 	polkitgnomeauthenticationdialog.h	polkitgnomeauthenticationdialog.c	\
 	main.c										\
-	$(BUILT_SOURCES)
+	$(BUILT_SOURCES)								\
+	$(NULL)
 
 polkit_gnome_authentication_agent_1_CPPFLAGS = 		\
 	-I$(top_srcdir)					\
@@ -37,7 +47,7 @@ polkit_gnome_authentication_agent_1_LDADD = 		\
 	$(POLKIT_GOBJECT_LIBS)				\
 	$(INTLLIBS)
 
-EXTRA_DIST =
+EXTRA_DIST = polkitgnomemarshal.list
 
 clean-local :
 	rm -f *~
diff --git a/src/polkitgnomeauthenticator.c b/src/polkitgnomeauthenticator.c
index 02b2547..698796f 100644
--- a/src/polkitgnomeauthenticator.c
+++ b/src/polkitgnomeauthenticator.c
@@ -32,6 +32,7 @@
 
 #include "polkitgnomeauthenticator.h"
 #include "polkitgnomeauthenticationdialog.h"
+#include "polkitgnomemarshal.h"
 
 struct _PolkitGnomeAuthenticator
 {
@@ -126,6 +127,7 @@ polkit_gnome_authenticator_class_init (PolkitGnomeAuthenticatorClass *klass)
    * PolkitGnomeAuthenticator::completed:
    * @authenticator: A #PolkitGnomeAuthenticator.
    * @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.
@@ -136,9 +138,10 @@ polkit_gnome_authenticator_class_init (PolkitGnomeAuthenticatorClass *klass)
                                             0,                      /* class offset     */
                                             NULL,                   /* accumulator      */
                                             NULL,                   /* accumulator data */
-                                            g_cclosure_marshal_VOID__BOOLEAN,
+                                            _polkit_gnome_marshal_VOID__BOOLEAN_BOOLEAN,
                                             G_TYPE_NONE,
-                                            1,
+                                            2,
+                                            G_TYPE_BOOLEAN,
                                             G_TYPE_BOOLEAN);
 }
 
@@ -471,7 +474,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/polkitgnomelistener.c b/src/polkitgnomelistener.c
index f09bef9..8309431 100644
--- a/src/polkitgnomelistener.c
+++ b/src/polkitgnomelistener.c
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <string.h>
+#include <glib/gi18n.h>
 
 #include "polkitgnomelistener.h"
 #include "polkitgnomeauthenticator.h"
@@ -148,6 +149,7 @@ maybe_initiate_next_authenticator (PolkitGnomeListener *listener)
 static void
 authenticator_completed (PolkitGnomeAuthenticator *authenticator,
                          gboolean                  gained_authorization,
+                         gboolean                  dismissed,
                          gpointer                  user_data)
 {
   AuthData *data = user_data;
@@ -158,6 +160,13 @@ authenticator_completed (PolkitGnomeAuthenticator *authenticator,
 
   g_object_unref (authenticator);
 
+  if (dismissed)
+    {
+      g_simple_async_result_set_error (data->simple,
+                                       POLKIT_ERROR,
+                                       POLKIT_ERROR_CANCELLED,
+                                       _("Authentation dialog was dismissed by the user"));
+    }
   g_simple_async_result_complete (data->simple);
   g_object_unref (data->simple);
 
diff --git a/src/polkitgnomemarshal.list b/src/polkitgnomemarshal.list
new file mode 100644
index 0000000..3259d90
--- /dev/null
+++ b/src/polkitgnomemarshal.list
@@ -0,0 +1 @@
+VOID:BOOLEAN,BOOLEAN



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]