diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-07-26 01:41:06 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-07-26 01:41:06 +0000 |
commit | 9bcd46bc010b64f2bff14463db3c4c0e82ff693b (patch) | |
tree | 358bde0b5402723d16cdc43d162bef462ce1586e | |
parent | added isCompletelySigned function (diff) | |
download | gpg4usb-9bcd46bc010b64f2bff14463db3c4c0e82ff693b.tar.gz gpg4usb-9bcd46bc010b64f2bff14463db3c4c0e82ff693b.zip |
changed bool iscompletlysigned to int issigned and added setverifylabel to verifynotification-class
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@505 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | context.cpp | 14 | ||||
-rw-r--r-- | gpgwin.cpp | 25 | ||||
-rw-r--r-- | gpgwin.h | 2 | ||||
-rw-r--r-- | verifynotification.cpp | 8 | ||||
-rw-r--r-- | verifynotification.h | 4 |
5 files changed, 24 insertions, 29 deletions
diff --git a/context.cpp b/context.cpp index 49af498..f8ca426 100644 --- a/context.cpp +++ b/context.cpp @@ -519,21 +519,7 @@ gpgme_signature_t Context::verify(QByteArray inBuffer) { } result = gpgme_op_verify_result (mCtx); - sign = result->signatures; - -/* while (sign) { - qDebug() << "sig summary: " << sign->summary; - qDebug() << "sig fingerprint: " << sign->fpr; - qDebug() << "sig status: " << sign->status << " - " << gpg_err_code(sign->status) << " - " << gpg_strerror(sign->status); - if (sign->status != 0) { - error = 1; - } - qDebug() << "sig validity: " << sign->validity; - qDebug() << "sig validity reason: " << sign->validity_reason << " - " << gpg_err_code(sign->validity_reason) << " - " << gpgme_strerror(sign->validity_reason); - sign = sign->next; - } -*/ return sign; } @@ -708,15 +708,20 @@ void GpgWin::sign() cursor.endEditBlock(); } } -bool GpgWin::isCompletedlySigned(const QByteArray &text) { - +/* + * isSigned returns: + * - 0, if text isn't signed at all + * - 1, if text is partially signed + * - 2, if text is completly signed + */ +int GpgWin::isSigned(const QByteArray &text) { if (text.startsWith("-----BEGIN PGP SIGNED MESSAGE-----") && text.endsWith("-----END PGP SIGNATURE-----")) { - qDebug() << "totally signed"; - return true; - } else { - qDebug("partially signed"); - return false; + return 2; } + if (text.contains("-----BEGIN PGP SIGNED MESSAGE-----") && text.contains("-----END PGP SIGNATURE-----")) { + return 1; + } + return 0; } void GpgWin::verify() @@ -725,7 +730,7 @@ void GpgWin::verify() QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here? preventNoDataErr(&text); - isCompletedlySigned(text); + isSigned(text); gpgme_signature_t sign = mCtx->verify(text); @@ -734,10 +739,10 @@ void GpgWin::verify() } else { // TODO: should get verifynotification get the whole signature for analysizing VerifyNotification *vn = new VerifyNotification(); + vn->setVerifyLabel(QString("Verified")); edit->curPage()->showNotificationWidget(vn); } - // while (sign) { qDebug() << "sig summary: " << sign->summary; qDebug() << "sig fingerprint: " << sign->fpr; @@ -748,9 +753,7 @@ void GpgWin::verify() qDebug() << "kein passender Schlüssel gefunden. Vom Schlüsselserver importieren?"; } sign = sign->next; - } - } void GpgWin::importKeyDialog() @@ -98,7 +98,7 @@ private: void saveSettings(); void preventNoDataErr(QByteArray *in); void parseMime(QByteArray *message); - bool isCompletedlySigned(const QByteArray &text); + int isSigned(const QByteArray &text); TextEdit *edit; QMenu *fileMenu; diff --git a/verifynotification.cpp b/verifynotification.cpp index 0c42fdf..2de1a2a 100644 --- a/verifynotification.cpp +++ b/verifynotification.cpp @@ -3,7 +3,7 @@ VerifyNotification::VerifyNotification(QWidget *parent) : QWidget(parent) { - QLabel *verifyLabel = new QLabel("Verified"); + verifyLabel = new QLabel("Verified"); QHBoxLayout *notificationWidgetLayout = new QHBoxLayout(); notificationWidgetLayout->setContentsMargins(0,0,0,0); @@ -25,6 +25,10 @@ VerifyNotification::VerifyNotification(QWidget *parent) : verifyButton->setMenu(verifyMenu); notificationWidgetLayout->addStretch(1); notificationWidgetLayout->addWidget(verifyButton); +} - +void VerifyNotification::setVerifyLabel(QString text) +{ + verifyLabel->setText(text); + return; } diff --git a/verifynotification.h b/verifynotification.h index 13c5fd0..539504f 100644 --- a/verifynotification.h +++ b/verifynotification.h @@ -13,11 +13,13 @@ class VerifyNotification : public QWidget Q_OBJECT public: explicit VerifyNotification(QWidget *parent = 0); - + void setVerifyLabel(QString text); signals: public slots: +private: + QLabel *verifyLabel; }; #endif // VERIFYNOTIFICATION_H |