aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ui/data_struct/SoftwareVersion.h8
-rw-r--r--src/ui/function/TestListedKeyServerThread.cpp47
-rw-r--r--src/ui/function/TestListedKeyServerThread.h55
-rw-r--r--src/ui/function/VersionCheckThread.cpp13
-rw-r--r--src/ui/help/AboutDialog.cpp13
-rw-r--r--src/ui/keygen/KeygenDialog.cpp138
-rw-r--r--src/ui/keygen/KeygenDialog.h7
-rw-r--r--src/ui/keygen/SubkeyGenerateDialog.cpp122
-rw-r--r--src/ui/keygen/SubkeyGenerateDialog.h10
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp5
-rw-r--r--src/ui/settings/SettingsKeyServer.cpp81
-rw-r--r--src/ui/smtp/SendMailDialog.cpp5
-rw-r--r--ui/SendMailDialog.ui4
13 files changed, 353 insertions, 155 deletions
diff --git a/src/ui/data_struct/SoftwareVersion.h b/src/ui/data_struct/SoftwareVersion.h
index 942f22ce..be646b71 100644
--- a/src/ui/data_struct/SoftwareVersion.h
+++ b/src/ui/data_struct/SoftwareVersion.h
@@ -36,6 +36,7 @@ struct SoftwareVersion {
bool current_prerelease = false;
bool current_draft = false;
bool load_info_done = false;
+ bool current_version_found = false;
std::string publish_date;
std::string release_note;
@@ -45,7 +46,12 @@ struct SoftwareVersion {
}
[[nodiscard]] bool VersionWithDrawn() const {
- return load_info_done && current_prerelease && !current_draft;
+ return load_info_done && !current_version_found && current_prerelease &&
+ !current_draft;
+ }
+
+ [[nodiscard]] bool CurrentVersionReleased() const {
+ return load_info_done && current_version_found;
}
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/function/TestListedKeyServerThread.cpp b/src/ui/function/TestListedKeyServerThread.cpp
new file mode 100644
index 00000000..4f816860
--- /dev/null
+++ b/src/ui/function/TestListedKeyServerThread.cpp
@@ -0,0 +1,47 @@
+/**
+ * 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 "TestListedKeyServerThread.h"
+
+void GpgFrontend::UI::TestListedKeyServerThread::run() {
+ for (const auto& url : urls_) {
+ const auto keyserver_url = url;
+
+ auto key_url = QUrl{keyserver_url};
+
+ LOG(INFO) << "key server domain" << key_url.host().toStdString();
+
+ QTcpSocket socket(nullptr);
+ socket.abort();
+ socket.connectToHost(key_url.host(), 80);
+ if (socket.waitForConnected(timeout_)) {
+ result_.push_back("Reachable");
+ } else {
+ result_.push_back("Not Reachable");
+ }
+ socket.close();
+ }
+
+ emit signalKeyServerListTestResult(result_);
+}
diff --git a/src/ui/function/TestListedKeyServerThread.h b/src/ui/function/TestListedKeyServerThread.h
new file mode 100644
index 00000000..99fd6c6d
--- /dev/null
+++ b/src/ui/function/TestListedKeyServerThread.h
@@ -0,0 +1,55 @@
+/**
+ * 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_TESTLISTEDKEYSERVERTHREAD_H
+#define GPGFRONTEND_TESTLISTEDKEYSERVERTHREAD_H
+
+#include "GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+class TestListedKeyServerThread : public QThread {
+ Q_OBJECT
+ public:
+ explicit TestListedKeyServerThread(const QStringList& urls, int timeout,
+ QWidget* parent = nullptr)
+ : QThread(parent), urls_(urls), timeout_(timeout) {}
+
+ signals:
+ void signalKeyServerListTestResult(const QStringList& result);
+
+ protected:
+ void run() override;
+
+ private:
+ QStringList urls_;
+ QStringList result_;
+ int timeout_ = 500;
+};
+
+} // namespace GpgFrontend::UI
+
+class TestListedKeyServerThread {};
+
+#endif // GPGFRONTEND_TESTLISTEDKEYSERVERTHREAD_H
diff --git a/src/ui/function/VersionCheckThread.cpp b/src/ui/function/VersionCheckThread.cpp
index 52d1b22a..bfd6ea46 100644
--- a/src/ui/function/VersionCheckThread.cpp
+++ b/src/ui/function/VersionCheckThread.cpp
@@ -39,16 +39,14 @@ void VersionCheckThread::run() {
SoftwareVersion version;
version.current_version = current_version;
- auto manager = new QNetworkAccessManager(nullptr);
+ auto manager = std::make_unique<QNetworkAccessManager>(nullptr);
try {
using namespace nlohmann;
-
LOG(INFO) << "current version" << current_version;
std::string latest_version_url =
"https://api.github.com/repos/saturneric/gpgfrontend/releases/latest";
-
std::string current_version_url =
"https://api.github.com/repos/saturneric/gpgfrontend/releases/tags/" +
current_version;
@@ -59,7 +57,7 @@ void VersionCheckThread::run() {
auto _reply = manager->get(latest_request);
while (_reply->isRunning()) QApplication::processEvents();
if (_reply->error() != QNetworkReply::NoError) {
- LOG(ERROR) << "network error";
+ LOG(ERROR) << "current version request error";
version.latest_version = current_version;
} else {
latest_reply_bytes_ = _reply->readAll();
@@ -95,10 +93,10 @@ void VersionCheckThread::run() {
while (_reply->isRunning()) QApplication::processEvents();
current_reply_bytes_ = _reply->readAll();
if (_reply->error() != QNetworkReply::NoError) {
- LOG(ERROR) << "network error";
- manager->deleteLater();
- return;
+ LOG(ERROR) << "current version request network error";
+ version.current_version_found = false;
} else {
+ version.current_version_found = true;
auto current_reply_json =
nlohmann::json::parse(current_reply_bytes_.toStdString());
bool current_prerelease = current_reply_json["prerelease"],
@@ -114,7 +112,6 @@ void VersionCheckThread::run() {
LOG(INFO) << "error occurred";
version.load_info_done = false;
}
- manager->deleteLater();
emit upgradeVersion(version);
}
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp
index a3db6eda..78ff5557 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/help/AboutDialog.cpp
@@ -225,6 +225,19 @@ void UpdateTab::slotShowVersionStatus(const SoftwareVersion& version) {
"href=\"https://github.com/saturneric/GpgFrontend/releases\">" +
_("Here") + "</a> " + _("to download the latest stable version.") +
"</center>");
+ upgradeLabel->show();
+ } else if (!version.CurrentVersionReleased()) {
+ upgradeLabel->setText(
+ "<center>" +
+ QString(_("This version has not been released yet, it may be a beta "
+ "version. If you are not a tester and care about version "
+ "stability, please do not use this version.")) +
+ "</center><center>" + _("Please click") +
+ " <a "
+ "href=\"https://github.com/saturneric/GpgFrontend/releases\">" +
+ _("Here") + "</a> " + _("to download the latest stable version.") +
+ "</center>");
+ upgradeLabel->show();
}
}
diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp
index af9aa4e4..2baa22f4 100644
--- a/src/ui/keygen/KeygenDialog.cpp
+++ b/src/ui/keygen/KeygenDialog.cpp
@@ -27,6 +27,7 @@
#include "gpg/function/GpgKeyOpera.h"
#include "ui/SignalStation.h"
#include "ui/WaitingDialog.h"
+#include "ui/settings/GlobalSettingStation.h"
namespace GpgFrontend::UI {
@@ -34,6 +35,22 @@ KeyGenDialog::KeyGenDialog(QWidget* parent) : QDialog(parent) {
buttonBox =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+
+ // max expire date time
+ bool longer_expiration_date = false;
+ try {
+ longer_expiration_date = settings.lookup("general.longer_expiration_date");
+ LOG(INFO) << "longer_expiration_date" << longer_expiration_date;
+
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("longer_expiration_date");
+ }
+
+ max_date_time_ = longer_expiration_date
+ ? QDateTime::currentDateTime().toLocalTime().addYears(30)
+ : QDateTime::currentDateTime().toLocalTime().addYears(2);
+
this->setWindowTitle(_("Generate Key"));
this->setModal(true);
@@ -83,9 +100,8 @@ void KeyGenDialog::slotKeyGenAccept() {
* primary keys should have a reasonable expiration date (no more than 2 years
* in the future)
*/
- if (dateEdit->dateTime() > QDateTime::currentDateTime().addYears(2)) {
- error_stream << " " << _("Expiration time no more than 2 years.")
- << std::endl;
+ if (dateEdit->dateTime() > max_date_time_) {
+ error_stream << " " << _("Expiration time too long.") << std::endl;
}
auto err_string = error_stream.str();
@@ -94,23 +110,23 @@ void KeyGenDialog::slotKeyGenAccept() {
/**
* create the string for key generation
*/
- genKeyInfo->setName(nameEdit->text().toStdString());
- genKeyInfo->setEmail(emailEdit->text().toStdString());
- genKeyInfo->setComment(commentEdit->text().toStdString());
+ gen_key_info_->setName(nameEdit->text().toStdString());
+ gen_key_info_->setEmail(emailEdit->text().toStdString());
+ gen_key_info_->setComment(commentEdit->text().toStdString());
- genKeyInfo->setKeySize(keySizeSpinBox->value());
+ gen_key_info_->setKeySize(keySizeSpinBox->value());
if (expireCheckBox->checkState()) {
- genKeyInfo->setNonExpired(true);
+ gen_key_info_->setNonExpired(true);
} else {
- genKeyInfo->setExpired(
+ gen_key_info_->setExpired(
boost::posix_time::from_time_t(dateEdit->dateTime().toTime_t()));
}
GpgGenKeyResult result;
gpgme_error_t error = false;
auto thread = QThread::create([&]() {
- error = GpgKeyOpera::GetInstance().GenerateKey(genKeyInfo, result);
+ error = GpgKeyOpera::GetInstance().GenerateKey(gen_key_info_, result);
});
thread->start();
@@ -178,10 +194,10 @@ QGroupBox* KeyGenDialog::create_key_usage_group_box() {
auto* auth = new QCheckBox(_("Authentication"), groupBox);
auth->setTristate(false);
- keyUsageCheckBoxes.push_back(encrypt);
- keyUsageCheckBoxes.push_back(sign);
- keyUsageCheckBoxes.push_back(cert);
- keyUsageCheckBoxes.push_back(auth);
+ key_usage_check_boxes_.push_back(encrypt);
+ key_usage_check_boxes_.push_back(sign);
+ key_usage_check_boxes_.push_back(cert);
+ key_usage_check_boxes_.push_back(auth);
grid->addWidget(encrypt, 0, 0);
grid->addWidget(sign, 0, 1);
@@ -195,95 +211,95 @@ QGroupBox* KeyGenDialog::create_key_usage_group_box() {
void KeyGenDialog::slotEncryptionBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowEncryption(false);
+ gen_key_info_->setAllowEncryption(false);
} else {
- genKeyInfo->setAllowEncryption(true);
+ gen_key_info_->setAllowEncryption(true);
}
}
void KeyGenDialog::slotSigningBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowSigning(false);
+ gen_key_info_->setAllowSigning(false);
} else {
- genKeyInfo->setAllowSigning(true);
+ gen_key_info_->setAllowSigning(true);
}
}
void KeyGenDialog::slotCertificationBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowCertification(false);
+ gen_key_info_->setAllowCertification(false);
} else {
- genKeyInfo->setAllowCertification(true);
+ gen_key_info_->setAllowCertification(true);
}
}
void KeyGenDialog::slotAuthenticationBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowAuthentication(false);
+ gen_key_info_->setAllowAuthentication(false);
} else {
- genKeyInfo->setAllowAuthentication(true);
+ gen_key_info_->setAllowAuthentication(true);
}
}
void KeyGenDialog::slotActivatedKeyType(int index) {
qDebug() << "key type index changed " << index;
- genKeyInfo->setAlgo(this->keyTypeComboBox->itemText(index).toStdString());
+ gen_key_info_->setAlgo(this->keyTypeComboBox->itemText(index).toStdString());
refresh_widgets_state();
}
void KeyGenDialog::refresh_widgets_state() {
qDebug() << "refresh_widgets_state called";
- if (genKeyInfo->isAllowEncryption())
- keyUsageCheckBoxes[0]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowEncryption())
+ key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[0]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeEncryption())
- keyUsageCheckBoxes[0]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeEncryption())
+ key_usage_check_boxes_[0]->setDisabled(false);
else
- keyUsageCheckBoxes[0]->setDisabled(true);
+ key_usage_check_boxes_[0]->setDisabled(true);
- if (genKeyInfo->isAllowSigning())
- keyUsageCheckBoxes[1]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowSigning())
+ key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[1]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeSigning())
- keyUsageCheckBoxes[1]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeSigning())
+ key_usage_check_boxes_[1]->setDisabled(false);
else
- keyUsageCheckBoxes[1]->setDisabled(true);
+ key_usage_check_boxes_[1]->setDisabled(true);
- if (genKeyInfo->isAllowCertification())
- keyUsageCheckBoxes[2]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowCertification())
+ key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[2]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeCertification())
- keyUsageCheckBoxes[2]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeCertification())
+ key_usage_check_boxes_[2]->setDisabled(false);
else
- keyUsageCheckBoxes[2]->setDisabled(true);
+ key_usage_check_boxes_[2]->setDisabled(true);
- if (genKeyInfo->isAllowAuthentication())
- keyUsageCheckBoxes[3]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowAuthentication())
+ key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[3]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeAuthentication())
- keyUsageCheckBoxes[3]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeAuthentication())
+ key_usage_check_boxes_[3]->setDisabled(false);
else
- keyUsageCheckBoxes[3]->setDisabled(true);
+ key_usage_check_boxes_[3]->setDisabled(true);
- if (genKeyInfo->isAllowNoPassPhrase())
+ if (gen_key_info_->isAllowNoPassPhrase())
noPassPhraseCheckBox->setDisabled(false);
else
noPassPhraseCheckBox->setDisabled(true);
- keySizeSpinBox->setRange(genKeyInfo->getSuggestMinKeySize(),
- genKeyInfo->getSuggestMaxKeySize());
- keySizeSpinBox->setValue(genKeyInfo->getKeySize());
- keySizeSpinBox->setSingleStep(genKeyInfo->getSizeChangeStep());
+ keySizeSpinBox->setRange(gen_key_info_->getSuggestMinKeySize(),
+ gen_key_info_->getSuggestMaxKeySize());
+ keySizeSpinBox->setValue(gen_key_info_->getKeySize());
+ keySizeSpinBox->setSingleStep(gen_key_info_->getSizeChangeStep());
}
void KeyGenDialog::set_signal_slot() {
@@ -293,13 +309,13 @@ void KeyGenDialog::set_signal_slot() {
connect(expireCheckBox, SIGNAL(stateChanged(int)), this,
SLOT(slotExpireBoxChanged()));
- connect(keyUsageCheckBoxes[0], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[0], SIGNAL(stateChanged(int)), this,
SLOT(slotEncryptionBoxChanged(int)));
- connect(keyUsageCheckBoxes[1], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[1], SIGNAL(stateChanged(int)), this,
SLOT(slotSigningBoxChanged(int)));
- connect(keyUsageCheckBoxes[2], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[2], SIGNAL(stateChanged(int)), this,
SLOT(slotCertificationBoxChanged(int)));
- connect(keyUsageCheckBoxes[3], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[3], SIGNAL(stateChanged(int)), this,
SLOT(slotAuthenticationBoxChanged(int)));
connect(keyTypeComboBox, SIGNAL(currentIndexChanged(int)), this,
@@ -308,9 +324,9 @@ void KeyGenDialog::set_signal_slot() {
connect(noPassPhraseCheckBox, &QCheckBox::stateChanged, this,
[this](int state) -> void {
if (state == 0) {
- genKeyInfo->setNonPassPhrase(false);
+ gen_key_info_->setNonPassPhrase(false);
} else {
- genKeyInfo->setNonPassPhrase(true);
+ gen_key_info_->setNonPassPhrase(true);
}
});
}
@@ -334,11 +350,9 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
keyTypeComboBox->setCurrentIndex(0);
}
- QDateTime maxDateTime = QDateTime::currentDateTime().addYears(2);
-
- dateEdit = new QDateTimeEdit(maxDateTime, this);
+ dateEdit = new QDateTimeEdit(QDateTime::currentDateTime().addYears(2), this);
dateEdit->setMinimumDateTime(QDateTime::currentDateTime());
- dateEdit->setMaximumDateTime(maxDateTime);
+ dateEdit->setMaximumDateTime(max_date_time_);
dateEdit->setDisplayFormat("dd/MM/yyyy hh:mm:ss");
dateEdit->setCalendarPopup(true);
dateEdit->setEnabled(true);
diff --git a/src/ui/keygen/KeygenDialog.h b/src/ui/keygen/KeygenDialog.h
index c16a2e76..1b9fdb2a 100644
--- a/src/ui/keygen/KeygenDialog.h
+++ b/src/ui/keygen/KeygenDialog.h
@@ -55,9 +55,9 @@ class KeyGenDialog : public QDialog {
QRegularExpression re_email{
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])+)\]))"};
- QStringList errorMessages; /** List of errors occuring when checking entries
+ QStringList error_messages_; /** List of errors occuring when checking entries
of lineedits */
- std::unique_ptr<GenKeyInfo> genKeyInfo = std::make_unique<GenKeyInfo>();
+ std::unique_ptr<GenKeyInfo> gen_key_info_ = std::make_unique<GenKeyInfo>();
QDialogButtonBox* buttonBox; /** Box for standard buttons */
QLabel* errorLabel{}; /** Label containing error message */
@@ -72,9 +72,10 @@ class KeyGenDialog : public QDialog {
QGroupBox* keyUsageGroupBox{}; /** Group of Widgets detecting the usage of the
Key **/
+ QDateTime max_date_time_;
// ENCR, SIGN, CERT, AUTH
- std::vector<QCheckBox*> keyUsageCheckBoxes;
+ std::vector<QCheckBox*> key_usage_check_boxes_;
void generateKeyDialog();
diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp
index 337b545f..70d3ee3c 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.cpp
+++ b/src/ui/keygen/SubkeyGenerateDialog.cpp
@@ -28,11 +28,28 @@
#include "gpg/function/GpgKeyOpera.h"
#include "ui/SignalStation.h"
#include "ui/WaitingDialog.h"
+#include "ui/settings/GlobalSettingStation.h"
namespace GpgFrontend::UI {
SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent)
- : QDialog(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ : QDialog(parent), key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+
+ // max expire date time
+ bool longer_expiration_date = false;
+ try {
+ longer_expiration_date = settings.lookup("general.longer_expiration_date");
+ LOG(INFO) << "longer_expiration_date" << longer_expiration_date;
+
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("longer_expiration_date");
+ }
+
+ max_date_time_ = longer_expiration_date
+ ? QDateTime::currentDateTime().toLocalTime().addYears(30)
+ : QDateTime::currentDateTime().toLocalTime().addYears(2);
+
buttonBox =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@@ -79,10 +96,10 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() {
auto* auth = new QCheckBox(_("Authentication"), groupBox);
auth->setTristate(false);
- keyUsageCheckBoxes.push_back(encrypt);
- keyUsageCheckBoxes.push_back(sign);
- keyUsageCheckBoxes.push_back(cert);
- keyUsageCheckBoxes.push_back(auth);
+ key_usage_check_boxes_.push_back(encrypt);
+ key_usage_check_boxes_.push_back(sign);
+ key_usage_check_boxes_.push_back(cert);
+ key_usage_check_boxes_.push_back(auth);
grid->addWidget(encrypt, 0, 0);
grid->addWidget(sign, 0, 1);
@@ -106,11 +123,10 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() {
keyTypeComboBox->setCurrentIndex(0);
}
- QDateTime maxDateTime = QDateTime::currentDateTime().addYears(2);
- dateEdit = new QDateTimeEdit(maxDateTime, this);
+ dateEdit = new QDateTimeEdit(QDateTime::currentDateTime().addYears(2), this);
dateEdit->setMinimumDateTime(QDateTime::currentDateTime());
- dateEdit->setMaximumDateTime(maxDateTime);
+ dateEdit->setMaximumDateTime(max_date_time_);
dateEdit->setDisplayFormat("dd/MM/yyyy hh:mm:ss");
dateEdit->setCalendarPopup(true);
dateEdit->setEnabled(true);
@@ -144,13 +160,13 @@ void SubkeyGenerateDialog::set_signal_slot() {
connect(expireCheckBox, SIGNAL(stateChanged(int)), this,
SLOT(slotExpireBoxChanged()));
- connect(keyUsageCheckBoxes[0], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[0], SIGNAL(stateChanged(int)), this,
SLOT(slotEncryptionBoxChanged(int)));
- connect(keyUsageCheckBoxes[1], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[1], SIGNAL(stateChanged(int)), this,
SLOT(slotSigningBoxChanged(int)));
- connect(keyUsageCheckBoxes[2], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[2], SIGNAL(stateChanged(int)), this,
SLOT(slotCertificationBoxChanged(int)));
- connect(keyUsageCheckBoxes[3], SIGNAL(stateChanged(int)), this,
+ connect(key_usage_check_boxes_[3], SIGNAL(stateChanged(int)), this,
SLOT(slotAuthenticationBoxChanged(int)));
connect(keyTypeComboBox, SIGNAL(currentIndexChanged(int)), this,
@@ -168,50 +184,50 @@ void SubkeyGenerateDialog::slotExpireBoxChanged() {
void SubkeyGenerateDialog::refresh_widgets_state() {
qDebug() << "refresh_widgets_state called";
- if (genKeyInfo->isAllowEncryption())
- keyUsageCheckBoxes[0]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowEncryption())
+ key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[0]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeEncryption())
- keyUsageCheckBoxes[0]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeEncryption())
+ key_usage_check_boxes_[0]->setDisabled(false);
else
- keyUsageCheckBoxes[0]->setDisabled(true);
+ key_usage_check_boxes_[0]->setDisabled(true);
- if (genKeyInfo->isAllowSigning())
- keyUsageCheckBoxes[1]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowSigning())
+ key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[1]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeSigning())
- keyUsageCheckBoxes[1]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeSigning())
+ key_usage_check_boxes_[1]->setDisabled(false);
else
- keyUsageCheckBoxes[1]->setDisabled(true);
+ key_usage_check_boxes_[1]->setDisabled(true);
- if (genKeyInfo->isAllowCertification())
- keyUsageCheckBoxes[2]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowCertification())
+ key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[2]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeCertification())
- keyUsageCheckBoxes[2]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeCertification())
+ key_usage_check_boxes_[2]->setDisabled(false);
else
- keyUsageCheckBoxes[2]->setDisabled(true);
+ key_usage_check_boxes_[2]->setDisabled(true);
- if (genKeyInfo->isAllowAuthentication())
- keyUsageCheckBoxes[3]->setCheckState(Qt::CheckState::Checked);
+ if (gen_key_info_->isAllowAuthentication())
+ key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Checked);
else
- keyUsageCheckBoxes[3]->setCheckState(Qt::CheckState::Unchecked);
+ key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Unchecked);
- if (genKeyInfo->isAllowChangeAuthentication())
- keyUsageCheckBoxes[3]->setDisabled(false);
+ if (gen_key_info_->isAllowChangeAuthentication())
+ key_usage_check_boxes_[3]->setDisabled(false);
else
- keyUsageCheckBoxes[3]->setDisabled(true);
+ key_usage_check_boxes_[3]->setDisabled(true);
- keySizeSpinBox->setRange(genKeyInfo->getSuggestMinKeySize(),
- genKeyInfo->getSuggestMaxKeySize());
- keySizeSpinBox->setValue(genKeyInfo->getKeySize());
- keySizeSpinBox->setSingleStep(genKeyInfo->getSizeChangeStep());
+ keySizeSpinBox->setRange(gen_key_info_->getSuggestMinKeySize(),
+ gen_key_info_->getSuggestMaxKeySize());
+ keySizeSpinBox->setValue(gen_key_info_->getKeySize());
+ keySizeSpinBox->setSingleStep(gen_key_info_->getSizeChangeStep());
}
void SubkeyGenerateDialog::slotKeyGenAccept() {
@@ -228,19 +244,19 @@ void SubkeyGenerateDialog::slotKeyGenAccept() {
auto err_string = err_stream.str();
if (err_string.empty()) {
- genKeyInfo->setKeySize(keySizeSpinBox->value());
+ gen_key_info_->setKeySize(keySizeSpinBox->value());
if (expireCheckBox->checkState()) {
- genKeyInfo->setNonExpired(true);
+ gen_key_info_->setNonExpired(true);
} else {
- genKeyInfo->setExpired(
+ gen_key_info_->setExpired(
boost::posix_time::from_time_t(dateEdit->dateTime().toTime_t()));
}
GpgError error;
auto thread = QThread::create([&]() {
LOG(INFO) << "Thread Started";
- error = GpgKeyOpera::GetInstance().GenerateSubkey(mKey, genKeyInfo);
+ error = GpgKeyOpera::GetInstance().GenerateSubkey(key_, gen_key_info_);
});
thread->start();
@@ -282,39 +298,39 @@ void SubkeyGenerateDialog::slotKeyGenAccept() {
void SubkeyGenerateDialog::slotEncryptionBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowEncryption(false);
+ gen_key_info_->setAllowEncryption(false);
} else {
- genKeyInfo->setAllowEncryption(true);
+ gen_key_info_->setAllowEncryption(true);
}
}
void SubkeyGenerateDialog::slotSigningBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowSigning(false);
+ gen_key_info_->setAllowSigning(false);
} else {
- genKeyInfo->setAllowSigning(true);
+ gen_key_info_->setAllowSigning(true);
}
}
void SubkeyGenerateDialog::slotCertificationBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowCertification(false);
+ gen_key_info_->setAllowCertification(false);
} else {
- genKeyInfo->setAllowCertification(true);
+ gen_key_info_->setAllowCertification(true);
}
}
void SubkeyGenerateDialog::slotAuthenticationBoxChanged(int state) {
if (state == 0) {
- genKeyInfo->setAllowAuthentication(false);
+ gen_key_info_->setAllowAuthentication(false);
} else {
- genKeyInfo->setAllowAuthentication(true);
+ gen_key_info_->setAllowAuthentication(true);
}
}
void SubkeyGenerateDialog::slotActivatedKeyType(int index) {
qDebug() << "key type index changed " << index;
- genKeyInfo->setAlgo(this->keyTypeComboBox->itemText(index).toStdString());
+ gen_key_info_->setAlgo(this->keyTypeComboBox->itemText(index).toStdString());
refresh_widgets_state();
}
diff --git a/src/ui/keygen/SubkeyGenerateDialog.h b/src/ui/keygen/SubkeyGenerateDialog.h
index ec7c9fb1..78f3ac92 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.h
+++ b/src/ui/keygen/SubkeyGenerateDialog.h
@@ -41,9 +41,10 @@ class SubkeyGenerateDialog : public QDialog {
void SubKeyGenerated();
private:
- GpgKey mKey;
+ GpgKey key_;
- std::unique_ptr<GenKeyInfo> genKeyInfo = std::make_unique<GenKeyInfo>(true);
+ std::unique_ptr<GenKeyInfo> gen_key_info_ =
+ std::make_unique<GenKeyInfo>(true);
QGroupBox* keyUsageGroupBox{};
QDialogButtonBox* buttonBox; /** Box for standardbuttons */
@@ -54,12 +55,11 @@ class SubkeyGenerateDialog : public QDialog {
QCheckBox* expireCheckBox{}; /** Checkbox, if key should expire */
// ENCR, SIGN, CERT, AUTH
- std::vector<QCheckBox*> keyUsageCheckBoxes;
+ std::vector<QCheckBox*> key_usage_check_boxes_;
+ QDateTime max_date_time_;
QGroupBox* create_key_usage_group_box();
-
QGroupBox* create_basic_info_group_box();
-
void set_signal_slot();
/**
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 09f29958..d5aa262a 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -525,6 +525,11 @@ void MainWindow::slotVersionUpgrade(const SoftwareVersion& version) {
"Github Releases "
"Page.<br/>"))
.arg(version.latest_version.c_str()));
+ } else if (!version.CurrentVersionReleased()) {
+ statusBar()->showMessage(
+ QString(_("This maybe a BETA Version (Latest Stable Version: %1)."))
+ .arg(version.latest_version.c_str()),
+ 30000);
}
}
diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/settings/SettingsKeyServer.cpp
index db27e003..ee60b40e 100644
--- a/src/ui/settings/SettingsKeyServer.cpp
+++ b/src/ui/settings/SettingsKeyServer.cpp
@@ -25,6 +25,7 @@
#include "SettingsKeyServer.h"
#include "GlobalSettingStation.h"
+#include "ui/function/TestListedKeyServerThread.h"
#include "ui_KeyServerSettings.h"
namespace GpgFrontend::UI {
@@ -232,35 +233,73 @@ void KeyserverTab::refreshTable() {
}
void KeyserverTab::slotTestListedKeyServer() {
- ui->keyServerListTable->blockSignals(true);
auto timeout =
QInputDialog::getInt(this, _("Set TCP Timeout"), tr("timeout(ms): "),
QLineEdit::Normal, 500, 2000);
+ QStringList urls;
const auto row_size = ui->keyServerListTable->rowCount();
for (int i = 0; i < row_size; i++) {
- const auto keyserver = ui->keyServerListTable->item(i, 1)->text();
- const auto status = ui->keyServerListTable->item(i, 3);
- if (keyserver == nullptr || status == nullptr) continue;
-
- auto key_url = QUrl{keyserver};
-
- LOG(INFO) << "key domain" << key_url.host().toStdString();
-
- QTcpSocket socket(this);
- socket.abort();
- socket.connectToHost(key_url.host(), 80);
- if (socket.waitForConnected(timeout)) {
- status->setText(_("Reachable"));
- status->setForeground(QBrush(QColor::fromRgb(0, 255, 0)));
- } else {
- status->setText(_("Not Reachable"));
- status->setForeground(QBrush(QColor::fromRgb(255, 0, 0)));
- }
- socket.close();
+ const auto keyserver_url = ui->keyServerListTable->item(i, 1)->text();
+ urls.push_back(keyserver_url);
}
- ui->keyServerListTable->blockSignals(false);
+
+ auto thread = new TestListedKeyServerThread(urls, timeout, this);
+ connect(thread,
+ &GpgFrontend::UI::TestListedKeyServerThread::
+ signalKeyServerListTestResult,
+ this, [=](const QStringList& result) {
+ const auto row_size = ui->keyServerListTable->rowCount();
+ if (result.size() != row_size) return;
+ ui->keyServerListTable->blockSignals(true);
+ for (int i = 0; i < row_size; i++) {
+ const auto status = result[i];
+ auto status_iem = ui->keyServerListTable->item(i, 3);
+ if (status == "Reachable") {
+ status_iem->setText(_("Reachable"));
+ status_iem->setForeground(QBrush(QColor::fromRgb(0, 255, 0)));
+ } else {
+ status_iem->setText(_("Not Reachable"));
+ status_iem->setForeground(QBrush(QColor::fromRgb(255, 0, 0)));
+ }
+ }
+ ui->keyServerListTable->blockSignals(false);
+ });
+ connect(thread, &QThread::finished, thread, &QThread::deleteLater);
+
+ // Waiting Dialog
+ auto* waiting_dialog = new QProgressDialog(this);
+ waiting_dialog->setMaximum(0);
+ waiting_dialog->setMinimum(0);
+ auto waiting_dialog_label =
+ new QLabel(QString(_("Test Key Server Connection...")) + "<br /><br />" +
+ _("This test only tests the network connectivity of the key "
+ "server. Passing the test does not mean that the key server "
+ "is functionally available."));
+ waiting_dialog_label->setWordWrap(true);
+ waiting_dialog->setLabel(waiting_dialog_label);
+ waiting_dialog->resize(420, 120);
+ connect(thread, &QThread::finished, [=]() {
+ waiting_dialog->finished(0);
+ waiting_dialog->deleteLater();
+ });
+ connect(waiting_dialog, &QProgressDialog::canceled, [=]() {
+ LOG(INFO) << "cancel clicked";
+ if (thread->isRunning()) thread->terminate();
+ QCoreApplication::quit();
+ exit(0);
+ });
+
+ // Show Waiting Dialog
+ waiting_dialog->show();
+ waiting_dialog->setFocus();
+
+ thread->start();
+ QEventLoop loop;
+ connect(thread, &QThread::finished, &loop, &QEventLoop::quit);
+ loop.exec();
}
+
void KeyserverTab::contextMenuEvent(QContextMenuEvent* event) {
QWidget::contextMenuEvent(event);
if (ui->keyServerListTable->selectedItems().length() > 0) {
diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/smtp/SendMailDialog.cpp
index a758a18c..f3ec5711 100644
--- a/src/ui/smtp/SendMailDialog.cpp
+++ b/src/ui/smtp/SendMailDialog.cpp
@@ -129,6 +129,11 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
ui->attacSignatureCheckBox->setText(_("Attach signature"));
ui->attachSenderPublickeyCheckBox->setText(_("Attach sender's public key"));
ui->contentEncryptCheckBox->setText(_("Encrypt content"));
+ ui->recipientEdit->setText(_("Edit Recipients(s)"));
+ ui->ccEdit->setText(_("Edit CC(s)"));
+ ui->bccEdit->setText(_("Edit BCC(s)"));
+ ui->senderKeyLabel->setText(_("Sender GPG Key: "));
+ ui->recipientKeysLabel->setText(_("Recipient(s) GPG Key: "));
auto pos = QPoint(100, 100);
LOG(INFO) << "parent" << parent;
diff --git a/ui/SendMailDialog.ui b/ui/SendMailDialog.ui
index 245798da..d29a5f63 100644
--- a/ui/SendMailDialog.ui
+++ b/ui/SendMailDialog.ui
@@ -347,7 +347,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item alignment="Qt::AlignLeft|Qt::AlignVCenter">
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="senderKeyLabel">
<property name="text">
<string>Sender GPG Key: </string>
</property>
@@ -371,7 +371,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item alignment="Qt::AlignLeft|Qt::AlignVCenter">
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="recipientKeysLabel">
<property name="text">
<string>Recipient(s) GPG Key: </string>
</property>