Page MenuHome GnuPG

No OneTemporary

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/ChangeLog b/ChangeLog
index 5216a96..a6d274a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1603 +1,1610 @@
2007-09-18 Werner Koch <wk@g10code.com>
+ * qt/secqlineedit.h (SecQLineEdit): New signal textModified.
+ * qt/secqlineedit.cpp (finishChange): Emit it.
+ * qt/pinentrydialog.cpp (setPinentryInfo): New.
+ (PinEntryDialog): Add arg ENABLE_QUALITY_BAR.
+ * qt/pinentrydialog.h (setPinentryInfo): New.
+ (PinEntryDialog): Add arg ENABLE_QUALITY_BAR.
+
* pinentry/pinentry.h (struct pinentry): Add member QUALITY_BAR
and CTX_ASSUAN.
* pinentry/pinentry.c (cmd_setqualitybar): New.
(copy_and_escape): New.
(pinentry_inq_quality): New.
2007-07-09 Werner Koch <wk@g10code.com>
* doc/pinentry.texi: Fixed direntry syntax.
* configure.ac: Add --without-libcap. From the Gentoo patch archive.
* gtk+-2/pinentry-gtk-2.c (create_window): Use expose-event
instead of map-event. From Alon Bar-Lev.
2007-07-06 Werner Koch <wk@g10code.com>
Released 0.7.3.
* config.sub, config.guess: Updated from current Savannah CVS.
2007-06-27 Werner Koch <wk@g10code.com>
* w32/main.c: Revamped the SetFocus stuff. It is all not that easy.
2007-06-26 Werner Koch <wk@g10code.com>
* w32/Makefile.am (pinentry_w32_LDFLAGS): Add -mconsole again.
* w32/main.c (dlg_proc): Set focus.
(resize_button): New. No code yet.
(dlg_proc): Call it for the buttons.
(w32_cmd_handler): Restore old foreground window.
2007-06-20 Werner Koch <wk@g10code.com>
* w32/Makefile.am (pinentry_w32_LDFLAGS): Remove -mconsole.
* w32/main.c (wchar_to_utf8): New.
(ok_button_clicked): Use it.
(utf8_to_wchar): New.
(set_dlg_item_text): New.
(dlg_proc): Use new function so that we are able to correctly
display all prompts.
(main): Load LockSetForegroundWindow.
(dlg_proc): Call LockSetForegroundWindow via its fnc ptr.
(center_window): New. Taken from GPGol.
(dlg_proc): Call it.
(w32_cmd_handler): Revamped the confirm mode.
2007-06-18 Werner Koch <wk@g10code.com>
* w32/main.c (dlg_proc): Call LockSetForegroundWindow.
* Makefile.am (signed-dist, %.sig): Remove.
* autogen.sh: Modernized.
2007-05-10 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry.h (pinentry_color_t): New type.
(struct pinentry): New members COLOR_FG, COLOR_FG_BRIGHT,
COLOR_BG, COLOR_SO.
* pinentry/pinentry.c (pinentry_parse_opts): Support new option --colors.
(parse_color): New function.
* pinentry/pinentry-curses.c (USE_COLORS): New macro.
(pinentry_color): New static variable.
(dialog_create): Redo color management.
* pinentry/pinentry-curses.c (dialog_create): Re-add calculation
of cancel button position. Adjust calculation of OK button
position if it is the only one used.
2007-04-13 Marcus Brinkmann <marcus@g10code.de>
* qt/secqlineedit.h (SecQLineEdit::contextMenuEvent,
SecQLineEdit::createPopupMenu): Remove prototype.
* qt/secqlineedit.cpp (SecQLineEdit::contextMenuEvent,
SecQLineEdit::createPopupMenu): Remove implementation.
Submitted by Tobias Koenig <tokoe@kde.org>.
2007-02-14 Werner Koch <wk@g10code.com>
* pinentry/pinentry.h (struct pinentry): Add TOUCH_FILE.
* pinentry/pinentry.c (option_handler): New option "touch-file".
(pinentry_have_display): Ignore an empty DISPLAY.
* pinentry/pinentry-curses.c (do_touch_file): New.
(curses_cmd_handler): Call it.
* configure.ac: Check for utime.h.
2007-01-24 Werner Koch <wk@g10code.com>
* pinentry/pinentry.c (cmd_message): New.
(cmd_confirm): New command option --one-button.
(cmd_getpin): Zeroise ONE_BUTTON.
* pinentry/pinentry.h (struct pinentry): Add field ONE_BUTTON.
* gtk/pinentry-gtk.c (create_window): Take care of new option.
* gtk+-2/pinentry-gtk-2.c (create_window): Ditto.
* pinentry/pinentry-curses.c (dialog_create): Ditto.
(dialog_create, dialog_switch_pos): Allow CANCEL to be optional.
2006-07-29 Marcus Brinkmann <marcus@g10code.de>
* secmem/secmem.c (init_pool): Close FD after establishing the
mapping.
2005-09-28 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (PINENTRY_GTK): Error out if iconv is not found but
needed.
* config.rpath: New file from gettext. Needed by iconv.m4.
2005-07-11 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry-curses.c (dialog_switch_pos): Set the cursor
state to invisible before moving around. Move the cursor to the
beginning of the dialog buttons for accessibility.
2005-06-16 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry-curses.c (dialog_run): Only convert pin if a
pin actually exists.
2005-01-27 Werner Koch <wk@g10code.com>
Released 0.7.2.
* gtk+-2/Makefile.am: Removed padlock-keyhole.xpm.
* configure.ac: Use AC_GNU_SOURCE instead of the custom define.
Prefer gtk2 pinentry over qt.
2005-01-21 Marcus Brinkmann <marcus@g10code.de>
* doc/pinentry.texi: Fix spelling errors.
Submitted by Ville Skyttä.
2004-12-23 Werner Koch <wk@g10code.com>
* w32/pinentry-w32.rc: Remove the default texts for description,
prompt and error. Make it system modal. Enlarge the description
field.
2004-12-22 Timo Schulz <twoaday@g10code.com>
* w32/main.c: Remove all helper functions and use a callback
to set the dialog items directly.
(dlg_proc): Set 'result' to -1 to indicate cancel.
(ok_button_clicked): Adjusted. Set 'result' to the len of
the PIN to indicate success.
2004-12-22 Werner Koch <wk@g10code.com>
* w32/main.c: Simplified.
* w32/dialog.h, w32/dialog.c, w32/controller.h, w32/controller.c:
Removed
* w32/resource.h, w32/pinentry-w32.rc, w32/main.c, w32/dialog.h
* w32/dialog.c, w32/controller.h, w32/controller.c
* w32/Makefile.am: New. Based on Timo's work.
Update to automake 1.9.
* autogen.sh (configure_ac): Add --build-w32 option.
* Makefile.am: Support for the W32 pinentry.
* configure.ac: Ditto. Reformatted some error messages.
Define the usual conditionals for W32.
Check for a couple of more usually required headers.
* pinentry/pinentry.h (sleep) [W32]: New.
* pinentry/pinentry.c: Include langinfo.h only if available.
(pinentry_loop) [DOSISH]: Don't do uid check.
* secmem/util.c [DOSISH]: Disable UID stuff.
2004-09-27 Marcus Brinkmann <marcus@g10code.de>
* acinclude.m4 (IU_LIB_NCURSES, IU_LIB_CURSES, IU_LIB_TERMCAP):
Moved to m4/curses.m4.
(AM_ICONV): Moved to m4/iconv.m4.
(AM_PATH_GLIB): Moved to m4/glib.m4.
(QT_FIND_FILE, QT_PATH_MOC, QT_PATH_X, QT_PRINT_PROGRAM,
QT_CHECK_VERSION, QT_PATH_1_3, QT_PATH, QT_CHECK_COMPILER_FLAG,
QT_REMOVE_FORBIDDEN, QT_VALIDIFY_CXXFLAGS, QT_CHECK_COMPILERS,
QT_CHECK_RPATH, QT_CHECK_LIBPTHREAD, QT_CHECK_PTHREAD_OPTION,
QT_CHECK_THREADING): Move to m4/qt.m4.
2004-09-21 Marcus Brinkmann <marcus@g10code.de>
* qt/Makefile.am (pinentry_qt_LDFLAGS): Add $(QT_RPATH).
Requested by Leo Savernik <l.savernik@aon.at>.
2004-09-02 Marcus Brinkmann <marcus@g10code.de>
* gtk+-2/padlock-keyhole.xpm: File removed.
* gtk+-2/pinentry-gtk-2.c (create_window): Use stock icon.
* gtk+-2/gtksecentry.h, gtk+-2/gtksecentry.c: Fix copyright notice.
Submitted by Albrecht Dress albrecht.dress@arcor.de.
2004-08-17 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Invoke AC_PROG_LN_S.
(PINENTRY_DEFAULT): New variable. Substitute it. Fail if no
default can be determined.
* Makefile.am (install-exec-local): Install pinentry default link.
* configure.ac: Check for Gtk+-2.
* gtk+-2: New directory with gtk+-2 pinentry.
* gtk+-2/Makefile.am, gtk+-2/gtksecentry.h, gtk+-2/gtksecentry.c,
gtk+-2/pinentry-gtk-2.c, gtk+-2/padlock-keyhole.xpm: New files.
* Makefile.am (pinentry_gtk_2): New variable.
(SUBDIRS): Add pinentry_gtk_2.
Submitted by Albrecht Dress albrecht.dress@arcor.de.
2004-08-04 Werner Koch <wk@g10code.de>
* pinentry/pinentry.c (usage): Print help to stdout.
2004-07-30 Moritz Schulte <moritz@g10code.com>
* qt/Makefile.am (ncurses_include): Removed
-I$(top_srcdir)/pinentry ...
(AM_CPPFLAGS): ... added: -I$(top_srcdir)/pinentry. Thanks to
Peter Eisentraut.
* pinentry/pinentry.c (pinentry_utf8_to_local): Declare INPUT
const.
(pinentry_local_to_utf8): Likewise.
(pinentry_utf8_to_local, pinentry_local_to_utf8): Compile only, if
either Curses or GTK+ support is enabled.
* configure.ac: Do also check for libiconv when the GTK+ version
of pinentry is to be build. Define PINENTRY_CURSES, PINENTRY_GTK,
PINENTRY_QT depending on which versions of pinentry should be
build.
2004-05-21 Marcus Brinkmann <marcus@g10code.de>
* acinclude.m4 (QT_CHECK_DIRECT): Removed.
(QT_PATH_1_3): Do never invoke QT_CHECK_DIRECT.
2004-04-21 Werner Koch <wk@gnupg.org>
Released 0.7.1.
2004-04-20 Werner Koch <wk@gnupg.org>
* secmem/secmem.c [!ORIGINAL_GPG_VERSION]: Include util.h for some
typedefs and protos.
(secmem_free, secmem_term): Use wipememory2 instead of memset.
* autogen.sh (configure_ac): Fixed version check (s/==/=/).
2004-04-02 Thomas Schwinge <schwinge@nic-nac-project.de>
* autogen.sh: Added ACLOCAL_FLAGS.
2004-02-23 Marcus Brinkmann <marcus@g10code.de>
* qt/main.cpp: Include "pinentry.h", not <pinentry.h>.
2004-01-30 Werner Koch <wk@gnupg.org>
* configure.ac (fopencookie): Remove that test.
2004-01-28 Moritz Schulte <mo@g10code.com>
* gtk/gtksecentry.c:
(gtk_secure_entry_key_press): Treat GDK_KP_Enter just like
GDK_Return.
2004-01-18 Marcus Brinkmann <marcus@g10code.de>
* qt/secqstring.cpp: Do not include "private/qunicodetables_p.h".
(isRightToLeft): De-optimize direction query.
* qt/secqinternal_p.h, qt/secqinternal.cpp: New files.
* qt/Makefile.am (pinentry_qt_SOURCES): Add secqinternal_p.h
and secqinternal.cpp.
(EXTRA_DIST): Add README.SecQ.
* qt/secqlineedit.cpp: Include "secqinternal_p.h".
(drawContents): Use SecQSharedDoubleBuffer.
2004-01-02 Werner Koch <wk@gnupg.org>
* configure.ac: Early check for a c++ compiler.
2003-12-23 Werner Koch <wk@gnupg.org>
Released 0.7.0.
Added Manifest files to all directories.
2003-12-22 Werner Koch <wk@gnupg.org>
* qt/main.cpp: Include errno.h.
(main): Translate the --display option to -display, so that the Qt
init code can grasp it.
* doc/ChangeLog: Removed and merged with this file.
* doc/pinentry.texi: Cleaned up.
* doc/fdl.texi: Removed.
* pinentry/pinentry.h (struct pinentry): Added LOCALE_ERR.
* gtk/pinentry-gtk.c (button_clicked): Set the LOCAE_ERR flag.
* pinentry/pinentry-curses.c (dialog_run): Ditto.
* pinentry/pinentry.c (cmd_getpin, cmd_confirm): Check this flag.
(pinentry_local_to_utf8): Release the correct buffer in the error
case. Print diagnostics.
(pinentry_utf8_to_local): Print diagnostics.
(pinentry_parse_opts): Make short options work.
(pinentry_utf8_to_local): Pass nl_langinfo to iconv_open.
* gtk/pinentry-gtk.c (button_clicked): Use the right value as
input for the conversion.
* pinentry/pinentry.c: New variable THIS_PGMNAME.
(pinentry_init): Add arg PGMNAME and store it. Use it at all
marked placed instead of the constant "pinentry".
(usage): Use it here too.
* curses/pinentry-curses.c (main): Call pinentry_init with our name.
* qt/main.cpp (main): Ditto.
* gtk/pinentry-gtk.c (main): Ditto.
* configure.ac: Check for mmap.
* secmem/util.h (wipememory2,wipememory,wipe): New.
* secmem/util.c (wipe): Removed.
* secmem/util.c (lower_privs, raise_privs): Commented out.
* pinentry/pinentry.c (pinentry_loop): Add paranoia check for
dropped privs.
* secmem/secmem.c (lock_pool): Cleanup syntax of cpp directives.
* gtk/pinentry-gtk.c (main): Print package name in the version line.
* curses/pinentry-curses.c (main): Ditto.
* qt/main.cpp (main): Ditto. Fixed typo.
* gtk/pinentry-gtk.c: Include memory.h.
2003-12-20 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry.h (struct pinentry): New member PARENT_WID.
* pinentry/pinentry.c (pinentry): Add new member here.
(usage): Add --parent-wid.
(pinentry_parse_opts): Add case for "parent-wid".
(option_handler): Same here.
2003-12-19 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry.c (cmd_setcancel): Use strcpy_escaped.
(cmd_setok): Likewise.
(cmd_setprompt): Likewise.
(pinentry_utf8_to_local): Don't use
nl_langinfo, but just lc_ctype directly.
* pinentry/pinentry.c (cmd_getpin): Do not convert passphrase to
UTF-8 here.
* gtk/pinentry-gtk.c (button_clicked): Convert passphrase to UTF8
here.
* pinentry/pinentry-curses.c (dialog_run): Likewise.
2003-12-14 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry.c (pinentry_init): Register secmem_term as
atexit function. Set assuan malloc hooks to secmem.
(pinentry_parse_opts): Add break statement to silence gcc warning.
* pinentry/pinentry.c (cmd_getpin): If canceled, release and clear
PINENTRY->pin nevertheless.
* acinclude.m4 (qt_incdirs): Add /usr/include/qt3.
* qt/Makefile.am (pinentry_qt_SOURCES): Remove cppmemory.h,
cppmemory.cpp, pinentrycontroller.h, pinentrycontroller.cpp.
(nodist_pinentry_qt_SOURCES): Remove pinentrycontroller.moc.cpp.
(libcurses): Move ../pinentry/libpinentry.a from here to ...
(pinentry_qt_LDADD): ... here. Change order a bit to make it
work.
* qt/cppmemory.h, qt/cppmemory.cpp, qt/pinentrycontroller.h,
qt/pinentrycontroller.cpp: Files removed.
* qt/secqstring.h, qt/secqstring.cpp, secqlineedit.h,
secqlineedit.cpp: New files.
* qt/Makefile.am (pinentry_qt_SOURCES): Add secqstring.h,
secqstring.cpp, secqlineedit.h, and secqlineedit.cpp.
(nodist_pinentry_qt_SOURCES): Add secqlineedit.moc.cpp.
* qt/main.cpp: Do not include "memory.h" or "secmem-util.h", nor
<new> or "pinentrycontroller.h". Include <qapplication.h>,
<qmessagebox.h>, <qwidget.h> and "secqstring.h". Always include
<pinentry.h>.
[USE_KDE]: Remove all instances.
(curses_main): Function removed.
(my_new_handler): Likewise.
(qt_main): Likewise.
(qt_cmd_handler): New function.
(pinentry_cmd_handler): Define always (to qt_cmd_handler).
(main): Rewritten.
* qt/pinentrydialog.cpp: Do not include <qlineedit.h>, but
"secqlineedit.h".
(PinEntryDialog::PinEntryDialog): Make _edit a SecQLineEdit
object. Connect accepted SIGNAL to accept SLOT, and rejected
SIGNAL to reject SLOT.
(PinEntryDialog::setText): Make argument SecQString rather than
QString.
(PinEntryDialog::text): Likewise for return value.
* qt/pinentrydialog.h: Declare SecQString and SecQLineEdit classes.
(class PinEntryDialog): Disable property text (for now). Adjust
argument of setText and return value of text, as well as type of
_edit.
2003-12-09 Werner Koch <wk@gnupg.org>
* README.CVS: New.
* Makefile.am (EXTRA_DIST): Add README.CVS
(ACLOCAL_AMFLAGS): New.
* configure.ac: Added min_automake_versions.
* autogen.sh: Revamped.
2003-04-23 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* configure.ac: Version 0.6.10-cvs
2003-04-23 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* configure.ac: Version 0.6.9
* qt/Makefile.am: Added moc files to DISTCLEANFILES
* qt/pinentrycontroller.cpp: Dont spew assuan debug stuff out on stderr.
2003-03-26 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* qt/cppmemory.cpp, qt/main.cpp: Only override array allocation
operators. This should take care of the reported memory-problems
and even make pinentry-qt use a bit less memory.
2003-02-15 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* qt/pinentrydialog.h, qt/pinentrydialog.cpp: Added icons
for error/non-error messages.
2003-02-07 Marcus Brinkmann <marcus@g10code.de>
Released 0.6.8.
2003-02-04 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* qt/main.cpp: Work around '--display' option. This fixes
the pinentry-qt problem reported by several people lately.
2003-01-24 Werner Koch <wk@gnupg.org>
* autogen.sh: Print a hint to use maintainer mode.
2002-12-24 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry-curses.c (collect_line): New function.
(COPY_OUT, MAKE_BUTTON): New macros.
(dialog_create): Rewrite the initializing code and the description
calculation routine with word wrapping.
2002-11-20 Werner Koch <wk@gnupg.org>
Released 0.6.7.
* pinentry/pinentry-curses.c (dialog_create): Better truncate
lines than to go into an infinite loop. We need to implement word
wrap.
(dialog_run): Add DIALOG_POS_NONE to switch so prevent a warning.
2002-11-12 Werner Koch <wk@gnupg.org>
* config.sub, config.guess: Updated from ftp.gnu.org/gnu/config
to version 2002-11-08.
2002-11-09 Werner Koch <wk@gnupg.org>
Released 0.6.6.
2002-11-08 Werner Koch <wk@gnupg.org>
* pinentry/pinentry-curses.c (convert_utf8_string): Renamed to
* pinentry/pinentry.c (pinentry_utf8_to_local): this. Changed
callers.
(pinentry_local_to_utf8): New.
(cmd_getpin): Convert result back to UTF-8.
* gtk/pinentry-gtk.c (create_utf8_label): New.
(create_window): Use it here to set the prompts.
2002-11-06 Werner Koch <wk@gnupg.org>
* pinentry/pinentry-curses.c (dialog_run): Fixed retrun value tests
for fopen.
2002-11-05 Werner Koch <wk@gnupg.org>
* secmem/util.c (init_uids): Make it a prototype.
* gtk/pinentry-gtk.c (enter_callback): Changed argument name to
avoid shadowing warning.
(create_window): Removed unused variable I.
(ok): Not used, commented.
* pinentry/pinentry.c: Include headers for getpid and sleep
prototypes.
* secmem/util.h: Correctly declare functions taking no args.
* gtk/pinentry-gtk.c: Move gtk headers to the top to avoid
compiler warnings about shadowing index etc.
* curses/pinentry-curses.c: Include stdio.h for the printf prototype.
* pinentry/pinentry-curses.c (dialog_switch_pos): Return a value.
* pinentry/pinentry.c (pinentry_have_display): New.
(pinentry_setbufferlen): Must return a value. Fixed documentation.
(usage): Print a question mark as a substitue for the program name.
* gtk/pinentry-gtk.c (main): use it here instead of getenv().
* qt/main.cpp (main): Ditto.
2002-10-11 Werner Koch <wk@gnupg.org>
* configure.ac, Makefile.am: Added doc/ and tests for makeinfo
* doc/pinentry.texi, doc/Makefile.am: New.
* doc/gpl.texi, doc/fdl.texi: Added these standard files.
2002-09-30 Werner Koch <wk@gnupg.org>
Released 0.6.5.
* qt/pinentrycontroller.cpp (optionHandler): Make sure that a
value is returned.
* configure.ac: Use -Wall also for C++.
2002-08-19 Steffen Hansen <steffen@hrhansen.dk>
* Relased 0.6.4.
2002-08-11 Steffen Hansen <steffen@hrhansen.dk>
* Adapted pinentry-qt to new CONFIRM spec.
2002-06-26 Werner Koch <wk@gnupg.org>
Release 0.6.3.
2002-05-24 Werner Koch <wk@gnupg.org>
* AUTHORS: Added Marcus
* README: Fixed spelling of Quintuple-Agent.
2002-05-13 Marcus Brinkmann <marcus@g10code.de>
Released 0.6.2.
* configure.ac: Set version number to 0.6.2.
* NEWS: Add information for 0.6.2.
* README: Update for release.
2002-05-09 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Add option --enable-fallback-curses and bind it to
the ncurses check. Add automake conditional
BUILD_LIBPINENTRY_CURSES and FALLBACK_CURSES. Add preprocessor
symbol FALLBACK_CURSES.
* curses/Makefile.am (AM_CPPFLAGS): Add $(NCURSES_INCLUDE).
(LDADD): Add ../pinentry/libpinentry-curses.a.
* curses/pinentry-curses.c: Include "pinentry-curses.h".
Moved most of the meat to ...
* pinentry/pinentry-curses.c: ... here. New file. Make all
functions and global variables static.
(dialog_cmd_handler): Rename to ...
(curses_cmd_handler): ... this.
* pinentry/pinentry-curses.h: New file.
* pinentry/Makefile.am (noinst_LIBRARIES)
[BUILD_LIBPINENTRY_CURSES]: Add libpinentry-curses.a.
(libpinentry_curses_a_SOURCES): New target.
* gtk/Makefile.am (INCLUDES): Moved all to ...
(AM_CPPFLAGS): ... here.
[CURSES_FALLBACK]: Define ncurses_include and libcurses.
(AM_CPPFLAGS): Add $(ncurses_include).
(LDADD): Add $(libcurses).
* gtk/pinentry-gtk.c: Rename TIMEOUT to TIME_OUT to avoid conflict
with curses.h.
[CURSES_FALLBACK]: Include "pinentry-curses.h".
(button_clicked): Likewise.
(create_window): Likewise.
(cmd_handler): Renamed to ...
(gtk_cmd_handler): ... this.
(pinentry_cmd_handler): Set to gtk_cmd_handler.
(main) [CURSES_FALLBACK]: Initialize GTK+ only if environment
variable DISPLAY is set, otherwise fall back to curses dialog.
* pinentry/pinentry.h: Protect against multiple inclusion.
2002-05-09 Marcus Brinkmann <marcus@g10code.de>
* curses/pinentry-curses.c (dialog_create): Allow multi-line error
texts.
* pinentry/pinentry.c (cmd_seterror): Call strcpy_escaped, rather
than strcpy, to allow percent-escaping the error text.
2002-04-25 Steffen Hansen <steffen@hrhansen.dk>
* pinentry-qt: Use ok and cancel value if
provided.
2002-04-25 Marcus Brinkmann <marcus@g10code.de>
* gtk/pinentry-gtk.c (create_window): Use ok and cancel value if
provided.
2002-04-25 Marcus Brinkmann <marcus@g10code.de>
* qt/pinentrycontroller.h: New members _ok and _cancel.
* qt/pinentrycontroller.cpp (registerCommands): Add SETOK and SETCANCEL.
(assuanOk): New method.
(assuanCancel): Likewise.
2002-04-25 Marcus Brinkmann <marcus@g10code.de>
* curses/pinentry-curses.c (dialog_create): Grok the new ok and
cancel members to set the pbutton texts, rather than parsing the
prompt in the confirm case.
* pinentry/pinentry.h (struct pinentry): Add new members ok and cancel.
* pinentry/pinentry.c (register_commands): Add new commands SETOK
and SETCANCEL to set button texts.
(struct pinentry pinentry): Add initializers for new members.
(cmd_setok): New function.
(cmd_setcancel): Likewise.
2002-04-24 Marcus Brinkmann <marcus@g10code.de>
* curses/pinentry-curses.c (dialog_create): Add '<' and '>' around
the user provided button texts. Replace sizeof by strlen to fix
size calculation of ok and cancel button.
2002-04-23 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry.h (struct pinentry): New variables lc_ctype
and lc_messages.
* pinentry/pinentry.c (usage): New options --lc-ctype and
--lc-messages.
(pinentry_parse_opts): Likewise.
(option_handler): Likewise.
(struct pinentry pinentry): New initializers for new members.
* curses/pinentry-curses.c (convert_utf8_string): New function.
(struct dialog): New members ok and cancel.
(dialog_create): New variables ERR, DESCRIPTION, ERROR, PROMPT,
OK, and CANCEL. Initialize them with the localised versions of
the pinentry strings. If in confirm mode, split up the prompt at
'|' and use the values as button texts. Use localised strings.
(dialog_switch_pos): Use localised strings.
(dialog_run): Free dialog strings.
* acinclude.m4 (AM_ICONV): New check from gettext.
* configure.ac: Run AM_ICONV if curses pinentry is build.
Don't check for inttypes.h, don't check size of unsigned int or
unsigned long.
(LIBCAP): Move check to interface independent part.
2002-04-21 Steffen Hansen <steffen@hrhansen.dk>
* Removed X11 dependency and use Qt for grabbing the keyboard.
* Clear the lineedit before asking the user for the PIN.
2002-04-12 Steffen Hansen <steffen@hrhansen.dk>
* Enable pinentry-qt if Qt is found
2002-04-06 Marcus Brinkmann <marcus@g10code.de>
* qt: New directory.
* qt/Makefile.am, qt/cppmemory.cpp, qt/main.cpp,
pinentrycontroller.cpp, qt/pinentrycontroller.h,
qt/pinentrydialog.cpp, qt/pinentrydialog.h: New file, copied from
kde/.
* kde: Directory removed.
* kde/Makefile.am, kde/cppmemory.cpp, kde/main.cpp,
kde/pinentry.desktop, kde/pinentrycontroller.cpp,
kde/pinentrycontroller.h, kde/pinentrydialog.cpp,
kde/pinentrydialog.h: Files removed.
* acinclude.m4: Removed the KE checks and completely overhauled
the Qt checks, putting all Qt checks in their own namespace QT_,
and make it declare QT_-prefixed variables for linking and
compilation.
* configure.ac: Use the new Qt checks instead the KDE checks.
Replace "kde" with "qt" everywhere.
* Makefile.am: Replace "kde" with "qt" everywhere.
2002-04-06 Marcus Brinkmann <marcus@g10code.de>
* acinclude.m4: Reworked the Qt and KDE checks, cutting out a lot
of dead and not-so-dead wood. Gave all KDE checks proper names.
* configure.ac: Use the new names for the KDE checks.
2002-04-06 Marcus Brinkmann <marcus@g10code.de>
* kde/Makefile.am (EXTRA_DIST): Remove variable.
(install-data-local): Remove target.
(uninstall-local): Likewise.
2002-04-05 Marcus Brinkmann <marcus@g10code.de>
Released 0.6.0.
* configure.ac: Set version number to 0.6.
* NEWS: Add information for 0.6.0.
* secmem/Makefile.am (libsecmem_a_SOURCES): Replace secmem.h with memory.
* kde/Makefile.am (pinentry_kde_SOURCES): Move
pinentrydialog.moc.cpp and pinentrycontroller.moc.cpp to ...
(nodist_pinentry_kde_SOURCES): ... this new target.
2002-04-05 Marcus Brinkmann <marcus@g10code.de>
* acinclude.m4: A lot of new checks more or less straight from KDE's
admin/acinclude.m4.in.
* configure.ac (AC_CANONICAL_HOST): Call that macro.
(AC_CHECK_COMPILERS, AC_PATH_KDE): Call those macros if KDE
pinentry is enabled.
* kde/Makefile.am (CXXFLAGS, XXX_PREFIX, XXX_KDE_DEFINES, LIB_QT,
LIB_KDECORE, LIB_KDEUI, KDE_RPATH, MOC, kde_appsdir): Variables removed.
(AM_CPPFLAGS): Replace XXX_KDE_DEFINES by all_includes.
(pinentry_kde_LDFLAGS): Add all_libraries.
* README: Document that automatic check is not possible for KDE.
2002-04-05 Marcus Brinkmann <marcus@g10code.de>
* curses/pinentry-curses.c (dialog_run): Add handling for TAB key.
(dialog_create): New variable description_x. Calculate dimension
of multi-line description correctly.
2002-04-04 Marcus Brinkmann <marcus@g10code.de>
* pinentry/pinentry.h (struct pinentry): New members DISPLAY,
TTYNAME and TTYTYPE.
* pinentry/pinentry.c (pinentry): Likewise.
* pinentry/pinentry.c: Include <string.h>.
(usage): Add new options --display,
--ttyname and --ttytype.
(option_handler): Likewise.
(pinentry_parse_opts): Likewise.
* curses/pinentry-curses.c (dialog_cmd_handler): Use
PINENTRY->ttyname and PINENTRY->ttytype.
2002-03-30 Marcus Brinkmann <marcus@g10code.de>
* acinclude.m4: Add AM_PATH_GLIB and AM_PATH_GTK.
2002-03-29 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Choose a more appropriate AC_CONFIG_SRCDIR.
2002-03-29 Marcus Brinkmann <marcus@g10code.de>
* kde/Makefile.am (pinentry_kde_LDADD): Link with $(LIBCAP).
* gtk/Makefile.am (install-exec-local): Moved to ...
* Makefile.am (install-exec-local): ... here.
2002-03-29 Marcus Brinkmann <marcus@g10code.de>
* kde/Makefile.am (kde_appsdir): New variable.
* kde/Makefile.am (install-data-local): Use DESTDIR.
(uninstall-local): Likewise.
2002-03-29 Marcus Brinkmann <marcus@g10code.de>
Merge of the gpinentry and curses pinentry program into the
pinentry distribution. For this, the structure of the repository
has been thoroughly overhauled. Some of the changes:
* secmem: New directory with secure memory allocation code.
* pinentry: New directory with pinentry support library.
* curses: New directory with curses frontend.
* gtk: New directory with GTK+ frontend.
* kde: New directory with only the core of the old kpinentry program.
* admin: Directory removed.
* po: Directory removed.
* kpinentry: Directory removed.
* doc: Directory removed.
* jnlib: Directory removed.x
The changes in more detail:
* AUTHORS: Add authors of other pinentry frontends.
* ChangeLog: Add the one from gpinentry.
* Makefile.am: Completely rewritten.
* README: Add content.
* TODO: Add content.
* NEWS: New file from gpinentry.
* THANKS: New file from gpinentry.
* acinclude.m4: New file.
* configure.ac: New file which configures for all frontends.
* curses/Makefile.am, curses/pinentry-curses.c: New files for
curses frontend.
* gtk/Makefile.am, gtk/gtksecentry.c, gtk/gtksecentry.h,
gtk/pinentry-gtk.c: New files, modified from gpinentry, for GTK+
frontend.
* kde/Makefile.am, kde/cppmemory.cpp, kde/main.cpp,
kde/pinentry.desktop, kde/pinentrycontroller.cpp,
kde/pinentrycontroller.h, kde/pinentrydialog.cpp,
kde/pinentrydialog.h: New files, modified from kpinentry, for KDE
frontend.
* pinentry/Makefile.am, pinentry/pinentry.c, pinentry/pinentry.h:
New files containing pinentry support library, partly factored out
from gpinentry.
* secmem/Makefile.am, secmem/memory.h, secmem/secmem-util.h,
secmem/secmem.c, secmem/util.c, secmem/util.h: New files
containing secure memory allocation code common to all pinentry
frontends.
* Makefile.dist, acconfig.h, configure.files, configure.in.in:
Files removed in favor of new configure.ac.
* pinentry.lsm: Removed file never used.
* stamp-h.in: Removed generated file.
* admin/ChangeLog, admin/Makefile.common, admin/acinclude.m4.in,
admin/am_edit, admin/am_edit.py, admin/conf.change.pl,
admin/config.guess, admin/config.pl, admin/config.sub,
admin/configure.in.min, admin/debianrules, admin/depcomp,
admin/install-sh, admin/libtool.m4.in, admin/ltcf-c.sh,
admin/ltcf-cxx.sh, admin/ltcf-gcj.sh, admin/ltconfig,
admin/ltmain.sh, admin/missing, admin/mkinstalldirs, admin/ylwrap:
Removed KDE build suite in favor of configure.ac.
* doc/Makefile.am, doc/en/Makefile.am, doc/en/index.docbook:
Removed files never used.
* jnlib/ChangeLog, jnlib/Makefile.am, jnlib/argparse.c,
jnlib/argparse.h jnlib/dotlock.c, jnlib/dotlock.h,
jnlib/libjnlib-config.h, jnlib/logging.c, jnlib/logging.h,
jnlib/mischelp.h, jnlib/stringhelp.c, jnlib/stringhelp.h,
jnlib/strlist.c, jnlib/strlist.h, jnlib/types.h, jnlib/xmalloc.c,
jnlib/xmalloc.h: Removed files no longer used.
* kpinentry/Makefile.am, kpinentry/cppmemory.cpp,
kpinentry/cppmemory.h, kpinentry/i18n.h, kpinentry/main.cpp,
kpinentry/memory.h, kpinentry/pinentry.desktop,
kpinentry/pinentrycontroller.cpp, kpinentry/pinentrycontroller.h,
kpinentry/pinentrydialog.cpp, kpinentry/pinentrydialog.h,
kpinentry/secmem.cpp, kpinentry/util.cpp, kpinentry/util.h:
Removed files in favor of new files in kde/.
* po/Makefile.am, po/pinentry.pot: Removed files never used.
* autogen.sh: New file.
2002-03-04 Werner Koch <wk@gnupg.org>
* gpinentry.c (enter_callback): New
(create_window): Connect it to the entry field.
2002-02-18 Werner Koch <wk@gnupg.org>
Released 0.5.1.
* gpinentry.c (create_window): Add CONFIRM_MODE.
(cmd_confirm): Implemented.
* assuan/: Updated from NewPG.
2002-01-20 Werner Koch <wk@gnupg.org>
* gpinentry.c (option_handler): New to allow changing of the grab
status.
(grab_keyboard): Shortcut this when global grab is not set.
2002-01-04 Werner Koch <wk@gnupg.org>
Released 0.5.0.
* configure.ac: Bumbed version
* util.h (xtoi_1, xtoi_2): New.
* gpinentry.c (strcpy_escaped): New
(cmd_setdesc, cmd_seterror): Use it here to allo multiline texts.
* gpinentry: Removed debugging outbut
(create_window): Tweaked layout.
2001-12-07 Werner Koch <wk@gnupg.org>
New package gpinentry based on quintuple-agent.
Removed all stuff except for the basic configuration stuff and
what is needed to build gpinentry. Also removed i18n support.
* gpinentry.c: Renamed from secret-query.c
2001-02-12 Robert Bihlmeyer <robbe@orcus.priv.at>
* 1.0.0 released. Woo-hoo!
* configure.in, NEWS: Bumped version.
2001-02-04 Robert Bihlmeyer <robbe@orcus.priv.at>
* agent.c (make_tmpdir): Honor $TMPDIR.
(agent): Would exit on every minor problem. Now, we just close the
offending connection.
Ignore SIGPIPE, so that EPIPE will close connection.
2001-01-11 Robert Bihlmeyer <robbe@orcus.priv.at>
* secmem.c: Move one include statement so that the thing compiles.
* secret-query.c (main): Minor source cosmetics.
2000-11-16 Robert Bihlmeyer <robbe@orcus.priv.at>
* gtksecentry.c (gtk_secure_entry_insert_text): Secured a couple
of memory (de)allocations that were missed. Thanks to John Steele
<jhs28@eng.cam.ac.uk> for spotting these.
2000-11-10 Robert Bihlmeyer <robbe@orcus.priv.at>
* Thoughts: Removed in favor of new TODO.
* README: Remove content and refer to doc/manual.info instead.
* agent.c (do_get): Would burn badly on a premature exit of the
query program (which would occur routinely if you selected /cancel/).
2000-10-25 Robert Bihlmeyer <robbe@orcus.priv.at>
* memory.h: Include sys/types.h for size_t.
2000-10-08 Robert Bihlmeyer <robbe@orcus.priv.at>
* README: Removed apology about missing documentation.
Updated paragraph about Linux capability patch.
Typo & Refill.
2000-10-03 Robert Bihlmeyer <robbe@orcus.priv.at>
* 0.9 released.
* Makefile.am (EXTRA_DIST): Distribute BUGS (the file, that is).
* configure.in, NEWS: Bumped version.
* Makefile.am, configure.in: Add debian subdir.
* README: Recommend GTK+.
Update list of checked platforms.
2000-10-02 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c (ok): Simplify.
Put empty line between headers and secret.
(usage): Document '--help' and '--version'.
* agent.c (do_get): Use enhanced secret-query output to fill in
options.
2000-10-01 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c (main): Clarify error.
* client.c (query_options): New global variable.
(main): New option '--query-options' to pass options to the query
program.
(xgetpass): Use it.
* agent.c (main): New option '--query-options' to pass options to
the query program.
(do_get): Use 'query_options'.
* acconfig.h, configure.in: Add QUERY_PROGRAM definition.
* client.c: Remove here.
* agent.c (do_get): Use it here, too.
* secret-query.c (main): New option '--no-global-grab' introduced,
that prevents keyboard grabbing unless the window has focus.
2000-09-11 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c (usage): Add two missing pieces of "\n\".
* agent.c (main): --nofork is now the default, and the option is
deprecated. New option --fork added to turn forking on again.
Close stdout (and stderr unless debugging) even when not forking,
so that normal usage inside eval is still possible.
(agent): Exit gracefully on HUP, so that logging out now kills the
agent.
* README (Contact Information): Old URL - duh!
(Using Secret Agent): We no longer fork per default.
* Makefile.am (lib/libutil.a): New target, allows targets that not
automatically recurse (but still depend on libutil.a) to succeed.
2000-07-20 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c (usage): New function.
(main): Parse options: debug, enhanced, help, version.
Turn on locale support.
If enhanced, insert widgets to ask for timeout and insurance.
(ok): If enhanced, print more information on exit.
(grab_keyboard): Die if grab was unsuccessful.
2000-05-31 Robert Bihlmeyer <robbe@orcus.priv.at>
* 0.8 released.
* configure.in, NEWS: Bumped version.
* Makefile.am (SUBDIRS): Include doc.
* configure.in, acconfig.h: Check for ssize_t.
Check for vsnprintf(), strdup().
Generate doc/Makefile.
* apgp.c, agpg.c, agentlib.c, util.c: Include more stuff.
* agent.c (do_get): Use asprintf() instead of snprintf() so we
don't need to roll our own for yet another function.
Fix some includes.
* acinclude.m4: gettext macros copied from automake and fixed.
2000-05-30 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in, Makefile.am: Properly include doc subdir.
2000-05-29 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in, acconfig.h: Add test for XMESSAGE path.
* client.c (main): Decode command from string to integer code
first, then evaluate that in ifs.
* secret-ask.c: New file, external ask-for-confirmation utility.
* configure.in, Makefile.am: Add secret-ask to programs being
built when GTK is available. Rename QUERY to more descriptive
GTK_PROGRAMS.
* agent.c (do_get): If GTK is available, try executing secret-ask
first.
Only put the comment into the insure-question if there is a
comment.
(main): --csh was missing from usage message.
2000-04-23 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c (constrain_size): Lower window max_width to
accomodate bugs in GTK and Scwm.
* agent.c (main): Set x_enabled if X appears to be available.
Use it to selectively make FLAGS_INSURE supported.
(do_get): Use it instead of testing at every call.
(do_put): Requests containing unsupported flags fail.
(forget_old_stuff): Would not set next_deadline correctly.
(do_get): Implement FLAGS_INSURE.
* client.c (main): "list" format changed so that comment is to the
far right. Display the deadline as proper date/time, too.
1999-11-11 Robert Bihlmeyer <robbe@orcus.priv.at>
* agent.c (next_deadline): New global variable, holds time when
next secret has to be killed.
(store): Keep it up-to-date.
(forget_old_stuff): New function, reaps secrets ready to kill,
keeps next_deadline updated.
(agent): Use it on all secrets, whenever a deadline is active.
1999-11-08 Robert Bihlmeyer <robbe@orcus.priv.at>
* agent.h (request_put): Add flags, deadline. Increase REQUEST_MAGIC.
(reply_get): Ditto, and increase REPLY_MAGIC.
* agent.c (store): Store flags, deadline in reply.
(do_put): Hand flags, deadline from request on to store().
(do_get): Store on-demand queried secrets without deadline or
special flags, for now.
(agent): Do not ignore obsolete clients, return an error reply.
* agentlib.c (agent_put): Add flags, deadline arguments, and copy
them into the request.
* agentlib.h (agent_put): Update prototype.
* * client.c (main): Added --time-to-live (-t) and --insure (-i)
options, influencing PUT's deadline and flags, respectively.
(main): Change list format to include new attributes.
1999-11-05 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: <getopt.h> check had redundant definition.
* acconfig.h: Remove here, too.
* configure.in: Check for <inttypes.h>. If not found, check for
unsigned {int, long} sizes.
* agent.h: Either include <inttypes.h>, or try to define uint32_t
yourself.
Need to include "config.h".
1999-11-04 Robert Bihlmeyer <robbe@orcus.priv.at>
* Makefile.am (signed-dist): New rule, generates sig for dist.
(%.sig): New rule, for detached signatures in general.
* configure.in: Check for ulong.
* acconfig.h: Document it.
* secmem.c: Unconditionally defining it is no longer necessary
here. But do include <sys/types.h> in all cases.
* 0.7 released.
* secmem.c: ulong is not defined on all systems.
* agent.h: <inttypes.h> should define `uint32_t' as per Unix98, so
we use that.
1999-11-02 Robert Bihlmeyer <robbe@orcus.priv.at>
* agent.h: Augmented requests and replies with magic numbers.
Data structures heavily commented.
All structures and enums typedef'd.
* agent.c: Adapted.
(store): Set magic number in stored reply.
(do_put): Set magic number in reply.
(do_delete): Ditto.
(do_list): Ditto.
(agent): Check magic number in request.
* agentlib.c: Adapted.
(send_request): Set magic number in request. Check it in reply.
* agentlib.h: Adapted.
* agpg.c: Adapted.
* apgp.c: Adapted.
* client.c: Adapted.
1999-10-31 Robert Bihlmeyer <robbe@orcus.priv.at>
* secmem.c: Instead of defining ulong directly, include
<sys/types.h>
* secret-query.c (constrain_size): New function, puts constrains
on size of toplevel window.
(grab_keyboard): Removed protection against multiple calls.
(ungrab_keyboard): New function, cancelling a keyboard grab.
(main): Hang `grab_keyboard' onto map-event which makes it
actually work, hang `ungrab_keyboard' onto unmap-event.
Hang `constrain_size' onto size-request.
* secmem.c: ulong was undefined on some systems.
1999-10-19 Robert Bihlmeyer <robbe@orcus.priv.at>
* Makefile.am (install-exec-local): Ignore setcap errors.
* apgp.c: New program, based on agpg.c, but for pgp2.6.
* Makefile.am (bin_PROGRAMS, apgp_SOURCES): Added it.
* agpg.c (GPG): New constant.
(find_id, main): Use it throughout.
(find_id): Forgot to pclose on success.
* secret-query.c (main): Don't expand anything.
Use a button box for the buttons.
Prompt label can be overridden from the commandline.
* agent.c (do_get): Make spawned secret-query show the id.
* client.c (xgetpass): Pass prompt to secret-query.
(main): Include id in xgetpass prompt.
1999-10-14 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: setcap must be searched outside the usual user
PATH, too.
* Makefile.am (install-exec-local): Set cap_ipc_lock permitted on
installed binaries, if possible.
* agent.c (xdup2): New function, dup2 with error handling.
(move_fd): New function, moves fds.
(store): New function, abstracted out from do_put.
(do_put): Use it.
(do_get): If secret was not found, and DISPLAY is set, try to
query the user about it. If successful, store it.
(main): Route standard file descriptors to /dev/null rather than
just closing them. The latter would confuse children.
1999-10-13 Robert Bihlmeyer <robbe@orcus.priv.at>
* gtksecentry.c, gtksecentry.h: New files, being slightly modified
versions of GTK+'s gtkentry.[ch], spiffed up to use secure memory.
* secret-query.c (ok, unselect, main): Replace GtkEntry with
GtkSecureEntry.
(main): Initialize secure memory.
* Makefile.am (secret_query_SOURCES): Added gtksecentry.[ch].
* README (Security): New chapter.
* configure.in, acconfig.h: Check for POSIX capabilities, and the
setcap program.
* Makefile.am: Link LIBCAP to those binaries using secmem.c.
* util.h: Include <sys/types.h> for size_t.
1999-09-21 Robert Bihlmeyer <robbe@orcus.priv.at>
* secmem.c: Synced with gnupg-1.0 (top new feature: capabilities).
(log_fatal): New function, logs to stderr, and dies.
1999-09-08 Robert Bihlmeyer <robbe@orcus.priv.at>
* secmem.c (log_info): New function, logs to stderr.
* agent.c (agent): select() expects the number of fds, not the
highest fd. So remember that number.
* agent.c (agent): Don't use FD_SETSIZE, which is not defined on
all systems. Remember the number of the highest descriptor
instead.
* configure.in: Replace getline() instead of getdelim() because
this is the function we really need. Still check for getdelim(),
though - there are systems out there where this is provided, but
getline() is not.
1999-09-01 Robert Bihlmeyer <robbe@orcus.priv.at>
* 0.6 released.
* configure.in: Bump version.
* NEWS: Updated.
1999-08-31 Robert Bihlmeyer <robbe@orcus.priv.at>
* util.c (init_uids, lower_privs, raise_privs, drop_privs): New
functions, for setuid binaries, extracted from agent.c.
* util.h: Add prototypes for them.
* agpg.c (main): Use them.
* client.c (main): Ditto.
* agent.c (main): Ditto. Removed code that did the same.
Unconditionally include "asprintf.h" (it protects itself now).
1999-08-25 Robert Bihlmeyer <robbe@orcus.priv.at>
* Makefile.am (SUBDIRS): Process . before test so that "make
check" always builds all in . first.
1999-08-21 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c: Include "config.h".
* agent.h (reply_list_entry, reply_list): New reply structures.
* agent.c (send_list_entry): New function.
(do_list): First send number of entries, then each entry via
send_list_entry().
* agentlib.c (agent_list): Read entries returned by LIST request.
* client.c (main): Output all entries returned by agent_list().
* agentlib.c (agent_put): Don't construct PUT request in insecure
stack space.
1999-08-20 Robert Bihlmeyer <robbe@orcus.priv.at>
* NEWS: Bump patchlevel.
* configure.in: Bump patchlevel.
Check for missing setenv().
1999-08-09 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: Check for strsignal().
* client-test: Obsoleted by test/client.
* Makefile.am (SUBDIRS): New subdirectory.
* configure.in (AC_OUTPUT): Add here, too.
* 0.5 released.
* README: Explain why secret-client will not output secrets to a
tty, and mention the cat-trick.
* agent.c (main): If seteuid is not available, don't use it and
issue a warning if running setuid.
* configure.in: Run together two REPLACE_FUNCS.
Check for seteuid.
* client-test: Mask out insecure memory warnings.
* agentlib.c (send_request): Let the calling functions reserve
space for the reply, but offer a simple way for simple requests.
(agent_get): Allocate secure memory.
* agent.c (main): Moved secmem_init() after the fork, since that
seemingly munlock's all pages.
Drop priviledges just in case somebody wants to install this
suid-root.
Flush stdout.
* agpg.c (find_id): Would reorder arguments.
Initialize opt_version.
(main): Initialize secure memory.
* Makefile.am (agpg_SOURCES): Link with secure memory module.
* client.c (usage): Fixed another program name reference.
1999-08-06 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: Conditionally define HAVE_GTK.
* acconfig.h: Add here too.
* client.c (xgetpass): Use "secret-query" only if it was built.
(main): Don't output secret (GET command) to ttys.
* agpg.c (find_id): Also print own version if "--version" is given.
(main): Check agent_init() errors.
Print error if exec fails.
* agent.c (main): Added an option to produce csh-compatible
output.
* agent.c, client.c: Forgot the terminating NULL in long options.
Fixed the program names in usage and version output.
* agent.c (create_socket): AF_UNIX and PF_UNIX are Unix98, so
that's what we use. AF_LOCAL, PF_LOCAL removed.
* agentlib.c (agent_init): Ditto.
1999-08-05 Robert Bihlmeyer <robbe@orcus.priv.at>
* 0.4 released.
* configure.in: Bumped version.
Check for missing getdelim.
* cgpg: Removed, obsoleted by agpg.
* Makefile.am: Here, too.
* agpg.c (find_id): New function.
(main): Use it.
* Makefile.am (INCLUDES): Put GTK_FLAGS and GLIB_FLAGS here. It
is the easiest way for sources needing it, and it won't hurt those
that don't.
(agent.o): Explicit command removed accordingly.
1999-08-04 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: Need double quoting in nested AC_MSG_WARN.
* client.c (xgetpass): If no tty is available, but a DISPLAY is,
fork off "secure-query" to read the secret.
Put the fgets into a loop that keeps reading until all of the
secret is read.
* client-test: Unset DISPLAY, so that "secret-query" is never used.
1999-08-03 Robert Bihlmeyer <robbe@orcus.priv.at>
* agpg.c: New file, first cut at a C version of the gpg wrapper,
written in a hurry (20 keys waiting to be signed, and a growling
stomach).
* Makefile.am: Add it to built programs.
(LDADD): New default.
(secret_client_LDADD): Removed, since it was identical to default.
1999-08-01 Robert Bihlmeyer <robbe@orcus.priv.at>
* secret-query.c: New program, queries the user for a password.
* Makefile.am (bin_PROGRAMS): Added it.
* configure.in: Check for GTK+, build "secret-query" only when
that is available.
* cgpg: Extra argument for ID is no longer necessary. cgpg will
scan the gpg args for switches that affect user-id, and determine
the right key itself. Per convention, the key-id is used by "GET".
* configure.in: The project name is now "secret-agent".
* Makefile.am: "agent" & "client" renamed to "secret-agent" &
"secret-client", respectively.
* client-test: Adapt to new names.
* Thoughts: Removed discussion of other names.
Added indication of which things already work.
* agent.c (make_tmpdir): Removed occurance of "gpg-agent."
* README: First proper version.
* client-test: Context diffs are more portable then unified diffs.
* agent.c, agent.h, agentlib.c, agentlib.h, client.c, memory.h,
util.c, util.h: Banner updated to new name.
1999-07-29 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: Check for missing asprintf.
Check if -lsocket is needed.
* secmem.c (secmem_dump_stats): Replace usage of ulong.
* Makefile.am (INCLUDES): Add the lib subdirectory to include search.
* agent.c: Forgot to include <string.h>.
Include RYO asprintf header if this function is missing.
For the sake of compatibility, provide a definition for AF_LOCAL,
PF_LOCAL, if missing.
* agentlib.c: Ditto.
1999-07-28 Robert Bihlmeyer <robbe@orcus.priv.at>
* Makefile.am (client_SOURCES): Add "secmem.c", "memory.h".
* client.c (xgetpass): Use secmem_malloc() instead of RYO.
(main): Init and shutdown secmem.
1999-07-27 Robert Bihlmeyer <robbe@orcus.priv.at>
* Makefile.am (agent_SOURCES): Add "secmem.c", "i18n.h", "memory.h".
(client_SOURCES): Add "i18n.h".
* client.c (main): Exit on agent_init() failure.
* agent.c (main): Init secmem.
Make --debug switch cumulative.
(cleanup): Shutdown secmem.
(do_put): Use secmem for storage of secrets.
(do_delete): Use secmem_free(). Since this wipes the memory on its
own, wipe() is superflous now.
(agent): Use secmem for inbound requests.
(delete_secret): New function, takes part of do_delete's
functionality.
(do_put): Use it to remove old versions stored under the same id.
(do_delete): Use it to delete secrets.
* memory.h: New file.
* secmem.c: New file, snarfed from GnuPG and modified slightly.
* acinclude.m4: New file.
* configure.in: (ALL_LINGUAS): Expanded list of available
languages. Most of them only have a few translations from gpg,
tough ...
getopt_long test was commented out for debugging,
and left such. Fixed.
Check for mlock.
* acconfig.h: Comment HAVE_BROKEN_MLOCK.
* cgpg: A space was missing.
* i18n.h: New file, centralizing the gettext macro defs.
* agent.c (BLIND): New macro, that blinds out a secret if debug
level is too low.
(do_put): Use it.
(do_get): Use it.
Include i18n.h.
* agentlib.c: Include i18n.h
* client.c (usage): New function.
Usage-message made gettext-friendly.
(xgetpass): Use perror() instead of fprintf().
(main): Use it.
Make comment an optional argument of PUT.
Include i18n.h.
1999-07-26 Robert Bihlmeyer <robbe@orcus.priv.at>
* Makefile.am (client_LDADD): Add lib/libutil.a for portability.
(agent_LDADD): Ditto.
(SUBDIRS): Add lib directory.
(bin_SCRIPTS): New with cgpg, so it gets installed, too.
* configure.in: Add lib/Makefile to output.
1999-07-24 Robert Bihlmeyer <robbe@orcus.priv.at>
* cgpg: New file.
* Makefile.am (EXTRA_DIST): Added it.
* agent.c: Moved inclusion of config.h before inclusion of
libintl.h since the latter needs HAVE_LC_MESSAGE.
* client.c: Ditto.
* clientlib.c: Ditto.
* client-test: Update for new client semantics.
* client.c (check_status): Use debugmsg(). Do nothing if not
debugging.
(xgetpass): New function, getpass replacement that uses mlock'ed
memory.
(main): PUT now asks for the secret rather then getting it from
the commandline.
GET prints only the secret to stdout.
* configure.in: Rearranged.
Check for socklen_t.
* acconfig.h: Added a definition for it.
* client.c: Include packaged getopt.h if the system doesn't provide
one.
* agent.c: Ditto.
(create_socket): Replace AF_FILE, PF_FILE with AF_LOCAL, PF_LOCAL
for portability.
* agentlib.c (agent_init): Ditto.
Explicitly cast addr to a sockaddr pointer.
* Makefile.am (client_LDADD): Added @INTLLIBS@.
(agent_LDADD): Ditto.
1999-07-19 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in: Check for getopt.h and getopt_long.
* acconfig.h (HAVE_GETOPT_H): New define.
* lib/getopt.c, lib/getopt1.c, lib/getopt.h: Added.
1999-07-18 Robert Bihlmeyer <robbe@orcus.priv.at>
* 0.2 released.
* NEWS: Updated.
* Makefile.am (agent.o): Mentioning the source explicitly does not
work for srcdir!=builddir.
* client.c (main): Function arguments are not always evaluated in
order, so drop the neat ++optind in favor of optind+1, optind+2,
etc.
* configure.in: Upped version.
1999-06-28 Robert Bihlmeyer <robbe@orcus.priv.at>
* util.h: Added multi-inclusion guard.
* agent.c Include "util.h".
(main): Forgot to exit at end.
(do_delete): Assume that value is a string and wipe it accordingly.
* configure.in (--enable-debug): New switch.
* agent.h (status_t): Added STATUS_COMM_ERR code.
Added multi-inclusion guard.
* client.c (main): Abstracted out most functionality into a
function library, namely:
* agentlib.c: New file.
* agentlib.h: New file.
* Makefile.am (client_SOURCES): Added agentlib.c, agentlib.h.
* Makefile.am (INCLUDES): GLIB_CFLAGS moved again, this time to
the agent.o target.
1999-06-15 Robert Bihlmeyer <robbe@orcus.priv.at>
* 0.1 released.
* Makefile.am (agent_CFLAGS): Removed - did not work.
(INCLUDES): Moved the GLIB stuff here.
1999-06-14 Robert Bihlmeyer <robbe@orcus.priv.at>
* configure.in (ALL_LINGUAS): Added `de'.
* agent.c (do_get): Added more debugmsgs.
(do_put): Wouldn't allocate enough for `value'.
(main): New option "--nofork" prevents forking.
Use macros for the std filedescriptor numbers.
Only close stderr if not debugging.
(main): Make Usage string gettext-friendly.
* client-test (cleanup): New function.
Call it on shell exit.
(client): New function.
Use it instead of calling client binary directly.
diff client output with expected one in GET testcases.
1999-06-13 Robert Bihlmeyer <robbe@orcus.priv.at>
* agent.c (failed_reply): New constant.
(do_list): Use it.
(do_put): The hash key was overwritten - strdup it.
Construct a GET reply and save that in the hash.
(do_get): Just send the preconstructed reply if the id is present,
and failed_reply otherwise.
(do_delete): Actually free the hashed stuff.
* client.c: Exit with error if agent returned STATUS_FAIL.
* Makefile.am (EXTRA_DIST): Added autogen.sh, Thoughts,
client-test.
(TESTS): Added client-test.
(AUTOMAKE_OPTIONS): Added gnits.
Copyright 2002, 2003 g10 Code GmbH
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/NEWS b/NEWS
index f5fbc12..77823a7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,139 +1,142 @@
Noteworthy changes in version 0.7.4
------------------------------------------------
+* Pinentry-gtk-2 and pinentry-qt now support a simple passphrase
+ quality indicator.
+
Noteworthy changes in version 0.7.3 (2007-07-06)
------------------------------------------------
* New command MESSAGE and --one-button compatibility option to
CONFIRM.
* New Assuan option touch-file to set a file which will be touched
after ncurses does not need the display anymore.
* New option --colors=FG,BG,SO to set the colors for the curses
pinentry.
* Pinentry-w32 does now basicaly work. It needs some finishing
though. For example the buttons should resize themself according
to the size of the text.
Noteworthy changes in version 0.7.2 (2005-01-27)
------------------------------------------------
* Remove bug in configure script that would use installed version of
Qt even if another path was explicitely specified with QTDIR.
* Honor the rpath setting for Qt.
* Add GTK+-2 pinentry.
* Install a symbolic link under the name "pinentry" that defaults to
pinentry-gtk, pinentry-qt, pinentry-gtk-2, or pinentry-curses, in
that order.
Noteworthy changes in version 0.7.1 (2004-04-21)
------------------------------------------------
* Removed unneeded Assuan cruft.
* Fixes for *BSD.
Noteworthy changes in version 0.7.0 (2003-12-23)
------------------------------------------------
* Make UTF8 description (prompt, error message, button texts) work.
* Make sure that secmem_term is called before program termination.
* Make assuan in Gtk and Curses pinentry use secure memory for
storage.
* Fixed a bug that would occur if a canceled GETPIN was immediately
followed by a CONFIRM.
* Disabled undo/redo in Qt pinentry.
* Print diagnostics for locale problems and return a new error code
in that case.
Noteworthy changes in version 0.6.8 (2003-02-07)
------------------------------------------------
* Bug fix in pinentry-qt.
Noteworthy changes in version 0.6.7 (2002-11-20)
------------------------------------------------
* Workaround for a bug in the curses version which led to an infinite
loop.
Noteworthy changes in version 0.6.6 (2002-11-09)
------------------------------------------------
* Fixed handling of DISPLAY and --display for the sake of the curses
fallback.
* UTF-8 conversion does now work for the GTK+ and CURSES version.
Noteworthy changes in version 0.6.5 (2002-09-30)
------------------------------------------------
* Handle Assuan options in the qt version.
Noteworthy changes in version 0.6.4 (2002-08-19)
------------------------------------------------
* Handle CONFIRM command in the qt version.
Noteworthy changes in version 0.6.3 (2002-06-26)
------------------------------------------------
* Minor bug fixes to the qt version.
Noteworthy changes in version 0.6.2 (2002-05-13)
------------------------------------------------
* Error texts can now be percent-escaped.
* The Curses pinentry supports multi-line error texts.
* The GTK+ and Qt pinentry can fall back to curses if no display is
available.
Noteworthy changes in version 0.6.1 (2002-04-25)
------------------------------------------------
* The Curses pinentry supports user-provided button texts via the
new SETOK and SETCANCEL commands.
* The Curses pinentry supports setting the desired character set
locale with --lc-ctype and correctly translates the UTF-8 strings
into that.
Noteworthy changes in version 0.6.0 (2002-04-05)
------------------------------------------------
* Merged all pinentry frontends into a single module.
* There is now a Curses frontend.
* The curses pinentry supports --ttyname and --ttytype options to
set the desired input/output terminal and its type.
Noteworthy changes in version 0.5.1 (2002-02-18)
------------------------------------------------
* CONFIRM command works
Noteworthy changes in version 0.5.0 (2002-01-04)
------------------------------------------------
* Window layout is somewhat nicer
* percent escape sequences do now work for SETDESC and SETERROR
diff --git a/qt/main.cpp b/qt/main.cpp
index 3137cf8..e284c2f 100644
--- a/qt/main.cpp
+++ b/qt/main.cpp
@@ -1,181 +1,182 @@
/* main.cpp - Secure KDE dialog for PIN entry.
Copyright (C) 2002 Klarälvdalens Datakonsult AB
Copyright (C) 2003 g10 Code GmbH
Written by Steffen Hansen <steffen@klaralvdalens-datakonsult.se>.
Modified by Marcus Brinkmann <marcus@g10code.de>.
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., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <errno.h>
#include <qapplication.h>
#include <qwidget.h>
#include <qmessagebox.h>
#include "secqstring.h"
#include "pinentrydialog.h"
#include "pinentry.h"
#ifdef FALLBACK_CURSES
#include <pinentry-curses.h>
#endif
/* Hack for creating a QWidget with a "foreign" window ID */
class ForeignWidget : public QWidget
{
public:
ForeignWidget( WId wid ) : QWidget( 0 )
{
QWidget::destroy();
create( wid, false, false );
}
~ForeignWidget()
{
destroy( false, false );
}
};
static int
qt_cmd_handler (pinentry_t pe)
{
QWidget *parent = 0;
int want_pass = !!pe->pin;
if (want_pass)
{
/* FIXME: Add parent window ID to pinentry and GTK. */
if (pe->parent_wid)
parent = new ForeignWidget (pe->parent_wid);
- PinEntryDialog pinentry (parent, 0, true);
+ PinEntryDialog pinentry (parent, NULL, true, !!pe->quality_bar);
+ pinentry.setPinentryInfo (pe);
pinentry.setPrompt (QString::fromUtf8 (pe->prompt));
pinentry.setDescription (QString::fromUtf8 (pe->description));
/* If we reuse the same dialog window. */
#if 0
pinentry.setText (SecQString::null);
#endif
if (pe->ok)
pinentry.setOkText (QString::fromUtf8 (pe->ok));
if (pe->cancel)
pinentry.setCancelText (QString::fromUtf8 (pe->cancel));
if (pe->error)
pinentry.setError (QString::fromUtf8 (pe->error));
bool ret = pinentry.exec ();
if (!ret)
return -1;
char *pin = (char *) pinentry.text().utf8();
if (!pin)
return -1;
int len = strlen (pin);
if (len >= 0)
{
pinentry_setbufferlen (pe, len + 1);
if (pe->pin)
{
strcpy (pe->pin, pin);
::secmem_free (pin);
return len;
}
}
::secmem_free (pin);
return -1;
}
else
{
bool ret = QMessageBox::information (parent, "", pe->description,
pe->ok ? pe->ok : "OK",
pe->cancel ? pe->cancel : "Cancel");
return !ret;
}
}
pinentry_cmd_handler_t pinentry_cmd_handler = qt_cmd_handler;
int
main (int argc, char *argv[])
{
pinentry_init ("pinentry-qt");
#ifdef FALLBACK_CURSES
if (!pinentry_have_display (argc, argv))
pinentry_cmd_handler = curses_cmd_handler;
else
#endif
{
/* Qt does only understand -display but not --display; thus we
are fixing that here. The code is pretty simply and may get
confused if an argument is called "--display". */
char **new_argv, *p;
size_t n;
int i, done;
for (n=0,i=0; i < argc; i++)
n += strlen (argv[i])+1;
n++;
new_argv = (char**)calloc (argc+1, sizeof *new_argv);
if (new_argv)
*new_argv = (char*)malloc (n);
if (!new_argv || !*new_argv)
{
fprintf (stderr, "pinentry-qt: can't fixup argument list: %s\n",
strerror (errno));
exit (EXIT_FAILURE);
}
for (done=0,p=*new_argv,i=0; i < argc; i++)
if (!done && !strcmp (argv[i], "--display"))
{
new_argv[i] = "-display";
done = 1;
}
else
{
new_argv[i] = strcpy (p, argv[i]);
p += strlen (argv[i]) + 1;
}
/* We use a modal dialog window, so we don't need the application
window anymore. */
i = argc;
new QApplication (i, new_argv);
}
/* Consumes all arguments. */
if (pinentry_parse_opts (argc, argv))
{
printf ("pinentry-qt (pinentry) " VERSION "\n");
exit (EXIT_SUCCESS);
}
if (pinentry_loop ())
return 1;
return 0;
}
diff --git a/qt/pinentrydialog.cpp b/qt/pinentrydialog.cpp
index ecd05b5..7009523 100644
--- a/qt/pinentrydialog.cpp
+++ b/qt/pinentrydialog.cpp
@@ -1,157 +1,215 @@
/* pinentrydialog.cpp - A secure KDE dialog for PIN entry.
Copyright (C) 2002 Klarälvdalens Datakonsult AB
+ Copyright (C) 2007 g10 Code GmbH
Written by Steffen Hansen <steffen@klaralvdalens-datakonsult.se>.
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., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA */
+
#include <qlayout.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qmessagebox.h>
+#include <qprogressbar.h>
#include "secqlineedit.h"
#include "pinentrydialog.h"
+#include "pinentry.h"
-PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name, bool modal )
+PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name,
+ bool modal, bool enable_quality_bar )
: QDialog( parent, name, modal ), _grabbed( false )
{
QBoxLayout* top = new QVBoxLayout( this, 6 );
QBoxLayout* upperLayout = new QHBoxLayout( top );
_icon = new QLabel( this );
_icon->setPixmap( QMessageBox::standardIcon( QMessageBox::Information ) );
upperLayout->addWidget( _icon );
QBoxLayout* labelLayout = new QVBoxLayout( upperLayout );
_error = new QLabel( this );
labelLayout->addWidget( _error );
+ if (enable_quality_bar)
+ {
+ _quality_bar = new QProgressBar (this);
+ _quality_bar->setCenterIndicator (true);
+ labelLayout->addWidget ( _quality_bar );
+ _have_quality_bar = true;
+ }
+ else
+ _have_quality_bar = false;
+
_desc = new QLabel( this );
labelLayout->addWidget( _desc );
QBoxLayout* l = new QHBoxLayout( top );
_prompt = new QLabel( this );
l->addWidget( _prompt );
_edit = new SecQLineEdit( this );
_edit->setMaxLength( 256 );
_edit->setEchoMode( SecQLineEdit::Password );
l->addWidget( _edit );
l = new QHBoxLayout( top );
_ok = new QPushButton( tr("OK"), this );
_cancel = new QPushButton( tr("Cancel"), this );
l->addWidget( _ok );
l->addStretch();
l->addWidget( _cancel );
_ok->setDefault(true);
connect( _ok, SIGNAL( clicked() ),
this, SIGNAL( accepted() ) );
connect( _cancel, SIGNAL( clicked() ),
this, SIGNAL( rejected() ) );
-
+ connect( _edit, SIGNAL( textModified(const SecQString&) ),
+ this, SLOT( updateQuality(const SecQString&) ) );
connect (this, SIGNAL (accepted ()),
this, SLOT (accept ()));
connect (this, SIGNAL (rejected ()),
this, SLOT (reject ()));
-
_edit->setFocus();
}
void PinEntryDialog::paintEvent( QPaintEvent* ev )
{
// Grab keyboard when widget is mapped to screen
// It might be a little weird to do it here, but it works!
if( !_grabbed ) {
_edit->grabKeyboard();
_grabbed = true;
}
QDialog::paintEvent( ev );
}
void PinEntryDialog::hideEvent( QHideEvent* ev )
{
_edit->releaseKeyboard();
_grabbed = false;
QDialog::hideEvent( ev );
}
void PinEntryDialog::keyPressEvent( QKeyEvent* e )
{
if ( e->state() == 0 && e->key() == Key_Escape ) {
emit rejected();
return;
}
QDialog::keyPressEvent( e );
}
+
+void PinEntryDialog::updateQuality( const SecQString & txt )
+{
+ char *pin;
+ int length;
+ int percent;
+ QPalette pal;
+
+ if (!_have_quality_bar || !_pinentry_info)
+ return;
+ pin = (char*)txt.utf8();
+ length = strlen (pin);
+ percent = length? pinentry_inq_quality (_pinentry_info, pin, length) : 0;
+ ::secmem_free (pin);
+ if (!length)
+ {
+ _quality_bar->reset ();
+ }
+ else
+ {
+ pal = _quality_bar->palette ();
+ if (percent < 0)
+ {
+ pal.setColor (QColorGroup::Highlight, QColor("red"));
+ percent = -percent;
+ }
+ else
+ {
+ pal.setColor (QColorGroup::Highlight, QColor("green"));
+ }
+ _quality_bar->setPalette (pal);
+ _quality_bar->setProgress (percent);
+ }
+}
+
+
void PinEntryDialog::setDescription( const QString& txt )
{
_desc->setText( txt );
_icon->setPixmap( QMessageBox::standardIcon( QMessageBox::Information ) );
setError( QString::null );
}
QString PinEntryDialog::description() const
{
return _desc->text();
}
void PinEntryDialog::setError( const QString& txt )
{
- if( !txt.isNull() )_icon->setPixmap( QMessageBox::standardIcon( QMessageBox::Critical ) );
+ if ( !txt.isNull() )
+ _icon->setPixmap( QMessageBox::standardIcon( QMessageBox::Critical ) );
_error->setText( txt );
}
QString PinEntryDialog::error() const
{
return _error->text();
}
void PinEntryDialog::setText( const SecQString& txt )
{
_edit->setText( txt );
}
SecQString PinEntryDialog::text() const
{
return _edit->text();
}
void PinEntryDialog::setPrompt( const QString& txt )
{
_prompt->setText( txt );
}
QString PinEntryDialog::prompt() const
{
return _prompt->text();
}
void PinEntryDialog::setOkText( const QString& txt )
{
_ok->setText( txt );
}
void PinEntryDialog::setCancelText( const QString& txt )
{
_cancel->setText( txt );
}
+
+
+void PinEntryDialog::setPinentryInfo (pinentry_t peinfo )
+{
+ _pinentry_info = peinfo;
+}
diff --git a/qt/pinentrydialog.h b/qt/pinentrydialog.h
index b1eed36..ce6f63e 100644
--- a/qt/pinentrydialog.h
+++ b/qt/pinentrydialog.h
@@ -1,77 +1,88 @@
/* pinentrydialog.h - A secure KDE dialog for PIN entry.
Copyright (C) 2002 Klarälvdalens Datakonsult AB
Written by Steffen Hansen <steffen@klaralvdalens-datakonsult.se>.
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., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA */
#ifndef __PINENTRYDIALOG_H__
#define __PINENTRYDIALOG_H__
#include <qdialog.h>
+#include "pinentry.h"
class QLabel;
class QPushButton;
+class QProgressBar;
class SecQLineEdit;
class SecQString;
class PinEntryDialog : public QDialog {
Q_OBJECT
Q_PROPERTY( QString description READ description WRITE setDescription )
Q_PROPERTY( QString error READ error WRITE setError )
// Q_PROPERTY( SecQString text READ text WRITE setText )
Q_PROPERTY( QString prompt READ prompt WRITE setPrompt )
public:
friend class PinEntryController; // TODO: remove when assuan lets me use Qt eventloop.
- PinEntryDialog( QWidget* parent = 0, const char* name = 0, bool modal = false );
+ PinEntryDialog( QWidget* parent = 0, const char* name = 0,
+ bool modal = false, bool enable_quality_bar = false );
void setDescription( const QString& );
QString description() const;
void setError( const QString& );
QString error() const;
void setText( const SecQString& );
SecQString text() const;
void setPrompt( const QString& );
QString prompt() const;
void setOkText( const QString& );
void setCancelText( const QString& );
+ void setPinentryInfo (pinentry_t);
+
+public slots:
+ void updateQuality(const SecQString &);
+
signals:
void accepted();
void rejected();
protected:
virtual void keyPressEvent( QKeyEvent *e );
virtual void hideEvent( QHideEvent* );
virtual void paintEvent( QPaintEvent* );
private:
QLabel* _icon;
QLabel* _desc;
QLabel* _error;
QLabel* _prompt;
+ QProgressBar* _quality_bar;
SecQLineEdit* _edit;
QPushButton* _ok;
QPushButton* _cancel;
bool _grabbed;
+ bool _have_quality_bar;
+ pinentry_t _pinentry_info;
};
#endif // __PINENTRYDIALOG_H__
diff --git a/qt/secqlineedit.cpp b/qt/secqlineedit.cpp
index 3da62d7..42d3749 100644
--- a/qt/secqlineedit.cpp
+++ b/qt/secqlineedit.cpp
@@ -1,1949 +1,1953 @@
/* secqlineedit.cpp - Secure version of QLineEdit.
Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
Copyright (C) 2003 g10 Code GmbH
The license of the original qlineedit.cpp file from which this file
is derived can be found below. Modified by Marcus Brinkmann
<marcus@g10code.de>. All modifications are licensed as follows, so
that the intersection of the two licenses is then the GNU General
Public License version 2.
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., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA */
/* Undo/Redo is disabled, because it uses unsecure memory for the
history buffer. */
#define SECURE_NO_UNDO 1
/**********************************************************************
** $Id$
**
** Implementation of SecQLineEdit widget class
**
** Created : 941011
**
** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
**
** This file is part of the widgets module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "secqlineedit.h"
#include "qpainter.h"
#include "qdrawutil.h"
#include "qfontmetrics.h"
#include "qpixmap.h"
#include "qclipboard.h"
#include "qapplication.h"
#include "qtimer.h"
#include "qpopupmenu.h"
#include "qstringlist.h"
#include "qguardedptr.h"
#include "qstyle.h"
#include "qwhatsthis.h"
#include "secqinternal_p.h"
#include "private/qtextlayout_p.h"
#include "qvaluevector.h"
#if defined(QT_ACCESSIBILITY_SUPPORT)
#include "qaccessible.h"
#endif
#ifndef QT_NO_ACCEL
#include "qkeysequence.h"
#define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
#else
#define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
#endif
#define innerMargin 1
struct SecQLineEditPrivate : public Qt
{
SecQLineEditPrivate( SecQLineEdit *q )
: q(q), cursor(0), cursorTimer(0), tripleClickTimer(0), frame(1),
cursorVisible(0), separator(0), readOnly(0), modified(0),
direction(QChar::DirON), alignment(0),
echoMode(0), textDirty(0), selDirty(0),
ascent(0), maxLength(32767), menuId(0),
hscroll(0),
undoState(0), selstart(0), selend(0),
imstart(0), imend(0), imselstart(0), imselend(0)
{}
void init( const SecQString&);
SecQLineEdit *q;
SecQString text;
int cursor;
int cursorTimer;
QPoint tripleClick;
int tripleClickTimer;
uint frame : 1;
uint cursorVisible : 1;
uint separator : 1;
uint readOnly : 1;
uint modified : 1;
uint direction : 5;
uint alignment : 3;
uint echoMode : 2;
uint textDirty : 1;
uint selDirty : 1;
int ascent;
int maxLength;
int menuId;
int hscroll;
void finishChange( int validateFromState = -1, bool setModified = TRUE );
void setCursorVisible( bool visible );
// undo/redo handling
enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection };
struct Command {
inline Command(){}
inline Command( CommandType type, int pos, QChar c )
:type(type),c(c),pos(pos){}
uint type : 4;
QChar c;
int pos;
};
int undoState;
QValueVector<Command> history;
#ifndef SECURE_NO_UNDO
void addCommand( const Command& cmd );
#endif /* SECURE_NO_UNDO */
void insert( const SecQString& s );
void del( bool wasBackspace = FALSE );
void remove( int pos );
inline void separate() { separator = TRUE; }
#ifndef SECURE_NO_UNDO
inline void undo( int until = -1 ) {
if ( !isUndoAvailable() )
return;
deselect();
while ( undoState && undoState > until ) {
Command& cmd = history[--undoState];
switch ( cmd.type ) {
case Insert:
text.remove( cmd.pos, 1);
cursor = cmd.pos;
break;
case Remove:
case RemoveSelection:
text.insert( cmd.pos, cmd.c );
cursor = cmd.pos + 1;
break;
case Delete:
case DeleteSelection:
text.insert( cmd.pos, cmd.c );
cursor = cmd.pos;
break;
case Separator:
continue;
}
if ( until < 0 && undoState ) {
Command& next = history[undoState-1];
if ( next.type != cmd.type && next.type < RemoveSelection
&& !( cmd.type >= RemoveSelection && next.type != Separator ) )
break;
}
}
modified = ( undoState != 0 );
textDirty = TRUE;
}
inline void redo() {
if ( !isRedoAvailable() )
return;
deselect();
while ( undoState < (int)history.size() ) {
Command& cmd = history[undoState++];
switch ( cmd.type ) {
case Insert:
text.insert( cmd.pos, cmd.c );
cursor = cmd.pos + 1;
break;
case Remove:
case Delete:
case RemoveSelection:
case DeleteSelection:
text.remove( cmd.pos, 1 );
cursor = cmd.pos;
break;
case Separator:
continue;
}
if ( undoState < (int)history.size() ) {
Command& next = history[undoState];
if ( next.type != cmd.type && cmd.type < RemoveSelection
&& !( next.type >= RemoveSelection && cmd.type != Separator ) )
break;
}
}
textDirty = TRUE;
}
#endif /* SECURE_NO_UNDO */
inline bool isUndoAvailable() const { return !readOnly && undoState; }
inline bool isRedoAvailable() const { return !readOnly && undoState < (int)history.size(); }
// bidi
inline bool isRightToLeft() const { return direction==QChar::DirON?text.isRightToLeft():(direction==QChar::DirR); }
// selection
int selstart, selend;
inline bool allSelected() const { return !text.isEmpty() && selstart == 0 && selend == (int)text.length(); }
inline bool hasSelectedText() const { return !text.isEmpty() && selend > selstart; }
inline void deselect() { selDirty |= (selend > selstart); selstart = selend = 0; }
void removeSelectedText();
#ifndef QT_NO_CLIPBOARD
void copy( bool clipboard = TRUE ) const;
#endif
inline bool inSelection( int x ) const
{ if ( selstart >= selend ) return FALSE;
int pos = xToPos( x, QTextItem::OnCharacters ); return pos >= selstart && pos < selend; }
// input methods
int imstart, imend, imselstart, imselend;
// complex text layout
QTextLayout textLayout;
void updateTextLayout();
void moveCursor( int pos, bool mark = FALSE );
void setText( const SecQString& txt );
int xToPos( int x, QTextItem::CursorPosition = QTextItem::BetweenCharacters ) const;
inline int visualAlignment() const { return alignment ? alignment : int( isRightToLeft() ? AlignRight : AlignLeft ); }
QRect cursorRect() const;
void updateMicroFocusHint();
};
/*!
\class SecQLineEdit
\brief The SecQLineEdit widget is a one-line text editor.
\ingroup basic
\mainclass
A line edit allows the user to enter and edit a single line of
plain text with a useful collection of editing functions,
including undo and redo, cut and paste,
By changing the echoMode() of a line edit, it can also be used as
a "write-only" field, for inputs such as passwords.
The length of the text can be constrained to maxLength().
A related class is QTextEdit which allows multi-line, rich-text
editing.
You can change the text with setText() or insert(). The text is
retrieved with text(); the displayed text (which may be different,
see \l{EchoMode}) is retrieved with displayText(). Text can be
selected with setSelection() or selectAll(), and the selection can
be cut(), copy()ied and paste()d. The text can be aligned with
setAlignment().
When the text changes the textChanged() signal is emitted; when
the Return or Enter key is pressed the returnPressed() signal is
emitted.
+ When the text changes the textModified() signal is emitted in all
+ cases.
+
By default, SecQLineEdits have a frame as specified by the Windows
and Motif style guides; you can turn it off by calling
setFrame(FALSE).
The default key bindings are described below.
\target desc
\table
\header \i Keypress \i Action
\row \i Left Arrow \i Moves the cursor one character to the left.
\row \i Shift+Left Arrow \i Moves and selects text one character to the left.
\row \i Right Arrow \i Moves the cursor one character to the right.
\row \i Shift+Right Arrow \i Moves and selects text one character to the right.
\row \i Home \i Moves the cursor to the beginning of the line.
\row \i End \i Moves the cursor to the end of the line.
\row \i Backspace \i Deletes the character to the left of the cursor.
\row \i Ctrl+Backspace \i Deletes the word to the left of the cursor.
\row \i Delete \i Deletes the character to the right of the cursor.
\row \i Ctrl+Delete \i Deletes the word to the right of the cursor.
\row \i Ctrl+A \i Moves the cursor to the beginning of the line.
\row \i Ctrl+B \i Moves the cursor one character to the left.
\row \i Ctrl+C \i Copies the selected text to the clipboard.
(Windows also supports Ctrl+Insert for this operation.)
\row \i Ctrl+D \i Deletes the character to the right of the cursor.
\row \i Ctrl+E \i Moves the cursor to the end of the line.
\row \i Ctrl+F \i Moves the cursor one character to the right.
\row \i Ctrl+H \i Deletes the character to the left of the cursor.
\row \i Ctrl+K \i Deletes to the end of the line.
\row \i Ctrl+V \i Pastes the clipboard text into line edit.
(Windows also supports Shift+Insert for this operation.)
\row \i Ctrl+X \i Deletes the selected text and copies it to the clipboard.
(Windows also supports Shift+Delete for this operation.)
\row \i Ctrl+Z \i Undoes the last operation.
\row \i Ctrl+Y \i Redoes the last undone operation.
\endtable
Any other key sequence that represents a valid character, will
cause the character to be inserted into the line edit.
<img src=qlined-m.png> <img src=qlined-w.png>
\sa QTextEdit QLabel QComboBox
\link guibooks.html#fowler GUI Design Handbook: Field, Entry\endlink
*/
/*!
\fn void SecQLineEdit::textChanged( const SecQString& )
This signal is emitted whenever the text changes. The argument is
the new text.
*/
/*!
\fn void SecQLineEdit::selectionChanged()
This signal is emitted whenever the selection changes.
\sa hasSelectedText(), selectedText()
*/
/*!
\fn void SecQLineEdit::lostFocus()
This signal is emitted when the line edit has lost focus.
\sa hasFocus(), QWidget::focusInEvent(), QWidget::focusOutEvent()
*/
/*!
Constructs a line edit with no text.
The maximum text length is set to 32767 characters.
The \a parent and \a name arguments are sent to the QWidget constructor.
\sa setText(), setMaxLength()
*/
SecQLineEdit::SecQLineEdit( QWidget* parent, const char* name )
: QFrame( parent, name, WNoAutoErase ), d(new SecQLineEditPrivate( this ))
{
d->init( SecQString::null );
}
/*!
Constructs a line edit containing the text \a contents.
The cursor position is set to the end of the line and the maximum
text length to 32767 characters.
The \a parent and \a name arguments are sent to the QWidget
constructor.
\sa text(), setMaxLength()
*/
SecQLineEdit::SecQLineEdit( const SecQString& contents, QWidget* parent, const char* name )
: QFrame( parent, name, WNoAutoErase ), d(new SecQLineEditPrivate( this ))
{
d->init( contents );
}
/*!
Destroys the line edit.
*/
SecQLineEdit::~SecQLineEdit()
{
delete d;
}
/*!
\property SecQLineEdit::text
\brief the line edit's text
Setting this property clears the selection, clears the undo/redo
history, moves the cursor to the end of the line and resets the
\c modified property to FALSE.
The text is truncated to maxLength() length.
\sa insert()
*/
SecQString SecQLineEdit::text() const
{
return ( d->text.isNull() ? SecQString ("") : d->text );
}
void SecQLineEdit::setText( const SecQString& text)
{
resetInputContext();
d->setText( text );
d->modified = FALSE;
d->finishChange( -1, FALSE );
}
/*!
\property SecQLineEdit::displayText
\brief the displayed text
If \c EchoMode is \c Normal this returns the same as text(); if
\c EchoMode is \c Password it returns a string of asterisks
text().length() characters long, e.g. "******"; if \c EchoMode is
\c NoEcho returns an empty string, "".
\sa setEchoMode() text() EchoMode
*/
QString SecQLineEdit::displayText() const
{
if ( d->echoMode == NoEcho )
return QString::fromLatin1("");
QChar pwd_char = QChar (style().styleHint( QStyle::SH_LineEdit_PasswordCharacter, this));
QString res;
res.fill (pwd_char, d->text.length ());
return res;
}
/*!
\property SecQLineEdit::maxLength
\brief the maximum permitted length of the text
If the text is too long, it is truncated at the limit.
If truncation occurs any selected text will be unselected, the
cursor position is set to 0 and the first part of the string is
shown.
*/
int SecQLineEdit::maxLength() const
{
return d->maxLength;
}
void SecQLineEdit::setMaxLength( int maxLength )
{
d->maxLength = maxLength;
setText( d->text );
}
/*!
\property SecQLineEdit::frame
\brief whether the line edit draws itself with a frame
If enabled (the default) the line edit draws itself inside a
two-pixel frame, otherwise the line edit draws itself without any
frame.
*/
bool SecQLineEdit::frame() const
{
return frameShape() != NoFrame;
}
void SecQLineEdit::setFrame( bool enable )
{
setFrameStyle( enable ? ( LineEditPanel | Sunken ) : NoFrame );
}
/*!
\enum SecQLineEdit::EchoMode
This enum type describes how a line edit should display its
contents.
\value Normal Display characters as they are entered. This is the
default.
\value NoEcho Do not display anything. This may be appropriate
for passwords where even the length of the
password should be kept secret.
\value Password Display asterisks instead of the characters
actually entered.
\sa setEchoMode() echoMode()
*/
/*!
\property SecQLineEdit::echoMode
\brief the line edit's echo mode
The initial setting is \c Normal, but SecQLineEdit also supports \c
NoEcho and \c Password modes.
The widget's display and the ability to copy the text is affected
by this setting.
\sa EchoMode displayText()
*/
SecQLineEdit::EchoMode SecQLineEdit::echoMode() const
{
return (EchoMode) d->echoMode;
}
void SecQLineEdit::setEchoMode( EchoMode mode )
{
d->echoMode = mode;
d->updateTextLayout();
update();
}
/*!
Returns a recommended size for the widget.
The width returned, in pixels, is usually enough for about 15 to
20 characters.
*/
QSize SecQLineEdit::sizeHint() const
{
constPolish();
QFontMetrics fm( font() );
int h = QMAX(fm.lineSpacing(), 14) + 2*innerMargin;
int w = fm.width( 'x' ) * 17; // "some"
int m = frameWidth() * 2;
return (style().sizeFromContents(QStyle::CT_LineEdit, this,
QSize( w + m, h + m ).
expandedTo(QApplication::globalStrut())));
}
/*!
Returns a minimum size for the line edit.
The width returned is enough for at least one character.
*/
QSize SecQLineEdit::minimumSizeHint() const
{
constPolish();
QFontMetrics fm = fontMetrics();
int h = fm.height() + QMAX( 2*innerMargin, fm.leading() );
int w = fm.maxWidth();
int m = frameWidth() * 2;
return QSize( w + m, h + m );
}
/*!
\property SecQLineEdit::cursorPosition
\brief the current cursor position for this line edit
Setting the cursor position causes a repaint when appropriate.
*/
int SecQLineEdit::cursorPosition() const
{
return d->cursor;
}
void SecQLineEdit::setCursorPosition( int pos )
{
if ( pos <= (int) d->text.length() )
d->moveCursor( pos );
}
/*!
\property SecQLineEdit::alignment
\brief the alignment of the line edit
Possible Values are \c Qt::AlignAuto, \c Qt::AlignLeft, \c
Qt::AlignRight and \c Qt::AlignHCenter.
Attempting to set the alignment to an illegal flag combination
does nothing.
\sa Qt::AlignmentFlags
*/
int SecQLineEdit::alignment() const
{
return d->alignment;
}
void SecQLineEdit::setAlignment( int flag )
{
d->alignment = flag & 0x7;
update();
}
/*!
\obsolete
\fn void SecQLineEdit::cursorRight( bool, int )
Use cursorForward() instead.
\sa cursorForward()
*/
/*!
\obsolete
\fn void SecQLineEdit::cursorLeft( bool, int )
For compatibilty with older applications only. Use cursorBackward()
instead.
\sa cursorBackward()
*/
/*!
Moves the cursor forward \a steps characters. If \a mark is TRUE
each character moved over is added to the selection; if \a mark is
FALSE the selection is cleared.
\sa cursorBackward()
*/
void SecQLineEdit::cursorForward( bool mark, int steps )
{
int cursor = d->cursor;
if ( steps > 0 ) {
while( steps-- )
cursor = d->textLayout.nextCursorPosition( cursor );
} else if ( steps < 0 ) {
while ( steps++ )
cursor = d->textLayout.previousCursorPosition( cursor );
}
d->moveCursor( cursor, mark );
}
/*!
Moves the cursor back \a steps characters. If \a mark is TRUE each
character moved over is added to the selection; if \a mark is
FALSE the selection is cleared.
\sa cursorForward()
*/
void SecQLineEdit::cursorBackward( bool mark, int steps )
{
cursorForward( mark, -steps );
}
/*!
Moves the cursor one word forward. If \a mark is TRUE, the word is
also selected.
\sa cursorWordBackward()
*/
void SecQLineEdit::cursorWordForward( bool mark )
{
d->moveCursor( d->textLayout.nextCursorPosition(d->cursor, QTextLayout::SkipWords), mark );
}
/*!
Moves the cursor one word backward. If \a mark is TRUE, the word
is also selected.
\sa cursorWordForward()
*/
void SecQLineEdit::cursorWordBackward( bool mark )
{
d->moveCursor( d->textLayout.previousCursorPosition(d->cursor, QTextLayout::SkipWords), mark );
}
/*!
If no text is selected, deletes the character to the left of the
text cursor and moves the cursor one position to the left. If any
text is selected, the cursor is moved to the beginning of the
selected text and the selected text is deleted.
\sa del()
*/
void SecQLineEdit::backspace()
{
int priorState = d->undoState;
if ( d->hasSelectedText() ) {
d->removeSelectedText();
} else if ( d->cursor ) {
--d->cursor;
d->del( TRUE );
}
d->finishChange( priorState );
}
/*!
If no text is selected, deletes the character to the right of the
text cursor. If any text is selected, the cursor is moved to the
beginning of the selected text and the selected text is deleted.
\sa backspace()
*/
void SecQLineEdit::del()
{
int priorState = d->undoState;
if ( d->hasSelectedText() ) {
d->removeSelectedText();
} else {
int n = d->textLayout.nextCursorPosition( d->cursor ) - d->cursor;
while ( n-- )
d->del();
}
d->finishChange( priorState );
}
/*!
Moves the text cursor to the beginning of the line unless it is
already there. If \a mark is TRUE, text is selected towards the
first position; otherwise, any selected text is unselected if the
cursor is moved.
\sa end()
*/
void SecQLineEdit::home( bool mark )
{
d->moveCursor( 0, mark );
}
/*!
Moves the text cursor to the end of the line unless it is already
there. If \a mark is TRUE, text is selected towards the last
position; otherwise, any selected text is unselected if the cursor
is moved.
\sa home()
*/
void SecQLineEdit::end( bool mark )
{
d->moveCursor( d->text.length(), mark );
}
/*!
\property SecQLineEdit::modified
\brief whether the line edit's contents has been modified by the user
The modified flag is never read by SecQLineEdit; it has a default value
of FALSE and is changed to TRUE whenever the user changes the line
edit's contents.
This is useful for things that need to provide a default value but
do not start out knowing what the default should be (perhaps it
depends on other fields on the form). Start the line edit without
the best default, and when the default is known, if modified()
returns FALSE (the user hasn't entered any text), insert the
default value.
Calling clearModified() or setText() resets the modified flag to
FALSE.
*/
bool SecQLineEdit::isModified() const
{
return d->modified;
}
/*!
Resets the modified flag to FALSE.
\sa isModified()
*/
void SecQLineEdit::clearModified()
{
d->modified = FALSE;
d->history.clear();
d->undoState = 0;
}
/*!
\obsolete
\property SecQLineEdit::edited
\brief whether the line edit has been edited. Use modified instead.
*/
bool SecQLineEdit::edited() const { return d->modified; }
void SecQLineEdit::setEdited( bool on ) { d->modified = on; }
/*!
\obsolete
\property SecQLineEdit::hasMarkedText
\brief whether part of the text has been selected by the user. Use hasSelectedText instead.
*/
/*!
\property SecQLineEdit::hasSelectedText
\brief whether there is any text selected
hasSelectedText() returns TRUE if some or all of the text has been
selected by the user; otherwise returns FALSE.
\sa selectedText()
*/
bool SecQLineEdit::hasSelectedText() const
{
return d->hasSelectedText();
}
/*!
\obsolete
\property SecQLineEdit::markedText
\brief the text selected by the user. Use selectedText instead.
*/
/*!
\property SecQLineEdit::selectedText
\brief the selected text
If there is no selected text this property's value is
QString::null.
\sa hasSelectedText()
*/
SecQString SecQLineEdit::selectedText() const
{
if ( d->hasSelectedText() )
return d->text.mid( d->selstart, d->selend - d->selstart );
return SecQString::null;
}
/*!
selectionStart() returns the index of the first selected character in the
line edit or -1 if no text is selected.
\sa selectedText()
*/
int SecQLineEdit::selectionStart() const
{
return d->hasSelectedText() ? d->selstart : -1;
}
/*!
Selects text from position \a start and for \a length characters.
\sa deselect() selectAll()
*/
void SecQLineEdit::setSelection( int start, int length )
{
if ( start < 0 || start > (int)d->text.length() || length < 0 ) {
d->selstart = d->selend = 0;
} else {
d->selstart = start;
d->selend = QMIN( start + length, (int)d->text.length() );
d->cursor = d->selend;
}
update();
}
/*!
\property SecQLineEdit::undoAvailable
\brief whether undo is available
*/
bool SecQLineEdit::isUndoAvailable() const
{
return d->isUndoAvailable();
}
/*!
\property SecQLineEdit::redoAvailable
\brief whether redo is available
*/
bool SecQLineEdit::isRedoAvailable() const
{
return d->isRedoAvailable();
}
/*!
Selects all the text (i.e. highlights it) and moves the cursor to
the end. This is useful when a default value has been inserted
because if the user types before clicking on the widget, the
selected text will be deleted.
\sa setSelection() deselect()
*/
void SecQLineEdit::selectAll()
{
d->selstart = d->selend = d->cursor = 0;
d->moveCursor( d->text.length(), TRUE );
}
/*!
Deselects any selected text.
\sa setSelection() selectAll()
*/
void SecQLineEdit::deselect()
{
d->deselect();
d->finishChange();
}
/*!
Deletes any selected text, inserts \a newText and sets it as the
new contents of the line edit.
*/
void SecQLineEdit::insert( const SecQString &newText )
{
// q->resetInputContext(); //#### FIX ME IN QT
int priorState = d->undoState;
d->removeSelectedText();
d->insert( newText );
d->finishChange( priorState );
}
/*!
Clears the contents of the line edit.
*/
void SecQLineEdit::clear()
{
int priorState = d->undoState;
resetInputContext();
d->selstart = 0;
d->selend = d->text.length();
d->removeSelectedText();
d->separate();
d->finishChange( priorState );
}
/*!
Undoes the last operation if undo is \link
SecQLineEdit::undoAvailable available\endlink. Deselects any current
selection, and updates the selection start to the current cursor
position.
*/
void SecQLineEdit::undo()
{
#ifndef SECURE_NO_UNDO
resetInputContext();
d->undo();
d->finishChange( -1, FALSE );
#endif
}
/*!
Redoes the last operation if redo is \link
SecQLineEdit::redoAvailable available\endlink.
*/
void SecQLineEdit::redo()
{
#ifndef SECURE_NO_UNDO
resetInputContext();
d->redo();
d->finishChange();
#endif
}
/*!
\property SecQLineEdit::readOnly
\brief whether the line edit is read only.
In read-only mode, the user can still copy the text to the
clipboard (if echoMode() is \c Normal), but cannot edit it.
SecQLineEdit does not show a cursor in read-only mode.
\sa setEnabled()
*/
bool SecQLineEdit::isReadOnly() const
{
return d->readOnly;
}
void SecQLineEdit::setReadOnly( bool enable )
{
d->readOnly = enable;
#ifndef QT_NO_CURSOR
setCursor( enable ? arrowCursor : ibeamCursor );
#endif
update();
}
#ifndef QT_NO_CLIPBOARD
/*!
Copies the selected text to the clipboard and deletes it, if there
is any, and if echoMode() is \c Normal.
\sa copy() paste() setValidator()
*/
void SecQLineEdit::cut()
{
if ( hasSelectedText() ) {
copy();
del();
}
}
/*!
Copies the selected text to the clipboard, if there is any, and if
echoMode() is \c Normal.
\sa cut() paste()
*/
void SecQLineEdit::copy() const
{
d->copy();
}
/*!
Inserts the clipboard's text at the cursor position, deleting any
selected text, providing the line edit is not \link
SecQLineEdit::readOnly read-only\endlink.
\sa copy() cut()
*/
void SecQLineEdit::paste()
{
d->removeSelectedText();
insert( QApplication::clipboard()->text( QClipboard::Clipboard ) );
}
void SecQLineEditPrivate::copy( bool clipboard ) const
{
#ifndef SECURE
QString t = q->selectedText();
if ( !t.isEmpty() && echoMode == SecQLineEdit::Normal ) {
q->disconnect( QApplication::clipboard(), SIGNAL(selectionChanged()), q, 0);
QApplication::clipboard()->setText( t, clipboard ? QClipboard::Clipboard : QClipboard::Selection );
q->connect( QApplication::clipboard(), SIGNAL(selectionChanged()),
q, SLOT(clipboardChanged()) );
}
#endif
}
#endif // !QT_NO_CLIPBOARD
/*!\reimp
*/
void SecQLineEdit::resizeEvent( QResizeEvent *e )
{
QFrame::resizeEvent( e );
}
/*! \reimp
*/
bool SecQLineEdit::event( QEvent * e )
{
if ( e->type() == QEvent::AccelOverride && !d->readOnly ) {
QKeyEvent* ke = (QKeyEvent*) e;
if ( ke->state() == NoButton || ke->state() == ShiftButton
|| ke->state() == Keypad ) {
if ( ke->key() < Key_Escape ) {
ke->accept();
} else if ( ke->state() == NoButton
|| ke->state() == ShiftButton ) {
switch ( ke->key() ) {
case Key_Delete:
case Key_Home:
case Key_End:
case Key_Backspace:
case Key_Left:
case Key_Right:
ke->accept();
default:
break;
}
}
} else if ( ke->state() & ControlButton ) {
switch ( ke->key() ) {
// Those are too frequently used for application functionality
/* case Key_A:
case Key_B:
case Key_D:
case Key_E:
case Key_F:
case Key_H:
case Key_K:
*/
case Key_C:
case Key_V:
case Key_X:
case Key_Y:
case Key_Z:
case Key_Left:
case Key_Right:
#if defined (Q_WS_WIN)
case Key_Insert:
case Key_Delete:
#endif
ke->accept();
default:
break;
}
}
} else if ( e->type() == QEvent::Timer ) {
// should be timerEvent, is here for binary compatibility
int timerId = ((QTimerEvent*)e)->timerId();
if ( timerId == d->cursorTimer ) {
if(!hasSelectedText() || style().styleHint( QStyle::SH_BlinkCursorWhenTextSelected ))
d->setCursorVisible( !d->cursorVisible );
} else if ( timerId == d->tripleClickTimer ) {
killTimer( d->tripleClickTimer );
d->tripleClickTimer = 0;
}
}
return QWidget::event( e );
}
/*! \reimp
*/
void SecQLineEdit::mousePressEvent( QMouseEvent* e )
{
if ( e->button() == RightButton )
return;
if ( d->tripleClickTimer && ( e->pos() - d->tripleClick ).manhattanLength() <
QApplication::startDragDistance() ) {
selectAll();
return;
}
bool mark = e->state() & ShiftButton;
int cursor = d->xToPos( e->pos().x() );
d->moveCursor( cursor, mark );
}
/*! \reimp
*/
void SecQLineEdit::mouseMoveEvent( QMouseEvent * e )
{
#ifndef QT_NO_CURSOR
if ( ( e->state() & MouseButtonMask ) == 0 ) {
if ( !d->readOnly )
setCursor( ( d->inSelection( e->pos().x() ) ? arrowCursor : ibeamCursor ) );
}
#endif
if ( e->state() & LeftButton ) {
d->moveCursor( d->xToPos( e->pos().x() ), TRUE );
}
}
/*! \reimp
*/
void SecQLineEdit::mouseReleaseEvent( QMouseEvent* e )
{
#ifndef QT_NO_CLIPBOARD
if (QApplication::clipboard()->supportsSelection() ) {
if ( e->button() == LeftButton ) {
d->copy( FALSE );
} else if ( !d->readOnly && e->button() == MidButton ) {
d->deselect();
insert( QApplication::clipboard()->text( QClipboard::Selection ) );
}
}
#endif
}
/*! \reimp
*/
void SecQLineEdit::mouseDoubleClickEvent( QMouseEvent* e )
{
if ( e->button() == Qt::LeftButton ) {
deselect();
d->cursor = d->xToPos( e->pos().x() );
d->cursor = d->textLayout.previousCursorPosition( d->cursor, QTextLayout::SkipWords );
// ## text layout should support end of words.
int end = d->textLayout.nextCursorPosition( d->cursor, QTextLayout::SkipWords );
while ( end > d->cursor && d->text[end-1].isSpace() )
--end;
d->moveCursor( end, TRUE );
d->tripleClickTimer = startTimer( QApplication::doubleClickInterval() );
d->tripleClick = e->pos();
}
}
/*!
\fn void SecQLineEdit::returnPressed()
This signal is emitted when the Return or Enter key is pressed.
*/
/*!
Converts key press event \a e into a line edit action.
If Return or Enter is pressed the signal returnPressed() is
emitted.
The default key bindings are listed in the \link #desc detailed
description.\endlink
*/
void SecQLineEdit::keyPressEvent( QKeyEvent * e )
{
d->setCursorVisible( TRUE );
if ( e->key() == Key_Enter || e->key() == Key_Return ) {
emit returnPressed();
e->ignore();
return;
}
if ( !d->readOnly ) {
QString t = e->text();
if ( !t.isEmpty() && (!e->ascii() || e->ascii()>=32) &&
e->key() != Key_Delete &&
e->key() != Key_Backspace ) {
#ifdef Q_WS_X11
extern bool qt_hebrew_keyboard_hack;
if ( qt_hebrew_keyboard_hack ) {
// the X11 keyboard layout is broken and does not reverse
// braces correctly. This is a hack to get halfway correct
// behaviour
if ( d->isRightToLeft() ) {
QChar *c = (QChar *)t.unicode();
int l = t.length();
while( l-- ) {
if ( c->mirrored() )
*c = c->mirroredChar();
c++;
}
}
}
#endif
insert( t );
return;
}
}
bool unknown = FALSE;
if ( e->state() & ControlButton ) {
switch ( e->key() ) {
case Key_A:
#if defined(Q_WS_X11)
home( e->state() & ShiftButton );
#else
selectAll();
#endif
break;
case Key_B:
cursorForward( e->state() & ShiftButton, -1 );
break;
#ifndef QT_NO_CLIPBOARD
case Key_C:
copy();
break;
#endif
case Key_D:
if ( !d->readOnly ) {
del();
}
break;
case Key_E:
end( e->state() & ShiftButton );
break;
case Key_F:
cursorForward( e->state() & ShiftButton, 1 );
break;
case Key_H:
if ( !d->readOnly ) {
backspace();
}
break;
case Key_K:
if ( !d->readOnly ) {
int priorState = d->undoState;
d->deselect();
while ( d->cursor < (int) d->text.length() )
d->del();
d->finishChange( priorState );
}
break;
#if defined(Q_WS_X11)
case Key_U:
if ( !d->readOnly )
clear();
break;
#endif
#ifndef QT_NO_CLIPBOARD
case Key_V:
if ( !d->readOnly )
paste();
break;
case Key_X:
if ( !d->readOnly && d->hasSelectedText() && echoMode() == Normal ) {
copy();
del();
}
break;
#if defined (Q_WS_WIN)
case Key_Insert:
copy();
break;
#endif
#endif
case Key_Delete:
if ( !d->readOnly ) {
cursorWordForward( TRUE );
del();
}
break;
case Key_Backspace:
if ( !d->readOnly ) {
cursorWordBackward( TRUE );
del();
}
break;
case Key_Right:
case Key_Left:
if ( d->isRightToLeft() == (e->key() == Key_Right) ) {
if ( echoMode() == Normal )
cursorWordBackward( e->state() & ShiftButton );
else
home( e->state() & ShiftButton );
} else {
if ( echoMode() == Normal )
cursorWordForward( e->state() & ShiftButton );
else
end( e->state() & ShiftButton );
}
break;
case Key_Z:
if ( !d->readOnly ) {
if(e->state() & ShiftButton)
redo();
else
undo();
}
break;
case Key_Y:
if ( !d->readOnly )
redo();
break;
default:
unknown = TRUE;
}
} else { // ### check for *no* modifier
switch ( e->key() ) {
case Key_Shift:
// ### TODO
break;
case Key_Left:
case Key_Right: {
int step = (d->isRightToLeft() == (e->key() == Key_Right)) ? -1 : 1;
cursorForward( e->state() & ShiftButton, step );
}
break;
case Key_Backspace:
if ( !d->readOnly ) {
backspace();
}
break;
case Key_Home:
#ifdef Q_WS_MACX
case Key_Up:
#endif
home( e->state() & ShiftButton );
break;
case Key_End:
#ifdef Q_WS_MACX
case Key_Down:
#endif
end( e->state() & ShiftButton );
break;
case Key_Delete:
if ( !d->readOnly ) {
#if defined (Q_WS_WIN)
if ( e->state() & ShiftButton ) {
cut();
break;
}
#endif
del();
}
break;
#if defined (Q_WS_WIN)
case Key_Insert:
if ( !d->readOnly && e->state() & ShiftButton )
paste();
else
unknown = TRUE;
break;
#endif
case Key_F14: // Undo key on Sun keyboards
if ( !d->readOnly )
undo();
break;
#ifndef QT_NO_CLIPBOARD
case Key_F16: // Copy key on Sun keyboards
copy();
break;
case Key_F18: // Paste key on Sun keyboards
if ( !d->readOnly )
paste();
break;
case Key_F20: // Cut key on Sun keyboards
if ( !d->readOnly && hasSelectedText() && echoMode() == Normal ) {
copy();
del();
}
break;
#endif
default:
unknown = TRUE;
}
}
if ( e->key() == Key_Direction_L )
d->direction = QChar::DirL;
else if ( e->key() == Key_Direction_R )
d->direction = QChar::DirR;
if ( unknown )
e->ignore();
}
/*! \reimp
*/
void SecQLineEdit::imStartEvent( QIMEvent *e )
{
if ( d->readOnly ) {
e->ignore();
return;
}
d->removeSelectedText();
d->updateMicroFocusHint();
d->imstart = d->imend = d->imselstart = d->imselend = d->cursor;
}
/*! \reimp
*/
void SecQLineEdit::imComposeEvent( QIMEvent *e )
{
if ( d->readOnly ) {
e->ignore();
} else {
d->text.replace( d->imstart, d->imend - d->imstart, e->text() );
d->imend = d->imstart + e->text().length();
d->imselstart = d->imstart + e->cursorPos();
d->imselend = d->imselstart + e->selectionLength();
d->cursor = e->selectionLength() ? d->imend : d->imselend;
d->updateTextLayout();
update();
}
}
/*! \reimp
*/
void SecQLineEdit::imEndEvent( QIMEvent *e )
{
if ( d->readOnly ) {
e->ignore();
} else {
d->text.remove( d->imstart, d->imend - d->imstart );
d->cursor = d->imselstart = d->imselend = d->imend = d->imstart;
d->textDirty = TRUE;
insert( e->text() );
}
}
/*!\reimp
*/
void SecQLineEdit::focusInEvent( QFocusEvent* e )
{
if ( e->reason() == QFocusEvent::Tab ||
e->reason() == QFocusEvent::Backtab ||
e->reason() == QFocusEvent::Shortcut )
selectAll();
if ( !d->cursorTimer ) {
int cft = QApplication::cursorFlashTime();
d->cursorTimer = cft ? startTimer( cft/2 ) : -1;
}
d->updateMicroFocusHint();
}
/*!\reimp
*/
void SecQLineEdit::focusOutEvent( QFocusEvent* e )
{
if ( e->reason() != QFocusEvent::ActiveWindow &&
e->reason() != QFocusEvent::Popup )
deselect();
d->setCursorVisible( FALSE );
if ( d->cursorTimer > 0 )
killTimer( d->cursorTimer );
d->cursorTimer = 0;
emit lostFocus();
}
/*!\reimp
*/
void SecQLineEdit::drawContents( QPainter *p )
{
const QColorGroup& cg = colorGroup();
QRect cr = contentsRect();
QFontMetrics fm = fontMetrics();
QRect lineRect( cr.x() + innerMargin, cr.y() + (cr.height() - fm.height() + 1) / 2,
cr.width() - 2*innerMargin, fm.height() );
QBrush bg = QBrush( paletteBackgroundColor() );
if ( paletteBackgroundPixmap() )
bg = QBrush( cg.background(), *paletteBackgroundPixmap() );
else if ( !isEnabled() )
bg = cg.brush( QColorGroup::Background );
p->save();
p->setClipRegion( QRegion(cr) - lineRect );
p->fillRect( cr, bg );
p->restore();
SecQSharedDoubleBuffer buffer( p, lineRect.x(), lineRect.y(),
lineRect.width(), lineRect.height(),
hasFocus() ? SecQSharedDoubleBuffer::Force : 0 );
p = buffer.painter();
p->fillRect( lineRect, bg );
// locate cursor position
int cix = 0;
QTextItem ci = d->textLayout.findItem( d->cursor );
if ( ci.isValid() ) {
if ( d->cursor != (int)d->text.length() && d->cursor == ci.from() + ci.length()
&& ci.isRightToLeft() != d->isRightToLeft() )
ci = d->textLayout.findItem( d->cursor + 1 );
cix = ci.x() + ci.cursorToX( d->cursor - ci.from() );
}
// horizontal scrolling
int minLB = QMAX( 0, -fm.minLeftBearing() );
int minRB = QMAX( 0, -fm.minRightBearing() );
int widthUsed = d->textLayout.widthUsed() + 1 + minRB;
if ( (minLB + widthUsed) <= lineRect.width() ) {
switch ( d->visualAlignment() ) {
case AlignRight:
d->hscroll = widthUsed - lineRect.width();
break;
case AlignHCenter:
d->hscroll = ( widthUsed - lineRect.width() ) / 2;
break;
default:
d->hscroll = 0;
break;
}
d->hscroll -= minLB;
} else if ( cix - d->hscroll >= lineRect.width() ) {
d->hscroll = cix - lineRect.width() + 1;
} else if ( cix - d->hscroll < 0 ) {
d->hscroll = cix;
} else if ( widthUsed - d->hscroll < lineRect.width() ) {
d->hscroll = widthUsed - lineRect.width() + 1;
}
// the y offset is there to keep the baseline constant in case we have script changes in the text.
QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->ascent-fm.ascent());
// draw text, selections and cursors
p->setPen( cg.text() );
bool supressCursor = d->readOnly, hasRightToLeft = d->isRightToLeft();
int textflags = 0;
if ( font().underline() )
textflags |= Qt::Underline;
if ( font().strikeOut() )
textflags |= Qt::StrikeOut;
if ( font().overline() )
textflags |= Qt::Overline;
for ( int i = 0; i < d->textLayout.numItems(); i++ ) {
QTextItem ti = d->textLayout.itemAt( i );
hasRightToLeft |= ti.isRightToLeft();
int tix = topLeft.x() + ti.x();
int first = ti.from();
int last = ti.from() + ti.length() - 1;
// text and selection
if ( d->selstart < d->selend && (last >= d->selstart && first < d->selend ) ) {
QRect highlight = QRect( QPoint( tix + ti.cursorToX( QMAX( d->selstart - first, 0 ) ),
lineRect.top() ),
QPoint( tix + ti.cursorToX( QMIN( d->selend - first, last - first + 1 ) ) - 1,
lineRect.bottom() ) ).normalize();
p->save();
p->setClipRegion( QRegion( lineRect ) - highlight, QPainter::CoordPainter );
p->drawTextItem( topLeft, ti, textflags );
p->setClipRect( lineRect & highlight, QPainter::CoordPainter );
p->fillRect( highlight, cg.highlight() );
p->setPen( cg.highlightedText() );
p->drawTextItem( topLeft, ti, textflags );
p->restore();
} else {
p->drawTextItem( topLeft, ti, textflags );
}
// input method edit area
if ( d->imstart < d->imend && (last >= d->imstart && first < d->imend ) ) {
QRect highlight = QRect( QPoint( tix + ti.cursorToX( QMAX( d->imstart - first, 0 ) ), lineRect.top() ),
QPoint( tix + ti.cursorToX( QMIN( d->imend - first, last - first + 1 ) )-1, lineRect.bottom() ) ).normalize();
p->save();
p->setClipRect( lineRect & highlight, QPainter::CoordPainter );
int h1, s1, v1, h2, s2, v2;
cg.color( QColorGroup::Base ).hsv( &h1, &s1, &v1 );
cg.color( QColorGroup::Background ).hsv( &h2, &s2, &v2 );
QColor imCol;
imCol.setHsv( h1, s1, ( v1 + v2 ) / 2 );
p->fillRect( highlight, imCol );
p->drawTextItem( topLeft, ti, textflags );
p->restore();
}
// input method selection
if ( d->imselstart < d->imselend && (last >= d->imselstart && first < d->imselend ) ) {
QRect highlight = QRect( QPoint( tix + ti.cursorToX( QMAX( d->imselstart - first, 0 ) ), lineRect.top() ),
QPoint( tix + ti.cursorToX( QMIN( d->imselend - first, last - first + 1 ) )-1, lineRect.bottom() ) ).normalize();
p->save();
p->setClipRect( lineRect & highlight, QPainter::CoordPainter );
p->fillRect( highlight, cg.text() );
p->setPen( paletteBackgroundColor() );
p->drawTextItem( topLeft, ti, textflags );
p->restore();
}
}
// draw cursor
if ( d->cursorVisible && !supressCursor ) {
QPoint from( topLeft.x() + cix, lineRect.top() );
QPoint to = from + QPoint( 0, lineRect.height() );
p->drawLine( from, to );
if ( hasRightToLeft ) {
to = from + QPoint( (ci.isRightToLeft()?-2:2), 2 );
p->drawLine( from, to );
from.ry() += 4;
p->drawLine( from, to );
}
}
buffer.end();
}
enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
/*! \reimp */
void SecQLineEdit::windowActivationChange( bool b )
{
//### remove me with WHighlightSelection attribute
if ( palette().active() != palette().inactive() )
update();
QWidget::windowActivationChange( b );
}
/*! \reimp */
void SecQLineEdit::setPalette( const QPalette & p )
{
//### remove me with WHighlightSelection attribute
QWidget::setPalette( p );
update();
}
/*!
\obsolete
\fn void SecQLineEdit::repaintArea( int from, int to )
Repaints all characters from \a from to \a to. If cursorPos is
between from and to, ensures that cursorPos is visible.
*/
/*! \reimp
*/
void SecQLineEdit::setFont( const QFont & f )
{
QWidget::setFont( f );
d->updateTextLayout();
}
void SecQLineEdit::clipboardChanged()
{
}
void SecQLineEditPrivate::init( const SecQString& txt )
{
#ifndef QT_NO_CURSOR
q->setCursor( readOnly ? arrowCursor : ibeamCursor );
#endif
q->setFocusPolicy( QWidget::StrongFocus );
q->setInputMethodEnabled( TRUE );
// Specifies that this widget can use more, but is able to survive on
// less, horizontal space; and is fixed vertically.
q->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
q->setBackgroundMode( PaletteBase );
q->setKeyCompression( TRUE );
q->setMouseTracking( TRUE );
q->setAcceptDrops( TRUE );
q->setFrame( TRUE );
text = txt;
updateTextLayout();
cursor = text.length();
}
void SecQLineEditPrivate::updateTextLayout()
{
// replace all non-printable characters with spaces (to avoid
// drawing boxes when using fonts that don't have glyphs for such
// characters)
const QString &displayText = q->displayText();
QString str(displayText.unicode(), displayText.length());
QChar* uc = (QChar*)str.unicode();
for (int i = 0; i < (int)str.length(); ++i) {
if (! uc[i].isPrint())
uc[i] = QChar(0x0020);
}
textLayout.setText( str, q->font() );
// ### want to do textLayout.setRightToLeft( text.isRightToLeft() );
textLayout.beginLayout( QTextLayout::SingleLine );
textLayout.beginLine( INT_MAX );
while ( !textLayout.atEnd() )
textLayout.addCurrentItem();
ascent = 0;
textLayout.endLine(0, 0, Qt::AlignLeft, &ascent);
}
int SecQLineEditPrivate::xToPos( int x, QTextItem::CursorPosition betweenOrOn ) const
{
x-= q->contentsRect().x() - hscroll + innerMargin;
for ( int i = 0; i < textLayout.numItems(); ++i ) {
QTextItem ti = textLayout.itemAt( i );
QRect tir = ti.rect();
if ( x >= tir.left() && x <= tir.right() )
return ti.xToCursor( x - tir.x(), betweenOrOn ) + ti.from();
}
return x < 0 ? 0 : text.length();
}
QRect SecQLineEditPrivate::cursorRect() const
{
QRect cr = q->contentsRect();
int cix = cr.x() - hscroll + innerMargin;
QTextItem ci = textLayout.findItem( cursor );
if ( ci.isValid() ) {
if ( cursor != (int)text.length() && cursor == ci.from() + ci.length()
&& ci.isRightToLeft() != isRightToLeft() )
ci = textLayout.findItem( cursor + 1 );
cix += ci.x() + ci.cursorToX( cursor - ci.from() );
}
int ch = q->fontMetrics().height();
return QRect( cix-4, cr.y() + ( cr.height() - ch + 1) / 2, 8, ch + 1 );
}
void SecQLineEditPrivate::updateMicroFocusHint()
{
if ( q->hasFocus() ) {
QRect r = cursorRect();
q->setMicroFocusHint( r.x(), r.y(), r.width(), r.height() );
}
}
void SecQLineEditPrivate::moveCursor( int pos, bool mark )
{
if ( pos != cursor )
separate();
bool fullUpdate = mark || hasSelectedText();
if ( mark ) {
int anchor;
if ( selend > selstart && cursor == selstart )
anchor = selend;
else if ( selend > selstart && cursor == selend )
anchor = selstart;
else
anchor = cursor;
selstart = QMIN( anchor, pos );
selend = QMAX( anchor, pos );
} else {
selstart = selend = 0;
}
if ( fullUpdate ) {
cursor = pos;
q->update();
} else {
setCursorVisible( FALSE );
cursor = pos;
setCursorVisible( TRUE );
}
updateMicroFocusHint();
if ( mark ) {
if( !q->style().styleHint( QStyle::SH_BlinkCursorWhenTextSelected ))
setCursorVisible( FALSE );
emit q->selectionChanged();
}
}
void SecQLineEditPrivate::finishChange( int validateFromState, bool setModified )
{
bool lineDirty = selDirty;
if ( textDirty ) {
if ( validateFromState >= 0 ) {
#ifndef SECURE_NO_UNDO
undo( validateFromState );
#endif /* SECURE_NO_UNDO */
history.resize( undoState );
textDirty = setModified = FALSE;
}
updateTextLayout();
updateMicroFocusHint();
lineDirty |= textDirty;
if ( setModified )
modified = TRUE;
if ( textDirty ) {
textDirty = FALSE;
emit q->textChanged( text );
}
+ emit q->textModified( text );
#if defined(QT_ACCESSIBILITY_SUPPORT)
QAccessible::updateAccessibility( q, 0, QAccessible::ValueChanged );
#endif
}
if ( selDirty ) {
selDirty = FALSE;
emit q->selectionChanged();
}
if ( lineDirty || !setModified )
q->update();
}
void SecQLineEditPrivate::setText( const SecQString& txt )
{
deselect();
SecQString oldText = text;
text = txt.isEmpty() ? SecQString ("") : txt.left( maxLength );
history.clear();
undoState = 0;
cursor = text.length();
textDirty = 1; // Err on safe side.
}
void SecQLineEditPrivate::setCursorVisible( bool visible )
{
if ( (bool)cursorVisible == visible )
return;
if ( cursorTimer )
cursorVisible = visible;
QRect r = cursorRect();
if ( !q->contentsRect().contains( r ) )
q->update();
else
q->update( r );
}
#ifndef SECURE_NO_UNDO
void SecQLineEditPrivate::addCommand( const Command& cmd )
{
if ( separator && undoState && history[undoState-1].type != Separator ) {
history.resize( undoState + 2 );
history[undoState++] = Command( Separator, 0, 0 );
} else {
history.resize( undoState + 1);
}
separator = FALSE;
history[ undoState++ ] = cmd;
}
#endif /* SECURE_NO_UNDO */
void SecQLineEditPrivate::insert( const SecQString& s )
{
int remaining = maxLength - text.length();
text.insert( cursor, s.left(remaining) );
for ( int i = 0; i < (int) s.left(remaining).length(); ++i )
{
#ifndef SECURE_NO_UNDO
addCommand( Command( Insert, cursor, s.at(i) ) );
#endif /* SECURE_NO_UNDO */
cursor++;
}
textDirty = TRUE;
}
void SecQLineEditPrivate::del( bool wasBackspace )
{
if ( cursor < (int) text.length() ) {
#ifndef SECURE_NO_UNDO
addCommand ( Command( (CommandType)(wasBackspace?Remove:Delete), cursor, text.at(cursor) ) );
#endif /* SECURE_NO_UNDO */
text.remove( cursor, 1 );
textDirty = TRUE;
}
}
void SecQLineEditPrivate::removeSelectedText()
{
if ( selstart < selend && selend <= (int) text.length() ) {
separate();
#ifndef SECURE_NO_UNDO
int i ;
if ( selstart <= cursor && cursor < selend ) {
// cursor is within the selection. Split up the commands
// to be able to restore the correct cursor position
for ( i = cursor; i >= selstart; --i )
addCommand ( Command( DeleteSelection, i, text.at(i) ) );
for ( i = selend - 1; i > cursor; --i )
addCommand ( Command( DeleteSelection, i - cursor + selstart - 1, text.at(i) ) );
} else {
for ( i = selend-1; i >= selstart; --i )
addCommand ( Command( RemoveSelection, i, text.at(i) ) );
}
#endif /* SECURE_NO_UNDO */
text.remove( selstart, selend - selstart );
if ( cursor > selstart )
cursor -= QMIN( cursor, selend ) - selstart;
deselect();
textDirty = TRUE;
}
}
diff --git a/qt/secqlineedit.h b/qt/secqlineedit.h
index b29fbb6..40346ae 100644
--- a/qt/secqlineedit.h
+++ b/qt/secqlineedit.h
@@ -1,227 +1,228 @@
/* secqlineedit.h - Secure version of QLineEdit.
Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
Copyright (C) 2003 g10 Code GmbH
The license of the original qlineedit.h file from which this file
is derived can be found below. Modified by Marcus Brinkmann
<marcus@g10code.de>. All modifications are licensed as follows, so
that the intersection of the two licenses is then the GNU General
Public License version 2.
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., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA */
#include "secqstring.h"
/* This disables some insecure code. */
#define SECURE 1
/**********************************************************************
** $Id$
**
** Definition of SecQLineEdit widget class
**
** Created : 941011
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the widgets module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef SECQLINEEDIT_H
#define SECQLINEEDIT_H
struct SecQLineEditPrivate;
class QPopupMenu;
#ifndef QT_H
#include "qframe.h"
#include "qstring.h"
#endif // QT_H
class QTextParagraph;
class QTextCursor;
class Q_EXPORT SecQLineEdit : public QFrame
{
Q_OBJECT
Q_ENUMS( EchoMode )
// Q_PROPERTY( SecQString text READ text WRITE setText )
Q_PROPERTY( int maxLength READ maxLength WRITE setMaxLength )
Q_PROPERTY( bool frame READ frame WRITE setFrame )
Q_PROPERTY( EchoMode echoMode READ echoMode WRITE setEchoMode )
Q_PROPERTY( QString displayText READ displayText )
Q_PROPERTY( int cursorPosition READ cursorPosition WRITE setCursorPosition )
Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
Q_PROPERTY( bool edited READ edited WRITE setEdited DESIGNABLE false )
Q_PROPERTY( bool modified READ isModified )
Q_PROPERTY( bool hasMarkedText READ hasMarkedText DESIGNABLE false )
Q_PROPERTY( bool hasSelectedText READ hasSelectedText )
// Q_PROPERTY( SecQString markedText READ markedText DESIGNABLE false )
// Q_PROPERTY( SecQString selectedText READ selectedText )
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
Q_PROPERTY( bool undoAvailable READ isUndoAvailable )
Q_PROPERTY( bool redoAvailable READ isRedoAvailable )
public:
SecQLineEdit( QWidget* parent, const char* name=0 );
SecQLineEdit( const SecQString &, QWidget* parent, const char* name=0 );
SecQLineEdit( const SecQString &, const QString &, QWidget* parent, const char* name=0 );
~SecQLineEdit();
SecQString text() const;
QString displayText() const;
int maxLength() const;
bool frame() const;
enum EchoMode { Normal, NoEcho, Password };
EchoMode echoMode() const;
bool isReadOnly() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
int cursorPosition() const;
bool validateAndSet( const SecQString &, int, int, int ); // obsolete
int alignment() const;
#ifndef QT_NO_COMPAT
void cursorLeft( bool mark, int steps = 1 ) { cursorForward( mark, -steps ); }
void cursorRight( bool mark, int steps = 1 ) { cursorForward( mark, steps ); }
#endif
void cursorForward( bool mark, int steps = 1 );
void cursorBackward( bool mark, int steps = 1 );
void cursorWordForward( bool mark );
void cursorWordBackward( bool mark );
void backspace();
void del();
void home( bool mark );
void end( bool mark );
bool isModified() const;
void clearModified();
bool edited() const; // obsolete, use isModified()
void setEdited( bool ); // obsolete, use clearModified()
bool hasSelectedText() const;
SecQString selectedText() const;
int selectionStart() const;
bool isUndoAvailable() const;
bool isRedoAvailable() const;
#ifndef QT_NO_COMPAT
bool hasMarkedText() const { return hasSelectedText(); }
SecQString markedText() const { return selectedText(); }
#endif
public slots:
virtual void setText( const SecQString &);
virtual void selectAll();
virtual void deselect();
virtual void insert( const SecQString &);
virtual void clear();
virtual void undo();
virtual void redo();
virtual void setMaxLength( int );
virtual void setFrame( bool );
virtual void setEchoMode( EchoMode );
virtual void setReadOnly( bool );
virtual void setFont( const QFont & );
virtual void setPalette( const QPalette & );
virtual void setSelection( int, int );
virtual void setCursorPosition( int );
virtual void setAlignment( int flag );
#ifndef QT_NO_CLIPBOARD
virtual void cut();
virtual void copy() const;
virtual void paste();
#endif
signals:
void textChanged( const SecQString &);
+ void textModified( const SecQString &);
void returnPressed();
void lostFocus();
void selectionChanged();
protected:
bool event( QEvent * );
void mousePressEvent( QMouseEvent * );
void mouseMoveEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void mouseDoubleClickEvent( QMouseEvent * );
void keyPressEvent( QKeyEvent * );
void imStartEvent( QIMEvent * );
void imComposeEvent( QIMEvent * );
void imEndEvent( QIMEvent * );
void focusInEvent( QFocusEvent * );
void focusOutEvent( QFocusEvent * );
void resizeEvent( QResizeEvent * );
void drawContents( QPainter * );
void windowActivationChange( bool );
#ifndef QT_NO_COMPAT
void repaintArea( int, int ) { update(); }
#endif
private slots:
void clipboardChanged();
public:
QChar passwordChar() const; // obsolete internal
private:
friend struct SecQLineEditPrivate;
SecQLineEditPrivate * d;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
SecQLineEdit( const SecQLineEdit & );
SecQLineEdit &operator=( const SecQLineEdit & );
#endif
};
#endif // SECQLINEEDIT_H

File Metadata

Mime Type
text/x-diff
Expires
Tue, Dec 9, 1:05 AM (1 h, 36 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
db/68/40f204b9b330d442dfc076c46ff3

Event Timeline