aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpg4usb.qrc2
-rw-r--r--include/MainWindow.h20
-rw-r--r--include/gpg/GpgContext.h6
-rw-r--r--release/icons/button_cancel.pngbin3612 -> 3242 bytes
-rw-r--r--release/icons/button_copy.pngbin1989 -> 1475 bytes
-rw-r--r--release/icons/button_cut.pngbin3406 -> 2828 bytes
-rw-r--r--release/icons/button_delete.pngbin0 -> 2202 bytes
-rw-r--r--release/icons/button_next.pngbin2583 -> 6380 bytes
-rw-r--r--release/icons/button_ok.pngbin2856 -> 6709 bytes
-rw-r--r--release/icons/button_paste.pngbin2704 -> 2727 bytes
-rw-r--r--release/icons/button_previous.pngbin5229 -> 5914 bytes
-rw-r--r--release/icons/configure.pngbin2897 -> 4277 bytes
-rw-r--r--release/icons/decrypted_verified.pngbin0 -> 3935 bytes
-rw-r--r--release/icons/edit.pngbin2011 -> 1491 bytes
-rw-r--r--[-rwxr-xr-x]release/icons/error.pngbin3080 -> 6721 bytes
-rw-r--r--release/icons/exit.pngbin2446 -> 4925 bytes
-rw-r--r--release/icons/export_key_to_clipboard.pngbin4672 -> 2659 bytes
-rw-r--r--release/icons/export_key_to_file.pngbin3976 -> 4577 bytes
-rw-r--r--release/icons/fileopen.pngbin2654 -> 3100 bytes
-rw-r--r--release/icons/fileprint.pngbin3369 -> 2915 bytes
-rw-r--r--release/icons/filesave.pngbin2627 -> 2348 bytes
-rw-r--r--release/icons/filesaveas.pngbin3846 -> 4333 bytes
-rw-r--r--release/icons/format-line-spacing-double.pngbin769 -> 676 bytes
-rw-r--r--release/icons/format-line-spacing-normal.pngbin628 -> 707 bytes
-rw-r--r--release/icons/format-line-spacing-triple.pngbin798 -> 534 bytes
-rw-r--r--release/icons/gpgfrontend-logo_small (copy).pngbin0 -> 12857 bytes
-rw-r--r--release/icons/help.pngbin4662 -> 2723 bytes
-rw-r--r--release/icons/import_key_from_clipboard.pngbin4169 -> 1952 bytes
-rw-r--r--[-rwxr-xr-x]release/icons/import_key_from_file.pngbin3985 -> 2404 bytes
-rw-r--r--release/icons/import_key_from_server.pngbin3068 -> 4802 bytes
-rw-r--r--release/icons/importkey_editor.pngbin3352 -> 4040 bytes
-rw-r--r--[-rwxr-xr-x]release/icons/key_export.pngbin2534 -> 1449 bytes
-rw-r--r--release/icons/key_generate.pngbin5140 -> 2708 bytes
-rw-r--r--[-rwxr-xr-x]release/icons/key_import.pngbin2775 -> 2576 bytes
-rw-r--r--release/icons/keymgmt.pngbin2746 -> 3408 bytes
-rw-r--r--[-rwxr-xr-x]release/icons/kgpg_key2.pngbin850 -> 3837 bytes
-rw-r--r--release/icons/misc_doc.pngbin1126 -> 1482 bytes
-rw-r--r--release/icons/undo.pngbin2653 -> 4347 bytes
-rw-r--r--src/MainWindow.cpp123
-rw-r--r--src/gpg/GpgContext.cpp244
-rw-r--r--src/gpg/result_analyse/DecryptResultAnalyse.cpp37
-rw-r--r--src/gpg/result_analyse/EncryptResultAnalyse.cpp24
-rw-r--r--src/gpg/result_analyse/SignResultAnalyse.cpp67
-rw-r--r--src/gpg/result_analyse/VerifyResultAnalyse.cpp198
-rwxr-xr-xsrc/ui/KeyMgmt.cpp7
-rw-r--r--src/ui/KeyServerImportDialog.cpp8
46 files changed, 395 insertions, 341 deletions
diff --git a/gpg4usb.qrc b/gpg4usb.qrc
index 912d47c1..5726af72 100644
--- a/gpg4usb.qrc
+++ b/gpg4usb.qrc
@@ -13,11 +13,13 @@
<file alias="button_cut.png">release/icons/button_cut.png</file>
<file alias="button_ok.png">release/icons/button_ok.png</file>
<file alias="button_paste.png">release/icons/button_paste.png</file>
+ <file alias="button_delete.png">release/icons/button_delete.png</file>
<file alias="configure.png">release/icons/configure.png</file>
<file alias="decrypted.png">release/icons/decrypted.png</file>
<file alias="edit.png">release/icons/edit.png</file>
<file alias="encrypted.png">release/icons/encrypted.png</file>
<file alias="encrypted_signed.png">release/icons/encrypted_signed.png</file>
+ <file alias="decrypted_verified.png">release/icons/decrypted_verified.png</file>
<file alias="exit.png">release/icons/exit.png</file>
<file alias="export_key_to_file.png">release/icons/export_key_to_file.png</file>
<file alias="fileencryption.png">release/icons/fileencrytion.png</file>
diff --git a/include/MainWindow.h b/include/MainWindow.h
index 66a11169..e083e93a 100644
--- a/include/MainWindow.h
+++ b/include/MainWindow.h
@@ -98,6 +98,12 @@ private slots:
void slotVerify();
/**
+ * @details decrypt and verify the text of currently active textedit-page
+ * with the currently checked keys
+ */
+ void slotDecryptVerify();
+
+ /**
* @details Show the details of the first of the first of selected keys
*/
void slotShowKeyDetails();
@@ -213,8 +219,6 @@ private slots:
*/
void slotAddPgpHeader();
-// void dropEvent(QDropEvent *event);
-
/**
* @details Disable tab related actions, if number of tabs is 0.
* @param number number of the opened tabs and -1, if no tab is opened
@@ -274,16 +278,9 @@ private:
void saveSettings();
/**
- * @brief
- *
- * @param message
- */
- void parseMime(QByteArray *message);
-
- /**
* @brief return true, if restart is needed
*/
- bool getRestartNeeded() const;
+ [[nodiscard]] bool getRestartNeeded() const;
TextEdit *edit; /** Tabwidget holding the edit-windows */
QMenu *fileMenu; /** Submenu for file-operations*/
@@ -317,7 +314,8 @@ private:
QAction *closeTabAct; /** Action to print */
QAction *quitAct; /** Action to quit application */
QAction *encryptAct; /** Action to encrypt text */
- QAction *encryptSignAct; /** Action to encrypt text */
+ QAction *encryptSignAct; /** Action to encrypt and sign text */
+ QAction *decryptVerifyAct; /** Action to encrypt and sign text */
QAction *decryptAct; /** Action to decrypt text */
QAction *signAct; /** Action to sign text */
QAction *verifyAct; /** Action to verify text */
diff --git a/include/gpg/GpgContext.h b/include/gpg/GpgContext.h
index 2ffbeac2..fb2762f3 100644
--- a/include/gpg/GpgContext.h
+++ b/include/gpg/GpgContext.h
@@ -91,6 +91,10 @@ namespace GpgME {
gpgme_error_t decrypt(const QByteArray &inBuffer, QByteArray *outBuffer, gpgme_decrypt_result_t *result);
+ gpgme_error_t
+ decryptVerify(const QByteArray &inBuffer, QByteArray *outBuffer, gpgme_decrypt_result_t *decrypt_result,
+ gpgme_verify_result_t *verify_result);
+
void clearPasswordCache();
void exportSecretKey(const QString &uid, QByteArray *outBuffer);
@@ -165,7 +169,7 @@ namespace GpgME {
void slotRefreshKeyList();
- void slotUpdateKeyList(QString key_id);
+ void slotUpdateKeyList(const QString& key_id);
private:
gpgme_ctx_t mCtx{};
diff --git a/release/icons/button_cancel.png b/release/icons/button_cancel.png
index 75980de0..57e2c6cf 100644
--- a/release/icons/button_cancel.png
+++ b/release/icons/button_cancel.png
Binary files differ
diff --git a/release/icons/button_copy.png b/release/icons/button_copy.png
index a04d2f7f..03bcd93b 100644
--- a/release/icons/button_copy.png
+++ b/release/icons/button_copy.png
Binary files differ
diff --git a/release/icons/button_cut.png b/release/icons/button_cut.png
index 57c4711c..a5e0c2d8 100644
--- a/release/icons/button_cut.png
+++ b/release/icons/button_cut.png
Binary files differ
diff --git a/release/icons/button_delete.png b/release/icons/button_delete.png
new file mode 100644
index 00000000..50e7098d
--- /dev/null
+++ b/release/icons/button_delete.png
Binary files differ
diff --git a/release/icons/button_next.png b/release/icons/button_next.png
index 3a84a546..b642910e 100644
--- a/release/icons/button_next.png
+++ b/release/icons/button_next.png
Binary files differ
diff --git a/release/icons/button_ok.png b/release/icons/button_ok.png
index 94aac4b2..50310aed 100644
--- a/release/icons/button_ok.png
+++ b/release/icons/button_ok.png
Binary files differ
diff --git a/release/icons/button_paste.png b/release/icons/button_paste.png
index 099c51ff..260fa568 100644
--- a/release/icons/button_paste.png
+++ b/release/icons/button_paste.png
Binary files differ
diff --git a/release/icons/button_previous.png b/release/icons/button_previous.png
index 41bf3aac..67980245 100644
--- a/release/icons/button_previous.png
+++ b/release/icons/button_previous.png
Binary files differ
diff --git a/release/icons/configure.png b/release/icons/configure.png
index 2bf463be..b2c3c62f 100644
--- a/release/icons/configure.png
+++ b/release/icons/configure.png
Binary files differ
diff --git a/release/icons/decrypted_verified.png b/release/icons/decrypted_verified.png
new file mode 100644
index 00000000..5e45f625
--- /dev/null
+++ b/release/icons/decrypted_verified.png
Binary files differ
diff --git a/release/icons/edit.png b/release/icons/edit.png
index bee26454..01a6662b 100644
--- a/release/icons/edit.png
+++ b/release/icons/edit.png
Binary files differ
diff --git a/release/icons/error.png b/release/icons/error.png
index d64c533f..3137becb 100755..100644
--- a/release/icons/error.png
+++ b/release/icons/error.png
Binary files differ
diff --git a/release/icons/exit.png b/release/icons/exit.png
index 08e97b40..8ed3161d 100644
--- a/release/icons/exit.png
+++ b/release/icons/exit.png
Binary files differ
diff --git a/release/icons/export_key_to_clipboard.png b/release/icons/export_key_to_clipboard.png
index 9dbeb7a3..74cc910a 100644
--- a/release/icons/export_key_to_clipboard.png
+++ b/release/icons/export_key_to_clipboard.png
Binary files differ
diff --git a/release/icons/export_key_to_file.png b/release/icons/export_key_to_file.png
index c1ccf8d2..d083f63e 100644
--- a/release/icons/export_key_to_file.png
+++ b/release/icons/export_key_to_file.png
Binary files differ
diff --git a/release/icons/fileopen.png b/release/icons/fileopen.png
index 73419296..461abcdc 100644
--- a/release/icons/fileopen.png
+++ b/release/icons/fileopen.png
Binary files differ
diff --git a/release/icons/fileprint.png b/release/icons/fileprint.png
index 05e15987..1b780552 100644
--- a/release/icons/fileprint.png
+++ b/release/icons/fileprint.png
Binary files differ
diff --git a/release/icons/filesave.png b/release/icons/filesave.png
index 0006ad42..ce80e05f 100644
--- a/release/icons/filesave.png
+++ b/release/icons/filesave.png
Binary files differ
diff --git a/release/icons/filesaveas.png b/release/icons/filesaveas.png
index 2be6df25..14ce8aee 100644
--- a/release/icons/filesaveas.png
+++ b/release/icons/filesaveas.png
Binary files differ
diff --git a/release/icons/format-line-spacing-double.png b/release/icons/format-line-spacing-double.png
index a131803a..813c393c 100644
--- a/release/icons/format-line-spacing-double.png
+++ b/release/icons/format-line-spacing-double.png
Binary files differ
diff --git a/release/icons/format-line-spacing-normal.png b/release/icons/format-line-spacing-normal.png
index debc26bb..f3d48aca 100644
--- a/release/icons/format-line-spacing-normal.png
+++ b/release/icons/format-line-spacing-normal.png
Binary files differ
diff --git a/release/icons/format-line-spacing-triple.png b/release/icons/format-line-spacing-triple.png
index 3ef2e484..e83ee98f 100644
--- a/release/icons/format-line-spacing-triple.png
+++ b/release/icons/format-line-spacing-triple.png
Binary files differ
diff --git a/release/icons/gpgfrontend-logo_small (copy).png b/release/icons/gpgfrontend-logo_small (copy).png
new file mode 100644
index 00000000..d34c6c31
--- /dev/null
+++ b/release/icons/gpgfrontend-logo_small (copy).png
Binary files differ
diff --git a/release/icons/help.png b/release/icons/help.png
index 915f9fd6..54821e49 100644
--- a/release/icons/help.png
+++ b/release/icons/help.png
Binary files differ
diff --git a/release/icons/import_key_from_clipboard.png b/release/icons/import_key_from_clipboard.png
index d06fb26e..2e45baed 100644
--- a/release/icons/import_key_from_clipboard.png
+++ b/release/icons/import_key_from_clipboard.png
Binary files differ
diff --git a/release/icons/import_key_from_file.png b/release/icons/import_key_from_file.png
index 621c4e29..5db35a6f 100755..100644
--- a/release/icons/import_key_from_file.png
+++ b/release/icons/import_key_from_file.png
Binary files differ
diff --git a/release/icons/import_key_from_server.png b/release/icons/import_key_from_server.png
index 5d88ab58..06034660 100644
--- a/release/icons/import_key_from_server.png
+++ b/release/icons/import_key_from_server.png
Binary files differ
diff --git a/release/icons/importkey_editor.png b/release/icons/importkey_editor.png
index 4fa7e01a..406b29c4 100644
--- a/release/icons/importkey_editor.png
+++ b/release/icons/importkey_editor.png
Binary files differ
diff --git a/release/icons/key_export.png b/release/icons/key_export.png
index ba72a3d4..6703498e 100755..100644
--- a/release/icons/key_export.png
+++ b/release/icons/key_export.png
Binary files differ
diff --git a/release/icons/key_generate.png b/release/icons/key_generate.png
index 78a644be..c67edd21 100644
--- a/release/icons/key_generate.png
+++ b/release/icons/key_generate.png
Binary files differ
diff --git a/release/icons/key_import.png b/release/icons/key_import.png
index 0226c2f3..399e96ee 100755..100644
--- a/release/icons/key_import.png
+++ b/release/icons/key_import.png
Binary files differ
diff --git a/release/icons/keymgmt.png b/release/icons/keymgmt.png
index 42b6ec07..b2d8c761 100644
--- a/release/icons/keymgmt.png
+++ b/release/icons/keymgmt.png
Binary files differ
diff --git a/release/icons/kgpg_key2.png b/release/icons/kgpg_key2.png
index 43e5a521..129c55d5 100755..100644
--- a/release/icons/kgpg_key2.png
+++ b/release/icons/kgpg_key2.png
Binary files differ
diff --git a/release/icons/misc_doc.png b/release/icons/misc_doc.png
index 78851f36..57878ba3 100644
--- a/release/icons/misc_doc.png
+++ b/release/icons/misc_doc.png
Binary files differ
diff --git a/release/icons/undo.png b/release/icons/undo.png
index 5cbf37d0..19717cc8 100644
--- a/release/icons/undo.png
+++ b/release/icons/undo.png
Binary files differ
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 3d17b9ad..665ee2ca 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -287,10 +287,10 @@ void MainWindow::createActions() {
encryptAct->setToolTip(tr("Encrypt Message"));
connect(encryptAct, SIGNAL(triggered()), this, SLOT(slotEncrypt()));
- encryptSignAct = new QAction(tr("&Encrypt Sign"), this);
+ encryptSignAct = new QAction(tr("&Encrypt &Sign"), this);
encryptSignAct->setIcon(QIcon(":encrypted_signed.png"));
- encryptSignAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E + Qt::Key_S));
- encryptSignAct->setToolTip(tr("Encrypt And Sign Message"));
+ encryptSignAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E));
+ encryptSignAct->setToolTip(tr("Encrypt and Sign Message"));
connect(encryptSignAct, SIGNAL(triggered()), this, SLOT(slotEncryptSign()));
decryptAct = new QAction(tr("&Decrypt"), this);
@@ -299,6 +299,12 @@ void MainWindow::createActions() {
decryptAct->setToolTip(tr("Decrypt Message"));
connect(decryptAct, SIGNAL(triggered()), this, SLOT(slotDecrypt()));
+ decryptVerifyAct = new QAction(tr("&Decrypt &Verify"), this);
+ decryptVerifyAct->setIcon(QIcon(":decrypted_verified.png"));
+ decryptVerifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
+ decryptVerifyAct->setToolTip(tr("Decrypt and Verify Message"));
+ connect(decryptVerifyAct, SIGNAL(triggered()), this, SLOT(slotDecryptVerify()));
+
/*
* File encryption submenu
*/
@@ -485,6 +491,7 @@ void MainWindow::createMenus() {
cryptMenu->addAction(encryptAct);
cryptMenu->addAction(encryptSignAct);
cryptMenu->addAction(decryptAct);
+ cryptMenu->addAction(decryptVerifyAct);
cryptMenu->addSeparator();
cryptMenu->addAction(signAct);
cryptMenu->addAction(verifyAct);
@@ -537,6 +544,7 @@ void MainWindow::createToolBars() {
cryptToolBar->addAction(encryptAct);
cryptToolBar->addAction(encryptSignAct);
cryptToolBar->addAction(decryptAct);
+ cryptToolBar->addAction(decryptVerifyAct);
cryptToolBar->addAction(signAct);
cryptToolBar->addAction(verifyAct);
//cryptToolBar->addAction(fileEncryptionAct);
@@ -695,42 +703,6 @@ void MainWindow::slotStartWizard() {
wizard->setModal(true);
}
-/*
- * if this is mime, split text and attachments...
- * message contains only text afterwards
- */
-void MainWindow::parseMime(QByteArray *message) {
- /*if (! Mime::isMultipart(message)) {
- qDebug() << "no multipart";
- return;
- }*/
- //qDebug() << "multipart";
-
- QString pText;
- bool showmadock = false;
-
- Mime *mime = new Mime(message);
- foreach(MimePart tmp, mime->parts()) {
- if (tmp.header.getValue("Content-Type") == "text/plain"
- && tmp.header.getValue("Content-Transfer-Encoding") != "base64") {
-
- QByteArray body;
- if (tmp.header.getValue("Content-Transfer-Encoding") == "quoted-printable") {
- Mime::quotedPrintableDecode(tmp.body, body);
- } else {
- body = tmp.body;
- }
- pText.append(QString(body));
- } else {
- (mAttachments->addMimePart(&tmp));
- showmadock = true;
- }
- }
- *message = pText.toUtf8();
- if (showmadock) {
- attachmentDock->show();
- }
-}
void MainWindow::slotCheckAttachmentFolder() {
// TODO: always check?
@@ -811,6 +783,8 @@ void MainWindow::slotEncrypt() {
infoBoard->slotRefresh(reportText, INFO_ERROR_OK);
else
infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+
+ delete resultAnalyse;
}
void MainWindow::slotSign() {
@@ -854,6 +828,8 @@ void MainWindow::slotSign() {
infoBoard->slotRefresh(reportText, INFO_ERROR_OK);
else
infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+
+ delete resultAnalyse;
}
void MainWindow::slotDecrypt() {
@@ -870,28 +846,8 @@ void MainWindow::slotDecrypt() {
auto error = mCtx->decrypt(text, decrypted, &result);
infoBoard->associateTextEdit(edit->curTextPage());
- /*
- * 1) is it mime (content-type:)
- * 2) parse header
- * 2) choose action depending on content-type
- */
- if (Mime::isMime(decrypted)) {
- Header header = Mime::getHeader(decrypted);
- // is it multipart, is multipart-parsing enabled
- if (header.getValue("Content-Type") == "multipart/mixed"
- && settings.value("mime/parseMime").toBool()) {
- parseMime(decrypted);
- } else if (header.getValue("Content-Type") == "text/plain"
- && settings.value("mime/parseQP").toBool()) {
- if (header.getValue("Content-Transfer-Encoding") == "quoted-printable") {
- auto *decoded = new QByteArray();
- Mime::quotedPrintableDecode(*decrypted, *decoded);
- //TODO: remove header
- decrypted = decoded;
- }
- }
- }
- edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted));
+ if(gpgme_err_code(error) == GPG_ERR_NO_ERROR)
+ edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted));
auto resultAnalyse = new DecryptResultAnalyse(mCtx, error, result);
@@ -902,6 +858,8 @@ void MainWindow::slotDecrypt() {
infoBoard->slotRefresh(reportText, INFO_ERROR_OK);
else
infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+
+ delete resultAnalyse;
}
void MainWindow::slotFind() {
@@ -950,6 +908,7 @@ void MainWindow::slotVerify() {
});
}
+ delete resultAnalyse;
}
/*
@@ -1171,5 +1130,47 @@ void MainWindow::slotEncryptSign() {
else
infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+ delete resultAnalyseEncr;
+ delete resultAnalyseSign;
+}
+void MainWindow::slotDecryptVerify() {
+
+ if (edit->tabCount() == 0 || edit->slotCurPage() == nullptr) {
+ return;
+ }
+
+ auto *decrypted = new QByteArray();
+ QByteArray text = edit->curTextPage()->toPlainText().toUtf8();
+ GpgME::GpgContext::preventNoDataErr(&text);
+
+ gpgme_decrypt_result_t d_result = nullptr;
+ gpgme_verify_result_t v_result = nullptr;
+ // try decrypt, if fail do nothing, especially don't replace text
+ auto error = mCtx->decryptVerify(text, decrypted, &d_result, &v_result);
+ infoBoard->associateTextEdit(edit->curTextPage());
+
+ if(gpgme_err_code(error) == GPG_ERR_NO_ERROR)
+ edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted));
+
+ auto resultAnalyseDecrypt = new DecryptResultAnalyse(mCtx, error, d_result);
+ auto resultAnalyseVerify = new VerifyResultAnalyse(mCtx, error, v_result);
+
+ int status = std::min(resultAnalyseDecrypt->getStatus(), resultAnalyseVerify->getStatus());
+ auto &reportText = resultAnalyseDecrypt->getResultReport() + resultAnalyseVerify->getResultReport();
+ if (status < 0)
+ infoBoard->slotRefresh(reportText, INFO_ERROR_CRITICAL);
+ else if (status > 0)
+ infoBoard->slotRefresh(reportText, INFO_ERROR_OK);
+ else
+ infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+
+ if (resultAnalyseVerify->getStatus() >= 0) {
+ infoBoard->resetOptionActionsMenu();
+ infoBoard->addOptionalAction("Show Verify Details", [this, error, v_result]() {
+ VerifyDetailsDialog(this, mCtx, mKeyList, error, v_result);
+ });
+ }
+ delete resultAnalyseDecrypt;
+ delete resultAnalyseVerify;
}
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index bd1aa013..a6be9c3c 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -26,6 +26,7 @@
#include "ui/keygen/KeygenThread.h"
#include <unistd.h> /* contains read/write */
+#include <Mime.h>
#ifdef _WIN32
#include <windows.h>
@@ -381,7 +382,7 @@ namespace GpgME {
gpgme_key_t recipients[keys.count() + 1];
int index = 0;
- for(const auto& key : keys) {
+ for (const auto &key : keys) {
recipients[index++] = key.key_refer;
}
@@ -412,12 +413,43 @@ namespace GpgME {
gpgme_data_release(dataOut);
}
- if(result != nullptr) {
+ if (result != nullptr) {
*result = gpgme_op_encrypt_result(mCtx);
}
return err;
}
+
+ /**
+ * if this is mime, split text and attachments...
+ * message contains only text afterwards
+ */
+ void parseMime(QByteArray *message) {
+
+ QString pText;
+ bool show_ma_dock = false;
+
+ Mime *mime = new Mime(message);
+ for(MimePart tmp : mime->parts()) {
+ if (tmp.header.getValue("Content-Type") == "text/plain" && tmp.header.getValue("Content-Transfer-Encoding") != "base64") {
+ QByteArray body;
+ if (tmp.header.getValue("Content-Transfer-Encoding") == "quoted-printable") {
+ Mime::quotedPrintableDecode(tmp.body, body);
+ } else {
+ body = tmp.body;
+ }
+ pText.append(QString(body));
+ } else {
+ // TODO
+ show_ma_dock = true;
+ }
+ }
+ *message = pText.toUtf8();
+ if (show_ma_dock) {
+ // TODO
+ }
+ }
+
/** Decrypt QByteAarray, return QByteArray
* mainly from http://basket.kde.org/ (kgpgme.cpp)
*/
@@ -425,47 +457,21 @@ namespace GpgME {
GpgContext::decrypt(const QByteArray &inBuffer, QByteArray *outBuffer, gpgme_decrypt_result_t *result) {
gpgme_data_t dataIn = nullptr, dataOut = nullptr;
gpgme_decrypt_result_t m_result = nullptr;
- QString errorString;
outBuffer->resize(0);
- if (mCtx) {
+ if (mCtx != nullptr) {
err = gpgme_data_new_from_mem(&dataIn, inBuffer.data(), inBuffer.size(), 1);
- checkErr(err);
- if (!err) {
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
err = gpgme_data_new(&dataOut);
- checkErr(err);
- if (!err) {
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
err = gpgme_op_decrypt(mCtx, dataIn, dataOut);
- checkErr(err);
-
- if (gpg_err_code(err) == GPG_ERR_DECRYPT_FAILED) {
- errorString.append(gpgErrString(err)).append("<br>");
- m_result = gpgme_op_decrypt_result(mCtx);
- checkErr(m_result->recipients->status);
- errorString.append(gpgErrString(m_result->recipients->status)).append("<br>");
- errorString.append(
- tr("<br>No private key with id %1 present dataIn keyring").arg(
- m_result->recipients->keyid));
- } else {
- errorString.append(gpgErrString(err)).append("<br>");
- }
-
- if (!err) {
- m_result = gpgme_op_decrypt_result(mCtx);
- if (m_result->unsupported_algorithm) {
- QMessageBox::critical(0, tr("Unsupported algorithm"), m_result->unsupported_algorithm);
- } else {
- err = readToBuffer(dataOut, outBuffer);
- checkErr(err);
- }
+ m_result = gpgme_op_decrypt_result(mCtx);
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
+ err = readToBuffer(dataOut, outBuffer);
}
}
}
}
- if (gpg_err_code(err) != GPG_ERR_NO_ERROR && gpg_err_code(err) != GPG_ERR_CANCELED) {
- QMessageBox::critical(nullptr, tr("Error decrypting:"), errorString);
- return false;
- }
if (!settings.value("general/rememberPassword").toBool()) {
clearPasswordCache();
@@ -478,7 +484,29 @@ namespace GpgME {
gpgme_data_release(dataOut);
}
- if(result != nullptr) {
+ /*
+ * 1) is it mime (content-type:)
+ * 2) parse header
+ * 2) choose action depending on content-type
+ */
+ if (Mime::isMime(outBuffer)) {
+ Header header = Mime::getHeader(outBuffer);
+ // is it multipart, is multipart-parsing enabled
+ if (header.getValue("Content-Type") == "multipart/mixed"
+ && settings.value("mime/parseMime").toBool()) {
+ parseMime(outBuffer);
+ } else if (header.getValue("Content-Type") == "text/plain"
+ && settings.value("mime/parseQP").toBool()) {
+ if (header.getValue("Content-Transfer-Encoding") == "quoted-printable") {
+ auto *decoded = new QByteArray();
+ Mime::quotedPrintableDecode(*outBuffer, *decoded);
+ //TODO: remove header
+ outBuffer = decoded;
+ }
+ }
+ }
+
+ if (result != nullptr) {
*result = m_result;
}
return err;
@@ -682,7 +710,7 @@ namespace GpgME {
m_result = gpgme_op_verify_result(mCtx);
- if(result != nullptr) {
+ if (result != nullptr) {
*result = m_result;
}
@@ -709,7 +737,9 @@ namespace GpgME {
verify_result = gpgme_op_verify_result (mCtx);
*/
//}
- gpg_error_t GpgContext::sign(const QVector<GpgKey>& keys, const QByteArray &inBuffer, QByteArray *outBuffer, bool detached, gpgme_sign_result_t *result) {
+ gpg_error_t
+ GpgContext::sign(const QVector<GpgKey> &keys, const QByteArray &inBuffer, QByteArray *outBuffer, bool detached,
+ gpgme_sign_result_t *result) {
gpgme_error_t gpgmeError;
gpgme_data_t dataIn, dataOut;
@@ -763,7 +793,7 @@ namespace GpgME {
m_result = gpgme_op_sign_result(mCtx);
- if(result != nullptr) {
+ if (result != nullptr) {
*result = m_result;
}
@@ -835,8 +865,8 @@ namespace GpgME {
if (key.fpr == fpr) {
return key;
} else {
- for(auto &subkey : key.subKeys) {
- if(subkey.fpr == fpr) {
+ for (auto &subkey : key.subKeys) {
+ if (subkey.fpr == fpr) {
return key;
}
}
@@ -848,9 +878,9 @@ namespace GpgME {
/**
* note: is_private_key status is not returned
*/
- const GpgKey & GpgContext::getKeyById(const QString &id) {
+ const GpgKey &GpgContext::getKeyById(const QString &id) {
- for(const auto &key : mKeyList) {
+ for (const auto &key : mKeyList) {
if (key.id == id) {
return key;
} else {
@@ -884,7 +914,7 @@ namespace GpgME {
auto gpgmeError =
gpgme_op_keysign(mCtx, target.key_refer, uid.toUtf8().constData(), expires_time_t, flags);
- if(gpgmeError == GPG_ERR_NO_ERROR) {
+ if (gpgmeError == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(target.id);
return true;
} else {
@@ -923,22 +953,22 @@ namespace GpgME {
}
}
- void GpgContext::slotUpdateKeyList(QString key_id) {
+ void GpgContext::slotUpdateKeyList(const QString &key_id) {
auto it = mKeyMap.find(key_id);
if (it != mKeyMap.end()) {
gpgme_key_t new_key_refer;
auto gpgmeErr = gpgme_get_key(mCtx, key_id.toUtf8().constData(), &new_key_refer, 0);
- if(gpgme_err_code(gpgmeErr) == GPG_ERR_EOF) {
+ if (gpgme_err_code(gpgmeErr) == GPG_ERR_EOF) {
gpgmeErr = gpgme_get_key(mCtx, key_id.toUtf8().constData(), &new_key_refer, 1);
- if(gpgme_err_code(gpgmeErr) == GPG_ERR_EOF) {
+ if (gpgme_err_code(gpgmeErr) == GPG_ERR_EOF) {
throw std::runtime_error("key_id not found in key database");
}
}
- if(new_key_refer != nullptr) {
+ if (new_key_refer != nullptr) {
it.value()->swapKeyRefer(new_key_refer);
emit signalKeyInfoChanged();
}
@@ -949,11 +979,10 @@ namespace GpgME {
bool GpgContext::addUID(const GpgKey &key, const GpgUID &uid) {
QString userid = QString("%1 (%3) <%2>").arg(uid.name, uid.email, uid.comment);
auto gpgmeError = gpgme_op_adduid(mCtx, key.key_refer, userid.toUtf8().constData(), 0);
- if(gpgmeError == GPG_ERR_NO_ERROR) {
+ if (gpgmeError == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(key.id);
return true;
- }
- else {
+ } else {
checkErr(gpgmeError);
return false;
}
@@ -962,11 +991,10 @@ namespace GpgME {
bool GpgContext::revUID(const GpgKey &key, const GpgUID &uid) {
auto gpgmeError = gpgme_op_revuid(mCtx, key.key_refer, uid.uid.toUtf8().constData(), 0);
- if(gpgmeError == GPG_ERR_NO_ERROR) {
+ if (gpgmeError == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(key.id);
return true;
- }
- else {
+ } else {
checkErr(gpgmeError);
return false;
}
@@ -975,11 +1003,10 @@ namespace GpgME {
bool GpgContext::setPrimaryUID(const GpgKey &key, const GpgUID &uid) {
auto gpgmeError = gpgme_op_set_uid_flag(mCtx, key.key_refer,
uid.uid.toUtf8().constData(), "primary", nullptr);
- if(gpgmeError == GPG_ERR_NO_ERROR) {
+ if (gpgmeError == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(key.id);
return true;
- }
- else {
+ } else {
checkErr(gpgmeError);
return false;
}
@@ -990,13 +1017,12 @@ namespace GpgME {
auto signing_key = getKeyById(signature.keyid);
auto gpgmeError = gpgme_op_revsig(mCtx, key.key_refer,
- signing_key.key_refer,
- signature.uid.toUtf8().constData(), 0);
- if(gpg_err_code(gpgmeError) == GPG_ERR_NO_ERROR) {
+ signing_key.key_refer,
+ signature.uid.toUtf8().constData(), 0);
+ if (gpg_err_code(gpgmeError) == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(key.id);
return true;
- }
- else {
+ } else {
checkErr(gpgmeError);
return false;
}
@@ -1004,7 +1030,7 @@ namespace GpgME {
bool GpgContext::generateSubkey(const GpgKey &key, GenKeyInfo *params) {
- if(!params->isSubKey()) {
+ if (!params->isSubKey()) {
return false;
}
@@ -1038,11 +1064,10 @@ namespace GpgME {
auto gpgmeError = gpgme_op_createsubkey(mCtx, key.key_refer,
algo, 0, expires, flags);
- if(gpgmeError == GPG_ERR_NO_ERROR) {
+ if (gpgmeError == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(key.id);
return true;
- }
- else {
+ } else {
checkErr(gpgmeError);
return false;
}
@@ -1050,33 +1075,33 @@ namespace GpgME {
bool GpgContext::setExpire(const GpgKey &key, const GpgSubKey *subkey, QDateTime *expires) {
unsigned long expires_time = 0;
- if(expires != nullptr) {
+ if (expires != nullptr) {
qDebug() << "Expire Datetime" << expires->toString();
expires_time = QDateTime::currentDateTime().secsTo(*expires);
}
const char *subfprs = nullptr;
- if(subkey != nullptr) {
+ if (subkey != nullptr) {
subfprs = subkey->fpr.toUtf8().constData();
}
auto gpgmeError = gpgme_op_setexpire(mCtx, key.key_refer,
expires_time, subfprs, 0);
- if(gpgmeError == GPG_ERR_NO_ERROR) {
+ if (gpgmeError == GPG_ERR_NO_ERROR) {
emit signalKeyUpdated(key.id);
return true;
- }
- else {
+ } else {
checkErr(gpgmeError);
return false;
}
}
bool GpgContext::checkIfKeyCanSign(const GpgKey &key) {
- if(std::any_of(key.subKeys.begin(), key.subKeys.end(), [] (const GpgSubKey &subkey) -> bool {
+ if (std::any_of(key.subKeys.begin(), key.subKeys.end(), [](const GpgSubKey &subkey) -> bool {
return subkey.secret && subkey.can_sign && !subkey.disabled && !subkey.revoked && !subkey.expired;
- })) return true;
+ }))
+ return true;
return false;
}
@@ -1085,16 +1110,18 @@ namespace GpgME {
}
bool GpgContext::checkIfKeyCanAuth(const GpgKey &key) {
- if(std::any_of(key.subKeys.begin(), key.subKeys.end(), [] (const GpgSubKey &subkey) -> bool {
+ if (std::any_of(key.subKeys.begin(), key.subKeys.end(), [](const GpgSubKey &subkey) -> bool {
return subkey.secret && subkey.can_authenticate && !subkey.disabled && !subkey.revoked && !subkey.expired;
- })) return true;
+ }))
+ return true;
return false;
}
bool GpgContext::checkIfKeyCanEncr(const GpgKey &key) {
- if(std::any_of(key.subKeys.begin(), key.subKeys.end(), [] (const GpgSubKey &subkey) -> bool {
+ if (std::any_of(key.subKeys.begin(), key.subKeys.end(), [](const GpgSubKey &subkey) -> bool {
return subkey.can_encrypt && !subkey.disabled && !subkey.revoked && !subkey.expired;
- })) return true;
+ }))
+ return true;
return false;
}
@@ -1103,11 +1130,6 @@ namespace GpgME {
gpgme_data_t dataIn = nullptr, dataOut = nullptr;
outBuffer->resize(0);
- if (keys.count() == 0) {
- QMessageBox::critical(nullptr, tr("No Key Selected"), tr("No Key Selected"));
- return false;
- }
-
setSigners(keys);
//gpgme_encrypt_result_t e_result;
@@ -1115,25 +1137,25 @@ namespace GpgME {
/* set key for user */
int index = 0;
- for(const auto &key : keys) {
+ for (const auto &key : keys) {
recipients[index++] = key.key_refer;
}
//Last entry dataIn array has to be nullptr
recipients[keys.count()] = nullptr;
//If the last parameter isnt 0, a private copy of data is made
- if (mCtx) {
+ if (mCtx != nullptr) {
err = gpgme_data_new_from_mem(&dataIn, inBuffer.data(), inBuffer.size(), 1);
- checkErr(err);
- if (!err) {
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
err = gpgme_data_new(&dataOut);
- checkErr(err);
- if (!err) {
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
err = gpgme_op_encrypt_sign(mCtx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, dataIn, dataOut);
- checkErr(err);
- if (!err) {
+ if (encr_result != nullptr)
+ *encr_result = gpgme_op_encrypt_result(mCtx);
+ if (sign_result != nullptr)
+ *sign_result = gpgme_op_sign_result(mCtx);
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
err = readToBuffer(dataOut, outBuffer);
- checkErr(err);
}
}
}
@@ -1145,19 +1167,43 @@ namespace GpgME {
gpgme_data_release(dataOut);
}
- if(encr_result != nullptr) {
- *encr_result = gpgme_op_encrypt_result(mCtx);
- }
- if(sign_result != nullptr) {
- *sign_result = gpgme_op_sign_result(mCtx);
- }
-
return err;
}
-}
-
+ gpgme_error_t
+ GpgContext::decryptVerify(const QByteArray &inBuffer, QByteArray *outBuffer, gpgme_decrypt_result_t *decrypt_result,
+ gpgme_verify_result_t *verify_result) {
+ gpgme_data_t dataIn = nullptr, dataOut = nullptr;
+ outBuffer->resize(0);
+ if (mCtx != nullptr) {
+ err = gpgme_data_new_from_mem(&dataIn, inBuffer.data(), inBuffer.size(), 1);
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
+ err = gpgme_data_new(&dataOut);
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
+ err = gpgme_op_decrypt_verify(mCtx, dataIn, dataOut);
+ if (decrypt_result != nullptr)
+ *decrypt_result = gpgme_op_decrypt_result(mCtx);
+ if (verify_result != nullptr)
+ *verify_result = gpgme_op_verify_result(mCtx);
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
+ err = readToBuffer(dataOut, outBuffer);
+ }
+ }
+ }
+ }
+ if (!settings.value("general/rememberPassword").toBool()) {
+ clearPasswordCache();
+ }
+ if (dataIn) {
+ gpgme_data_release(dataIn);
+ }
+ if (dataOut) {
+ gpgme_data_release(dataOut);
+ }
+ return err;
+ }
+} \ No newline at end of file
diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.cpp b/src/gpg/result_analyse/DecryptResultAnalyse.cpp
index 79c6bc51..d0f3ae99 100644
--- a/src/gpg/result_analyse/DecryptResultAnalyse.cpp
+++ b/src/gpg/result_analyse/DecryptResultAnalyse.cpp
@@ -7,36 +7,33 @@
DecryptResultAnalyse::DecryptResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_decrypt_result_t result)
: mCtx(ctx) {
- if(result == nullptr) {
- return;
- }
-
stream << "Decrypt Report: " << endl << "-----" << endl;
if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
stream << "Status: Success" << endl;
} else {
- stream << "Status" << gpgme_strerror(error) << endl;
- if (result->unsupported_algorithm != nullptr) {
+ setStatus(-1);
+ stream << "Status: " << gpgme_strerror(error) << endl;
+
+ if (result != nullptr && result->unsupported_algorithm != nullptr)
stream << "Unsupported algo: " << result->unsupported_algorithm << endl;
- }
}
- if (result->file_name != nullptr) {
- stream << "File name: " << result->file_name << endl;
+ if(result != nullptr) {
+ if (result->file_name != nullptr)
+ stream << "File name: " << result->file_name << endl;
+ stream << endl;
+
+ auto reci = result->recipients;
+ if (reci != nullptr)
+ stream << "Recipient(s): " << endl;
+ while (reci != nullptr) {
+ printReci(stream, reci);
+ reci = reci->next;
+ }
}
- stream << endl;
-
- auto reci = result->recipients;
-
- if (reci != nullptr) {
- stream << "Recipient(s): " << endl;
- }
- while (reci != nullptr) {
- printReci(stream, reci);
- reci = reci->next;
- }
+ stream << "-----" << endl << endl;
}
diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.cpp b/src/gpg/result_analyse/EncryptResultAnalyse.cpp
index f41b88a5..8cdd7750 100644
--- a/src/gpg/result_analyse/EncryptResultAnalyse.cpp
+++ b/src/gpg/result_analyse/EncryptResultAnalyse.cpp
@@ -6,10 +6,6 @@
EncryptResultAnalyse::EncryptResultAnalyse(gpgme_error_t error, gpgme_encrypt_result_t result) {
- if(result == nullptr) {
- return;
- }
-
stream << "# Encrypt Report: " << endl << "-----" << endl;
if(gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
@@ -17,15 +13,17 @@ EncryptResultAnalyse::EncryptResultAnalyse(gpgme_error_t error, gpgme_encrypt_re
}
else {
stream << "Status:" << gpgme_strerror(error) << endl;
- stream << "Invalid Recipients: " << endl;
- setStatus(0);
- auto inv_reci = result->invalid_recipients;
- while(inv_reci != nullptr) {
- stream << "Fingerprint: " << inv_reci->fpr << endl;
- stream << "Reason: " << gpgme_strerror(inv_reci->reason) << endl;
- stream << endl;
-
- inv_reci = inv_reci->next;
+ setStatus(-1);
+ if (result != nullptr) {
+ stream << "Invalid Recipients: " << endl;
+ auto inv_reci = result->invalid_recipients;
+ while (inv_reci != nullptr) {
+ stream << "Fingerprint: " << inv_reci->fpr << endl;
+ stream << "Reason: " << gpgme_strerror(inv_reci->reason) << endl;
+ stream << endl;
+
+ inv_reci = inv_reci->next;
+ }
}
}
diff --git a/src/gpg/result_analyse/SignResultAnalyse.cpp b/src/gpg/result_analyse/SignResultAnalyse.cpp
index eda95ff1..15d6ddf5 100644
--- a/src/gpg/result_analyse/SignResultAnalyse.cpp
+++ b/src/gpg/result_analyse/SignResultAnalyse.cpp
@@ -26,53 +26,56 @@
SignResultAnalyse::SignResultAnalyse(gpgme_error_t error, gpgme_sign_result_t result) {
- if(result == nullptr) {
- return;
- }
-
stream << "# Sign Report: " << endl
<< "-----" << endl;
stream << "Status: " << gpgme_strerror(error) << endl << endl;
- auto new_sign = result->signatures;
+ if(gpg_err_code(error) != GPG_ERR_NO_ERROR) {
+ setStatus(-1);
+ }
- while(new_sign != nullptr) {
- stream << "> A New Signature: " << endl;
+ if(result != nullptr) {
- stream << "Sign mode: ";
- if(new_sign->type == GPGME_SIG_MODE_NORMAL)
- stream << "Normal";
- else if(new_sign->type == GPGME_SIG_MODE_CLEAR)
- stream << "Clear";
- else if(new_sign->type == GPGME_SIG_MODE_DETACH)
- stream << "Detach";
+ auto new_sign = result->signatures;
- stream << endl;
+ while (new_sign != nullptr) {
+ stream << "> A New Signature: " << endl;
- stream << "Public key algo: " << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << endl;
- stream << "Hash algo: " << gpgme_hash_algo_name(new_sign->hash_algo) << endl;
- stream << "Date of signature: " << QDateTime::fromTime_t(new_sign->timestamp).toString() << endl;
+ stream << "Sign mode: ";
+ if (new_sign->type == GPGME_SIG_MODE_NORMAL)
+ stream << "Normal";
+ else if (new_sign->type == GPGME_SIG_MODE_CLEAR)
+ stream << "Clear";
+ else if (new_sign->type == GPGME_SIG_MODE_DETACH)
+ stream << "Detach";
- stream << endl;
+ stream << endl;
- new_sign = new_sign->next;
- }
+ stream << "Public key algo: " << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << endl;
+ stream << "Hash algo: " << gpgme_hash_algo_name(new_sign->hash_algo) << endl;
+ stream << "Date of signature: " << QDateTime::fromTime_t(new_sign->timestamp).toString() << endl;
+
+ stream << endl;
+
+ new_sign = new_sign->next;
+ }
+
+ auto invalid_signer = result->invalid_signers;
- auto invalid_signer = result->invalid_signers;
+ if (invalid_signer != nullptr)
+ stream << "Invalid Signers: " << endl;
- if(invalid_signer!= nullptr)
- stream << "Invalid Signers: " << endl;
+ while (invalid_signer != nullptr) {
+ setStatus(0);
+ stream << "Fingerprint: " << invalid_signer->fpr << endl;
+ stream << "Reason: " << gpgme_strerror(invalid_signer->reason) << endl;
+ stream << endl;
- while(invalid_signer != nullptr) {
- setStatus(0);
- stream << "Fingerprint: " << invalid_signer->fpr << endl;
- stream << "Reason: " << gpgme_strerror(invalid_signer->reason) << endl;
- stream << endl;
+ invalid_signer = invalid_signer->next;
+ }
- invalid_signer = invalid_signer->next;
}
- stream << "-----" << endl;
- stream << endl;
+ stream << "-----" << endl << endl;
}
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
index bb88b7e7..898d62e1 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp
+++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
@@ -8,113 +8,115 @@
VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_verify_result_t result)
: mCtx(ctx) {
- if(result == nullptr) {
- return;
- }
-
stream << "# Verify Report: " << endl << "-----" << endl;
stream << "Status: " << gpgme_strerror(error) << endl;
- auto sign = result->signatures;
+ if(result != nullptr) {
- if (sign == nullptr){
- stream << "> Not Signature Found" << endl;
- status = -1;
- return;
- }
+ auto sign = result->signatures;
+
+ if (sign == nullptr) {
+ stream << "> Not Signature Found" << endl;
+ setStatus(-1);
+ return;
+ }
+
+
+ stream << "> It was Signed ON " << QDateTime::fromTime_t(sign->timestamp).toString() << endl;
+ stream << endl << "> It Contains:" << endl;
- stream << "> It was Signed ON " << QDateTime::fromTime_t(sign->timestamp).toString() << endl;
-
- stream << endl << "> It Contains:" << endl;
-
- bool canContinue = true;
-
- while (sign && canContinue) {
-
- switch (gpg_err_code(sign->status)) {
- case GPG_ERR_BAD_SIGNATURE:
- stream << QApplication::tr("One or More Bad Signatures.") << endl;
- canContinue = false;
- setStatus(-1);
- break;
- case GPG_ERR_NO_ERROR:
- stream << QApplication::tr("A ");
- if(sign->summary & GPGME_SIGSUM_GREEN) {
- stream << QApplication::tr("Good ");
- }
- if(sign->summary & GPGME_SIGSUM_RED) {
- stream << QApplication::tr("Bad ");
- }
- if(sign->summary & GPGME_SIGSUM_SIG_EXPIRED) {
- stream << QApplication::tr("Expired ");
- }
- if(sign->summary & GPGME_SIGSUM_KEY_MISSING) {
- stream << QApplication::tr("Missing Key's ");
- }
- if(sign->summary & GPGME_SIGSUM_KEY_REVOKED) {
- stream << QApplication::tr("Revoked Key's ");
- }
- if(sign->summary & GPGME_SIGSUM_KEY_EXPIRED) {
- stream << QApplication::tr("Expired Key's ");
- }
- if(sign->summary & GPGME_SIGSUM_CRL_MISSING) {
- stream << QApplication::tr("Missing CRL's ");
- }
-
- if(sign->summary & GPGME_SIGSUM_VALID) {
- stream << QApplication::tr("Signature Fully Valid.") << endl;
- } else {
- stream << QApplication::tr("Signature NOT Fully Valid.") << endl;
- }
-
- if(!(sign->status & GPGME_SIGSUM_KEY_MISSING)) {
- if(!printSigner(stream, sign)) {
+ bool canContinue = true;
+
+ while (sign && canContinue) {
+
+ switch (gpg_err_code(sign->status)) {
+ case GPG_ERR_BAD_SIGNATURE:
+ stream << QApplication::tr("One or More Bad Signatures.") << endl;
+ canContinue = false;
+ setStatus(-1);
+ break;
+ case GPG_ERR_NO_ERROR:
+ stream << QApplication::tr("A ");
+ if (sign->summary & GPGME_SIGSUM_GREEN) {
+ stream << QApplication::tr("Good ");
+ }
+ if (sign->summary & GPGME_SIGSUM_RED) {
+ stream << QApplication::tr("Bad ");
+ }
+ if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) {
+ stream << QApplication::tr("Expired ");
+ }
+ if (sign->summary & GPGME_SIGSUM_KEY_MISSING) {
+ stream << QApplication::tr("Missing Key's ");
+ }
+ if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) {
+ stream << QApplication::tr("Revoked Key's ");
+ }
+ if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) {
+ stream << QApplication::tr("Expired Key's ");
+ }
+ if (sign->summary & GPGME_SIGSUM_CRL_MISSING) {
+ stream << QApplication::tr("Missing CRL's ");
+ }
+
+ if (sign->summary & GPGME_SIGSUM_VALID) {
+ stream << QApplication::tr("Signature Fully Valid.") << endl;
+ } else {
+ stream << QApplication::tr("Signature NOT Fully Valid.") << endl;
+ }
+
+ if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) {
+ if (!printSigner(stream, sign)) {
+ setStatus(0);
+ }
+ } else {
+ stream << QApplication::tr("Key is NOT present with ID 0x") << QString(sign->fpr) << endl;
+ }
+
+ setStatus(1);
+
+ break;
+ case GPG_ERR_NO_PUBKEY:
+ stream << QApplication::tr("A signature could NOT be verified due to a Missing Key\n");
+ setStatus(-1);
+ break;
+ case GPG_ERR_CERT_REVOKED:
+ stream << QApplication::tr(
+ "A signature is valid but the key used to verify the signature has been revoked\n");
+ if (!printSigner(stream, sign)) {
+ setStatus(0);
+ }
+ setStatus(-1);
+ break;
+ case GPG_ERR_SIG_EXPIRED:
+ stream << QApplication::tr("A signature is valid but expired\n");
+ if (!printSigner(stream, sign)) {
+ setStatus(0);
+ }
+ setStatus(-1);
+ break;
+ case GPG_ERR_KEY_EXPIRED:
+ stream << QApplication::tr(
+ "A signature is valid but the key used to verify the signature has expired.\n");
+ if (!printSigner(stream, sign)) {
setStatus(0);
}
- } else {
- stream << QApplication::tr("Key is NOT present with ID 0x") << QString(sign->fpr) << endl;
- }
-
- setStatus(1);
-
- break;
- case GPG_ERR_NO_PUBKEY:
- stream << QApplication::tr("A signature could NOT be verified due to a Missing Key\n");
- setStatus(-1);
- break;
- case GPG_ERR_CERT_REVOKED:
- stream << QApplication::tr("A signature is valid but the key used to verify the signature has been revoked\n");
- if(!printSigner(stream, sign)) {
- setStatus(0);
- }
- setStatus(-1);
- break;
- case GPG_ERR_SIG_EXPIRED:
- stream << QApplication::tr("A signature is valid but expired\n");
- if(!printSigner(stream, sign)) {
- setStatus(0);
- }
- setStatus(-1);
- break;
- case GPG_ERR_KEY_EXPIRED:
- stream << QApplication::tr("A signature is valid but the key used to verify the signature has expired.\n");
- if(!printSigner(stream, sign)) {
- setStatus(0);
- }
- break;
- case GPG_ERR_GENERAL:
- stream << QApplication::tr("There was some other error which prevented the signature verification.\n");
- status = -1;
- canContinue = false;
- break;
- default:
- stream << QApplication::tr("Error for key with fingerprint ") <<
- GpgME::GpgContext::beautifyFingerprint(QString(sign->fpr));
- setStatus(-1);
+ break;
+ case GPG_ERR_GENERAL:
+ stream << QApplication::tr(
+ "There was some other error which prevented the signature verification.\n");
+ status = -1;
+ canContinue = false;
+ break;
+ default:
+ stream << QApplication::tr("Error for key with fingerprint ") <<
+ GpgME::GpgContext::beautifyFingerprint(QString(sign->fpr));
+ setStatus(-1);
+ }
+ stream << endl;
+ sign = sign->next;
}
- stream << endl;
- sign = sign->next;
}
stream << "-----" << endl;
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp
index e32a1092..76c98601 100755
--- a/src/ui/KeyMgmt.cpp
+++ b/src/ui/KeyMgmt.cpp
@@ -119,7 +119,7 @@ void KeyMgmt::createActions()
deleteCheckedKeysAct = new QAction(tr("Delete Checked Key(s)"), this);
deleteCheckedKeysAct->setToolTip(tr("Delete the Checked keys"));
- deleteCheckedKeysAct->setIcon(QIcon(":button_cancel.png"));
+ deleteCheckedKeysAct->setIcon(QIcon(":button_delete.png"));
connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteCheckedKeys()));
showKeyDetailsAct = new QAction(tr("Show Keydetails"), this);
@@ -269,6 +269,7 @@ void KeyMgmt::slotExportKeyToFile()
{
auto *keyArray = new QByteArray();
if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) {
+ delete keyArray;
return;
}
auto &key = mCtx->getKeyById(mKeyList->getSelected()->first());
@@ -276,8 +277,10 @@ void KeyMgmt::slotExportKeyToFile()
QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)");
QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ delete keyArray;
return;
+ }
QTextStream stream(&file);
stream << *keyArray;
file.close();
diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp
index a0775acc..789e194d 100644
--- a/src/ui/KeyServerImportDialog.cpp
+++ b/src/ui/KeyServerImportDialog.cpp
@@ -132,7 +132,7 @@ void KeyServerImportDialog::setMessage(const QString &text, bool error) {
}
void KeyServerImportDialog::slotSearch() {
- QUrl urlFromRemote = keyServerComboBox->currentText() + ":11371/pks/lookup?search=" + searchLineEdit->text() +
+ QUrl urlFromRemote = keyServerComboBox->currentText() + "/pks/lookup?search=" + searchLineEdit->text() +
"&op=index&options=mr";
qnam = new QNetworkAccessManager(this);
QNetworkReply *reply = qnam->get(QNetworkRequest(urlFromRemote));
@@ -175,10 +175,10 @@ void KeyServerImportDialog::slotSearchFinished() {
}
} else {
int row = 0;
- char buff[1024];
bool strikeout = false;
- while (reply->readLine(buff, sizeof(buff)) != -1) {
- QString decoded = QString::fromUtf8(QByteArray::fromPercentEncoding(buff));
+ while (reply->canReadLine()) {
+ auto line_buff = reply->readLine().trimmed();
+ QString decoded = QString::fromUtf8(line_buff.constData(), line_buff.size());
QStringList line = decoded.split(":");
//TODO: have a look at two following pub lines