diff options
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | context.cpp | 10 | ||||
-rw-r--r-- | context.h | 3 | ||||
-rw-r--r-- | gpgwin.cpp | 3 | ||||
-rwxr-xr-x | settingsdialog.cpp | 15 | ||||
-rwxr-xr-x | settingsdialog.h | 3 |
6 files changed, 32 insertions, 6 deletions
@@ -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'); @@ -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; @@ -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(); |