aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-07-04 19:17:53 +0000
committerSaturneric <[email protected]>2021-07-04 19:17:53 +0000
commitfe2f448d517bb0f7d37c22fe99b2bd13ef1a61c3 (patch)
tree952ad3bc8cb5f76c0d1e02792a62a3825ef6fdf0 /src
parentAdjust and improve the basic settings page (diff)
parentUpdate Github Action Files. (diff)
downloadGpgFrontend-fe2f448d517bb0f7d37c22fe99b2bd13ef1a61c3.tar.gz
GpgFrontend-fe2f448d517bb0f7d37c22fe99b2bd13ef1a61c3.zip
Merge branch 'main' into develop
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt46
-rw-r--r--src/gpg/GpgContext.cpp37
-rw-r--r--src/ui/KeyImportDetailDialog.cpp5
-rw-r--r--src/ui/KeyServerImportDialog.cpp5
-rw-r--r--src/ui/KeyUploadDialog.cpp45
-rw-r--r--src/ui/Wizard.cpp55
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.cpp14
-rw-r--r--src/ui/keypair_details/KeyPairSubkeyTab.cpp5
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp4
9 files changed, 129 insertions, 87 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1a3d2860..97fae047 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,8 +17,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/release)
message(STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
# Set Resource Output Path
-if(APPLE)
- set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources)
+if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ if(APPLE)
+ set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources)
+ elseif(LINUX)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/gpgfrontend DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gpgfrontend/usr/share)
+ endif()
else()
set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
@@ -45,10 +50,14 @@ file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTO
file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
file(COPY ${CMAKE_SOURCE_DIR}/resource/conf DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
-if(APPLE)
- file(COPY ${CMAKE_SOURCE_DIR}/gpgfrontend.icns DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- # Refresh App Bundle
- file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app)
+if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ if(APPLE)
+ file(COPY ${CMAKE_SOURCE_DIR}/gpgfrontend.icns DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ # Refresh App Bundle
+ file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app)
+ elseif(LINUX)
+ file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gpgfrontend/usr/bin/${AppName})
+ endif()
endif()
# Copy Utils Files
@@ -80,16 +89,25 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
MACOSX_BUNDLE_LONG_VERSION_STRING ${BUILD_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_BUNDLE_VERSION ${BUILD_VERSION}
- MACOSX_BUNDLE_ICON_FILE "gpgfrontend.icns"
- )
+ MACOSX_BUNDLE_ICON_FILE "gpgfrontend.icns")
add_custom_command(TARGET ${AppName} POST_BUILD
COMMAND /bin/rm -rf ./${AppName}.app/Contents/Resources
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Deleting Resources IN App Bundle")
+ COMMENT "Deleting Resources in App Bundle")
add_custom_command(TARGET ${AppName} POST_BUILD
COMMAND /bin/mv -n ./Resources ./${AppName}.app/Contents/
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Copying Resources INTO App Bundle Resource")
+ COMMENT "Copying Resources into App Bundle Resource")
+ elseif(LINUX)
+ add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
+ add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/mkdir ./gpgfrontend/usr/bin && /bin/mv -f ./${AppName} ./gpgfrontend/usr/bin/
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Copying Binary into App Image")
+ add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/mkdir ./gpgfrontend/usr/lib
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Complement to build the required architecture")
else()
add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
endif()
@@ -101,13 +119,13 @@ IF (MINGW)
message(STATUS "Link Application Static Library For MINGW")
target_link_libraries(${AppName}
gpgfrontend-ui gpg
- Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
-
-
+ Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core
+ crypto ssl)
else()
message(STATUS "Link Application Static Library For UNIX")
target_link_libraries(${AppName}
gpgfrontend-ui gpg
- Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
+ Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core
+ crypto ssl)
endif()
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index 603ad90b..67bae907 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -653,22 +653,27 @@ namespace GpgME {
return QString::fromUtf8(gpgme_strerror(err));
}
-/** export private key, TODO errohandling, e.g. like in seahorse (seahorse-gpg-op.c) **/
-
- void GpgContext::exportSecretKey(const QString &uid, QByteArray *outBuffer) {
- qDebug() << *outBuffer;
+ bool GpgContext::exportSecretKey(const GpgKey &key, QByteArray *outBuffer) {
+ qDebug() << "Export Secret Key" << key.id;
+ gpgme_key_t target_key[2] = {
+ key.key_refer,
+ nullptr
+ };
+
+ gpgme_data_t dataOut;
+ gpgme_data_new(&dataOut);
// export private key to outBuffer
- QStringList arguments;
- arguments << "--armor" << "--export-secret-key" << uid;
- auto *p_errArray = new QByteArray();
- executeGpgCommand(arguments, outBuffer, p_errArray);
-
- // append public key to outBuffer
- auto *pubKey = new QByteArray();
- QStringList keyList;
- keyList.append(uid);
- exportKeys(&keyList, pubKey);
- outBuffer->append(*pubKey);
+ gpgme_error_t error = gpgme_op_export_keys(mCtx, target_key,GPGME_EXPORT_MODE_SECRET, dataOut);
+
+ if(gpgme_err_code(error) != GPG_ERR_NO_ERROR) {
+ checkErr(error);
+ gpgme_data_release(dataOut);
+ return false;
+ }
+
+ readToBuffer(dataOut, outBuffer);
+ gpgme_data_release(dataOut);
+ return true;
}
/** return type should be gpgme_error_t*/
@@ -1241,4 +1246,4 @@ namespace GpgME {
}
return true;
}
-} \ No newline at end of file
+}
diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/KeyImportDetailDialog.cpp
index 3d8d1cdc..8d303886 100644
--- a/src/ui/KeyImportDetailDialog.cpp
+++ b/src/ui/KeyImportDetailDialog.cpp
@@ -26,9 +26,8 @@
KeyImportDetailDialog::KeyImportDetailDialog(GpgME::GpgContext *ctx, GpgImportInformation result, bool automatic,
QWidget *parent)
- : QDialog(parent) {
- mCtx = ctx;
- mResult = std::move(result);
+ : QDialog(parent), mCtx(ctx), mResult(std::move(result)) {
+
// If no key for import found, just show a message
if (mResult.considered == 0) {
if(automatic)
diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp
index 1999b443..ec740691 100644
--- a/src/ui/KeyServerImportDialog.cpp
+++ b/src/ui/KeyServerImportDialog.cpp
@@ -60,7 +60,6 @@ KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *ke
waitingBar = new QProgressBar();
waitingBar->setVisible(false);
waitingBar->setRange(0, 0);
- waitingBar->setFixedHeight(24);
waitingBar->setFixedWidth(200);
// Layout for messagebox
@@ -100,7 +99,7 @@ KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *ke
this->setWindowTitle(tr("Import Keys from Keyserver"));
if(automatic) {
- this->setFixedSize(200, 42);
+ this->setFixedSize(240, 42);
} else {
// Restore window size & location
if (this->settings.value("ImportKeyFromServer/setWindowSize").toBool()) {
@@ -121,8 +120,6 @@ KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *ke
}
}
-
-
this->setModal(true);
}
diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp
index 6ee6aa78..e28b4230 100644
--- a/src/ui/KeyUploadDialog.cpp
+++ b/src/ui/KeyUploadDialog.cpp
@@ -27,10 +27,27 @@
#include <utility>
KeyUploadDialog::KeyUploadDialog(GpgME::GpgContext *ctx, const QVector<GpgKey> &keys, QWidget *parent)
-: appPath(qApp->applicationDirPath()),
-settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
-QDialog(parent) {
- ctx->exportKeys(keys, mKeyData);
+ : appPath(qApp->applicationDirPath()),
+ settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
+ mCtx(ctx),
+ mKeys(keys),
+ QDialog(parent) {
+
+
+ auto *pb = new QProgressBar();
+ pb->setRange(0, 0);
+
+ auto *layout = new QVBoxLayout();
+ layout->addWidget(pb);
+ this->setLayout(layout);
+
+ this->setModal(true);
+ this->setWindowTitle(tr("Uploading Public Key"));
+ this->setFixedSize(240, 42);
+}
+
+void KeyUploadDialog::slotUpload() {
+ mCtx->exportKeys(mKeys, mKeyData);
uploadKeyToServer(mKeyData);
}
@@ -66,30 +83,14 @@ void KeyUploadDialog::uploadKeyToServer(QByteArray &keys) {
this, SLOT(slotUploadFinished()));
- // A Waiting Dialog
- auto *dialog = new QDialog(this, Qt::CustomizeWindowHint | Qt::WindowTitleHint);
- dialog->setModal(true);
- dialog->setWindowTitle(tr("Uploading Public Key"));
- dialog->setFixedSize(200, 42);
-
- auto *pb = new QProgressBar();
- pb->setRange(0, 0);
- pb->setFixedSize(200, 24);
-
- auto *layout = new QVBoxLayout(dialog);
- layout->addWidget(pb);
- dialog->setLayout(layout);
-
- dialog->show();
-
// Keep Waiting
while(reply->isRunning()) {
QApplication::processEvents();
}
// Done
- dialog->hide();
- dialog->close();
+ this->hide();
+ this->close();
}
void KeyUploadDialog::slotUploadFinished() {
diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp
index b3236cfc..456e8c52 100644
--- a/src/ui/Wizard.cpp
+++ b/src/ui/Wizard.cpp
@@ -162,27 +162,34 @@ 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 ") + "<a href=""Wizard::Page_GenKey"">"
+ "may possibly want to read how to") + "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/generate-key\">"
+ tr("create a new keypair") + "</a><hr>");
+ keygenLabel->setTextFormat(Qt::RichText);
+ keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ keygenLabel->setOpenExternalLinks(true);
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 GPGFrontend you may want to ")
- + "<a href=""Wizard::Page_ImportFromGpg4usb"">"
- + tr("import settings and/or keys from GPGFrontend") + "</a>");
- importGpg4usbLabel->setWordWrap(true);
- connect(importGpg4usbLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotJumpPage(QString)));
+ auto *encrDecyTextLabel = new QLabel(tr("If you want to learn how to encrypt and decrypt text, you can read ")
+ + "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/encrypt-decrypt-text\">"
+ + tr("this document") + "</a><hr>");
- auto *importGnupgLabel = new QLabel(tr("If you are already using GnuPG you may want to ")
- + "<a href=""Wizard::Page_ImportFromGnupg"">"
- + tr("import keys from GnuPG") + "</a><hr>");
- importGnupgLabel->setWordWrap(true);
- connect(importGnupgLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotJumpPage(QString)));
+ encrDecyTextLabel->setTextFormat(Qt::RichText);
+ encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ encrDecyTextLabel->setOpenExternalLinks(true);
+ encrDecyTextLabel->setWordWrap(true);
+
+ auto *signVerifyTextLabel = new QLabel(tr("If you want to sign and verify text, you can read ")
+ + "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/manual/sign-verify-text\">"
+ + tr("this document") + "</a>");
+ signVerifyTextLabel->setTextFormat(Qt::RichText);
+ signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ signVerifyTextLabel->setOpenExternalLinks(true);
+ signVerifyTextLabel->setWordWrap(true);
auto *layout = new QVBoxLayout();
layout->addWidget(keygenLabel);
- layout->addWidget(importGnupgLabel);
- layout->addWidget(importGpg4usbLabel);
+ layout->addWidget(encrDecyTextLabel);
+ layout->addWidget(signVerifyTextLabel);
setLayout(layout);
nextPage = Wizard::Page_Conclusion;
}
@@ -369,7 +376,7 @@ KeyGenPage::KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent)
layout->addWidget(topLabel);
layout->addWidget(linkLabel);
layout->addWidget(createKeyButtonBox);
- connect(createKeyButton, SIGNAL(clicked()), this, SLOT(slotGenerateKeyDialog()));
+ connect(createKeyButton, SIGNAL(clicked(bool)), this, SLOT(slotGenerateKeyDialog()));
setLayout(layout);
}
@@ -379,8 +386,9 @@ int KeyGenPage::nextId() const {
}
void KeyGenPage::slotGenerateKeyDialog() {
+ qDebug() << "Try Opening KeyGenDialog";
auto *keyGenDialog = new KeyGenDialog(mCtx, this);
- keyGenDialog->exec();
+ keyGenDialog->show();
wizard()->next();
}
@@ -389,9 +397,14 @@ 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>"
- "The offline help 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);
+ bottomLabel->setOpenExternalLinks(true);
bottomLabel->setWordWrap(true);
openHelpCheckBox = new QCheckBox(tr("Open offline help."));
@@ -401,11 +414,11 @@ ConclusionPage::ConclusionPage(QWidget *parent)
dontShowWizardCheckBox->setChecked(Qt::Checked);
registerField("showWizard", dontShowWizardCheckBox);
- registerField("openHelp", openHelpCheckBox);
+ // registerField("openHelp", openHelpCheckBox);
auto *layout = new QVBoxLayout;
layout->addWidget(bottomLabel);
- layout->addWidget(openHelpCheckBox);
+ // layout->addWidget(openHelpCheckBox);
layout->addWidget(dontShowWizardCheckBox);
setLayout(layout);
setVisible(true);
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp
index c72a7685..013d8e11 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/keypair_details/KeyPairDetailTab.cpp
@@ -131,16 +131,17 @@ KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, Q
auto *privKeyBox = new QGroupBox(tr("Operations"));
auto *vboxPK = new QVBoxLayout();
- auto *exportButton = new QPushButton(tr("Export Private Key"));
+ auto *exportButton = new QPushButton(tr("Export Private Key (Include Subkeys)"));
vboxPK->addWidget(exportButton);
connect(exportButton, SIGNAL(clicked()), this, SLOT(slotExportPrivateKey()));
if(mKey.has_master_key) {
- auto *editExpiresButton = new QPushButton(tr("Modify Expiration Datetime"));
+ auto *editExpiresButton = new QPushButton(tr("Modify Expiration Datetime (Master Key)"));
vboxPK->addWidget(editExpiresButton);
connect(editExpiresButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime()));
- auto *keyServerOperaButton = new QPushButton(tr("Key Server Operation"));
+ auto *keyServerOperaButton = new QPushButton(tr("Key Server Operation (Pubkey)"));
+ keyServerOperaButton->setStyleSheet("text-align:center;");
vboxPK->addWidget(keyServerOperaButton);
connect(keyServerOperaButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime()));
@@ -197,7 +198,12 @@ void KeyPairDetailTab::slotExportPrivateKey() {
// export key, if ok was clicked
if (ret == QMessageBox::Ok) {
auto *keyArray = new QByteArray();
- mCtx->exportSecretKey(*keyid, keyArray);
+
+ if(!mCtx->exportSecretKey(mKey, keyArray)) {
+ QMessageBox::critical(this, "Error", "An error occurred during the export operation.");
+ return;
+ }
+
auto &key = mCtx->getKeyById(*keyid);
QString fileString = key.name + " " +key.email + "(" +
key.id + ")_secret.asc";
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
index c5647553..70c7e4b8 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
@@ -222,7 +222,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
}
void KeyPairSubkeyTab::createSubkeyOperaMenu() {
- subkeyOperaMenu = new QMenu();
+ subkeyOperaMenu = new QMenu(this);
// auto *revokeSubkeyAct = new QAction(tr("Revoke Subkey"));
auto *editSubkeyAct = new QAction(tr("Edit Expire Date"));
connect(editSubkeyAct, SIGNAL(triggered(bool)), this, SLOT(slotEditSubkey()));
@@ -232,6 +232,7 @@ void KeyPairSubkeyTab::createSubkeyOperaMenu() {
}
void KeyPairSubkeyTab::slotEditSubkey() {
+ qDebug() << "Slot Edit Subkry";
auto *subkey = getSelectedSubkey();
if(subkey == buffered_subkeys[0]) {
subkey = nullptr;
@@ -245,7 +246,7 @@ void KeyPairSubkeyTab::slotRevokeSubkey() {
}
void KeyPairSubkeyTab::contextMenuEvent(QContextMenuEvent *event) {
- if (subkeyList->selectedItems().length() > 0) {
+ if (!subkeyList->selectedItems().isEmpty()) {
subkeyOperaMenu->exec(event->globalPos());
}
}
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index dcc31527..f820a4e6 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -352,7 +352,9 @@ void MainWindow::refreshKeysFromKeyserver() {
void MainWindow::uploadKeyToServer() {
QVector<GpgKey> keys;
keys.append(mKeyList->getSelectedKey());
- auto *dialog = new KeyUploadDialog(mCtx, keys);
+ auto *dialog = new KeyUploadDialog(mCtx, keys, this);
+ dialog->show();
+ dialog->slotUpload();
}
void MainWindow::slotFileEncrypt() {