summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2017-12-07 11:29:46 +0100
committerAndre Heinecke <[email protected]>2017-12-07 11:29:46 +0100
commit58b9c4e03e045fab59a5f14d4e1f999f35005e42 (patch)
treee9ffbd9d3e753c70c26e652495a2720e1de527b4
parent59ebf371ec05662abf2656e243c567b6541bd1d0 (diff)
Readd Certifications view in Cert Details
This was lost in the new detailswidget. Now we have it again as simple treeview of the useridlistmodel.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/dialogs/certificatedetailswidget.cpp14
-rw-r--r--src/dialogs/certificatedetailswidget.ui187
-rw-r--r--src/dialogs/weboftrustdialog.cpp68
-rw-r--r--src/dialogs/weboftrustdialog.h47
-rw-r--r--src/dialogs/weboftrustwidget.cpp136
-rw-r--r--src/dialogs/weboftrustwidget.h46
7 files changed, 417 insertions, 83 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8b87e43..7ebe844 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -117,6 +117,8 @@ set(_kleopatra_SRCS
dialogs/setinitialpindialog.cpp
dialogs/certificatedetailswidget.cpp
dialogs/trustchainwidget.cpp
+ dialogs/weboftrustwidget.cpp
+ dialogs/weboftrustdialog.cpp
dialogs/subkeyswidget.cpp
dialogs/gencardkeydialog.cpp
dialogs/updatenotification.cpp
diff --git a/src/dialogs/certificatedetailswidget.cpp b/src/dialogs/certificatedetailswidget.cpp
index 204d358..10c8860 100644
--- a/src/dialogs/certificatedetailswidget.cpp
+++ b/src/dialogs/certificatedetailswidget.cpp
@@ -20,6 +20,7 @@
#include "kleopatra_debug.h"
#include "trustchainwidget.h"
#include "subkeyswidget.h"
+#include "weboftrustdialog.h"
#include "commands/changepassphrasecommand.h"
#include "commands/changeexpirycommand.h"
@@ -48,6 +49,8 @@
Q_DECLARE_METATYPE(GpgME::UserID)
+using namespace Kleo;
+
class CertificateDetailsWidget::Private
{
public:
@@ -62,6 +65,7 @@ public:
void revokeUID(const GpgME::UserID &uid);
void genRevokeCert();
void certifyClicked();
+ void webOfTrustClicked();
void addUserID();
void changePassphrase();
void changeExpiration();
@@ -96,6 +100,7 @@ void CertificateDetailsWidget::Private::setupCommonProperties()
ui.certifyBtn->setVisible(isOpenPGP && !hasSecret);
ui.changeExpirationBtn->setVisible(isOpenPGP && hasSecret);
ui.addUserIDBtn->setVisible(hasSecret);
+ ui.webOfTrustBtn->setVisible(isOpenPGP);
ui.hboxLayout_1->addStretch(1);
@@ -223,6 +228,13 @@ void CertificateDetailsWidget::Private::certifyClicked()
cmd->start();
}
+void CertificateDetailsWidget::Private::webOfTrustClicked()
+{
+ QScopedPointer<WebOfTrustDialog> dlg(new WebOfTrustDialog(q));
+ dlg->setKey(key);
+ dlg->exec();
+}
+
void CertificateDetailsWidget::Private::addUserID()
{
auto cmd = new Kleo::Commands::AddUserIDCommand(key);
@@ -443,6 +455,8 @@ CertificateDetailsWidget::CertificateDetailsWidget(QWidget *parent)
this, [this]() { d->publishCertificate(); });
connect(d->ui.certifyBtn, &QPushButton::clicked,
this, [this]() { d->certifyClicked(); });
+ connect(d->ui.webOfTrustBtn, &QPushButton::clicked,
+ this, [this]() { d->webOfTrustClicked(); });
connect(Kleo::KeyCache::instance().get(), &Kleo::KeyCache::keysMayHaveChanged,
this, [this]() { d->keysMayHaveChanged(); });
diff --git a/src/dialogs/certificatedetailswidget.ui b/src/dialogs/certificatedetailswidget.ui
index b2867b1..dbedce2 100644
--- a/src/dialogs/certificatedetailswidget.ui
+++ b/src/dialogs/certificatedetailswidget.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>631</width>
+ <width>701</width>
<height>571</height>
</rect>
</property>
@@ -51,14 +51,14 @@
</item>
<item>
<widget class="QPushButton" name="genRevokeBtn">
- <property name="text">
- <string>Generate &amp;revocation certificate</string>
- </property>
<property name="toolTip">
- <string>A revocation certificate is a file that serves as a "kill switch" to publicly
-declare that a key shall not anymore be used. It is not possible"
+ <string>A revocation certificate is a file that serves as a &quot;kill switch&quot; to publicly
+declare that a key shall not anymore be used. It is not possible&quot;
to retract such a revocation certificate once it has been published.</string>
</property>
+ <property name="text">
+ <string>Generate &amp;revocation certificate</string>
+ </property>
</widget>
</item>
<item>
@@ -78,63 +78,41 @@ to retract such a revocation certificate once it has been published.</string>
<property name="flat">
<bool>false</bool>
</property>
- <layout class="QGridLayout" name="gridLayout_3">
- <property name="horizontalSpacing">
- <number>60</number>
- </property>
- <property name="verticalSpacing">
- <number>6</number>
- </property>
- <item row="1" column="0">
- <widget class="QLabel" name="expiresLbl">
- <property name="text">
- <string>Expires:</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1" colspan="2">
- <widget class="QLabel" name="smimeIssuer">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="validFromLbl">
<property name="text">
- <string>unknown</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::TextBrowserInteraction</set>
+ <string>Valid from:</string>
</property>
</widget>
</item>
- <item row="7" column="0">
- <widget class="QLabel" name="compliance">
+ <item row="0" column="1">
+ <widget class="QLabel" name="validFrom">
<property name="text">
- <string>Compliance:</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
+ <string>00/00/00</string>
</property>
<property name="textInteractionFlags">
- <set>Qt::TextBrowserInteraction</set>
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
- <item row="7" column="1" colspan="2">
- <widget class="QLabel" name="complianceLbl">
- <property name="text">
- <string>unknown</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
+ <item row="0" column="2">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="textInteractionFlags">
- <set>Qt::TextBrowserInteraction</set>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
</property>
- </widget>
+ </spacer>
</item>
- <item row="8" column="0">
- <widget class="QPushButton" name="moreDetailsBtn">
+ <item row="1" column="0">
+ <widget class="QLabel" name="expiresLbl">
<property name="text">
- <string>&amp;More details...</string>
+ <string>Expires:</string>
</property>
</widget>
</item>
@@ -152,9 +130,12 @@ to retract such a revocation certificate once it has been published.</string>
</item>
<item>
<widget class="QToolButton" name="changeExpirationBtn">
- <property name="text">
+ <property name="toolTip">
<string>Change</string>
</property>
+ <property name="text">
+ <string/>
+ </property>
<property name="icon">
<iconset theme="editor">
<normaloff>.</normaloff>.</iconset>
@@ -172,14 +153,14 @@ to retract such a revocation certificate once it has been published.</string>
</item>
</layout>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="validFromLbl">
+ <item row="2" column="0">
+ <widget class="QLabel" name="typeLbl">
<property name="text">
- <string>Valid from:</string>
+ <string>Type:</string>
</property>
</widget>
</item>
- <item row="2" column="1" colspan="2">
+ <item row="2" column="1">
<widget class="QLabel" name="type">
<property name="text">
<string>unknown</string>
@@ -196,67 +177,107 @@ to retract such a revocation certificate once it has been published.</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLabel" name="validFrom">
+ <item row="3" column="1" colspan="2">
+ <widget class="QLabel" name="fingerprint">
<property name="text">
- <string>00/00/00</string>
+ <string>unknown</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
- <item row="6" column="0">
- <widget class="QLabel" name="smimeIssuerLbl">
+ <item row="4" column="0">
+ <widget class="QLabel" name="publishingLbl">
<property name="text">
- <string>Issuer:</string>
+ <string>Publishing:</string>
</property>
</widget>
</item>
- <item row="5" column="0">
- <widget class="QLabel" name="publishingLbl">
+ <item row="4" column="1">
+ <widget class="QPushButton" name="publishing">
<property name="text">
- <string>Publishing:</string>
+ <string>Publish Certificate</string>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="typeLbl">
+ <item row="5" column="0">
+ <widget class="QLabel" name="smimeIssuerLbl">
<property name="text">
- <string>Type:</string>
+ <string>Issuer:</string>
</property>
</widget>
</item>
- <item row="0" column="2">
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <item row="5" column="1" colspan="2">
+ <widget class="QLabel" name="smimeIssuer">
+ <property name="text">
+ <string>unknown</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ <property name="wordWrap">
+ <bool>true</bool>
</property>
- </spacer>
+ <property name="textInteractionFlags">
+ <set>Qt::TextBrowserInteraction</set>
+ </property>
+ </widget>
</item>
- <item row="3" column="1" colspan="2">
- <widget class="QLabel" name="fingerprint">
+ <item row="6" column="0">
+ <widget class="QLabel" name="compliance">
<property name="text">
- <string>unknown</string>
+ <string>Compliance:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
</property>
<property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ <set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
- <item row="5" column="1">
- <widget class="QPushButton" name="publishing">
+ <item row="6" column="1">
+ <widget class="QLabel" name="complianceLbl">
<property name="text">
- <string>Publish Certificate</string>
+ <string>unknown</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
+ <item row="7" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="moreDetailsBtn">
+ <property name="text">
+ <string>&amp;More details...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="webOfTrustBtn">
+ <property name="text">
+ <string>&amp;Certifications...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/dialogs/weboftrustdialog.cpp b/src/dialogs/weboftrustdialog.cpp
new file mode 100644
index 0000000..933b84d
--- /dev/null
+++ b/src/dialogs/weboftrustdialog.cpp
@@ -0,0 +1,68 @@
+/* Copyright (c) 2017 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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 "weboftrustdialog.h"
+#include "weboftrustwidget.h"
+
+#include <QDialogButtonBox>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+#include <gpgme++/key.h>
+
+#include <KLocalizedString>
+#include <KSharedConfig>
+#include <KConfigGroup>
+
+using namespace Kleo;
+
+WebOfTrustDialog::WebOfTrustDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ KConfigGroup dialog(KSharedConfig::openConfig(), "WebOfTrustDialog");
+ const QSize size = dialog.readEntry("Size", QSize(900, 400));
+ if (size.isValid()) {
+ resize(size);
+ }
+ setWindowTitle(i18n("Certifications"));
+
+ mWidget = new WebOfTrustWidget(this);
+ auto l = new QVBoxLayout(this);
+ l->addWidget(mWidget);
+
+ auto bbox = new QDialogButtonBox(this);
+ auto btn = bbox->addButton(QDialogButtonBox::Close);
+ connect(btn, &QPushButton::pressed, this, &QDialog::accept);
+ l->addWidget(bbox);
+}
+
+void WebOfTrustDialog::setKey(const GpgME::Key &key)
+{
+ mWidget->setKey(key);
+}
+
+GpgME::Key WebOfTrustDialog::key() const
+{
+ return mWidget->key();
+}
+
+WebOfTrustDialog::~WebOfTrustDialog()
+{
+ KConfigGroup dialog(KSharedConfig::openConfig(), "WebOfTrustDialog");
+ dialog.writeEntry("Size", size());
+ dialog.sync();
+}
diff --git a/src/dialogs/weboftrustdialog.h b/src/dialogs/weboftrustdialog.h
new file mode 100644
index 0000000..1402ee3
--- /dev/null
+++ b/src/dialogs/weboftrustdialog.h
@@ -0,0 +1,47 @@
+/* Copyright (c) 2017 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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 KLEO_WEBOFTRUSTDIALOG_H
+#define KLEO_WEBOFTRUSTDIALOG_H
+
+#include <QWidget>
+#include <QDialog>
+
+namespace GpgME {
+class Key;
+}
+
+namespace Kleo {
+class WebOfTrustWidget;
+
+class WebOfTrustDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit WebOfTrustDialog(QWidget *parent = nullptr);
+ ~WebOfTrustDialog();
+
+ void setKey(const GpgME::Key &key);
+ GpgME::Key key() const;
+
+private:
+ WebOfTrustWidget *mWidget;
+};
+
+} // namespace Kleo
+#endif
diff --git a/src/dialogs/weboftrustwidget.cpp b/src/dialogs/weboftrustwidget.cpp
new file mode 100644
index 0000000..89e6eed
--- /dev/null
+++ b/src/dialogs/weboftrustwidget.cpp
@@ -0,0 +1,136 @@
+/* Copyright (c) 2017 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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 <QHBoxLayout>
+#include <QHeaderView>
+#include <QVBoxLayout>
+#include <QTreeView>
+
+#include <gpgme++/key.h>
+#include <gpgme++/keylistresult.h>
+
+#include <QGpgME/Protocol>
+#include <QGpgME/KeyListJob>
+
+#include <Libkleo/UserIDListModel>
+
+#include "weboftrustwidget.h"
+#include "kleopatra_debug.h"
+
+#include <KMessageBox>
+#include <KLocalizedString>
+
+using namespace Kleo;
+
+class WebOfTrustWidget::Private
+{
+public:
+ Private(WebOfTrustWidget *qq)
+ : q(qq)
+ {
+ certificationsTV = new QTreeView;
+ certificationsTV->setModel(&certificationsModel);
+ certificationsTV->setAllColumnsShowFocus(true);
+ certificationsTV->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ auto vLay = new QVBoxLayout;
+ vLay->addWidget(certificationsTV);
+
+ q->setLayout(vLay);
+ }
+
+
+ void startSignatureListing()
+ {
+ if (keyListJob) {
+ return;
+ }
+ QGpgME::KeyListJob *const job = QGpgME::openpgp()->keyListJob(/*remote*/false, /*includeSigs*/true, /*validate*/true);
+ if (!job) {
+ return;
+ }
+
+ connect(job, &QGpgME::KeyListJob::result,
+ q, [this](GpgME::KeyListResult result, std::vector<GpgME::Key>, QString, GpgME::Error) {
+ signatureListingDone(result);
+ });
+
+ connect(job, &QGpgME::KeyListJob::nextKey,
+ q, [this](const GpgME::Key &key) {
+ signatureListingNextKey (key);
+ });
+ job->start(QStringList(QString::fromLatin1(key.primaryFingerprint())));
+ keyListJob = job;
+ }
+
+ void signatureListingNextKey(const GpgME::Key &key)
+ {
+ GpgME::Key merged = key;
+ merged.mergeWith(this->key);
+ q->setKey(merged);
+ }
+
+ void signatureListingDone(const GpgME::KeyListResult &result)
+ {
+ if (result.error()) {
+ KMessageBox::information(q, xi18nc("@info",
+ "<para>An error occurred while loading the certifications: "
+ "<message>%1</message></para>",
+ QString::fromLocal8Bit(result.error().asString())),
+ i18nc("@title", "Certifications Loading Failed"));
+ }
+ keyListJob = nullptr;
+ }
+
+ GpgME::Key key;
+ UserIDListModel certificationsModel;
+ QGpgME::KeyListJob *keyListJob;
+ QTreeView *certificationsTV;
+
+private:
+ WebOfTrustWidget *q;
+};
+
+
+WebOfTrustWidget::WebOfTrustWidget(QWidget *parent) :
+ QWidget(parent),
+ d(new Private(this))
+{
+}
+
+GpgME::Key WebOfTrustWidget::key() const
+{
+ return d->key;
+}
+
+void WebOfTrustWidget::setKey(const GpgME::Key &key)
+{
+ if (key.protocol() != GpgME::OpenPGP) {
+ qCDebug(KLEOPATRA_LOG) << "Trust chain is only supported for CMS keys";
+ return;
+ }
+
+ d->key = key;
+ d->certificationsModel.setKey(key);
+ d->certificationsTV->expandAll();
+ d->certificationsTV->header()->resizeSections(QHeaderView::ResizeToContents);
+ d->startSignatureListing();
+}
+
+WebOfTrustWidget::~WebOfTrustWidget()
+{
+}
diff --git a/src/dialogs/weboftrustwidget.h b/src/dialogs/weboftrustwidget.h
new file mode 100644
index 0000000..1396dda
--- /dev/null
+++ b/src/dialogs/weboftrustwidget.h
@@ -0,0 +1,46 @@
+/* Copyright (c) 2017 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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 KLEO_WEBOFTRUSTWIDGET_H
+#define KLEO_WEBOFTRUSTWIDGET_H
+
+#include <QWidget>
+
+namespace GpgME {
+class Key;
+}
+
+namespace Kleo {
+
+class WebOfTrustWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit WebOfTrustWidget(QWidget *parent = nullptr);
+ ~WebOfTrustWidget();
+
+ void setKey(const GpgME::Key &key);
+ GpgME::Key key() const;
+
+private:
+ class Private;
+ const QScopedPointer<Private> d;
+};
+} // namespace Kleo
+#endif
+