aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-08-27 14:22:39 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-08-27 14:22:39 +0000
commit1491bf832e06d0c1c3f6c9ced236c090263002d3 (patch)
tree3b3cecda5a662c4bc214aa76200ede16e1455c22
parentfix bug that crashes windows-build when encrypting twice (diff)
downloadgpg4usb-1491bf832e06d0c1c3f6c9ced236c090263002d3.tar.gz
gpg4usb-1491bf832e06d0c1c3f6c9ced236c090263002d3.zip
implement remember password functionality
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@367 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--TODO4
-rw-r--r--context.cpp10
-rw-r--r--context.h3
-rw-r--r--gpgwin.cpp3
-rwxr-xr-xsettingsdialog.cpp15
-rwxr-xr-xsettingsdialog.h3
6 files changed, 32 insertions, 6 deletions
diff --git a/TODO b/TODO
index c805117..fb4d6cd 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,13 @@
TODO:
-----
Release 0.2.5
-- minimal MIME support (understand and decode "Content-Encoding" header, e.g. "quoted printable")
+- minimal MIME support (understand and decode "Content-Encoding" header, e.g. "quoted printable") [DONE]
- File-Encryption: Warning if file overwritten [DONE]
- more doku on building gpg4usb (especially on windows)
- doku for translating gpg4usb
- add translation for french
+- remember Password [DONE]
+- "Forget Password after X minutes"
Release 0.3
- PGP-MIME, find and show inline encrypted files
diff --git a/context.cpp b/context.cpp
index 2630ee1..614a7ad 100644
--- a/context.cpp
+++ b/context.cpp
@@ -315,9 +315,11 @@ bool Context::decrypt(const QByteArray &inBuffer, QByteArray *outBuffer)
if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) {
QMessageBox::critical(0, "Error decrypting:", gpgme_strerror(err));
}
+
//if (err != GPG_ERR_NO_ERROR)
- // always clear password cache. TODO: implement passwort save
- clearCache();
+ if (! settings.value("general/rememberPassword").toBool()) {
+ clearPasswordCache();
+ }
if (in) {
gpgme_data_release(in);
@@ -382,7 +384,7 @@ gpgme_error_t Context::passphrase(const char *uid_hint,
if (last_was_bad) {
s += "<i>Wrong password.</i><br><br>\n\n";
- clearCache();
+ clearPasswordCache();
}
/** if uid provided */
@@ -429,7 +431,7 @@ gpgme_error_t Context::passphrase(const char *uid_hint,
}
/** also from kgpgme.cpp, seems to clear password from mem */
-void Context::clearCache()
+void Context::clearPasswordCache()
{
if (mPasswordCache.size() > 0) {
mPasswordCache.fill('\0');
diff --git a/context.h b/context.h
index 234ec5b..a023ce0 100644
--- a/context.h
+++ b/context.h
@@ -67,7 +67,7 @@ public:
bool encrypt(QStringList *uidList, const QByteArray &inBuffer,
QByteArray *outBuffer);
bool decrypt(const QByteArray &inBuffer, QByteArray *outBuffer);
- void clearCache();
+ void clearPasswordCache();
void exportSecretKey(QString uid, QByteArray *outBuffer);
gpgme_key_t getKeyDetails(QString uid);
@@ -80,6 +80,7 @@ private:
gpgme_error_t err;
gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray *outBuffer);
QByteArray mPasswordCache;
+ QSettings settings;
bool debug;
void checkErr(gpgme_error_t err) const;
void checkErr(gpgme_error_t err, QString comment) const;
diff --git a/gpgwin.cpp b/gpgwin.cpp
index cc721f7..53d5d1e 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -361,6 +361,9 @@ void GpgWin::closeEvent(QCloseEvent *event)
event->ignore();
}
+ // clear password from memory
+ mCtx->clearPasswordCache();
+
}
void GpgWin::open()
diff --git a/settingsdialog.cpp b/settingsdialog.cpp
index f175b54..44f444d 100755
--- a/settingsdialog.cpp
+++ b/settingsdialog.cpp
@@ -137,6 +137,15 @@ SettingsDialog::SettingsDialog(QWidget *parent)
mimeParseBox->setLayout(mimeParseBoxLayout);
/*****************************************
+ * remember Password-Box
+ *****************************************/
+ rememberPasswordBox = new QGroupBox(tr("Remember Password"));
+ rememberPasswordBoxLayout = new QHBoxLayout();
+ rememberPasswordCheckBox = new QCheckBox(tr("Remember password till closing gpg4usb"), this);
+ rememberPasswordBoxLayout->addWidget(rememberPasswordCheckBox);
+ rememberPasswordBox->setLayout(rememberPasswordBoxLayout);
+
+ /*****************************************
* Button-Box
*****************************************/
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@@ -152,6 +161,7 @@ SettingsDialog::SettingsDialog(QWidget *parent)
vbox->addWidget(windowSizeBox);
vbox->addWidget(saveCheckedKeysBox);
vbox->addWidget(mimeParseBox);
+ vbox->addWidget(rememberPasswordBox);
vbox->addWidget(langBox);
vbox->addWidget(buttonBox);
setLayout(vbox);
@@ -199,6 +209,9 @@ void SettingsDialog::setSettings()
// Keysaving
if (settings.value("keys/keySave").toBool()) saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
+ // Remember Password
+ if (settings.value("general/rememberPassword").toBool()) rememberPasswordCheckBox->setCheckState(Qt::Checked);
+
// MIME-Parsing
if (settings.value("mime/parsemime").toBool()) mimeParseCheckBox->setCheckState(Qt::Checked);
@@ -243,6 +256,8 @@ void SettingsDialog::applySettings()
settings.setValue("window/windowSave", windowSizeCheckBox->isChecked());
settings.setValue("keys/keySave", saveCheckedKeysCheckBox->isChecked());
+ // TODO: clear passwordCache instantly on unset rememberPassword
+ settings.setValue("general/rememberPassword", rememberPasswordCheckBox->isChecked());
settings.setValue("mime/parsemime" , mimeParseCheckBox->isChecked());
settings.setValue("mime/parseQP" , mimeQPCheckBox->isChecked());
diff --git a/settingsdialog.h b/settingsdialog.h
index ce558bf..ef9e2da 100755
--- a/settingsdialog.h
+++ b/settingsdialog.h
@@ -46,6 +46,7 @@ private:
QGroupBox *iconStyleBox;
QGroupBox *windowSizeBox;
QGroupBox *saveCheckedKeysBox;
+ QGroupBox *rememberPasswordBox;
QGroupBox *mimeParseBox;
QDialogButtonBox *buttonBox;
@@ -60,6 +61,7 @@ private:
QRadioButton *iconAllButton;
QCheckBox *windowSizeCheckBox;
QCheckBox *saveCheckedKeysCheckBox;
+ QCheckBox *rememberPasswordCheckBox;
QCheckBox *mimeParseCheckBox;
QCheckBox *mimeQPCheckBox;
QCheckBox *mimeOpenAttachmentCheckBox;
@@ -70,6 +72,7 @@ private:
QHBoxLayout *iconStyleBoxLayout;
QHBoxLayout *windowSizeBoxLayout;
QHBoxLayout *saveCheckedKeysBoxLayout;
+ QHBoxLayout *rememberPasswordBoxLayout;
QVBoxLayout *mimeParseBoxLayout;
QVBoxLayout *vbox;
void setSettings();