[git] Pinentry - branch, master, updated. pinentry-0.9.7-10-g287d40e

by Andre Heinecke cvs at cvs.gnupg.org
Thu Apr 14 15:29:48 CEST 2016


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  287d40e879f767dbcb3d19b3629b872c08d39cf4 (commit)
       via  49a7ac5209aa54f3b91209acc899463e8097f808 (commit)
       via  15685a9c1471eb01066e0bbdb7d6b929a8fcc314 (commit)
      from  04115b3289dcc9b02044f88c08580618c055a571 (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 287d40e879f767dbcb3d19b3629b872c08d39cf4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Apr 14 15:21:13 2016 +0200

    Qt: Restrict list of icon themes to try
    
    * qt/main.cpp (main): Only search in select icon themes.
    
    --
    Gnome Icon theme does not use a lock for document-encrypt icon
    and this looks strange. Mainly the goal is not to show the Oxygen
    Icon built into pinentry on a breeze Desktop.

diff --git a/qt/main.cpp b/qt/main.cpp
index a051240..bc7796f 100644
--- a/qt/main.cpp
+++ b/qt/main.cpp
@@ -341,9 +341,19 @@ main(int argc, char *argv[])
         i = argc;
         app.reset(new QApplication(i, new_argv));
         const QIcon fallback = QIcon(QLatin1String(":/document-encrypt.png"));
-        const QIcon icon = QIcon::fromTheme(QLatin1String("document-encrypt"),
-                                            fallback);
-        app->setWindowIcon(icon);
+        const QString themeName = QIcon::themeName().toLower();
+        /* Some themes dont have an lock representation for document-encrypt
+           we need to filter out these. */
+        const QStringList okThemes = QStringList() << QLatin1String("breeze")
+                                                   << QLatin1String("breeze-dark")
+                                                   << QLatin1String("oxygen")
+                                                   << QLatin1String("mono");
+        if (okThemes.contains(themeName)) {
+            app->setWindowIcon(QIcon::fromTheme(QLatin1String("document-encrypt"),
+                                                fallback));
+        } else {
+            app->setWindowIcon(fallback);
+        }
     }
 
     pinentry_parse_opts(argc, argv);

commit 49a7ac5209aa54f3b91209acc899463e8097f808
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Apr 14 15:01:47 2016 +0200

    Qt: Add actions to make passphrase visible
    
    * qt/main.cpp (qt_cmd_handler): Support visibility tooltips.
    * qt/pinentrydialog.cpp (PinEntryDialog::PinEntryDialog):
     Add a checkbox or line actions.
     (PinEntryDialog::checkRepeat): Renabed to textChanged.
     (PinEntryDialog::toggleVisibility): New. Toggle echo mode.
    * qt/pinentrydialog.h: Update accordingly.
    
    --
    The Action comes in two flavors to avoid having to include new
    icons in pinentry (and thus have a text-only fallback) and also
    because Qt4 does not support direct line edit actions and I don't
    want to raise the requirement to Qt 5.2 yet.
    
    GnuPG-Bug-ID: 2139

diff --git a/qt/main.cpp b/qt/main.cpp
index 3c653ee..a051240 100644
--- a/qt/main.cpp
+++ b/qt/main.cpp
@@ -169,10 +169,17 @@ qt_cmd_handler(pinentry_t pe)
     const QString repeatString =
         pe->repeat_passphrase ? from_utf8(pe->repeat_passphrase) :
                                 QString();
+    const QString visibilityTT =
+        pe->default_tt_visi ? from_utf8(pe->default_tt_visi) :
+                              QLatin1String("Show passphrase");
+    const QString hideTT =
+        pe->default_tt_hide ? from_utf8(pe->default_tt_hide) :
+                              QLatin1String("Hide passphrase");
+
 
     if (want_pass) {
         PinEntryDialog pinentry(parent, 0, pe->timeout, true, !!pe->quality_bar,
-                                repeatString);
+                                repeatString, visibilityTT, hideTT);
 
         pinentry.setPinentryInfo(pe);
         pinentry.setPrompt(escape_accel(from_utf8(pe->prompt)));
@@ -196,7 +203,6 @@ qt_cmd_handler(pinentry_t pe)
         if (pe->quality_bar_tt) {
             pinentry.setQualityBarTT(from_utf8(pe->quality_bar_tt));
         }
-
         bool ret = pinentry.exec();
         if (!ret) {
             return -1;
diff --git a/qt/pinentrydialog.cpp b/qt/pinentrydialog.cpp
index aca3a52..44a3a9f 100644
--- a/qt/pinentrydialog.cpp
+++ b/qt/pinentrydialog.cpp
@@ -35,6 +35,8 @@
 #include <QLabel>
 #include <QPalette>
 #include <QLineEdit>
+#include <QAction>
+#include <QCheckBox>
 
 #ifdef Q_OS_WIN
 #include <windows.h>
@@ -112,8 +114,17 @@ void PinEntryDialog::slotTimeout()
 
 PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
                                int timeout, bool modal, bool enable_quality_bar,
-                               const QString &repeatString)
-    : QDialog(parent, Qt::WindowStaysOnTopHint), mRepeat(NULL), _grabbed(false)
+                               const QString &repeatString,
+                               const QString &visibilityTT,
+                               const QString &hideTT)
+    : QDialog(parent, Qt::WindowStaysOnTopHint),
+      mRepeat(NULL),
+      _grabbed(false),
+      mVisibilityTT(visibilityTT),
+      mHideTT(hideTT),
+      mVisiActionEdit(NULL),
+      mVisiActionRepeat(NULL),
+      mVisiCB(NULL)
 {
     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
 
@@ -178,6 +189,8 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
     connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
     connect(_edit, SIGNAL(textChanged(QString)),
             this, SLOT(updateQuality(QString)));
+    connect(_edit, SIGNAL(textChanged(QString)),
+            this, SLOT(textChanged(QString)));
 
     _edit->setFocus();
 
@@ -197,9 +210,7 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
         mRepeat->setMaxLength(256);
         mRepeat->setEchoMode(QLineEdit::Password);
         connect(mRepeat, SIGNAL(textChanged(QString)),
-                this, SLOT(checkRepeat(QString)));
-        connect(_edit, SIGNAL(textChanged(QString)),
-                this, SLOT(checkRepeat(QString)));
+                this, SLOT(textChanged(QString)));
         QLabel *repeatLabel = new QLabel(repeatString);
         repeatLabel->setBuddy(mRepeat);
         grid->addWidget(repeatLabel, row, 1);
@@ -207,13 +218,37 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
         setTabOrder(_edit, mRepeat);
         setTabOrder(mRepeat, _ok);
     }
-    row += 2;
-    grid->addWidget(buttons, row, 0, 1, 3);
+    /* Set up the show password action */
+    const QIcon visibilityIcon = QIcon::fromTheme(QLatin1String("visibility"));
+    const QIcon hideIcon = QIcon::fromTheme(QLatin1String("hint"));
+#if QT_VERSION >= 0x050200
+    if (!visibilityIcon.isNull() && !hideIcon.isNull()) {
+        mVisiActionEdit = _edit->addAction(visibilityIcon, QLineEdit::TrailingPosition);
+        mVisiActionEdit->setVisible(false);
+        mVisiActionEdit->setToolTip(mVisibilityTT);
+        if (mRepeat) {
+            mVisiActionRepeat = mRepeat->addAction(visibilityIcon, QLineEdit::TrailingPosition);
+            mVisiActionRepeat->setVisible(false);
+            mVisiActionRepeat->setToolTip(mVisibilityTT);
+            connect(mVisiActionRepeat, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
+        }
+        connect(mVisiActionEdit, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
+    } else
+#endif
+    {
+        if (!mVisibilityTT.isNull()) {
+            mVisiCB = new QCheckBox(mVisibilityTT);
+            connect(mVisiCB, SIGNAL(toggled(bool)), this, SLOT(toggleVisibility()));
+            grid->addWidget(mVisiCB, row++, 1, 1, 2, Qt::AlignLeft);
+        }
+    }
+    grid->addWidget(buttons, ++row, 0, 1, 3);
 
     grid->addWidget(_icon, 0, 0, row - 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
 
     grid->setSizeConstraint(QLayout::SetFixedSize);
 
+
     connect(qApp, SIGNAL(focusChanged(QWidget *, QWidget *)),
             this, SLOT(focusChanged(QWidget *, QWidget *)));
 }
@@ -367,15 +402,62 @@ void PinEntryDialog::focusChanged(QWidget *old, QWidget *now)
 
 }
 
-void PinEntryDialog::checkRepeat(const QString &repPin)
+void PinEntryDialog::textChanged(const QString &text)
 {
-    if (mRepeat->text() == _edit->text()) {
+    Q_UNUSED(text);
+    if (mRepeat && mRepeat->text() == _edit->text()) {
         _ok->setEnabled(true);
         _ok->setToolTip(QString());
-    } else {
+    } else if (mRepeat) {
         _ok->setEnabled(false);
         _ok->setToolTip(mRepeatError);
     }
+
+    if (mVisiActionEdit && sender() == _edit) {
+        mVisiActionEdit->setVisible(!_edit->text().isEmpty());
+    }
+    if (mVisiActionRepeat && sender() == mRepeat) {
+        mVisiActionRepeat->setVisible(!mRepeat->text().isEmpty());
+    }
+}
+
+void PinEntryDialog::toggleVisibility()
+{
+    if (sender() == mVisiActionEdit) {
+        if (_edit->echoMode() == QLineEdit::Password) {
+            mVisiActionEdit->setIcon(QIcon::fromTheme(QLatin1String("hint")));
+            mVisiActionEdit->setToolTip(mHideTT);
+            _edit->setEchoMode(QLineEdit::Normal);
+        } else {
+            mVisiActionEdit->setIcon(QIcon::fromTheme(QLatin1String("visibility")));
+            mVisiActionEdit->setToolTip(mVisibilityTT);
+            _edit->setEchoMode(QLineEdit::Password);
+        }
+    }
+    if (sender() == mVisiActionRepeat) {
+        if (mRepeat->echoMode() == QLineEdit::Password) {
+            mVisiActionRepeat->setIcon(QIcon::fromTheme(QLatin1String("hint")));
+            mVisiActionRepeat->setToolTip(mHideTT);
+            mRepeat->setEchoMode(QLineEdit::Normal);
+        } else {
+            mVisiActionRepeat->setIcon(QIcon::fromTheme(QLatin1String("visibility")));
+            mVisiActionRepeat->setToolTip(mVisibilityTT);
+            mRepeat->setEchoMode(QLineEdit::Password);
+        }
+    }
+    if (sender() == mVisiCB) {
+        if (mVisiCB->isChecked()) {
+            if (mRepeat) {
+                mRepeat->setEchoMode(QLineEdit::Normal);
+            }
+            _edit->setEchoMode(QLineEdit::Normal);
+        } else {
+            if (mRepeat) {
+                mRepeat->setEchoMode(QLineEdit::Password);
+            }
+            _edit->setEchoMode(QLineEdit::Password);
+        }
+    }
 }
 
 QString PinEntryDialog::repeatedPin() const
diff --git a/qt/pinentrydialog.h b/qt/pinentrydialog.h
index 1713412..4c1241c 100644
--- a/qt/pinentrydialog.h
+++ b/qt/pinentrydialog.h
@@ -36,6 +36,8 @@ class QPushButton;
 class QLineEdit;
 class QString;
 class QProgressBar;
+class QCheckBox;
+class QAction;
 
 QPixmap icon(QStyle::StandardPixmap which = QStyle::SP_CustomBase);
 
@@ -53,7 +55,9 @@ public:
     explicit PinEntryDialog(QWidget *parent = 0, const char *name = 0,
                             int timeout = 0, bool modal = false,
                             bool enable_quality_bar = false,
-                            const QString &repeatString = QString());
+                            const QString &repeatString = QString(),
+                            const QString &visibiltyTT = QString(),
+                            const QString &hideTT = QString());
 
     void setDescription(const QString &);
     QString description() const;
@@ -81,8 +85,9 @@ public:
 protected slots:
     void updateQuality(const QString &);
     void slotTimeout();
-    void checkRepeat(const QString &);
+    void textChanged(const QString &);
     void focusChanged(QWidget *old, QWidget *now);
+    void toggleVisibility();
 
 protected:
     /* reimp */ void showEvent(QShowEvent *event);
@@ -102,7 +107,12 @@ private:
     bool       _have_quality_bar;
     pinentry_t _pinentry_info;
     QTimer    *_timer;
-    QString    mRepeatError;
+    QString    mRepeatError,
+               mVisibilityTT,
+               mHideTT;
+    QAction   *mVisiActionEdit,
+              *mVisiActionRepeat;
+    QCheckBox *mVisiCB;
 };
 
 #endif // __PINENTRYDIALOG_H__

commit 15685a9c1471eb01066e0bbdb7d6b929a8fcc314
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Apr 14 14:58:46 2016 +0200

    Add support for visibility string options
    
    * doc/pinentry.texi: Note new values.
    * pinentry/pinentry.c (pinentry): Add default_cf_visi,
     default_tt_visi and default_tt_hide.
     (option_handler): Parse new values.
    * pinentry/pinentry.h (pinentry_t): Add new values.

diff --git a/doc/pinentry.texi b/doc/pinentry.texi
index fd1d624..dcff886 100644
--- a/doc/pinentry.texi
+++ b/doc/pinentry.texi
@@ -690,6 +690,17 @@ above condition is true and @code{tried_password_cache} is false, then
 a check box with the specified string should be displayed.  The check
 box must default to off.
 
+ at item @code{default-cf-visi}
+The string to show with a question if you want to confirm that
+the user wants to change the visibility of the password.
+
+ at item @code{default-tt-visi}
+Tooltip for an action that would reveal the entered password.
+
+ at item @code{default-tt-hide}
+Tooltip for an action that would hide the password revealed
+by the action labeld with @code{default-tt-visi}
+
 @end table
 
 When the handler is done, it should store the passphrase in
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index ef2b1fb..0c87271 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -79,6 +79,9 @@ pinentry_reset (int use_defaults)
   char *default_cancel = pinentry.default_cancel;
   char *default_prompt = pinentry.default_prompt;
   char *default_pwmngr = pinentry.default_pwmngr;
+  char *default_cf_visi = pinentry.default_cf_visi;
+  char *default_tt_visi = pinentry.default_tt_visi;
+  char *default_tt_hide = pinentry.default_tt_hide;
   char *touch_file = pinentry.touch_file;
 
   /* These options are set from the command line.  Don't reset
@@ -109,6 +112,9 @@ pinentry_reset (int use_defaults)
       free (pinentry.default_cancel);
       free (pinentry.default_prompt);
       free (pinentry.default_pwmngr);
+      free (pinentry.default_cf_visi);
+      free (pinentry.default_tt_visi);
+      free (pinentry.default_tt_hide);
       free (pinentry.touch_file);
       free (pinentry.display);
     }
@@ -162,6 +168,9 @@ pinentry_reset (int use_defaults)
       pinentry.default_cancel = default_cancel;
       pinentry.default_prompt = default_prompt;
       pinentry.default_pwmngr = default_pwmngr;
+      pinentry.default_cf_visi = default_cf_visi;
+      pinentry.default_tt_visi = default_tt_visi;
+      pinentry.default_tt_hide = default_tt_hide;
       pinentry.touch_file = touch_file;
 
       pinentry.debug = debug;
@@ -873,6 +882,24 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
       if (!pinentry.default_pwmngr)
 	return gpg_error_from_syserror ();
     }
+  else if (!strcmp (key, "default-cf-visi"))
+    {
+      pinentry.default_cf_visi = strdup (value);
+      if (!pinentry.default_cf_visi)
+	return gpg_error_from_syserror ();
+    }
+  else if (!strcmp (key, "default-tt-visi"))
+    {
+      pinentry.default_tt_visi = strdup (value);
+      if (!pinentry.default_tt_visi)
+	return gpg_error_from_syserror ();
+    }
+  else if (!strcmp (key, "default-tt-hide"))
+    {
+      pinentry.default_tt_hide = strdup (value);
+      if (!pinentry.default_tt_hide)
+	return gpg_error_from_syserror ();
+    }
   else if (!strcmp (key, "allow-external-password-cache") && !*value)
     {
       pinentry.allow_external_password_cache = 1;
diff --git a/pinentry/pinentry.h b/pinentry/pinentry.h
index 47a5567..b203cfe 100644
--- a/pinentry/pinentry.h
+++ b/pinentry/pinentry.h
@@ -171,6 +171,15 @@ struct pinentry
   /* (Assuan: "OPTION default-pwmngr
      SAVE_PASSWORD_WITH_PASSWORD_MANAGER?").  */
   char *default_pwmngr;
+  /* (Assuan: "OPTION default-cf-visi
+     Do you really want to make your passphrase visible?").  */
+  char *default_cf_visi;
+  /* (Assuan: "OPTION default-tt-visi
+     Make passphrase visible?").  */
+  char *default_tt_visi;
+  /* (Assuan: "OPTION default-tt-hide
+     Hide passphrase").  */
+  char *default_tt_hide;
 
   /* Whether we are allowed to read the password from an external
      cache.  (Assuan: "OPTION allow-external-password-cache")  */

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

Summary of changes:
 doc/pinentry.texi     |  11 ++++++
 pinentry/pinentry.c   |  27 +++++++++++++
 pinentry/pinentry.h   |   9 +++++
 qt/main.cpp           |  26 ++++++++++---
 qt/pinentrydialog.cpp | 102 +++++++++++++++++++++++++++++++++++++++++++++-----
 qt/pinentrydialog.h   |  16 ++++++--
 6 files changed, 173 insertions(+), 18 deletions(-)


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




More information about the Gnupg-commits mailing list