diff options
Diffstat (limited to '')
-rw-r--r-- | .github/workflows/release-ci.yml | 24 | ||||
-rw-r--r-- | .github/workflows/release.yml | 25 | ||||
-rw-r--r-- | include/gpg/GpgContext.h | 4 | ||||
-rwxr-xr-x | include/ui/KeyMgmt.h | 1 | ||||
-rw-r--r-- | include/ui/Wizard.h | 66 | ||||
-rw-r--r-- | include/ui/keygen/KeygenDialog.h | 5 | ||||
-rw-r--r-- | include/ui/keygen/KeygenThread.h | 50 | ||||
-rw-r--r-- | include/ui/keygen/SubkeyGenerateDialog.h | 10 | ||||
-rw-r--r-- | include/ui/keygen/SubkeyGenerateThread.h | 51 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/gpg/GpgContext.cpp | 18 | ||||
-rw-r--r-- | src/ui/Wizard.cpp | 242 | ||||
-rw-r--r-- | src/ui/keygen/KeygenDialog.cpp | 42 | ||||
-rw-r--r-- | src/ui/keygen/KeygenThread.cpp | 36 | ||||
-rw-r--r-- | src/ui/keygen/SubkeyGenerateDialog.cpp | 41 | ||||
-rw-r--r-- | src/ui/keygen/SubkeyGenerateThread.cpp | 36 |
16 files changed, 118 insertions, 535 deletions
diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index e4371bfc..2823e056 100644 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -42,6 +42,16 @@ jobs: sudo apt-get -y install libglu1-mesa-dev libfontconfig1-dev libx11-xcb-dev libicu-dev libxcb-* if: matrix.os == 'ubuntu-16.04' + - name: Codesign Configuration (macOS) + run: | + echo ${{secrets.MACOS_CERTIFICATE}} | base64 --decode > certificate.p12 + security create-keychain -p gpgfrontend build.keychain + security default-keychain -s build.keychain + security unlock-keychain -p gpgfrontend build.keychain + security import certificate.p12 -k build.keychain -P ${{secrets.MAOS_CERTIFICATE_PWD}} -T /usr/bin/codesign + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k gpgfrontend build.keychain + if: matrix.os == 'macos-latest' + - name: Install Dependence (macOS) run: | brew install cmake git autoconf automake qt@5 gcc texinfo gettext libgpg-error libassuan gpgme openssl @@ -132,13 +142,25 @@ jobs: run: cmake --build ${{github.workspace}}/build --config $env.BUILD_TYPE}} -- -j 2 if: matrix.os == 'ubuntu-16.04' || matrix.os == 'macos-latest' - - name: Package App Bundle (macOS) + - name: Build & Sign App Bundle (macOS) run: | macdeployqt ${{github.workspace}}/build/release/GpgFrontend.app + codesign --deep --force --options=runtime -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/release/GpgFrontend.app -v mkdir ${{github.workspace}}/build/tmp/ + if: matrix.os == 'macos-latest' + + - name: Package & Sign App Bundle (macOS) + run: | hdiutil create ${{github.workspace}}/build/tmp/tmp.dmg -ov -volname "GpgFrontend" -fs HFS+ -srcfolder ${{github.workspace}}/build/release/ mkdir ${{github.workspace}}/build/artifactOut hdiutil convert ${{github.workspace}}/build/tmp/tmp.dmg -format UDZO -o ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg + codesign -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg + mv ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg + if: matrix.os == 'macos-latest' + + - name: Notarize Release Build (macOS) + run: | + xcrun altool --notarize-app -f ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg --primary-bundle-id pub.gpgfrontend.gpgfrontend -u ${{secrets.APPLE_DEVELOPER_ID}} -p ${{secrets.APPLE_DEVELOPER_ID_SECRET}} if: matrix.os == 'macos-latest' - name: Package App Image (Linux) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ad2246c..31e2babb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,16 @@ jobs: sudo apt-get -y install libglu1-mesa-dev libfontconfig1-dev libx11-xcb-dev libicu-dev libxcb-* if: matrix.os == 'ubuntu-16.04' + - name: Codesign Configuration (macOS) + run: | + echo ${{secrets.MACOS_CERTIFICATE}} | base64 --decode > certificate.p12 + security create-keychain -p gpgfrontend build.keychain + security default-keychain -s build.keychain + security unlock-keychain -p gpgfrontend build.keychain + security import certificate.p12 -k build.keychain -P ${{secrets.MAOS_CERTIFICATE_PWD}} -T /usr/bin/codesign + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k gpgfrontend build.keychain + if: matrix.os == 'macos-latest' + - name: Install Dependence (macOS) run: | brew install cmake git autoconf automake qt@5 gcc texinfo gettext libgpg-error libassuan gpgme openssl @@ -136,14 +146,25 @@ jobs: id: vars run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Package App Bundle (macOS) + - name: Build & Sign App Bundle (macOS) run: | macdeployqt ${{github.workspace}}/build/release/GpgFrontend.app + codesign --deep --force --options=runtime -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/release/GpgFrontend.app -v mkdir ${{github.workspace}}/build/tmp/ + if: matrix.os == 'macos-latest' + + - name: Package & Sign App Bundle (macOS) + run: | hdiutil create ${{github.workspace}}/build/tmp/tmp.dmg -ov -volname "GpgFrontend" -fs HFS+ -srcfolder ${{github.workspace}}/build/release/ mkdir ${{github.workspace}}/build/artifactOut hdiutil convert ${{github.workspace}}/build/tmp/tmp.dmg -format UDZO -o ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg - mv ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg + codesign -s "Developer ID Application: Yu Hu (4279AWUL3X)" ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg + mv ${{github.workspace}}/build/artifactOut/GpgFrontend.dmg ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg + if: matrix.os == 'macos-latest' + + - name: Notarize Release Build (macOS) + run: | + xcrun altool --notarize-app -f ${{github.workspace}}/build/artifactOut/GpgFrontend-${{steps.vars.outputs.sha_short}}-x86_64.dmg --primary-bundle-id pub.gpgfrontend.gpgfrontend -u ${{secrets.APPLE_DEVELOPER_ID}} -p ${{secrets.APPLE_DEVELOPER_ID_SECRET}} if: matrix.os == 'macos-latest' - name: Package App Image (Linux) diff --git a/include/gpg/GpgContext.h b/include/gpg/GpgContext.h index fc4d8692..b25a5f81 100644 --- a/include/gpg/GpgContext.h +++ b/include/gpg/GpgContext.h @@ -81,9 +81,9 @@ namespace GpgME { bool exportKeys(const QVector<GpgKey> &keys, QByteArray &outBuffer); - bool generateKey(GenKeyInfo *params); + gpgme_error_t generateKey(GenKeyInfo *params); - bool generateSubkey(const GpgKey &key, GenKeyInfo *params); + gpgme_error_t generateSubkey(const GpgKey &key, GenKeyInfo *params); void deleteKeys(QStringList *uidList); diff --git a/include/ui/KeyMgmt.h b/include/ui/KeyMgmt.h index 59592bdf..fa352149 100755 --- a/include/ui/KeyMgmt.h +++ b/include/ui/KeyMgmt.h @@ -26,7 +26,6 @@ #define __KEYMGMT_H__ #include "ui/widgets/KeyList.h" -#include "ui/keygen/KeygenThread.h" #include "ui/keypair_details/KeyDetailsDialog.h" #include "KeyImportDetailDialog.h" #include "KeyServerImportDialog.h" diff --git a/include/ui/Wizard.h b/include/ui/Wizard.h index b2451bf2..79c7e321 100644 --- a/include/ui/Wizard.h +++ b/include/ui/Wizard.h @@ -30,14 +30,6 @@ #include "gpg/GpgConstants.h" #include "SettingsDialog.h" -class QCheckBox; - -class QLabel; - -class QLineEdit; - -class QRadioButton; - class Wizard : public QWizard { Q_OBJECT Q_ENUMS(WizardPages) @@ -50,8 +42,6 @@ public: Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = nullptr); - static bool importPubAndSecKeysFromDir(const QString& dir, KeyMgmt *keyMgmt); - private: GpgME::GpgContext *mCtx; KeyMgmt *mKeyMgmt; @@ -102,62 +92,6 @@ private: int nextPage; }; -class ImportFromGpg4usbPage : public QWizardPage { -Q_OBJECT - -public: - ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = nullptr); - -private slots: - - /** - * @details Import keys from gnupg-homedir, private or/and public depend on the checked boxes - */ - void slotImportFromOlderGpg4usb(); - - bool slotImportConfFromGpg4usb(const QString& dir); - -private: - [[nodiscard]] int nextId() const override; - - QString appPath; - QSettings settings; - - KeyMgmt *mKeyMgmt; - GpgME::GpgContext *mCtx; - QCheckBox *gpg4usbKeyCheckBox; - QCheckBox *gpg4usbConfigCheckBox; -}; - -class ImportFromGnupgPage : public QWizardPage { -Q_OBJECT - -public: - ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = nullptr); - -private slots: - - /** - * @details Import keys from gnupg-homedir, private or/and public depend on the checked boxes - */ - void slotrImportKeysFromGnupg(); - -private: - KeyMgmt *mKeyMgmt; - - [[nodiscard]] int nextId() const override; - - /** - * @details String containing the gnupg-homedir - * @returns String containg the gnupg-homedir, but NULL, if the in windows registry entry - * doesn't exist or in linux ~/.gnupg doesn't exist - */ - static QString getGnuPGHome(); - - GpgME::GpgContext *mCtx; - QPushButton *importFromGnupgButton; -}; - class KeyGenPage : public QWizardPage { Q_OBJECT diff --git a/include/ui/keygen/KeygenDialog.h b/include/ui/keygen/KeygenDialog.h index a2718a1d..4a37590a 100644 --- a/include/ui/keygen/KeygenDialog.h +++ b/include/ui/keygen/KeygenDialog.h @@ -25,10 +25,8 @@ #ifndef __KEYGENDIALOG_H__ #define __KEYGENDIALOG_H__ -#include "KeygenThread.h" #include "gpg/GpgContext.h" - class KeyGenDialog : public QDialog { Q_OBJECT @@ -54,7 +52,6 @@ private: R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"}; GpgME::GpgContext *mCtx; /** The current gpg context */ - KeyGenThread *kg{}; /** Thread for key generation */ QStringList errorMessages; /** List of errors occuring when checking entries of lineedits */ GenKeyInfo genKeyInfo{}; @@ -107,8 +104,6 @@ private slots: void slotActivatedKeyType(int index); - void slotKeyGenResult(bool success); - }; #endif // __KEYGENDIALOG_H__ diff --git a/include/ui/keygen/KeygenThread.h b/include/ui/keygen/KeygenThread.h deleted file mode 100644 index 30478050..00000000 --- a/include/ui/keygen/KeygenThread.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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. - * - */ - -#ifndef __KEYGENTHREAD_H__ -#define __KEYGENTHREAD_H__ - -#include "gpg/GpgContext.h" - -class KeyGenThread : public QThread { -Q_OBJECT - -public: - KeyGenThread(GenKeyInfo *keyGenParams, GpgME::GpgContext *ctx); - -signals: - void signalKeyGenerated(bool success); - -private: - GenKeyInfo *keyGenParams; - GpgME::GpgContext *mCtx; - QMutex mutex; - -protected: - - void run() override; - -}; - -#endif // __KEYGENTHREAD_H__ diff --git a/include/ui/keygen/SubkeyGenerateDialog.h b/include/ui/keygen/SubkeyGenerateDialog.h index b067122a..a1cfcf55 100644 --- a/include/ui/keygen/SubkeyGenerateDialog.h +++ b/include/ui/keygen/SubkeyGenerateDialog.h @@ -25,12 +25,7 @@ #ifndef GPGFRONTEND_SUBKEYGENERATEDIALOG_H #define GPGFRONTEND_SUBKEYGENERATEDIALOG_H -#include "GpgFrontend.h" -#include "gpg/GpgKey.h" -#include "gpg/GpgSubKey.h" -#include "gpg/GpgGenKeyInfo.h" - -#include "SubkeyGenerateThread.h" +#include "gpg/GpgContext.h" class SubkeyGenerateDialog : public QDialog { Q_OBJECT @@ -45,7 +40,6 @@ private: const GpgKey &mKey; GenKeyInfo genKeyInfo{}; - SubkeyGenerateThread *kg{}; /** Thread for key generation */ QGroupBox *keyUsageGroupBox{}; QDialogButtonBox *buttonBox; /** Box for standardbuttons */ @@ -91,8 +85,6 @@ private slots: void slotActivatedKeyType(int index); - void slotKeyGenResult(bool success); - }; diff --git a/include/ui/keygen/SubkeyGenerateThread.h b/include/ui/keygen/SubkeyGenerateThread.h deleted file mode 100644 index b442acea..00000000 --- a/include/ui/keygen/SubkeyGenerateThread.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 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]><[email protected]> starting on May 12, 2021. - * - */ - -#ifndef GPGFRONTEND_SUBKEYGENERATETHREAD_H -#define GPGFRONTEND_SUBKEYGENERATETHREAD_H - -#include "gpg/GpgContext.h" - -class SubkeyGenerateThread : public QThread { - Q_OBJECT - -public: - SubkeyGenerateThread(GpgKey key, GenKeyInfo *keyGenParams, GpgME::GpgContext *ctx); - -signals: - - void signalKeyGenerated(bool success); - -private: - const GpgKey mKey; - GenKeyInfo *keyGenParams; - GpgME::GpgContext *mCtx; - -protected: - - void run() override; -}; - - -#endif //GPGFRONTEND_SUBKEYGENERATETHREAD_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b225a09..ad56423d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,7 +90,7 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Release") add_executable(${AppName} MACOSX_BUNDLE ${ICON_RESOURCE} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS}) set_target_properties(${AppName} PROPERTIES BUNDLE True - MACOSX_BUNDLE_GUI_IDENTIFIER org.gnupg.gpgfrontend + MACOSX_BUNDLE_GUI_IDENTIFIER pub.gpgfrontend.gpgfrontend MACOSX_BUNDLE_BUNDLE_NAME ${AppName} MACOSX_BUNDLE_LONG_VERSION_STRING ${BUILD_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION} diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index 0462433d..72c04ac9 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -197,7 +197,7 @@ namespace GpgME { /** Generate New Key with values params * */ - bool GpgContext::generateKey(GenKeyInfo *params) { + gpgme_error_t GpgContext::generateKey(GenKeyInfo *params) { auto userid_utf8 = params->getUserid().toUtf8(); const char *userid = userid_utf8.constData(); @@ -232,12 +232,12 @@ namespace GpgME { err = gpgme_op_createkey(mCtx, userid, algo, 0, expires, nullptr, flags); - if (err != GPG_ERR_NO_ERROR) { + if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) { checkErr(err); - return false; + return err; } else { emit signalKeyDBChanged(); - return true; + return err; } } @@ -986,10 +986,10 @@ namespace GpgME { } } - bool GpgContext::generateSubkey(const GpgKey &key, GenKeyInfo *params) { + gpgme_error_t GpgContext::generateSubkey(const GpgKey &key, GenKeyInfo *params) { if (!params->isSubKey()) { - return false; + return GPG_ERR_CANCELED; } auto algo_utf8 = (params->getAlgo() + params->getKeySizeStr()).toUtf8(); @@ -1022,12 +1022,12 @@ namespace GpgME { auto gpgmeError = gpgme_op_createsubkey(mCtx, key.key_refer, algo, 0, expires, flags); - if (gpgmeError == GPG_ERR_NO_ERROR) { + if (gpgme_err_code(gpgmeError) == GPG_ERR_NO_ERROR) { emit signalKeyUpdated(key.id); - return true; + return gpgmeError; } else { checkErr(gpgmeError); - return false; + return gpgmeError; } } diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp index b0486cc9..8b482675 100644 --- a/src/ui/Wizard.cpp +++ b/src/ui/Wizard.cpp @@ -24,10 +24,6 @@ #include "ui/Wizard.h" -#ifdef Q_OS_WIN -#include "windows.h" -#endif - Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) : QWizard(parent), appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { @@ -36,8 +32,6 @@ Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) setPage(Page_Intro, new IntroPage(this)); setPage(Page_Choose, new ChoosePage(this)); - setPage(Page_ImportFromGpg4usb, new ImportFromGpg4usbPage(mCtx, mKeyMgmt, this)); - setPage(Page_ImportFromGnupg, new ImportFromGnupgPage(mCtx, mKeyMgmt, this)); setPage(Page_GenKey, new KeyGenPage(mCtx, this)); setPage(Page_Conclusion, new ConclusionPage(this)); #ifndef Q_WS_MAC @@ -54,7 +48,6 @@ Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) settings.remove("wizard/nextPage"); connect(this, SIGNAL(accepted()), this, SLOT(slotWizardAccepted())); - // connect(this, SIGNAL(signalOpenHelp(QString)), parentWidget(), SLOT(signalOpenHelp(QString))); } @@ -67,57 +60,20 @@ void Wizard::slotWizardAccepted() { } } -bool Wizard::importPubAndSecKeysFromDir(const QString &dir, KeyMgmt *keyMgmt) { - QFile secRingFile(dir + "/secring.gpg"); - QFile pubRingFile(dir + "/pubring.gpg"); - - // Return, if no keyrings are found in subdir of chosen dir - if (!(pubRingFile.exists() or secRingFile.exists())) { - QMessageBox::critical(0, tr("Import Error"), tr("Couldn't locate any keyring file in %1").arg(dir)); - return false; - } - - QByteArray inBuffer; - if (secRingFile.exists()) { - // write content of secringfile to inBuffer - if (!secRingFile.open(QIODevice::ReadOnly)) { - QMessageBox::critical(nullptr, tr("Import error"), - tr("Couldn't open private keyringfile: %1").arg(secRingFile.fileName())); - return false; - } - inBuffer = secRingFile.readAll(); - secRingFile.close(); - } - - if (pubRingFile.exists()) { - // try to import public keys - if (!pubRingFile.open(QIODevice::ReadOnly)) { - QMessageBox::critical(nullptr, tr("Import error"), - tr("Couldn't open public keyringfile: %1").arg(pubRingFile.fileName())); - return false; - } - inBuffer.append(pubRingFile.readAll()); - pubRingFile.close(); - } - keyMgmt->slotImportKeys(inBuffer); - inBuffer.clear(); - - return true; -} - IntroPage::IntroPage(QWidget *parent) : QWizardPage(parent), appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { setTitle(tr("Getting Started...")); setSubTitle(tr("... with GPGFrontend")); - auto *topLabel = new QLabel(tr("Welcome to use GPGFrontend for decrypting and signing text or file!")+ - " <br><br><a href='https://github.com/saturneric/GpgFrontend'>GpgFrontend</a> " + - tr("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP Crypto Tool.") + - tr("For brief information have a look at the") + "<a href='https://saturneric.github.io/GpgFrontend/index.html#/overview'>"+ - tr("Overview") +"</a> (" + - tr("by clicking the link, the page will open in the web browser") + - "). <br>"); + auto *topLabel = new QLabel(tr("Welcome to use GPGFrontend for decrypting and signing text or file!") + + " <br><br><a href='https://gpgfrontend.pub'>GpgFrontend</a> " + + tr("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP Crypto Tool.") + + tr("For brief information have a look at the") + + " <a href='https://gpgfrontend.pub/index.html#/overview'>" + + tr("Overview") + "</a> (" + + tr("by clicking the link, the page will open in the web browser") + + "). <br>"); topLabel->setTextFormat(Qt::RichText); topLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); topLabel->setOpenExternalLinks(true); @@ -130,7 +86,7 @@ IntroPage::IntroPage(QWidget *parent) languages = SettingsDialog::listLanguages(); auto *langSelectBox = new QComboBox(); - for(const auto &l : languages) { + for (const auto &l : languages) { langSelectBox->addItem(l); } // selected entry from config @@ -166,19 +122,21 @@ ChoosePage::ChoosePage(QWidget *parent) setSubTitle(tr("...by clicking on the appropriate link.")); 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 read how to") + " <a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/generate-key\">" + "may possibly want to read how to") + + " <a href=\"https://gpgfrontend.pub/index.html#/manual/generate-key\">" + tr("Generate Key") + "</a><hr>"); keygenLabel->setTextFormat(Qt::RichText); keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); keygenLabel->setOpenExternalLinks(true); keygenLabel->setWordWrap(true); - auto *encrDecyTextLabel = new QLabel(tr("If you want to learn how to encrypt, decrypt, sign and verify text, you can read ") - + "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/encrypt-decrypt-text\">" - + tr("Encrypt & Decrypt Text") + "</a> " + tr("or") - + " <a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/sign-verify-text\">" - + tr("Sign & Verify Text") - +"</a><hr>"); + auto *encrDecyTextLabel = new QLabel( + tr("If you want to learn how to encrypt, decrypt, sign and verify text, you can read ") + + "<a href=\"https://gpgfrontend.pub/index.html#/manual/encrypt-decrypt-text\">" + + tr("Encrypt & Decrypt Text") + "</a> " + tr("or") + + " <a href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-text\">" + + tr("Sign & Verify Text") + + "</a><hr>"); encrDecyTextLabel->setTextFormat(Qt::RichText); encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -186,11 +144,13 @@ ChoosePage::ChoosePage(QWidget *parent) encrDecyTextLabel->setWordWrap(true); auto *signVerifyTextLabel = new QLabel(tr("If you want to operate file, you can read ") - + "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/encrypt-decrypt-file\">" - + tr("Encrypt & Sign File") + "</a> " + tr("or") - + " <a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/sign-verify-file\">" - + tr("Sign & Verify File") - +"</a><hr>"); + + + "<a href=\"https://gpgfrontend.pub/index.html#/manual/encrypt-decrypt-file\">" + + tr("Encrypt & Sign File") + "</a> " + tr("or") + + + " <a href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-file\">" + + tr("Sign & Verify File") + + "</a><hr>"); signVerifyTextLabel->setTextFormat(Qt::RichText); signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); signVerifyTextLabel->setOpenExternalLinks(true); @@ -217,149 +177,6 @@ void ChoosePage::slotJumpPage(const QString &page) { wizard()->next(); } -ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) - : QWizardPage(parent), appPath(qApp->applicationDirPath()), - settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) { - mCtx = ctx; - mKeyMgmt = keyMgmt; - setTitle(tr("Import from...")); - setSubTitle(tr("...existing GPGFrontend")); - - 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 GPGFrontend in the appearing file dialog."), this); - topLabel->setWordWrap(true); - - gpg4usbKeyCheckBox = new QCheckBox(); - gpg4usbKeyCheckBox->setChecked(true); - auto *keyLabel = new QLabel(tr("Keys")); - - gpg4usbConfigCheckBox = new QCheckBox(); - gpg4usbConfigCheckBox->setChecked(true); - auto *configLabel = new QLabel(tr("Configuration")); - - auto *importFromGpg4usbButton = new QPushButton(tr("Import from GPGFrontend")); - connect(importFromGpg4usbButton, SIGNAL(clicked()), this, SLOT(slotImportFromOlderGpg4usb())); - - auto *gpg4usbLayout = new QGridLayout(); - gpg4usbLayout->addWidget(topLabel, 1, 1, 1, 2); - gpg4usbLayout->addWidget(gpg4usbKeyCheckBox, 2, 1, Qt::AlignRight); - gpg4usbLayout->addWidget(keyLabel, 2, 2); - gpg4usbLayout->addWidget(gpg4usbConfigCheckBox, 3, 1, Qt::AlignRight); - gpg4usbLayout->addWidget(configLabel, 3, 2); - gpg4usbLayout->addWidget(importFromGpg4usbButton, 4, 2); - - this->setLayout(gpg4usbLayout); -} - -void ImportFromGpg4usbPage::slotImportFromOlderGpg4usb() { - QString dir = QFileDialog::getExistingDirectory(this, tr("Other GPGFrontend directory")); - - // Return, if cancel was hit - if (dir.isEmpty()) { - return; - } - - // try to import keys, if appropriate box is checked, return, if import was unsuccessful - if (gpg4usbKeyCheckBox->isChecked()) { - if (!Wizard::importPubAndSecKeysFromDir(dir + "/keydb", mKeyMgmt)) { - return; - } - } - - // try to import config, if appropriate box is checked - if (gpg4usbConfigCheckBox->isChecked()) { - slotImportConfFromGpg4usb(dir); - - settings.setValue("wizard/nextPage", this->nextId()); - QMessageBox::information(nullptr, tr("Configuration Imported"), - tr("Imported Configuration from old GPGFrontend.<br>" - "Will now restart to activate the configuration.")); - // TODO: edit->maybesave? - qApp->exit(RESTART_CODE); - } - wizard()->next(); -} - -bool ImportFromGpg4usbPage::slotImportConfFromGpg4usb(const QString &dir) { - QString path = dir + "/conf/gpgfrontend.ini"; - QSettings oldconf(path, QSettings::IniFormat, this); - QSettings actualConf; - foreach(QString key, oldconf.allKeys()) { - actualConf.setValue(key, oldconf.value(key)); - } - return true; -} - -int ImportFromGpg4usbPage::nextId() const { - return Wizard::Page_Conclusion; -} - -ImportFromGnupgPage::ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) - : QWizardPage(parent) { - mCtx = ctx; - mKeyMgmt = keyMgmt; - setTitle(tr("Import keys...")); - setSubTitle(tr("...from existing GnuPG installation")); - - auto *gnupgLabel = new QLabel(tr("You can import keys from a locally installed GnuPG.<br><br> The location is read " - "from registry in Windows or assumed to be the .gnupg folder in the your home directory in Linux.<br>")); - gnupgLabel->setWordWrap(true); - - importFromGnupgButton = new QPushButton(tr("Import keys from GnuPG")); - connect(importFromGnupgButton, SIGNAL(clicked()), this, SLOT(slotrImportKeysFromGnupg())); - - auto *layout = new QGridLayout(); - layout->addWidget(gnupgLabel); - layout->addWidget(importFromGnupgButton); - - this->setLayout(layout); -} - -void ImportFromGnupgPage::slotrImportKeysFromGnupg() { - // first get gnupghomedir and check, if it exists - QString gnuPGHome = getGnuPGHome(); - if (gnuPGHome == nullptr) { - QMessageBox::critical(0, tr("Import Error"), tr("Couldn't locate GnuPG home directory")); - return; - } - - // Try to import the keyring files and return the return value of the method - Wizard::importPubAndSecKeysFromDir(gnuPGHome, mKeyMgmt); - wizard()->next(); -} - -QString ImportFromGnupgPage::getGnuPGHome() { - QString gnuPGHome = ""; -#ifdef _WIN32 - bool existsAndSuccess = false; - - HKEY hKey; - - existsAndSuccess = (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\GNU\\GNUPG", 0, KEY_READ, &hKey) == ERROR_SUCCESS); - - if (existsAndSuccess) { - QSettings gnuPGsettings("HKEY_CURRENT_USER\\Software\\GNU\\GNUPG", QSettings::NativeFormat); - if (gnuPGsettings.contains("HomeDir")) { - gnuPGHome = gnuPGsettings.value("HomeDir").toString(); - } else { - return NULL; - } - } -#else - gnuPGHome = QDir::homePath() + "/.gnupg"; - if (!QFile(gnuPGHome).exists()) { - return nullptr; - } -#endif - - return gnuPGHome; -} - -int ImportFromGnupgPage::nextId() const { - return Wizard::Page_Conclusion; -} - KeyGenPage::KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent) : QWizardPage(parent) { mCtx = ctx; @@ -407,10 +224,11 @@ ConclusionPage::ConclusionPage(QWidget *parent) setTitle(tr("Ready.")); setSubTitle(tr("Have fun with GPGFrontend!")); - auto *bottomLabel = new QLabel(tr("You are ready to use GPGFrontend now.<br><br>")+ - "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/overview\">" - + tr("The Online Document") + "</a>" - + tr(" will get you started with GPGFrontend. It will open in the main window.<br>")); + auto *bottomLabel = new QLabel(tr("You are ready to use GPGFrontend now.<br><br>") + + "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/overview\">" + + tr("The Online Document") + "</a>" + + + tr(" will get you started with GPGFrontend. It will open in the main window.<br>")); bottomLabel->setTextFormat(Qt::RichText); bottomLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp index 7991ddd1..98216dc6 100644 --- a/src/ui/keygen/KeygenDialog.cpp +++ b/src/ui/keygen/KeygenDialog.cpp @@ -23,6 +23,7 @@ */ #include "ui/keygen/KeygenDialog.h" +#include "ui/WaitingDialog.h" KeyGenDialog::KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent) : QDialog(parent), mCtx(ctx) { @@ -92,34 +93,28 @@ void KeyGenDialog::slotKeyGenAccept() { genKeyInfo.setExpired(dateEdit->dateTime()); } - kg = new KeyGenThread(&genKeyInfo, mCtx); - connect(kg, SIGNAL(signalKeyGenerated(bool)), this, SLOT(slotKeyGenResult(bool))); - kg->start(); - - this->accept(); - - auto *dialog = new QDialog(this, Qt::CustomizeWindowHint | Qt::WindowTitleHint); - dialog->setModal(true); - dialog->setWindowTitle(tr("Generating Key...")); - - auto *waitMessage = new QLabel( - tr("Collecting random data for key generation.\n This may take a while.\n To speed up the process use your computer\n (e.g. browse the net, listen to music,...)")); - auto *pb = new QProgressBar(); - pb->setRange(0, 0); - - auto *layout = new QVBoxLayout(dialog); - layout->addWidget(waitMessage); - layout->addWidget(pb); - dialog->setLayout(layout); + gpgme_error_t error = false; + auto thread = QThread::create([&]() { + error = mCtx->generateKey(&genKeyInfo); + }); + thread->start(); + auto *dialog = new WaitingDialog("Generating", this); dialog->show(); - while (kg->isRunning()) { + while (thread->isRunning()) { QCoreApplication::processEvents(); } dialog->close(); + if(gpgme_err_code(error) == GPG_ERR_NO_ERROR) { + QMessageBox::information(this, tr("Success"), tr("The new key pair has been generated.")); + this->close(); + } + else + QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error))); + } else { /** * create error message @@ -307,13 +302,6 @@ bool KeyGenDialog::check_email_address(const QString &str) { return re_email.match(str).hasMatch(); } -void KeyGenDialog::slotKeyGenResult(bool success) { - if(success) - QMessageBox::information(nullptr, tr("Success"), tr("The new key pair has been generated.")); - else - QMessageBox::critical(nullptr, tr("Failure"), tr("An error occurred during key generation.")); -} - QGroupBox *KeyGenDialog::create_basic_info_group_box() { errorLabel = new QLabel(tr("")); diff --git a/src/ui/keygen/KeygenThread.cpp b/src/ui/keygen/KeygenThread.cpp deleted file mode 100644 index d7b9d840..00000000 --- a/src/ui/keygen/KeygenThread.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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/keygen/KeygenThread.h" - -KeyGenThread::KeyGenThread(GenKeyInfo* keyGenParams, GpgME::GpgContext *ctx) -: mCtx(ctx), keyGenParams(keyGenParams), QThread(nullptr) { - connect(this, &KeyGenThread::finished, this, &KeyGenThread::deleteLater); -} - -void KeyGenThread::run() { - bool success = mCtx->generateKey(keyGenParams); - emit signalKeyGenerated(success); - emit finished({}); -} diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp index c545381f..3d709d81 100644 --- a/src/ui/keygen/SubkeyGenerateDialog.cpp +++ b/src/ui/keygen/SubkeyGenerateDialog.cpp @@ -23,6 +23,7 @@ */ #include "ui/keygen/SubkeyGenerateDialog.h" +#include "ui/WaitingDialog.h" SubkeyGenerateDialog::SubkeyGenerateDialog(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : genKeyInfo(true), mCtx(ctx), mKey(key), QDialog(parent) { @@ -224,34 +225,27 @@ void SubkeyGenerateDialog::slotKeyGenAccept() { genKeyInfo.setExpired(dateEdit->dateTime()); } - kg = new SubkeyGenerateThread(mKey ,&genKeyInfo, mCtx); - connect(kg, SIGNAL(signalKeyGenerated(bool)), this, SLOT(slotKeyGenResult(bool))); - kg->start(); - - this->accept(); - - auto *dialog = new QDialog(this, Qt::CustomizeWindowHint | Qt::WindowTitleHint); - dialog->setModal(true); - dialog->setWindowTitle(tr("Generating Subkey...")); - - auto *waitMessage = new QLabel( - tr("Collecting random data for subkey generation.\n This may take a while.\n To speed up the process use your computer\n (e.g. browse the net, listen to music,...)")); - auto *pb = new QProgressBar(); - pb->setRange(0, 0); - - auto *layout = new QVBoxLayout(dialog); - layout->addWidget(waitMessage); - layout->addWidget(pb); - dialog->setLayout(layout); + gpgme_error_t error = false; + auto thread = QThread::create([&]() { + error = mCtx->generateSubkey(mKey, &genKeyInfo); + }); + thread->start(); + auto *dialog = new WaitingDialog("Generating", this); dialog->show(); - while (!kg->isFinished() && kg->isRunning()) { + while (thread->isRunning()) { QCoreApplication::processEvents(); } dialog->close(); + if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) { + QMessageBox::information(nullptr, tr("Success"), tr("The new subkey has been generated.")); + this->close(); + } else + QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error))); + } else { /** * create error message @@ -303,10 +297,3 @@ void SubkeyGenerateDialog::slotActivatedKeyType(int index) { genKeyInfo.setAlgo(this->keyTypeComboBox->itemText(index)); refresh_widgets_state(); } - -void SubkeyGenerateDialog::slotKeyGenResult(bool success) { - if(success) - QMessageBox::information(nullptr, tr("Success"), tr("The new subkey has been generated.")); - else - QMessageBox::critical(nullptr, tr("Failure"), tr("An error occurred during subkey generation.")); -} diff --git a/src/ui/keygen/SubkeyGenerateThread.cpp b/src/ui/keygen/SubkeyGenerateThread.cpp deleted file mode 100644 index 125f35f8..00000000 --- a/src/ui/keygen/SubkeyGenerateThread.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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]><[email protected]> starting on May 12, 2021. - * - */ - -#include "ui/keygen/SubkeyGenerateThread.h" - -SubkeyGenerateThread::SubkeyGenerateThread(GpgKey key, GenKeyInfo *keyGenParams, GpgME::GpgContext *ctx) - : mKey(std::move(key)), keyGenParams(keyGenParams) , mCtx(ctx) { - connect(this, &SubkeyGenerateThread::finished, this, &SubkeyGenerateThread::deleteLater); -} - -void SubkeyGenerateThread::run() { - bool success = mCtx->generateSubkey(mKey, keyGenParams); - emit signalKeyGenerated(success); - emit finished({}); -} |