diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpg/GpgKey.cpp | 72 | ||||
-rw-r--r-- | src/gpg/Signature.cpp | 25 | ||||
-rw-r--r-- | src/ui/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/ui/Wizard.cpp | 32 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyDetailsDialog.cpp (renamed from src/ui/KeyDetailsDialog.cpp) | 8 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyPairDetailTab.cpp (renamed from src/ui/KeyPairDetailTab.cpp) | 2 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyPairSubkeyTab.cpp | 52 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyPairUIDTab.cpp | 144 |
8 files changed, 316 insertions, 22 deletions
diff --git a/src/gpg/GpgKey.cpp b/src/gpg/GpgKey.cpp index 5d474327..c1116f24 100644 --- a/src/gpg/GpgKey.cpp +++ b/src/gpg/GpgKey.cpp @@ -23,3 +23,75 @@ */ #include "gpg/GpgKey.h" + +void GpgKey::parse(gpgme_key_t key) { + if(key != nullptr) { + good = true; + is_private_key = key->secret; + fpr = key->fpr; + protocol = key->protocol; + expired = (key->expired != 0u); + revoked = (key->revoked != 0u); + + disabled = key->disabled; + + can_authenticate = key->can_authenticate; + can_certify = key->can_certify; + can_encrypt = key->can_encrypt; + can_sign = key->can_sign; + + last_update = QDateTime(QDateTime::fromTime_t(key->last_update)); + + switch (key->owner_trust) { + case GPGME_VALIDITY_UNKNOWN: + owner_trust = "Unknown"; + break; + case GPGME_VALIDITY_UNDEFINED: + owner_trust = "Undefined"; + break; + case GPGME_VALIDITY_NEVER: + owner_trust = "Never"; + break; + case GPGME_VALIDITY_MARGINAL: + owner_trust = "Marginal"; + break; + case GPGME_VALIDITY_FULL: + owner_trust = "FULL"; + break; + case GPGME_VALIDITY_ULTIMATE: + owner_trust = "Ultimate"; + break; + } + + auto uid = key->uids; + + while(uid != nullptr) { + uids.push_back(UID(uid)); + uid = uid->next; + } + + + if (!uids.isEmpty()) { + name = uids.first().name; + email = uids.first().email; + comment = uids.first().comment; + } + + auto next = key->subkeys; + + while (next != nullptr) { + subKeys.push_back(GpgSubKey(next)); + next = next->next; + } + + if (!subKeys.isEmpty()) { + id = subKeys.first().id; + expires = subKeys.first().expires; + pubkey_algo = subKeys.first().pubkey_algo; + create_time = subKeys.first().timestamp; + length = subKeys.first().length; + } else { + id = ""; + } + } +} diff --git a/src/gpg/Signature.cpp b/src/gpg/Signature.cpp new file mode 100644 index 00000000..9e7f0574 --- /dev/null +++ b/src/gpg/Signature.cpp @@ -0,0 +1,25 @@ +/** + * This file is part of GPGFrontend. + * + * GPGFrontend 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 3 of the License, or + * (at your option) any later version. + * + * Foobar 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 Foobar. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from gpg4usb-team. + * Their source code version also complies with GNU General Public License. + * + * The source code version of this software was modified and released + * by Saturneric<[email protected]> starting on May 12, 2021. + * + */ + +#include "gpg/Signature.h" diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 8398740b..c319b294 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,6 +1,7 @@ aux_source_directory(. QTUI_SOURCE) +aux_source_directory(./keypair_details QTUI_KEYPAIR_DETAILS_SOURCE) -add_library(qtui STATIC ${QTUI_SOURCE}) +add_library(qtui STATIC ${QTUI_SOURCE} ${QTUI_KEYPAIR_DETAILS_SOURCE}) target_link_libraries(qtui Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
\ No newline at end of file diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp index 71d26cd0..f7d8b717 100644 --- a/src/ui/Wizard.cpp +++ b/src/ui/Wizard.cpp @@ -109,9 +109,9 @@ bool Wizard::importPubAndSecKeysFromDir(const QString &dir, KeyMgmt *keyMgmt) { IntroPage::IntroPage(QWidget *parent) : QWizardPage(parent) { setTitle(tr("Getting started...")); - setSubTitle(tr("... with gpg4usb")); + setSubTitle(tr("... with GPGFrontend")); - auto *topLabel = new QLabel(tr("To use gpg4usb for decrypting and signing messages, you need a " + auto *topLabel = new QLabel(tr("To use GPGFrontend for decrypting and signing messages, you need a " "private key. The next page will help you with " "key generation or import.<br><br>" "For more information have a look at the <a href='docu_concepts.html'>concepts</a> " @@ -161,17 +161,17 @@ int IntroPage::nextId() const { ChoosePage::ChoosePage(QWidget *parent) : QWizardPage(parent) { setTitle(tr("Choose your action...")); - setSubTitle(tr("...by clicking on the apropriate link.")); + setSubTitle(tr("...by clicking on the appropriate link.")); - auto *keygenLabel = new QLabel(tr("If you have never used gpg4usb before and also don't own a gpg key yet you " + auto *keygenLabel = new QLabel(tr("If you have never used GPGFrontend before and also don't own a gpg key yet you " "may possibly want to ") + "<a href=""Wizard::Page_GenKey"">" + tr("create a new keypair") + "</a><hr>"); keygenLabel->setWordWrap(true); connect(keygenLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotJumpPage(Qtring))); - auto *importGpg4usbLabel = new QLabel(tr("If you upgrade from an older version of gpg4usb you may want to ") + auto *importGpg4usbLabel = new QLabel(tr("If you upgrade from an older version of GPGFrontend you may want to ") + "<a href=""Wizard::Page_ImportFromGpg4usb"">" - + tr("import settings and/or keys from gpg4usb") + "</a>"); + + tr("import settings and/or keys from GPGFrontend") + "</a>"); importGpg4usbLabel->setWordWrap(true); connect(importGpg4usbLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotJumpPage(QString))); @@ -207,11 +207,11 @@ ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *ke mCtx = ctx; mKeyMgmt = keyMgmt; setTitle(tr("Import from...")); - setSubTitle(tr("...existing gpg4usb")); + setSubTitle(tr("...existing GPGFrontend")); - auto *topLabel = new QLabel(tr("You can import keys and/or settings from existing gpg4usb. <br><br>" + auto *topLabel = new QLabel(tr("You can import keys and/or settings from existing GPGFrontend. <br><br>" "Just check what you want to import, click the import button and choose " - "the directory of your other gpg4usb in the appearing file dialog."), this); + "the directory of your other GPGFrontend in the appearing file dialog."), this); topLabel->setWordWrap(true); gpg4usbKeyCheckBox = new QCheckBox(); @@ -222,7 +222,7 @@ ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *ke gpg4usbConfigCheckBox->setChecked(true); auto *configLabel = new QLabel(tr("Configuration")); - auto *importFromGpg4usbButton = new QPushButton(tr("Import from gpg4usb")); + auto *importFromGpg4usbButton = new QPushButton(tr("Import from GPGFrontend")); connect(importFromGpg4usbButton, SIGNAL(clicked()), this, SLOT(slotImportFromOlderGpg4usb())); auto *gpg4usbLayout = new QGridLayout(); @@ -237,7 +237,7 @@ ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *ke } void ImportFromGpg4usbPage::slotImportFromOlderGpg4usb() { - QString dir = QFileDialog::getExistingDirectory(this, tr("Other gpg4usb directory")); + QString dir = QFileDialog::getExistingDirectory(this, tr("Other GPGFrontend directory")); // Return, if cancel was hit if (dir.isEmpty()) { @@ -258,7 +258,7 @@ void ImportFromGpg4usbPage::slotImportFromOlderGpg4usb() { QSettings settings; settings.setValue("wizard/nextPage", this->nextId()); QMessageBox::information(nullptr, tr("Configuration Imported"), - tr("Imported Configuration from old gpg4usb.<br>" + tr("Imported Configuration from old GPGFrontend.<br>" "Will now restart to activate the configuration.")); // TODO: edit->maybesave? qApp->exit(RESTART_CODE); @@ -267,7 +267,7 @@ void ImportFromGpg4usbPage::slotImportFromOlderGpg4usb() { } bool ImportFromGpg4usbPage::slotImportConfFromGpg4usb(const QString &dir) { - QString path = dir + "/conf/gpg4usb.ini"; + QString path = dir + "/conf/GPGFrontend.ini"; QSettings oldconf(path, QSettings::IniFormat, this); QSettings actualConf; foreach(QString key, oldconf.allKeys()) { @@ -389,10 +389,10 @@ void KeyGenPage::slotGenerateKeyDialog() { ConclusionPage::ConclusionPage(QWidget *parent) : QWizardPage(parent) { setTitle(tr("Ready.")); - setSubTitle(tr("Have fun with gpg4usb!")); + setSubTitle(tr("Have fun with GPGFrontend!")); - auto *bottomLabel = new QLabel(tr("You are ready to use gpg4usb now.<br><br>" - "The offline help will get you started with gpg4usb. " + auto *bottomLabel = new QLabel(tr("You are ready to use GPGFrontend now.<br><br>" + "The offline help will get you started with GPGFrontend. " "It will open in the main window.<br>")); bottomLabel->setWordWrap(true); diff --git a/src/ui/KeyDetailsDialog.cpp b/src/ui/keypair_details/KeyDetailsDialog.cpp index 3be333a1..7b09471b 100644 --- a/src/ui/KeyDetailsDialog.cpp +++ b/src/ui/keypair_details/KeyDetailsDialog.cpp @@ -22,14 +22,16 @@ * */ -#include "ui/KeyDetailsDialog.h" +#include "ui/keypair_details/KeyDetailsDialog.h" KeyDetailsDialog::KeyDetailsDialog(GpgME::GpgContext *ctx, const GpgKey& key, QWidget *parent) : QDialog(parent) { tabWidget = new QTabWidget(this); - tabWidget->addTab(new KeyPairDetailTab(ctx, key, this), tr("KeyPair Details")); + tabWidget->addTab(new KeyPairDetailTab(ctx, key, this), tr("KeyPair")); + tabWidget->addTab(new KeyPairUIDTab(ctx, key, this), tr("UIDs")); + tabWidget->addTab(new KeyPairSubkeyTab(ctx, key, this), tr("Subkeys")); auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(tabWidget); @@ -38,6 +40,4 @@ KeyDetailsDialog::KeyDetailsDialog(GpgME::GpgContext *ctx, const GpgKey& key, QW this->setWindowTitle(tr("Key Details")); this->setModal(true); this->show(); - - exec(); }
\ No newline at end of file diff --git a/src/ui/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp index 30be2a77..6974157f 100644 --- a/src/ui/KeyPairDetailTab.cpp +++ b/src/ui/keypair_details/KeyPairDetailTab.cpp @@ -2,7 +2,7 @@ // Created by eric on 2021/5/21. // -#include "ui/KeyPairDetailTab.h" +#include "ui/keypair_details/KeyPairDetailTab.h" KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : QWidget(parent) { diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp new file mode 100644 index 00000000..1c112609 --- /dev/null +++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp @@ -0,0 +1,52 @@ +/** + * This file is part of GPGFrontend. + * + * GPGFrontend 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 3 of the License, or + * (at your option) any later version. + * + * Foobar 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 Foobar. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from gpg4usb-team. + * Their source code version also complies with GNU General Public License. + * + * The source code version of this software was modified and released + * by Saturneric<[email protected]> starting on May 12, 2021. + * + */ + +#include "ui/keypair_details/KeyPairSubkeyTab.h" + +KeyPairSubkeyTab::KeyPairSubkeyTab(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : mCtx(ctx), key(key), QWidget(parent) { + +} + +void KeyPairSubkeyTab::creatSubkeyList() { + subkeyList = new QTableWidget(this); + subkeyList->setColumnCount(5); + subkeyList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + subkeyList->verticalHeader()->hide(); + subkeyList->setShowGrid(false); + subkeyList->setSelectionBehavior(QAbstractItemView::SelectRows); + + // tableitems not editable + subkeyList->setEditTriggers(QAbstractItemView::NoEditTriggers); + + // no focus (rectangle around tableitems) + // may be it should focus on whole row + subkeyList->setFocusPolicy(Qt::NoFocus); + subkeyList->setAlternatingRowColors(true); + + QStringList labels; + labels << tr("Subkey ID") << tr("Key Size") << tr("Algo") << tr("Create Time") << tr("Expire Time"); + + subkeyList->setHorizontalHeaderLabels(labels); + subkeyList->horizontalHeader()->setStretchLastSection(true); +} diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp new file mode 100644 index 00000000..e0128b55 --- /dev/null +++ b/src/ui/keypair_details/KeyPairUIDTab.cpp @@ -0,0 +1,144 @@ +// +// Created by eric on 2021/5/22. +// + +#include "ui/keypair_details/KeyPairUIDTab.h" + +KeyPairUIDTab::KeyPairUIDTab(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : QWidget(parent), key(key) { + + mCtx = ctx; + + createUIDList(); + createSignList(); + + auto uidButtonsLayout = new QGridLayout(); + + auto addUIDButton = new QPushButton(tr("New UID")); + auto manageUIDButton = new QPushButton(tr("Manage UID")); + + uidButtonsLayout->addWidget(addUIDButton, 0, 1); + uidButtonsLayout->addWidget(manageUIDButton, 0, 2); + + + auto sigButtonsLayout = new QGridLayout(); + + auto addSigButton = new QPushButton("New Signature"); + auto manageSigButton = new QPushButton(tr("Manage Signature")); + + sigButtonsLayout->addWidget(addSigButton, 0, 1); + sigButtonsLayout->addWidget(manageSigButton, 0, 2); + + auto gridLayout = new QGridLayout(); + gridLayout->addWidget(uidList, 0, 0); + gridLayout->addLayout(uidButtonsLayout, 1, 0); + + gridLayout->addWidget(sigList, 2, 0); + gridLayout->addLayout(sigButtonsLayout, 3, 0); + + setLayout(gridLayout); + + connect(mCtx, SIGNAL(signalKeyDBChanged()), this, SLOT(slotRefreshUIDList())); + connect(mCtx, SIGNAL(signalKeyDBChanged()), this, SLOT(slotRefreshSigList())); + + slotRefreshUIDList(); + slotRefreshSigList(); +} + +void KeyPairUIDTab::createUIDList() { + uidList = new QTableWidget(this); + uidList->setColumnCount(3); + uidList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + uidList->verticalHeader()->hide(); + uidList->setShowGrid(false); + uidList->setSelectionBehavior(QAbstractItemView::SelectRows); + + // tableitems not editable + uidList->setEditTriggers(QAbstractItemView::NoEditTriggers); + + // no focus (rectangle around tableitems) + // may be it should focus on whole row + uidList->setFocusPolicy(Qt::NoFocus); + uidList->setAlternatingRowColors(true); + + QStringList labels; + labels << tr("Name") << tr("Email") << tr("Comment"); + uidList->setHorizontalHeaderLabels(labels); + uidList->horizontalHeader()->setStretchLastSection(true); +} + +void KeyPairUIDTab::createSignList() { + sigList = new QTableWidget(this); + sigList->setColumnCount(5); + sigList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + sigList->verticalHeader()->hide(); + sigList->setShowGrid(false); + sigList->setSelectionBehavior(QAbstractItemView::SelectRows); + + // tableitems not editable + sigList->setEditTriggers(QAbstractItemView::NoEditTriggers); + + // no focus (rectangle around tableitems) + // may be it should focus on whole row + sigList->setFocusPolicy(Qt::NoFocus); + sigList->setAlternatingRowColors(true); + + QStringList labels; + labels << tr("Type") << tr("Name") << tr("Pubkey Id") << tr("Create Time") << tr("Valid Time"); + sigList->setHorizontalHeaderLabels(labels); + sigList->horizontalHeader()->setStretchLastSection(true); +} + +void KeyPairUIDTab::slotRefreshUIDList() { + int row = 0; + + uidList->clearContents(); + uidList->setRowCount(key.uids.size()); + + for(const auto& uid : key.uids) { + auto *tmp0 = new QTableWidgetItem(uid.name); + uidList->setItem(row, 0, tmp0); + + auto *tmp1 = new QTableWidgetItem(uid.email); + uidList->setItem(row, 1, tmp1); + + auto *tmp2 = new QTableWidgetItem(uid.comment); + uidList->setItem(row, 2, tmp2); + + row++; + } + + +} + +void KeyPairUIDTab::slotRefreshSigList() { + int row = 0; + + sigList->clearContents(); + + for(const auto& uid : key.uids) { + row += uid.signatures.size(); + } + sigList->setRowCount(row); + + row = 0; + for(const auto& uid : key.uids) { + for(const auto &sig : uid.signatures) { + auto *tmp0 = new QTableWidgetItem(sig.pubkey_algo); + uidList->setItem(row, 0, tmp0); + + auto *tmp1 = new QTableWidgetItem(sig.name); + uidList->setItem(row, 1, tmp1); + + auto *tmp2 = new QTableWidgetItem(sig.uid); + uidList->setItem(row, 2, tmp2); + + auto *tmp3 = new QTableWidgetItem(sig.create_time.toString()); + uidList->setItem(row, 3, tmp3); + + auto *tmp4 = new QTableWidgetItem(sig.expire_time.toString()); + uidList->setItem(row, 4, tmp4); + + row++; + } + } +} |