[git] Pinentry - branch, master, updated. pinentry-0.8.1-2-g8f64210

by Ben Kibbey cvs at cvs.gnupg.org
Mon Jun 27 15:00:57 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".

The branch, master has been updated
       via  8f64210ccec8c298fe6430246368966634486732 (commit)
      from  5190773293bc38550bbc8aeb1b539bfb47a47c78 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8f64210ccec8c298fe6430246368966634486732
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Sun Jun 26 15:56:11 2011 -0400

    Pinentry timeout support.
    
    This adds a new pinentry command SETTIMEOUT and pinentry command line
    option --timeout to set the number of seconds until the pinentry dialog
    closes itself (default is 60 seconds). Only the qt4 program has been
    modified to make use of it.
    
    The timer is cancelled when user input is detected. For confirmation
    dialog boxes with a Cancel button, the button press is emulated after the
    timer expires. For a confirmation box without a Cancel button, nothing
    happens.

diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 4c2b8d5..13b45f2 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -73,6 +73,7 @@ struct pinentry pinentry =
     0,		/* TTY LC_CTYPE.  */
     0,		/* TTY LC_MESSAGES.  */
     0,		/* Debug mode.  */
+    60,		/* Pinentry timeout in seconds.  */
 #ifdef ENABLE_ENHANCED
     0,		/* Enhanced mode.  */
 #endif
@@ -413,6 +414,7 @@ usage (void)
 "      --ttytype NAME    Set the tty terminal type\n"
 "      --lc-ctype        Set the tty LC_CTYPE value\n"
 "      --lc-messages     Set the tty LC_MESSAGES value\n"
+"      --timeout SECS    Timeout waiting for input after this many seconds\n"
 #ifdef ENABLE_ENHANCED
 "  -e, --enhanced        Ask for timeout and insurance, too\n"
 #endif
@@ -498,6 +500,7 @@ pinentry_parse_opts (int argc, char *argv[])
      { "colors", required_argument,	 0, 'c' },
      { "help", no_argument,              0, 'h' },
      { "version", no_argument, &opt_version, 1 },
+     { "timeout", required_argument, 0, 'o' },
      { NULL, 0, NULL, 0 }};
   
   while ((opt = getopt_long (argc, argv, "degh", opts, NULL)) != -1)
@@ -587,6 +590,9 @@ pinentry_parse_opts (int argc, char *argv[])
 				&pinentry.color_so_bright);
 	  break;
 
+	case 'o':
+	  pinentry.timeout = atoi(optarg);
+	  break;
         default:
           fprintf (stderr, "%s: oops: option not handled\n", this_pgmname);
 	  break;
@@ -819,6 +825,15 @@ cmd_setcancel (ASSUAN_CONTEXT ctx, char *line)
 
 
 static int
+cmd_settimeout (ASSUAN_CONTEXT ctx, char *line)
+{
+    if (line && *line)
+	pinentry.timeout = atoi(line);
+
+    return 0;
+}
+
+static int
 cmd_settitle (ASSUAN_CONTEXT ctx, char *line)
 {
   char *newt;
@@ -1052,6 +1067,7 @@ register_commands (ASSUAN_CONTEXT ctx)
       { "SETQUALITYBAR_TT", 0,  cmd_setqualitybar_tt },
       { "GETINFO",    0,  cmd_getinfo },
       { "SETTITLE",   0,  cmd_settitle },
+      { "SETTIMEOUT",   0,  cmd_settimeout },
       { NULL }
     };
   int i, j, rc;
diff --git a/pinentry/pinentry.h b/pinentry/pinentry.h
index 30452f5..d4f86f9 100644
--- a/pinentry/pinentry.h
+++ b/pinentry/pinentry.h
@@ -72,6 +72,9 @@ struct pinentry
   /* True if debug mode is requested.  */
   int debug;
 
+  /* The number of seconds before giving up while waiting for user input. */
+  int timeout;
+
 #ifdef ENABLE_ENHANCED
   /* True if enhanced mode is requested.  */
   int enhanced;
diff --git a/qt4/Makefile.am b/qt4/Makefile.am
index 66568a7..054427a 100644
--- a/qt4/Makefile.am
+++ b/qt4/Makefile.am
@@ -45,4 +45,5 @@ pinentry_qt4_SOURCES = pinentrydialog.h pinentrydialog.cpp \
 	main.cpp secstring.h secstring.cpp qsecurelineedit.h \
 	qsecurelineedit.cpp pinentrydialog.moc qsecurelineedit.moc \
 	qrc_pinentry.cpp \
-	qsecurelineedit_p.h
+	qsecurelineedit_p.h \
+	pinentryconfirm.cpp pinentryconfirm.h pinentryconfirm.moc
diff --git a/qt4/main.cpp b/qt4/main.cpp
index 55c14f5..7fdef37 100644
--- a/qt4/main.cpp
+++ b/qt4/main.cpp
@@ -28,6 +28,7 @@
 #include "config.h"
 #endif
 
+#include "pinentryconfirm.h"
 #include "pinentrydialog.h"
 #include "pinentry.h"
 
@@ -152,7 +153,7 @@ qt_cmd_handler (pinentry_t pe)
 
   if (want_pass)
     {
-      PinEntryDialog pinentry (parent, 0, true, !!pe->quality_bar);
+      PinEntryDialog pinentry (parent, 0, pe->timeout, true, !!pe->quality_bar);
 
       pinentry.setPinentryInfo (pe);
       pinentry.setPrompt (escape_accel (from_utf8 (pe->prompt)) );
@@ -201,7 +202,7 @@ qt_cmd_handler (pinentry_t pe)
           pe->notok      ? QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel :
           /* else */       QMessageBox::Ok|QMessageBox::Cancel ;
 
-      QMessageBox box( QMessageBox::Information, title, desc, buttons, parent );
+      PinentryConfirm box( QMessageBox::Information, pe->timeout, title, desc, buttons, parent );
 
       const struct {
           QMessageBox::StandardButton button;
diff --git a/qt4/pinentryconfirm.cpp b/qt4/pinentryconfirm.cpp
new file mode 100644
index 0000000..b22aef5
--- /dev/null
+++ b/qt4/pinentryconfirm.cpp
@@ -0,0 +1,42 @@
+/*
+   pinentryconfirm.cpp - A QMessageBox with a timeout
+
+   Copyright (C) 2011 Ben Kibbey <bjk at luxsci.net>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+#include "pinentryconfirm.h"
+#include <QAbstractButton>
+
+PinentryConfirm::PinentryConfirm(Icon icon, int timeout, const QString &title,
+	const QString &desc, StandardButtons buttons, QWidget *parent) :
+    QMessageBox(icon, title, desc, buttons, parent)
+{
+    if (timeout > 0) {
+	_timer = new QTimer(this);
+	connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
+	_timer->start(timeout*1000);
+    }
+}
+
+void PinentryConfirm::slotTimeout()
+{
+    QAbstractButton *b = button(QMessageBox::Cancel);
+
+    if (b)
+	b->animateClick(0);
+}
+
+#include "pinentryconfirm.moc"
diff --git a/qt4/pinentryconfirm.h b/qt4/pinentryconfirm.h
new file mode 100644
index 0000000..3113750
--- /dev/null
+++ b/qt4/pinentryconfirm.h
@@ -0,0 +1,41 @@
+/*
+   pinentryconfirm.h - A QMessageBox with a timeout
+
+   Copyright (C) 2011 Ben Kibbey <bjk at luxsci.net>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+#ifndef PINENTRYCONFIRM_H
+#define PINENTRYCONFIRM_H
+
+#include <QMessageBox>
+#include <QTimer>
+
+class PinentryConfirm : public QMessageBox
+{
+    Q_OBJECT
+    public:
+	PinentryConfirm(Icon, int timeout, const QString &title,
+		const QString &desc, StandardButtons buttons,
+		QWidget *parent);
+
+    private slots:
+	void slotTimeout();
+
+    private:
+	QTimer *_timer;
+};
+
+#endif
diff --git a/qt4/pinentryconfirm.moc b/qt4/pinentryconfirm.moc
new file mode 100644
index 0000000..e69e08e
--- /dev/null
+++ b/qt4/pinentryconfirm.moc
@@ -0,0 +1,79 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'pinentryconfirm.h'
+**
+** Created: Sun Jun 26 15:32:15 2011
+**      by: The Qt Meta Object Compiler version 62 (Qt 4.7.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "pinentryconfirm.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'pinentryconfirm.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 62
+#error "This file was generated using the moc from 4.7.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_PinentryConfirm[] = {
+
+ // content:
+       5,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       1,   14, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+ // slots: signature, parameters, type, tag, flags
+      17,   16,   16,   16, 0x08,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_PinentryConfirm[] = {
+    "PinentryConfirm\0\0slotTimeout()\0"
+};
+
+const QMetaObject PinentryConfirm::staticMetaObject = {
+    { &QMessageBox::staticMetaObject, qt_meta_stringdata_PinentryConfirm,
+      qt_meta_data_PinentryConfirm, 0 }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &PinentryConfirm::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *PinentryConfirm::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *PinentryConfirm::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_PinentryConfirm))
+        return static_cast<void*>(const_cast< PinentryConfirm*>(this));
+    return QMessageBox::qt_metacast(_clname);
+}
+
+int PinentryConfirm::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QMessageBox::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        switch (_id) {
+        case 0: slotTimeout(); break;
+        default: ;
+        }
+        _id -= 1;
+    }
+    return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/qt4/pinentrydialog.cpp b/qt4/pinentrydialog.cpp
index 541baf4..95096d4 100644
--- a/qt4/pinentrydialog.cpp
+++ b/qt4/pinentrydialog.cpp
@@ -87,8 +87,13 @@ QPixmap icon( QStyle::StandardPixmap which )
     return pm;
 }
 
-PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name, bool modal,
-                                bool enable_quality_bar )
+void PinEntryDialog::slotTimeout()
+{
+    reject();
+}
+
+PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name,
+	int timeout, bool modal, bool enable_quality_bar )
   : QDialog( parent, Qt::WindowStaysOnTopHint ), _grabbed( false )
 {
   setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );
@@ -143,6 +148,12 @@ PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name, bool modal,
       _cancel->setIcon( style()->standardIcon( QStyle::SP_DialogCancelButton ) );
     }
  
+  if (timeout > 0) {
+      _timer = new QTimer(this);
+      connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
+      _timer->start(timeout*1000);
+  }
+
   connect( buttons, SIGNAL(accepted()), this, SLOT(accept()) );
   connect( buttons, SIGNAL(rejected()), this, SLOT(reject()) );
   connect( _edit, SIGNAL( textChanged(secqstring) ),
@@ -257,6 +268,7 @@ void PinEntryDialog::updateQuality(const secqstring & txt )
   int percent;
   QPalette pal;
 
+  _timer->stop();
   if (!_have_quality_bar || !_pinentry_info)
     return;
   secstring pinStr = toUtf8(txt);
diff --git a/qt4/pinentrydialog.h b/qt4/pinentrydialog.h
index 416abfe..6657060 100644
--- a/qt4/pinentrydialog.h
+++ b/qt4/pinentrydialog.h
@@ -26,6 +26,7 @@
 
 #include <QDialog>
 #include <QStyle>
+#include <QTimer>
 
 #include "secstring.h"
 #include "pinentry.h"
@@ -49,7 +50,7 @@ class PinEntryDialog : public QDialog {
   Q_PROPERTY( QString prompt READ prompt WRITE setPrompt )
 public:
   friend class PinEntryController; // TODO: remove when assuan lets me use Qt eventloop.
-  explicit PinEntryDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, bool enable_quality_bar = false );
+  explicit PinEntryDialog( QWidget* parent = 0, const char* name = 0, int timeout = 0, bool modal = false, bool enable_quality_bar = false );
 
   void setDescription( const QString& );
   QString description() const;
@@ -73,6 +74,7 @@ public:
 
 public slots:
   void updateQuality(const secqstring&);
+  void slotTimeout();
 
 protected:
   /* reimp */ void showEvent( QShowEvent* event );
@@ -92,6 +94,7 @@ private:
   bool       _grabbed;
   bool       _have_quality_bar;
   pinentry_t _pinentry_info;
+  QTimer*    _timer;
 };
 
 #endif // __PINENTRYDIALOG_H__
diff --git a/qt4/pinentrydialog.moc b/qt4/pinentrydialog.moc
index c9a0930..a99da49 100644
--- a/qt4/pinentrydialog.moc
+++ b/qt4/pinentrydialog.moc
@@ -1,8 +1,8 @@
 /****************************************************************************
 ** Meta object code from reading C++ file 'pinentrydialog.h'
 **
-** Created: Mon Mar 16 13:03:03 2009
-**      by: The Qt Meta Object Compiler version 59 (Qt 4.4.1)
+** Created: Sun Jun 26 15:13:15 2011
+**      by: The Qt Meta Object Compiler version 62 (Qt 4.7.3)
 **
 ** WARNING! All changes made in this file will be lost!
 *****************************************************************************/
@@ -10,8 +10,8 @@
 #include "pinentrydialog.h"
 #if !defined(Q_MOC_OUTPUT_REVISION)
 #error "The header file 'pinentrydialog.h' doesn't include <QObject>."
-#elif Q_MOC_OUTPUT_REVISION < 59
-#error "This file was generated using the moc from 4.4.1. It"
+#elif Q_MOC_OUTPUT_REVISION != 62
+#error "This file was generated using the moc from 4.7.3. It"
 #error "cannot be used with the include files from this version of Qt."
 #error "(The moc has changed too much.)"
 #endif
@@ -20,29 +20,33 @@ QT_BEGIN_MOC_NAMESPACE
 static const uint qt_meta_data_PinEntryDialog[] = {
 
  // content:
-       1,       // revision
+       5,       // revision
        0,       // classname
        0,    0, // classinfo
-       1,   10, // methods
-       4,   15, // properties
+       2,   14, // methods
+       4,   24, // properties
        0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
 
  // slots: signature, parameters, type, tag, flags
       16,   15,   15,   15, 0x0a,
+      42,   15,   15,   15, 0x0a,
 
  // properties: name, type, flags
-      50,   42, 0x0a095103,
-      62,   42, 0x0a095103,
-      79,   68, 0x0009510b,
-      83,   42, 0x0a095103,
+      64,   56, 0x0a095103,
+      76,   56, 0x0a095103,
+      93,   82, 0x0009510b,
+      97,   56, 0x0a095103,
 
        0        // eod
 };
 
 static const char qt_meta_stringdata_PinEntryDialog[] = {
     "PinEntryDialog\0\0updateQuality(secqstring)\0"
-    "QString\0description\0error\0secqstring\0"
-    "pin\0prompt\0"
+    "slotTimeout()\0QString\0description\0"
+    "error\0secqstring\0pin\0prompt\0"
 };
 
 const QMetaObject PinEntryDialog::staticMetaObject = {
@@ -50,9 +54,13 @@ const QMetaObject PinEntryDialog::staticMetaObject = {
       qt_meta_data_PinEntryDialog, 0 }
 };
 
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &PinEntryDialog::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
 const QMetaObject *PinEntryDialog::metaObject() const
 {
-    return &staticMetaObject;
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
 }
 
 void *PinEntryDialog::qt_metacast(const char *_clname)
@@ -71,8 +79,10 @@ int PinEntryDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
     if (_c == QMetaObject::InvokeMetaMethod) {
         switch (_id) {
         case 0: updateQuality((*reinterpret_cast< const secqstring(*)>(_a[1]))); break;
+        case 1: slotTimeout(); break;
+        default: ;
         }
-        _id -= 1;
+        _id -= 2;
     }
 #ifndef QT_NO_PROPERTIES
       else if (_c == QMetaObject::ReadProperty) {

-----------------------------------------------------------------------

Summary of changes:
 pinentry/pinentry.c                      |   16 ++++++
 pinentry/pinentry.h                      |    3 +
 qt4/Makefile.am                          |    3 +-
 qt4/main.cpp                             |    5 +-
 qt4/{secstring.h => pinentryconfirm.cpp} |   54 +++++++++++----------
 qt4/{secstring.h => pinentryconfirm.h}   |   43 ++++++++--------
 qt4/pinentryconfirm.moc                  |   79 ++++++++++++++++++++++++++++++
 qt4/pinentrydialog.cpp                   |   16 +++++-
 qt4/pinentrydialog.h                     |    5 ++-
 qt4/pinentrydialog.moc                   |   40 +++++++++------
 10 files changed, 196 insertions(+), 68 deletions(-)
 copy qt4/{secstring.h => pinentryconfirm.cpp} (51%)
 copy qt4/{secstring.h => pinentryconfirm.h} (52%)
 create mode 100644 qt4/pinentryconfirm.moc


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list