[PINENTRY PATCH 4/8] gtk2: Report timeout.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Nov 4 23:57:48 CET 2016


* gtk+-2/pinentry-gtk-2.c (create_window): Send pointer to pinentry
into timeout_cb.
(timeout_cb): Report if canceled due to timeout.

Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
 gtk+-2/pinentry-gtk-2.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gtk+-2/pinentry-gtk-2.c b/gtk+-2/pinentry-gtk-2.c
index cd6270f..544e595 100644
--- a/gtk+-2/pinentry-gtk-2.c
+++ b/gtk+-2/pinentry-gtk-2.c
@@ -38,6 +38,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <gpg-error.h>
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -515,9 +516,13 @@ show_hide_button_toggled (GtkWidget *widget, gpointer data)
 static gboolean
 timeout_cb (gpointer data)
 {
-  (void)data;
+  pinentry_t pinentry = (pinentry_t)data;
   if (!got_input)
-    gtk_main_quit ();
+    {
+      gtk_main_quit ();
+      if (pinentry)
+        pinentry->specific_err = gpg_error (GPG_ERR_TIMEOUT);
+    }
 
   /* Don't run again.  */
   timeout_source = 0;
@@ -873,7 +878,7 @@ create_window (pinentry_t ctx)
   gtk_window_present (GTK_WINDOW (win));  /* Make sure it has the focus.  */
 
   if (pinentry->timeout > 0)
-    timeout_source = g_timeout_add (pinentry->timeout*1000, timeout_cb, NULL);
+    timeout_source = g_timeout_add (pinentry->timeout*1000, timeout_cb, pinentry);
 
   return win;
 }
-- 
2.10.1




More information about the Gnupg-devel mailing list