diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-10-11 20:29:14 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-10-11 20:29:14 +0000 |
commit | 7df096cffe4806fbc1e13fbcc3170933876a115a (patch) | |
tree | eaeef8024c6466f28a350460f2890a19880e916b | |
parent | some commenting (diff) | |
download | gpg4usb-7df096cffe4806fbc1e13fbcc3170933876a115a.tar.gz gpg4usb-7df096cffe4806fbc1e13fbcc3170933876a115a.zip |
moved preventnodataerr to context.cpp, added refresh slots for verify
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@544 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | context.cpp | 18 | ||||
-rw-r--r-- | context.h | 7 | ||||
-rw-r--r-- | gpgwin.cpp | 37 | ||||
-rw-r--r-- | gpgwin.h | 10 | ||||
-rw-r--r-- | verifydetailsdialog.cpp | 32 | ||||
-rw-r--r-- | verifydetailsdialog.h | 24 | ||||
-rw-r--r-- | verifykeydetailbox.cpp | 21 | ||||
-rw-r--r-- | verifykeydetailbox.h | 21 | ||||
-rw-r--r-- | verifynotification.cpp | 7 | ||||
-rw-r--r-- | verifynotification.h | 3 |
11 files changed, 143 insertions, 38 deletions
@@ -22,6 +22,7 @@ Release 0.3.1 - export public key on export of private key too - put keydetails to keylist - dont hide verifynotification {DONE] +- import from keyserver doesn't end, if network-connection is available, but no connection to keyserver BUGS: - Sometimes two or more stars are shown at modified documents diff --git a/context.cpp b/context.cpp index b55467a..87b6c3f 100644 --- a/context.cpp +++ b/context.cpp @@ -615,6 +615,24 @@ bool Context::sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray return (err == GPG_ERR_NO_ERROR); } + +/* + * if there is no '\n' before the PGP-Begin-Block, but for example a whitespace, + * GPGME doesn't recognise the Message as encrypted. This function adds '\n' + * before the PGP-Begin-Block, if missing. + */ +void Context::preventNoDataErr(QByteArray *in) +{ + int block_start = in->indexOf("-----BEGIN PGP MESSAGE-----"); + if (block_start > 0 && in->at(block_start - 1) != '\n') { + in->insert(block_start, '\n'); + } + block_start = in->indexOf("-----BEGIN PGP SIGNED MESSAGE-----"); + if (block_start > 0 && in->at(block_start - 1) != '\n') { + in->insert(block_start, '\n'); + } +} + } @@ -90,6 +90,13 @@ public: // void decryptVerify(QByteArray in); void sign(const QByteArray &inBuffer, QByteArray *outBuffer); bool sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray *outBuffer ); + /** + * @details If text contains PGP-message, put a linebreak before the message, + * so that gpgme can decrypt correctly + * + * @param in Pointer to the QBytearray to check. + */ + void preventNoDataErr(QByteArray *in); signals: void keyDBChanged(); @@ -419,12 +419,12 @@ void GpgWin::createDockWindows() { /* KeyList-Dockwindow */ - encryptDock = new QDockWidget(tr("Encrypt for:"), this); - encryptDock->setObjectName("EncryptDock"); - encryptDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - addDockWidget(Qt::RightDockWidgetArea, encryptDock); - encryptDock->setWidget(mKeyList); - viewMenu->addAction(encryptDock->toggleViewAction()); + keylistDock = new QDockWidget(tr("Encrypt for:"), this); + keylistDock->setObjectName("EncryptDock"); + keylistDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + addDockWidget(Qt::RightDockWidgetArea, keylistDock); + keylistDock->setWidget(mKeyList); + viewMenu->addAction(keylistDock->toggleViewAction()); /* Attachments-Dockwindow */ @@ -564,23 +564,6 @@ void GpgWin::checkAttachmentFolder() { } } -/* - * if there is no '\n' before the PGP-Begin-Block, but for example a whitespace, - * GPGME doesn't recognise the Message as encrypted. This function adds '\n' - * before the PGP-Begin-Block, if missing. - */ -void GpgWin::preventNoDataErr(QByteArray *in) -{ - int block_start = in->indexOf("-----BEGIN PGP MESSAGE-----"); - if (block_start > 0 && in->at(block_start - 1) != '\n') { - in->insert(block_start, '\n'); - } - block_start = in->indexOf("-----BEGIN PGP SIGNED MESSAGE-----"); - if (block_start > 0 && in->at(block_start - 1) != '\n') { - in->insert(block_start, '\n'); - } -} - void GpgWin::importKeyFromEdit() { mCtx->importKey(edit->curTextPage()->toPlainText().toAscii()); @@ -620,7 +603,7 @@ void GpgWin::decrypt() { QByteArray *decrypted = new QByteArray(); QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here? - preventNoDataErr(&text); + mCtx->preventNoDataErr(&text); // try decrypt, if fail do nothing, especially don't replace text if(!mCtx->decrypt(text, decrypted)) { @@ -672,7 +655,7 @@ void GpgWin::verify() QDateTime timestamp; verify_label_status verifyStatus=VERIFY_ERROR_OK; QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here? - preventNoDataErr(&text); + mCtx->preventNoDataErr(&text); int textIsSigned = isSigned(text); gpgme_signature_t sign = mCtx->verify(text); @@ -809,7 +792,6 @@ void GpgWin::showKeyDetails() new KeyDetailsDialog(mCtx, key, this); } - void GpgWin::fileEncryption() { QStringList *keyList; @@ -829,7 +811,8 @@ void GpgWin::openSettingsDialog() this->setToolButtonStyle(buttonStyle); } -void GpgWin::cleanDoubleLinebreaks() { +void GpgWin::cleanDoubleLinebreaks() +{ QString content = edit->curTextPage()->toPlainText(); content.replace("\n\n", "\n"); edit->fillTextEditWithText(content); @@ -202,14 +202,6 @@ private: void saveSettings(); /** - * @details If text contains PGP-message, put a linebreak before the message, - * so that gpgme can decrypt correctly - * - * @param in Pointer to the QBytearray to check. - */ - void preventNoDataErr(QByteArray *in); - - /** * @brief * * @param message @@ -237,7 +229,7 @@ private: QToolBar *cryptToolBar; /** Toolbar holding crypt actions */ QToolBar *editToolBar; /** Toolbar holding edit actions */ QToolBar *keyToolBar; /** Toolbar holding key operations */ - QDockWidget *encryptDock; /** Encrypt Dock*/ + QDockWidget *keylistDock; /** Encrypt Dock*/ QDockWidget *attachmentDock; /** Attachment Dock */ QDialog *genkeyDialog; /** Dialog for key generation */ diff --git a/verifydetailsdialog.cpp b/verifydetailsdialog.cpp index 26a321b..9a18090 100644 --- a/verifydetailsdialog.cpp +++ b/verifydetailsdialog.cpp @@ -1,10 +1,33 @@ +/* + * verifydetailsdialog.cpp + * + * Copyright 2008 gpg4usb-team <[email protected]> + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + #include "verifydetailsdialog.h" VerifyDetailsDialog::VerifyDetailsDialog(QWidget *parent, GpgME::Context* ctx, KeyList* keyList, gpgme_signature_t signature) : QDialog(parent) { - this->mCtx = ctx; - this->mKeyList = keyList; + mCtx = ctx; + mKeyList = keyList; + + connect(mCtx, SIGNAL(keyDBChanged()), this, SLOT(refresh())); mVbox = new QVBoxLayout(); @@ -32,3 +55,8 @@ VerifyDetailsDialog::VerifyDetailsDialog(QWidget *parent, GpgME::Context* ctx, K this->show(); this->exec(); } + +void VerifyDetailsDialog::refresh() +{ + qDebug() << "refresh detail dialog"; +} diff --git a/verifydetailsdialog.h b/verifydetailsdialog.h index 748770d..8e24455 100644 --- a/verifydetailsdialog.h +++ b/verifydetailsdialog.h @@ -1,3 +1,24 @@ +/* + * verifydetailsdialog.h + * + * Copyright 2008 gpg4usb-team <[email protected]> + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + #ifndef __VERIFYDETAILSDIALOG_H__ #define __VERIFYDETAILSDIALOG_H__ @@ -10,6 +31,9 @@ class VerifyDetailsDialog : public QDialog public: explicit VerifyDetailsDialog(QWidget *parent, GpgME::Context* ctx, KeyList* mKeyList, gpgme_signature_t signature); +private slots: + void refresh(); + private: GpgME::Context* mCtx; KeyList* mKeyList; diff --git a/verifykeydetailbox.cpp b/verifykeydetailbox.cpp index 1b640d0..8f82d9a 100644 --- a/verifykeydetailbox.cpp +++ b/verifykeydetailbox.cpp @@ -1,3 +1,24 @@ +/* + * verifydetailbox.cpp + * + * Copyright 2008 gpg4usb-team <[email protected]> + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + #include "verifykeydetailbox.h" VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget *parent, GpgME::Context* ctx, KeyList* keyList, gpgme_signature_t signature) : diff --git a/verifykeydetailbox.h b/verifykeydetailbox.h index 456289f..ebca40c 100644 --- a/verifykeydetailbox.h +++ b/verifykeydetailbox.h @@ -1,3 +1,24 @@ +/* + * verifydetailbox.h + * + * Copyright 2008 gpg4usb-team <[email protected]> + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + #ifndef __VERIFYKEYDETAILBOX_H__ #define __VERIFYKEYDETAILBOX_H__ diff --git a/verifynotification.cpp b/verifynotification.cpp index 36cb9e8..0068638 100644 --- a/verifynotification.cpp +++ b/verifynotification.cpp @@ -29,6 +29,8 @@ VerifyNotification::VerifyNotification(QWidget *parent, GpgME::Context *ctx, Key mSignature = sign; verifyLabel = new QLabel(this); + connect(mCtx, SIGNAL(keyDBChanged()), this, SLOT(refresh())); + importFromKeyserverAct = new QAction(tr("Import missing key from Keyserver"), this); connect(importFromKeyserverAct, SIGNAL(triggered()), this, SLOT(importFromKeyserver())); @@ -84,3 +86,8 @@ void VerifyNotification::showVerifyDetails() { new VerifyDetailsDialog(this, mCtx, mKeyList, mSignature); } + +void VerifyNotification::refresh() +{ + qDebug() << "refresh signal called"; +} diff --git a/verifynotification.h b/verifynotification.h index 178169d..495593b 100644 --- a/verifynotification.h +++ b/verifynotification.h @@ -99,5 +99,8 @@ private: QHBoxLayout *notificationWidgetLayout; /** Layout for verify-notification */ QVector<QString> verifyDetailStringVector; /** Vector containing the text for labels in verifydetaildialog */ QVector<verify_label_status> verifyDetailStatusVector; /** Vector containing the status for labels in verifydetaildialog */ + +private slots: + void refresh(); }; #endif // __VERIFYNOTIFICATION_H__ |