[git] Pinentry - branch, master, updated. pinentry-1.1.0-11-g0fb3392

by Damien Goutte-Gattat via Gnupg-devel cvs at cvs.gnupg.org
Wed Aug 15 20:34:38 CEST 2018


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  0fb3392f61569cb93e52c81465bc8e4636bca3b7 (commit)
       via  a75786a11666a080cae67f6e386163fcf93ff233 (commit)
       via  4b06bc6009011a84e5e8d4da2f01659f35e5a2d5 (commit)
       via  fd22facabd784586f72eeecc72830620a534929c (commit)
      from  779b8e6df7d2678d40bc61ba9e9ff35324a40d03 (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 0fb3392f61569cb93e52c81465bc8e4636bca3b7
Author: Damien Goutte-Gattat via Gnupg-devel <gnupg-devel at gnupg.org>
Date:   Sat Aug 4 22:24:11 2018 +0100

    tqt: Disable echoing if backspace is pressed first.
    
    * tqt/secqlineedit.h (backspacePressed): New signal.
    * tqt/secqinternal.cpp (SecTQLineEdit::backspace): Emit new signal.
    * tqt/pinentrydialog.h (_got_input): New member field.
    (onBackspace): New slot.
    * tqt/pinentrydialog.cpp (onBackspace): New slot.
    (PinEntryDialog::updateQuality): Prevent echo disabling as soon as
    the text has been edited.
    
    GnuPG-bug-id: 3428
    Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>

diff --git a/tqt/pinentrydialog.cpp b/tqt/pinentrydialog.cpp
index 069eeaf..6a2ae12 100644
--- a/tqt/pinentrydialog.cpp
+++ b/tqt/pinentrydialog.cpp
@@ -32,7 +32,8 @@
 
 PinEntryDialog::PinEntryDialog( TQWidget* parent, const char* name,
                                 bool modal, bool enable_quality_bar )
-  : TQDialog( parent, name, modal, TQt::WStyle_StaysOnTop ), _grabbed( false )
+  : TQDialog( parent, name, modal, TQt::WStyle_StaysOnTop ), _grabbed( false ),
+    _got_input( false )
 {
   TQBoxLayout* top = new TQVBoxLayout( this, 6 );
   TQBoxLayout* upperLayout = new TQHBoxLayout( top );
@@ -89,6 +90,8 @@ PinEntryDialog::PinEntryDialog( TQWidget* parent, const char* name,
 	   this, SIGNAL( rejected() ) );
   connect( _edit, SIGNAL( textModified(const SecTQString&) ),
 	   this, SLOT( updateQuality(const SecTQString&) ) );
+  connect (_edit, SIGNAL (backspacePressed()),
+	   this, SLOT (onBackspace ()));
   connect (this, SIGNAL (accepted ()),
 	   this, SLOT (accept ()));
   connect (this, SIGNAL (rejected ()),
@@ -131,6 +134,8 @@ void PinEntryDialog::updateQuality( const SecTQString & txt )
   int percent;
   TQPalette pal;
 
+  _got_input = true;
+
   if (!_have_quality_bar || !_pinentry_info)
     return;
   pin = (char*)txt.utf8();
@@ -159,6 +164,13 @@ void PinEntryDialog::updateQuality( const SecTQString & txt )
 }
 
 
+void PinEntryDialog::onBackspace()
+{
+  if (!_got_input)
+    _edit->setEchoMode( SecTQLineEdit::NoEcho );
+}
+
+
 void PinEntryDialog::setDescription( const TQString& txt )
 {
   _desc->setText( txt );
diff --git a/tqt/pinentrydialog.h b/tqt/pinentrydialog.h
index d6f20c6..eb4d332 100644
--- a/tqt/pinentrydialog.h
+++ b/tqt/pinentrydialog.h
@@ -63,6 +63,7 @@ public:
 
 public slots:
   void updateQuality(const SecTQString &);
+  void onBackspace();
 
 signals:
   void accepted();
@@ -86,6 +87,7 @@ private:
   bool       _grabbed;
   bool       _have_quality_bar;
   pinentry_t _pinentry_info;
+  bool       _got_input;
 };
 
 
diff --git a/tqt/secqlineedit.cpp b/tqt/secqlineedit.cpp
index ee95c8d..da0637a 100644
--- a/tqt/secqlineedit.cpp
+++ b/tqt/secqlineedit.cpp
@@ -719,6 +719,8 @@ void SecTQLineEdit::backspace()
 	    d->del( TRUE );
     }
     d->finishChange( priorState );
+
+    emit backspacePressed();
 }
 
 /*!
diff --git a/tqt/secqlineedit.h b/tqt/secqlineedit.h
index bd28cec..126f231 100644
--- a/tqt/secqlineedit.h
+++ b/tqt/secqlineedit.h
@@ -187,6 +187,7 @@ signals:
     void returnPressed();
     void lostFocus();
     void selectionChanged();
+    void backspacePressed();
 
 protected:
     bool event( TQEvent * );

commit a75786a11666a080cae67f6e386163fcf93ff233
Author: Damien Goutte-Gattat via Gnupg-devel <gnupg-devel at gnupg.org>
Date:   Sat Aug 4 22:24:10 2018 +0100

    qt: Disable echoing if backspace is pressed first.
    
    * qt/pinlineedit.h: New file.
    * qt/pinlineedit.cpp: New file.
    * qt/Makefile.am: Add new source files.
    * qt/pinentrydialog.cpp (PinEntryDialog): New member _got_input;
    Type of _edit member changed to PinLineEdit.
    (PinEntryDialog::onBackspace): New slot.
    
    GnuPG-bug-id: 3428
    Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>

diff --git a/qt/Makefile.am b/qt/Makefile.am
index 698005e..840d0c0 100644
--- a/qt/Makefile.am
+++ b/qt/Makefile.am
@@ -43,16 +43,17 @@ pinentry_qt_LDADD = \
 	$(COMMON_LIBS) $(PINENTRY_QT_LIBS) $(libcurses) $(LIBCAP)
 
 BUILT_SOURCES = \
-	pinentryconfirm.moc pinentrydialog.moc
+	pinentryconfirm.moc pinentrydialog.moc pinlineedit.moc
 
 CLEANFILES = \
-	pinentryconfirm.moc pinentrydialog.moc
+	pinentryconfirm.moc pinentrydialog.moc pinlineedit.moc
 
 pinentry_qt_SOURCES = pinentrydialog.h pinentrydialog.cpp \
-	main.cpp qrc_pinentry.cpp pinentryconfirm.cpp pinentryconfirm.h
+	main.cpp qrc_pinentry.cpp pinentryconfirm.cpp pinentryconfirm.h \
+	pinlineedit.h pinlineedit.cpp
 
 nodist_pinentry_qt_SOURCES = \
-	pinentryconfirm.moc pinentrydialog.moc
+	pinentryconfirm.moc pinentrydialog.moc pinlineedit.moc
 
 .h.moc:
 	$(MOC) `test -f '$<' || echo '$(srcdir)/'`$< -o $@
diff --git a/qt/pinentrydialog.cpp b/qt/pinentrydialog.cpp
index d42ae4a..b7f2e53 100644
--- a/qt/pinentrydialog.cpp
+++ b/qt/pinentrydialog.cpp
@@ -36,6 +36,7 @@
 #include <QLineEdit>
 #include <QAction>
 #include <QCheckBox>
+#include "pinlineedit.h"
 
 #ifdef Q_OS_WIN
 #include <windows.h>
@@ -137,6 +138,7 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
     : QDialog(parent),
       mRepeat(NULL),
       _grabbed(false),
+      _got_input(false),
       mVisibilityTT(visibilityTT),
       mHideTT(hideTT),
       mVisiActionEdit(NULL),
@@ -163,7 +165,7 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
     _prompt = new QLabel(this);
     _prompt->hide();
 
-    _edit = new QLineEdit(this);
+    _edit = new PinLineEdit(this);
     _edit->setMaxLength(256);
     _edit->setEchoMode(QLineEdit::Password);
 
@@ -205,6 +207,8 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
             this, SLOT(updateQuality(QString)));
     connect(_edit, SIGNAL(textChanged(QString)),
             this, SLOT(textChanged(QString)));
+    connect(_edit, SIGNAL(backspacePressed()),
+            this, SLOT(onBackspace()));
 
     QTimer::singleShot(0, _edit, SLOT(setFocus()));
 
@@ -356,6 +360,16 @@ void PinEntryDialog::setQualityBarTT(const QString &txt)
     }
 }
 
+void PinEntryDialog::onBackspace()
+{
+    if (!_got_input) {
+        _edit->setEchoMode(QLineEdit::NoEcho);
+        if (mRepeat) {
+            mRepeat->setEchoMode(QLineEdit::NoEcho);
+        }
+    }
+}
+
 void PinEntryDialog::updateQuality(const QString &txt)
 {
     int length;
@@ -366,6 +380,8 @@ void PinEntryDialog::updateQuality(const QString &txt)
         _timer->stop();
     }
 
+    _got_input = true;
+
     if (!_have_quality_bar || !_pinentry_info) {
         return;
     }
diff --git a/qt/pinentrydialog.h b/qt/pinentrydialog.h
index 52b7343..396f03b 100644
--- a/qt/pinentrydialog.h
+++ b/qt/pinentrydialog.h
@@ -33,6 +33,7 @@
 class QLabel;
 class QPushButton;
 class QLineEdit;
+class PinLineEdit;
 class QString;
 class QProgressBar;
 class QCheckBox;
@@ -89,6 +90,7 @@ protected slots:
     void textChanged(const QString &);
     void focusChanged(QWidget *old, QWidget *now);
     void toggleVisibility();
+    void onBackspace();
 
 protected:
     /* reimp */ void showEvent(QShowEvent *event);
@@ -100,13 +102,14 @@ private:
     QLabel    *_prompt;
     QLabel    *_quality_bar_label;
     QProgressBar *_quality_bar;
-    QLineEdit *_edit;
-    QLineEdit *mRepeat;
+    PinLineEdit *_edit;
+    QLineEdit   *mRepeat;
     QPushButton *_ok;
     QPushButton *_cancel;
     bool       _grabbed;
     bool       _have_quality_bar;
     bool       _timed_out;
+    bool       _got_input;
     pinentry_t _pinentry_info;
     QTimer    *_timer;
     QString    mRepeatError,
diff --git a/qt/pinlineedit.cpp b/qt/pinlineedit.cpp
new file mode 100644
index 0000000..c7c7f36
--- /dev/null
+++ b/qt/pinlineedit.cpp
@@ -0,0 +1,36 @@
+/* pinlineedit.cpp - Modified QLineEdit widget.
+ * Copyright (C) 2018 Damien Goutte-Gattat
+ *
+ * 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, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include "pinlineedit.h"
+
+#include <QKeyEvent>
+
+PinLineEdit::PinLineEdit(QWidget *parent) : QLineEdit(parent)
+{
+}
+
+void
+PinLineEdit::keyPressEvent(QKeyEvent *e)
+{
+    QLineEdit::keyPressEvent(e);
+
+    if ( e->key() == Qt::Key::Key_Backspace )
+	emit backspacePressed();
+}
+
+#include "pinlineedit.moc"
diff --git a/qt/pinlineedit.h b/qt/pinlineedit.h
new file mode 100644
index 0000000..b1b48df
--- /dev/null
+++ b/qt/pinlineedit.h
@@ -0,0 +1,38 @@
+/* pinlineedit.h - Modified QLineEdit widget.
+ * Copyright (C) 2018 Damien Goutte-Gattat
+ *
+ * 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, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _PINLINEEDIT_H_
+#define _PINLINEEDIT_H_
+
+#include <QLineEdit>
+
+class PinLineEdit : public QLineEdit
+{
+    Q_OBJECT
+
+public:
+    PinLineEdit(QWidget *);
+
+signals:
+    void backspacePressed();
+
+protected:
+    void keyPressEvent(QKeyEvent *);
+};
+
+#endif // _PINLINEEDIT_H_

commit 4b06bc6009011a84e5e8d4da2f01659f35e5a2d5
Author: Damien Goutte-Gattat via Gnupg-devel <gnupg-devel at gnupg.org>
Date:   Sat Aug 4 22:24:09 2018 +0100

    gtk: Disable echoing if backspace is pressed first.
    
    * gtk+-2/pinentry-gtk-2.c (backspace_handler): New callback.
    (create_window): Attach previous callback to "backspace" signal.
    
    GnuPG-bug-id: 3428
    Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>

diff --git a/gtk+-2/pinentry-gtk-2.c b/gtk+-2/pinentry-gtk-2.c
index c803628..1e07fdc 100644
--- a/gtk+-2/pinentry-gtk-2.c
+++ b/gtk+-2/pinentry-gtk-2.c
@@ -419,6 +419,22 @@ changed_text_handler (GtkWidget *widget)
 }
 
 
+/* Called upon a press on Backspace in the entry widget.
+   Used to completely disable echoing if we got no prior input. */
+static void
+backspace_handler (GtkWidget *widget, gpointer data)
+{
+  (void)data;
+
+  if (!got_input)
+    {
+      gtk_entry_set_invisible_char (GTK_ENTRY (entry), 0);
+      if (repeat_entry)
+	gtk_entry_set_invisible_char (GTK_ENTRY (repeat_entry), 0);
+    }
+}
+
+
 #ifdef HAVE_LIBSECRET
 static void
 may_save_passphrase_toggled (GtkWidget *widget, gpointer data)
@@ -713,6 +729,8 @@ create_window (pinentry_t ctx)
       gtk_widget_set_size_request (entry, 200, -1);
       g_signal_connect (G_OBJECT (entry), "changed",
                         G_CALLBACK (changed_text_handler), entry);
+      g_signal_connect (G_OBJECT (entry), "backspace",
+                        G_CALLBACK (backspace_handler), entry);
       hbox = gtk_hbox_new (FALSE, HIG_TINY);
       gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
       /* There was a wish in issue #2139 that this button should not

commit fd22facabd784586f72eeecc72830620a534929c
Author: Damien Goutte-Gattat via Gnupg-devel <gnupg-devel at gnupg.org>
Date:   Sat Aug 4 22:24:08 2018 +0100

    curses: Disable echoing if backspace is pressed first.
    
    * pinentry/pinentry-curses.c (struct dialog): New fields got_input,
    no_echo.
    (dialog_input): Disable echoing and display instead "[no echo]" if
    the backspace key is pressed first.
    
    GnuPG-bug-id: 3428
    Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 89bb5b6..cfc1abd 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -94,6 +94,8 @@ struct dialog
   int pin_max;
   /* Length of PIN.  */
   int pin_len;
+  int got_input;
+  int no_echo;
 
   int ok_y;
   int ok_x;
@@ -596,6 +598,9 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
       addstr (dialog->ok);
     }
 
+  dialog->got_input = 0;
+  dialog->no_echo = 0;
+
  out:
   if (description)
     free (description);
@@ -730,6 +735,12 @@ dialog_input (dialog_t diag, int alt, int chr)
 		diag->pin_loc = diag->pin_len;
 	    }
 	}
+      else if (!diag->got_input)
+	{
+	  diag->no_echo = 1;
+	  move (diag->pin_y, diag->pin_x);
+	  addstr ("[no echo]");
+	}
       break;
 
     case 'l' - 'a' + 1: /* control-l */
@@ -801,19 +812,24 @@ dialog_input (dialog_t diag, int alt, int chr)
       break;
     }
 
-  if (old_loc < diag->pin_loc)
-    {
-      move (diag->pin_y, diag->pin_x + old_loc);
-      while (old_loc++ < diag->pin_loc)
-	addch ('*');
-    }
-  else if (old_loc > diag->pin_loc)
+  diag->got_input = 1;
+
+  if (!diag->no_echo)
     {
+      if (old_loc < diag->pin_loc)
+	{
+	  move (diag->pin_y, diag->pin_x + old_loc);
+	  while (old_loc++ < diag->pin_loc)
+	    addch ('*');
+	}
+      else if (old_loc > diag->pin_loc)
+	{
+	  move (diag->pin_y, diag->pin_x + diag->pin_loc);
+	  while (old_loc-- > diag->pin_loc)
+	    addch ('_');
+	}
       move (diag->pin_y, diag->pin_x + diag->pin_loc);
-      while (old_loc-- > diag->pin_loc)
-	addch ('_');
     }
-  move (diag->pin_y, diag->pin_x + diag->pin_loc);
 }
 
 static int

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

Summary of changes:
 gtk+-2/pinentry-gtk-2.c                 | 18 +++++++++++++++++
 pinentry/pinentry-curses.c              | 36 ++++++++++++++++++++++++---------
 qt/Makefile.am                          |  9 +++++----
 qt/pinentrydialog.cpp                   | 18 ++++++++++++++++-
 qt/pinentrydialog.h                     |  7 +++++--
 qt/pinlineedit.cpp                      | 36 +++++++++++++++++++++++++++++++++
 qt/{pinentryconfirm.h => pinlineedit.h} | 34 ++++++++++++-------------------
 tqt/pinentrydialog.cpp                  | 14 ++++++++++++-
 tqt/pinentrydialog.h                    |  2 ++
 tqt/secqlineedit.cpp                    |  2 ++
 tqt/secqlineedit.h                      |  1 +
 11 files changed, 138 insertions(+), 39 deletions(-)
 create mode 100644 qt/pinlineedit.cpp
 copy qt/{pinentryconfirm.h => pinlineedit.h} (50%)


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




More information about the Gnupg-commits mailing list