aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-10-17 23:49:14 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-10-17 23:49:14 +0000
commitd6f1fc5d0165d8cfc03f2f276addaf8bfb48f2b9 (patch)
treeb1dea76f4cf504c3bef580688e11f863591e0664
parentclose verifynotification on textchange() (diff)
downloadgpg4usb-d6f1fc5d0165d8cfc03f2f276addaf8bfb48f2b9.tar.gz
gpg4usb-d6f1fc5d0165d8cfc03f2f276addaf8bfb48f2b9.zip
more visible error if GPG_ERR_BAD_SIGNATURE
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@561 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--keylist.cpp18
-rw-r--r--keylist.h1
-rw-r--r--verifydetailsdialog.cpp28
-rw-r--r--verifykeydetailbox.cpp14
-rw-r--r--verifynotification.cpp82
5 files changed, 95 insertions, 48 deletions
diff --git a/keylist.cpp b/keylist.cpp
index f93f45f..01ae4dd 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -122,6 +122,24 @@ GpgKey KeyList::getKeyByFpr(QString fpr) {
return key;
}
+
+/**
+ * note: privkey status is not returned
+ */
+GpgKey KeyList::getKeyById(QString id) {
+ GpgKey key;
+ for (int i = 0; i < mKeyList->rowCount(); i++) {
+ if (mKeyList->item(i, 4)->text() == id) {
+ //key.privkey = mKeyList->item(i,1)->text();
+ key.id = mKeyList->item(i,4)->text();
+ key.name = mKeyList->item(i,2)->text();
+ key.email = mKeyList->item(i,3)->text();
+ key.fpr = mKeyList->item(i,5)->text();
+ }
+ }
+ return key;
+}
+
QStringList *KeyList::getChecked()
{
QStringList *ret = new QStringList();
diff --git a/keylist.h b/keylist.h
index be91e1e..b0985fe 100644
--- a/keylist.h
+++ b/keylist.h
@@ -44,6 +44,7 @@ public:
QStringList *getChecked();
QStringList *getPrivateChecked();
GpgKey getKeyByFpr(QString fpr);
+ GpgKey getKeyById(QString id);
void setChecked(QStringList *keyIds);
//QStringList *getPrivateChecked();
diff --git a/verifydetailsdialog.cpp b/verifydetailsdialog.cpp
index 7ccde37..8098210 100644
--- a/verifydetailsdialog.cpp
+++ b/verifydetailsdialog.cpp
@@ -56,18 +56,22 @@ void VerifyDetailsDialog::refresh()
timestamp.setTime_t(sign->timestamp);
// Set the title widget depending on sign status
- switch (mCtx->textIsSigned(text))
- {
- case 2:
- {
- mVboxLayout->addWidget(new QLabel(tr("Text was completely signed on\n %1 by:\n").arg(timestamp.toString(Qt::SystemLocaleLongDate))));
- break;
- }
- case 1:
- {
- mVboxLayout->addWidget(new QLabel(tr("Text was partially signed on\n %1 by:\n").arg(timestamp.toString(Qt::SystemLocaleLongDate))));
- break;
- }
+ if(gpg_err_code(sign->status) == GPG_ERR_BAD_SIGNATURE) {
+ mVboxLayout->addWidget(new QLabel(tr("Error Validating signature")));
+ } else {
+ switch (mCtx->textIsSigned(text))
+ {
+ case 2:
+ {
+ mVboxLayout->addWidget(new QLabel(tr("Text was completely signed on\n %1 by:\n").arg(timestamp.toString(Qt::SystemLocaleLongDate))));
+ break;
+ }
+ case 1:
+ {
+ mVboxLayout->addWidget(new QLabel(tr("Text was partially signed on\n %1 by:\n").arg(timestamp.toString(Qt::SystemLocaleLongDate))));
+ break;
+ }
+ }
}
// Add informationbox for every single key
diff --git a/verifykeydetailbox.cpp b/verifykeydetailbox.cpp
index 75d0a12..c06fa5c 100644
--- a/verifykeydetailbox.cpp
+++ b/verifykeydetailbox.cpp
@@ -65,11 +65,17 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget *parent, GpgME::Context* ctx, Key
}
default:
{
- grid->addWidget(new QLabel(tr("Status:")), 0, 0);
- grid->addWidget(new QLabel(tr("Fingerprint:")), 1, 0);
+ GpgKey key = mKeyList->getKeyById(signature->fpr);
+ this->setTitle(tr("Error for key with id 0x") + fpr);
+ grid->addWidget(new QLabel(tr("Name:")), 0, 0);
+ grid->addWidget(new QLabel(tr("EMail:")), 1, 0);
+ grid->addWidget(new QLabel(tr("Status:")), 2, 0);
+ grid->addWidget(new QLabel(tr("Fingerprint:")), 3, 0);
- grid->addWidget(new QLabel(gpg_strerror(signature->status)), 0, 1);
- grid->addWidget(new QLabel(beautifyFingerprint(signature->fpr)), 1, 1);
+ grid->addWidget(new QLabel(key.name), 0, 1);
+ grid->addWidget(new QLabel(key.email), 1, 1);
+ grid->addWidget(new QLabel(gpg_strerror(signature->status)), 2, 1);
+ grid->addWidget(new QLabel(beautifyFingerprint(key.fpr)), 3, 1);
break;
}
diff --git a/verifynotification.cpp b/verifynotification.cpp
index 9cb2fce..d6bac9e 100644
--- a/verifynotification.cpp
+++ b/verifynotification.cpp
@@ -110,29 +110,42 @@ bool VerifyNotification::refresh()
while (sign) {
switch (gpg_err_code(sign->status))
{
- case GPG_ERR_NO_PUBKEY:
- {
- verifyStatus=VERIFY_ERROR_WARN;
- verifyLabelText.append(tr("Key not present with id 0x")+QString(sign->fpr));
- this->keysNotInList->append(sign->fpr);
- unknownKeyFound=true;
- break;
- }
- case GPG_ERR_NO_ERROR:
- {
- GpgKey key = mKeyList->getKeyByFpr(sign->fpr);
- verifyLabelText.append(key.name);
- if (!key.email.isEmpty()) {
- verifyLabelText.append("<"+key.email+">");
+ case GPG_ERR_NO_PUBKEY:
+ {
+ verifyStatus=VERIFY_ERROR_WARN;
+ verifyLabelText.append(tr("Key not present with id 0x")+QString(sign->fpr));
+ this->keysNotInList->append(sign->fpr);
+ unknownKeyFound=true;
+ break;
+ }
+ case GPG_ERR_NO_ERROR:
+ {
+ GpgKey key = mKeyList->getKeyByFpr(sign->fpr);
+ verifyLabelText.append(key.name);
+ if (!key.email.isEmpty()) {
+ verifyLabelText.append("<"+key.email+">");
+ }
+ break;
+ }
+ case GPG_ERR_BAD_SIGNATURE:
+ {
+ textIsSigned = 3;
+ verifyStatus=VERIFY_ERROR_CRITICAL;
+ GpgKey key = mKeyList->getKeyById(sign->fpr);
+ verifyLabelText.append(key.name);
+ if (!key.email.isEmpty()) {
+ verifyLabelText.append("<"+key.email+">");
+ }
+ break;
+ }
+ default:
+ {
+ //textIsSigned = 3;
+ verifyStatus=VERIFY_ERROR_WARN;
+ //GpgKey key = mKeyList->getKeyByFpr(sign->fpr);
+ verifyLabelText.append(tr("Error for key with fingerprint ")+mCtx->beautifyFingerprint(QString(sign->fpr)));
+ break;
}
- break;
- }
- default:
- {
- verifyStatus=VERIFY_ERROR_WARN;
- verifyLabelText.append(tr("Error for key with fingerprint ")+mCtx->beautifyFingerprint(QString(sign->fpr)));
- break;
- }
}
verifyLabelText.append("\n");
sign = sign->next;
@@ -140,16 +153,21 @@ bool VerifyNotification::refresh()
switch (textIsSigned)
{
- case 2:
- {
- verifyLabelText.prepend(tr("Text was completely signed by: "));
- break;
- }
- case 1:
- {
- verifyLabelText.prepend(tr("Text was partially signed by: "));
- break;
- }
+ case 3:
+ {
+ verifyLabelText.prepend(tr("Error validating signature by: "));
+ break;
+ }
+ case 2:
+ {
+ verifyLabelText.prepend(tr("Text was completely signed by: "));
+ break;
+ }
+ case 1:
+ {
+ verifyLabelText.prepend(tr("Text was partially signed by: "));
+ break;
+ }
}
// If an unknown key is found, enable the importfromkeyserveraction