refactor: move tlsKeyLength to Settings
newkey: security/keySize <= General/tlsKeyLength removed tlsKeyLength from appconfig
This commit is contained in:
@ -153,7 +153,7 @@ void SettingsDialog::accept()
|
||||
Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked());
|
||||
m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked());
|
||||
m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text());
|
||||
m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt());
|
||||
Settings::setValue(Settings::Security::KeySize, ui->comboTlsKeyLength->currentText().toInt());
|
||||
Settings::setValue(Settings::Security::TlsEnabled, ui->groupSecurity->isChecked());
|
||||
m_appConfig.setLanguageSync(ui->cbLanguageSync->isChecked());
|
||||
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
|
||||
@ -210,12 +210,11 @@ void SettingsDialog::loadFromConfig()
|
||||
|
||||
void SettingsDialog::updateTlsControls()
|
||||
{
|
||||
|
||||
if (QFile(m_appConfig.tlsCertPath()).exists()) {
|
||||
updateKeyLengthOnFile(m_appConfig.tlsCertPath());
|
||||
} else {
|
||||
const auto keyLengthText = QString::number(m_appConfig.tlsKeyLength());
|
||||
ui->comboTlsKeyLength->setCurrentIndex(ui->comboTlsKeyLength->findText(keyLengthText));
|
||||
const auto keyLengthText = Settings::value(Settings::Security::KeySize).toString();
|
||||
ui->comboTlsKeyLength->setCurrentText(keyLengthText);
|
||||
}
|
||||
|
||||
const auto tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
@ -262,9 +261,8 @@ void SettingsDialog::updateKeyLengthOnFile(const QString &path)
|
||||
}
|
||||
|
||||
auto length = ssl.getCertKeyLength(path);
|
||||
auto index = ui->comboTlsKeyLength->findText(QString::number(length));
|
||||
ui->comboTlsKeyLength->setCurrentIndex(index);
|
||||
m_appConfig.setTlsKeyLength(length);
|
||||
ui->comboTlsKeyLength->setCurrentText(QString::number(length));
|
||||
Settings::setValue(Settings::Security::KeySize, length);
|
||||
}
|
||||
|
||||
void SettingsDialog::updateControls()
|
||||
|
||||
@ -82,6 +82,9 @@ QVariant Settings::defaultValue(const QString &key)
|
||||
if (key == Gui::WindowGeometry)
|
||||
return QRect();
|
||||
|
||||
if (key == Security::KeySize)
|
||||
return 2048;
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ public:
|
||||
};
|
||||
struct Security
|
||||
{
|
||||
inline static const auto KeySize = QStringLiteral("security/keySize");
|
||||
inline static const auto TlsEnabled = QStringLiteral("security/tlsEnabled");
|
||||
};
|
||||
|
||||
@ -89,6 +90,7 @@ private:
|
||||
, Gui::LogExpanded
|
||||
, Gui::SymbolicTrayIcon
|
||||
, Gui::WindowGeometry
|
||||
, Security::KeySize
|
||||
, Security::TlsEnabled
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@ -60,7 +60,7 @@ const char *const AppConfig::m_SettingsName[] = {
|
||||
"groupClientChecked",
|
||||
"serverHostname",
|
||||
"tlsCertPath",
|
||||
"tlsKeyLength",
|
||||
"", // 27 key length Moved to Deskflow settings
|
||||
"preventSleep",
|
||||
"languageSync",
|
||||
"invertScrollDirection",
|
||||
@ -132,7 +132,6 @@ void AppConfig::recallFromCurrentScope()
|
||||
m_InvertScrollDirection = getFromCurrentScope(kInvertScrollDirection, m_InvertScrollDirection).toBool();
|
||||
m_EnableService = getFromCurrentScope(kEnableService, m_EnableService).toBool();
|
||||
m_TlsCertPath = getFromCurrentScope(kTlsCertPath, m_TlsCertPath).toString();
|
||||
m_TlsKeyLength = getFromCurrentScope(kTlsKeyLength, m_TlsKeyLength).toInt();
|
||||
m_RequireClientCert = getFromCurrentScope(kRequireClientCert, m_RequireClientCert).toBool();
|
||||
}
|
||||
|
||||
@ -468,11 +467,6 @@ QString AppConfig::tlsCertPath() const
|
||||
return m_TlsCertPath;
|
||||
}
|
||||
|
||||
int AppConfig::tlsKeyLength() const
|
||||
{
|
||||
return m_TlsKeyLength;
|
||||
}
|
||||
|
||||
bool AppConfig::enableService() const
|
||||
{
|
||||
return m_EnableService;
|
||||
@ -531,16 +525,6 @@ void AppConfig::setTlsCertPath(const QString &value)
|
||||
m_TlsCertPath = value;
|
||||
}
|
||||
|
||||
void AppConfig::setTlsKeyLength(int value)
|
||||
{
|
||||
if (m_TlsKeyLength != value) {
|
||||
// deliberately only set the changed flag if there was a change.
|
||||
// it's important not to set this flag to false here.
|
||||
m_TlsChanged = true;
|
||||
}
|
||||
m_TlsKeyLength = value;
|
||||
}
|
||||
|
||||
void AppConfig::setServerGroupChecked(bool newValue)
|
||||
{
|
||||
m_ServerGroupChecked = newValue;
|
||||
|
||||
@ -27,7 +27,6 @@ namespace deskflow::gui {
|
||||
|
||||
const ElevateMode kDefaultElevateMode = ElevateMode::kAutomatic;
|
||||
const QString kDefaultLogFile = QStringLiteral("%1.log").arg(kAppId);
|
||||
const int kDefaultTlsKeyLength = 2048;
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
const ProcessMode kDefaultProcessMode = ProcessMode::kService;
|
||||
@ -82,7 +81,7 @@ private:
|
||||
kClientGroupChecked = 24,
|
||||
kServerHostname = 25,
|
||||
kTlsCertPath = 26,
|
||||
kTlsKeyLength = 27,
|
||||
// 27 = tlsKeyLength Moved to deskflow settings
|
||||
kPreventSleep = 28,
|
||||
kLanguageSync = 29,
|
||||
kInvertScrollDirection = 30,
|
||||
@ -136,7 +135,6 @@ public:
|
||||
ProcessMode processMode() const override;
|
||||
ElevateMode elevateMode() const override;
|
||||
QString tlsCertPath() const override;
|
||||
int tlsKeyLength() const override;
|
||||
QString logLevelText() const override;
|
||||
const QString &screenName() const override;
|
||||
bool logToFile() const override;
|
||||
@ -184,7 +182,6 @@ public:
|
||||
void setPreventSleep(bool b) override;
|
||||
void setEnableService(bool enabled) override;
|
||||
void setTlsCertPath(const QString &path) override;
|
||||
void setTlsKeyLength(int length) override;
|
||||
void setRequireClientCerts(bool requireClientCerts) override;
|
||||
|
||||
//
|
||||
@ -291,7 +288,6 @@ private:
|
||||
bool m_ClientGroupChecked = false;
|
||||
QString m_ServerHostname = "";
|
||||
bool m_EnableService = deskflow::gui::kDefaultProcessMode == ProcessMode::kService;
|
||||
int m_TlsKeyLength = deskflow::gui::kDefaultTlsKeyLength;
|
||||
bool m_LoadFromSystemScope = false;
|
||||
bool m_RequireClientCert = true;
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ public:
|
||||
|
||||
virtual IConfigScopes &scopes() const = 0;
|
||||
virtual QString tlsCertPath() const = 0;
|
||||
virtual int tlsKeyLength() const = 0;
|
||||
virtual ProcessMode processMode() const = 0;
|
||||
virtual ElevateMode elevateMode() const = 0;
|
||||
virtual QString logLevelText() const = 0;
|
||||
@ -72,7 +71,6 @@ public:
|
||||
virtual void setElevateMode(ElevateMode elevateMode) = 0;
|
||||
virtual void setPreventSleep(bool preventSleep) = 0;
|
||||
virtual void setTlsCertPath(const QString &tlsCertPath) = 0;
|
||||
virtual void setTlsKeyLength(int tlsKeyLength) = 0;
|
||||
virtual void setLanguageSync(bool languageSync) = 0;
|
||||
virtual void setInvertScrollDirection(bool invertScrollDirection) = 0;
|
||||
virtual void setEnableService(bool enableService) = 0;
|
||||
|
||||
@ -37,7 +37,7 @@ bool TlsUtility::generateCertificate()
|
||||
return false;
|
||||
}
|
||||
|
||||
auto length = m_appConfig.tlsKeyLength();
|
||||
auto length = Settings::value(Settings::Security::KeySize).toInt();
|
||||
|
||||
return m_certificate.generateCertificate(m_appConfig.tlsCertPath(), length);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ public:
|
||||
|
||||
MOCK_METHOD(deskflow::gui::IConfigScopes &, scopes, (), (const, override));
|
||||
MOCK_METHOD(QString, tlsCertPath, (), (const, override));
|
||||
MOCK_METHOD(int, tlsKeyLength, (), (const, override));
|
||||
MOCK_METHOD(ProcessMode, processMode, (), (const, override));
|
||||
MOCK_METHOD(ElevateMode, elevateMode, (), (const, override));
|
||||
MOCK_METHOD(QString, logLevelText, (), (const, override));
|
||||
@ -73,7 +72,6 @@ public:
|
||||
MOCK_METHOD(void, setElevateMode, (ElevateMode elevateMode), (override));
|
||||
MOCK_METHOD(void, setPreventSleep, (bool preventSleep), (override));
|
||||
MOCK_METHOD(void, setTlsCertPath, (const QString &tlsCertPath), (override));
|
||||
MOCK_METHOD(void, setTlsKeyLength, (int tlsKeyLength), (override));
|
||||
MOCK_METHOD(void, setLanguageSync, (bool languageSync), (override));
|
||||
MOCK_METHOD(void, setInvertScrollDirection, (bool invertScrollDirection), (override));
|
||||
MOCK_METHOD(void, setEnableService, (bool enableService), (override));
|
||||
|
||||
Reference in New Issue
Block a user