Page MenuHome GnuPG

No OneTemporary

diff --git a/src/gpgolgui/CMakeLists.txt b/src/gpgolgui/CMakeLists.txt
index aa3704a..fbcd376 100644
--- a/src/gpgolgui/CMakeLists.txt
+++ b/src/gpgolgui/CMakeLists.txt
@@ -1,36 +1,39 @@
# Copyright (C) 2018 Intevation GmbH <info@intevation.de>
#
# This file is Free Software under the GNU GPL (v>=2)
# and comes with ABSOLUTELY NO WARRANTY!
# See LICENSE.txt for details.
set(EXECUTABLE_NAME "gpgolgui")
set(EXECUTABLE_SRC
main.cpp
gpgolgui-options.h
gpgolgui.cpp
+ gpgolconfigpage.cpp
${CMAKE_SOURCE_DIR}/src/img/icon.rc
${CMAKE_SOURCE_DIR}/src/util/strhelp.c
${CMAKE_SOURCE_DIR}/src/util/w32-util.cpp
${CMAKE_SOURCE_DIR}/src/util/w32-gettext.c
)
+qt5_add_resources(EXECUTABLE_SRC gpgolgui.qrc)
+
add_executable(${EXECUTABLE_NAME}
${_add_executable_params}
${EXECUTABLE_SRC}
)
target_link_libraries(${EXECUTABLE_NAME}
Qt5::Widgets
KF5::WidgetsAddons
KF5::Libkleo
Gpgmepp
QGpgme
)
if (WIN32)
set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS "-municode")
endif(WIN32)
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
diff --git a/src/gpgolgui/gpgolconfigpage.cpp b/src/gpgolgui/gpgolconfigpage.cpp
new file mode 100644
index 0000000..1131570
--- /dev/null
+++ b/src/gpgolgui/gpgolconfigpage.cpp
@@ -0,0 +1,137 @@
+/* Copyright (C) 2018 by Intevation GmbH <info@intevation.de>
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+
+#include "gpgolconfigpage.h"
+#include "w32-gettext.h"
+#include "w32-util.h"
+
+#include <QDebug>
+#include <QGroupBox>
+#include <QLabel>
+#include <QCheckBox>
+#include <QVBoxLayout>
+
+
+GpgOLConfigPage::GpgOLConfigPage(QWidget *parent):
+ QWidget(parent)
+{
+ setupGUI();
+
+ load();
+}
+
+void GpgOLConfigPage::setVersion(const QString &version)
+{
+ mVersionLabel->setText(version);
+}
+
+void GpgOLConfigPage::setupGUI()
+{
+ auto baseLay = new QVBoxLayout(this);
+
+ mSMIMEGrp = new QGroupBox(_("Enable the S/MIME support"));
+ mSMIMEGrp->setCheckable(true);
+ mSMIMEGrp->setAlignment(Qt::AlignLeft);
+
+ auto smimeLay = new QVBoxLayout(mSMIMEGrp);
+
+ mPreferSMIMEChk = new QCheckBox(_("Prefer S/MIME when autoresolving recipients"));
+ smimeLay->addWidget(mPreferSMIMEChk);
+
+ baseLay->addWidget(mSMIMEGrp);
+
+ // The general group
+ auto generalGrp = new QGroupBox(_("General"));
+ auto generalLay = new QVBoxLayout(generalGrp);
+ generalGrp->setAlignment(Qt::AlignLeft);
+ mAlwaysSigChk = new QCheckBox(_("&Sign new messages by default"));
+ mAlwaysEncChk = new QCheckBox(_("&Encrypt new messages by default"));
+
+ generalLay->addWidget(mAlwaysSigChk);
+ generalLay->addWidget(mAlwaysEncChk);
+
+ baseLay->addWidget(generalGrp);
+
+ // The automation checkboxes
+ mAutomationGrp = new QGroupBox(_("Automation"));
+ mAutomationGrp->setToolTip(_("Enable or disable any automated key handling."));
+ auto autoLayout = new QVBoxLayout(mAutomationGrp);
+ mAutomationGrp->setCheckable(true);
+
+ mAutoTrustChk = new QCheckBox(QStringLiteral("%1 (%2)").arg(_("Automate OpenPGP trust based on communication history")).arg(_("experimental")));
+ mAutoTrustChk->setToolTip(_("This changes the trust model to \"tofu+pgp\" which tracks the history of key usage. Automated trust can <b>never</b> exceed level 2."));
+
+ mAutoSecureChk = new QCheckBox(_("Automatically secure messages"));
+ mAutoSecureChk->setToolTip(_("Automatically toggles secure if keys with at least level 1 trust were found for all recipients."));
+
+ autoLayout->addWidget(mAutoSecureChk);
+ autoLayout->addWidget(mAutoTrustChk);
+ baseLay->addWidget(mAutomationGrp);
+ baseLay->addStretch(1);
+}
+
+static bool strToBool(const std::string &str, bool defaultVal = false)
+{
+ if (str.empty()) {
+ return defaultVal;
+ }
+
+ if (str == "1") {
+ return true;
+ }
+ if (str == "0") {
+ return false;
+ }
+
+ qDebug() << "Unknown bool val" << str.c_str();
+ return defaultVal;
+}
+
+static bool loadBool(const char *name, bool defaultVal)
+{
+ return strToBool(W32::readRegStr(nullptr, GPGOL_REG_PATH, name), defaultVal);
+}
+
+static const QMap<QString, bool> defaultMap {
+ { QStringLiteral("enableSmime"), false },
+ { QStringLiteral("encryptDefault"), false },
+ { QStringLiteral("signDefault"), false },
+ { QStringLiteral("inlinePGP"), false },
+ { QStringLiteral("replyCrypt"), true },
+ { QStringLiteral("preferSmime"), false },
+ { QStringLiteral("debugGPGME"), false },
+ { QStringLiteral("automation"), true },
+ { QStringLiteral("autosecure"), true },
+ { QStringLiteral("autotrust"), false },
+ { QStringLiteral("import-autocrypt"), true },
+};
+
+void GpgOLConfigPage::updateGUI(const QMap<QString, bool> &values)
+{
+ bool smimeEnabled = values["enableSmime"];
+ mSMIMEGrp->setChecked(smimeEnabled);
+
+ mAutomationGrp->setChecked(values["automation"]);
+ mAutoSecureChk->setChecked(values["autosecure"]);
+ mAutoTrustChk->setChecked(values["autotrust"]);
+ mPreferSMIMEChk->setChecked(values["preferSmime"]);
+}
+
+void GpgOLConfigPage::load()
+{
+ QMap<QString, bool> confValues;
+
+ for (const auto &key: defaultMap.keys()) {
+ confValues[key] = loadBool(key.toLocal8Bit().constData(), defaultMap[key]);
+ }
+ updateGUI(confValues);
+}
+
+void GpgOLConfigPage::save() const
+{
+
+}
diff --git a/src/gpgolgui/gpgolconfigpage.h b/src/gpgolgui/gpgolconfigpage.h
new file mode 100644
index 0000000..923642e
--- /dev/null
+++ b/src/gpgolgui/gpgolconfigpage.h
@@ -0,0 +1,45 @@
+#ifndef GPGOLCONFIGPAGE_H
+#define GPGOLCONFIGPAGE_H
+/* Copyright (C) 2018 by Intevation GmbH <info@intevation.de>
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+#include <QWidget>
+#include <QMap>
+#include <QString>
+
+class QGroupBox;
+class QCheckBox;
+class QLabel;
+
+class GpgOLConfigPage: public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit GpgOLConfigPage(QWidget *parent = nullptr);
+
+ void save() const;
+ void load();
+ void defaults();
+
+ void setVersion(const QString &version);
+
+protected:
+ void setupGUI();
+ void updateGUI(const QMap<QString, bool> &values);
+
+private:
+ QGroupBox *mSMIMEGrp,
+ *mAutomationGrp;
+ QCheckBox *mPreferSMIMEChk,
+ *mAutoSecureChk,
+ *mAutoTrustChk,
+ *mAlwaysEncChk,
+ *mAlwaysSigChk;
+ QLabel *mVersionLabel;
+};
+
+#endif
diff --git a/src/gpgolgui/gpgolgui.cpp b/src/gpgolgui/gpgolgui.cpp
index c3e2f4a..bda92db 100644
--- a/src/gpgolgui/gpgolgui.cpp
+++ b/src/gpgolgui/gpgolgui.cpp
@@ -1,77 +1,90 @@
/* Copyright (C) 2018 by Intevation GmbH <info@intevation.de>
*
* This file is Free Software under the GNU GPL (v>=2)
* and comes with ABSOLUTELY NO WARRANTY!
* See LICENSE.txt for details.
*/
#include "gpgolgui.h"
#include "w32-gettext.h"
+#include "gpgolconfigpage.h"
#include <QLabel>
#include <QWidget>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QGpgME/Protocol>
#include <QGpgME/CryptoConfig>
#include <KPageDialog>
#include <KGuiItem>
#include <KStandardGuiItem>
#include <Libkleo/CryptoConfigModule>
-GpgOLGUI::GpgOLGUI(const QCommandLineParser &parser) : KPageDialog(nullptr)
+GpgOLGUI::GpgOLGUI(const QCommandLineParser &parser): KPageDialog(nullptr)
{
+ setWindowTitle(_("Configure GpgOL"));
setupGUI();
+
+ setWindowIcon(QIcon(":/gpgolicon.svg"));
+
+ resize(800, 500);
}
void GpgOLGUI::setupGUI()
{
- setFaceType( KPageDialog::List );
+ setFaceType(KPageDialog::List);
QDialogButtonBox *buttonBox = new QDialogButtonBox();
buttonBox->setStandardButtons(QDialogButtonBox::RestoreDefaults |
QDialogButtonBox::Cancel |
QDialogButtonBox::Ok);
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::RestoreDefaults),
KStandardGuiItem::defaults());
setButtonBox(buttonBox);
QGpgME::CryptoConfig *const config = QGpgME::cryptoConfig();
auto cryptoConfWidget = new Kleo::CryptoConfigModule(config,
Kleo::CryptoConfigModule::TabbedLayout);
+ auto gpgolConfWidget = new GpgOLConfigPage;
+
connect(cryptoConfWidget, &Kleo::CryptoConfigModule::changed,
this, [this] () {
mCryptoConfigChanged = true;
});
connect(buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
this, [this, cryptoConfWidget] () {
if (mCryptoConfigChanged) {
cryptoConfWidget->save();
}
close();
});
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked,
this, [this, cryptoConfWidget] () {
cryptoConfWidget->defaults();
mCryptoConfigChanged = true;
});
connect(buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::clicked,
this, [this] () {
close();
});
- KPageWidgetItem *page = new KPageWidgetItem(cryptoConfWidget, _("GnuPG System"));
+ KPageWidgetItem *page = new KPageWidgetItem(gpgolConfWidget, _("GpgOL"));
+ page->setHeader(_("Configure GpgOL"));
+ page->setIcon(QIcon(":/gpgolicon.svg"));
+ addPage(page);
+
+ page = new KPageWidgetItem(cryptoConfWidget, QStringLiteral("%1\n%2").arg(_("GnuPG System")).arg(_("(Technical)")));
page->setHeader(_("Configuration of GnuPG System options"));
page->setIcon(QIcon::fromTheme("document-encrypt"));
addPage(page);
}
diff --git a/src/gpgolgui/gpgolgui.qrc b/src/gpgolgui/gpgolgui.qrc
new file mode 100644
index 0000000..4a15572
--- /dev/null
+++ b/src/gpgolgui/gpgolgui.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file alias="gpgolicon.svg">../img/lock.svg</file>
+</qresource>
+</RCC>
diff --git a/src/util/w32-util.h b/src/util/w32-util.h
index a47794a..ff5dacb 100644
--- a/src/util/w32-util.h
+++ b/src/util/w32-util.h
@@ -1,50 +1,52 @@
/* Copyright (C) 2018 by Intevation GmbH <info@intevation.de>
*
* This file is Free Software under the GNU GPL (v>=2)
* and comes with ABSOLUTELY NO WARRANTY!
* See LICENSE.txt for details.
*/
#include <string>
/* The Registry key used by Gpg4win. */
#ifdef _WIN64
# define GPG4WIN_REGKEY_2 "Software\\Wow6432Node\\GNU\\GnuPG"
#else
# define GPG4WIN_REGKEY_2 "Software\\GNU\\GnuPG"
#endif
#ifdef _WIN64
# define GPG4WIN_REGKEY_3 "Software\\Wow6432Node\\Gpg4win"
#else
# define GPG4WIN_REGKEY_3 "Software\\Gpg4win"
#endif
+#define GPGOL_REG_PATH "Software\\GNU\\GpgOL"
+
namespace W32
{
/* Get the locale dir of Gpg4win. */
std::string getGpg4winLocaleDir();
/** Get the Gpg4win Install directory.
*
* Looks for the Gpg4win 3.x registry key.
* And checks that the directory can be read.
*
* @returns an empty string if no dir could be found.
*
**/
std::string getGpg4winDir();
/** Read a registry string value. If root is null first
* HKEY_CURRENT_USER is searched and then it falls back
* to HKEY_LOCAL_MACHINE . */
std::string readRegStr(const char *root,
const char *path,
const char *key);
bool writeRegStr(const char *root,
const char *path,
const char *key,
const char *val);
} // namespace W32

File Metadata

Mime Type
text/x-diff
Expires
Sat, Dec 6, 11:51 PM (1 d, 2 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
22/18/f2013f833251db322850fb854def

Event Timeline