refactor: TlsUtility::isEnabled is now a static member

This commit is contained in:
sithlord48
2025-11-22 08:32:00 -05:00
committed by Nick Bolton
parent bc857a7cb4
commit 4216acdb3a
4 changed files with 9 additions and 15 deletions

View File

@ -141,7 +141,7 @@ MainWindow::MainWindow()
qDebug().noquote() << "active settings path:" << Settings::settingsPath();
// Force generation of SHA256 for the localhost
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
if (TlsUtility::isEnabled()) {
if (Settings::value(Settings::Security::KeySize).toInt() < 2048) {
QMessageBox::information(
this, kAppName,
@ -371,7 +371,7 @@ void MainWindow::settingsChanged(const QString &key)
if ((key == Settings::Security::Certificate) || (key == Settings::Security::KeySize) ||
(key == Settings::Security::TlsEnabled) || (key == Settings::Security::CheckPeers)) {
if (m_tlsUtility.isEnabled() && !QFile::exists(Settings::value(Settings::Security::Certificate).toString())) {
if (TlsUtility::isEnabled() && !QFile::exists(Settings::value(Settings::Security::Certificate).toString())) {
m_tlsUtility.generateCertificate();
}
updateSecurityIcon(m_lblSecurityStatus->isVisible());
@ -581,7 +581,7 @@ void MainWindow::updateSecurityIcon(bool visible)
if (!visible)
return;
bool secureSocket = Settings::value(Settings::Security::TlsEnabled).toBool();
bool secureSocket = TlsUtility::isEnabled();
const auto txt =
secureSocket ? tr("%1 Encryption Enabled").arg(m_coreProcess.secureSocketVersion()) : tr("Encryption Disabled");
@ -1010,8 +1010,7 @@ void MainWindow::coreConnectionStateChanged(CoreConnectionState state)
void MainWindow::updateLocalFingerprint()
{
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
m_btnFingerprint->setVisible(tlsEnabled && QFile::exists(Settings::tlsLocalDb()));
m_btnFingerprint->setVisible(TlsUtility::isEnabled() && QFile::exists(Settings::tlsLocalDb()));
}
void MainWindow::hide()

View File

@ -234,11 +234,9 @@ void SettingsDialog::updateTlsControls()
ui->comboTlsKeyLength->setCurrentText(Settings::value(Settings::Security::KeySize).toString());
const auto tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
ui->lineTlsCertPath->setText(certificate);
ui->cbRequireClientCert->setChecked(Settings::value(Settings::Security::CheckPeers).toBool());
ui->groupSecurity->setChecked(tlsEnabled);
ui->groupSecurity->setChecked(TlsUtility::isEnabled());
ui->groupSecurity->setEnabled(Settings::isWritable());

View File

@ -18,7 +18,7 @@ TlsUtility::TlsUtility(QObject *parent) : QObject(parent)
// do nothing
}
bool TlsUtility::isEnabled() const
bool TlsUtility::isEnabled()
{
return Settings::value(Settings::Security::TlsEnabled).toBool();
}

View File

@ -23,13 +23,10 @@ public:
bool persistCertificate() const;
/**
* @brief Combines the availability and the enabled status of TLS.
*
* @return Given that the app setting for TLS is enabled:
* If licensing is enabled, it checks whether the product has TLS
* available, and if licensing is not enabled, true is returned.
* @brief Checks the settings values Settings::Security::TlsEnabled
* @return true when tls is enabled
*/
bool isEnabled() const;
static bool isEnabled();
private:
TlsCertificate m_certificate;