2012-06-10 16:50:54 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2016-09-07 14:24:00 +00:00
|
|
|
* Copyright (C) 2012-2016 Symless Ltd.
|
2012-06-10 16:50:54 +00:00
|
|
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
2016-10-18 17:45:15 +00:00
|
|
|
*
|
2012-06-10 16:50:54 +00:00
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2016-10-18 17:45:15 +00:00
|
|
|
*
|
2012-06-10 16:50:54 +00:00
|
|
|
* This package 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-13 09:21:02 +00:00
|
|
|
#include "QSynergyApplication.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
#include "AppConfig.h"
|
2013-06-04 17:37:27 +00:00
|
|
|
#include "QUtility.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
#include <QtCore>
|
|
|
|
|
#include <QtNetwork>
|
2020-02-25 17:00:30 +00:00
|
|
|
#include <QtWidgets/QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
#include "ConfigWriter.h"
|
2020-11-10 11:26:37 +00:00
|
|
|
#include "SslCertificate.h"
|
2020-04-23 17:11:20 +00:00
|
|
|
|
2021-02-04 17:10:27 +00:00
|
|
|
using GUI::Config::ConfigWriter;
|
2012-06-10 16:50:54 +00:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
|
const char AppConfig::m_SynergysName[] = "synergys.exe";
|
|
|
|
|
const char AppConfig::m_SynergycName[] = "synergyc.exe";
|
|
|
|
|
const char AppConfig::m_SynergyLogDir[] = "log/";
|
2020-03-31 10:09:50 +00:00
|
|
|
const char AppConfig::synergyConfigName[] = "synergy.sgc";
|
2012-07-28 22:58:51 +00:00
|
|
|
#define DEFAULT_PROCESS_MODE Service
|
2012-06-10 16:50:54 +00:00
|
|
|
#else
|
|
|
|
|
const char AppConfig::m_SynergysName[] = "synergys";
|
|
|
|
|
const char AppConfig::m_SynergycName[] = "synergyc";
|
|
|
|
|
const char AppConfig::m_SynergyLogDir[] = "/var/log/";
|
2020-03-31 10:09:50 +00:00
|
|
|
const char AppConfig::synergyConfigName[] = "synergy.conf";
|
2012-07-28 22:58:51 +00:00
|
|
|
#define DEFAULT_PROCESS_MODE Desktop
|
2012-06-10 16:50:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
2016-06-10 14:43:44 +00:00
|
|
|
const ElevateMode defaultElevateMode = ElevateAsNeeded;
|
|
|
|
|
|
2020-02-12 16:28:31 +00:00
|
|
|
const char* AppConfig::m_SynergySettingsName[] = {
|
|
|
|
|
"screenName",
|
|
|
|
|
"port",
|
|
|
|
|
"interface",
|
|
|
|
|
"logLevel2",
|
|
|
|
|
"logToFile",
|
|
|
|
|
"logFilename",
|
|
|
|
|
"wizardLastRun",
|
|
|
|
|
"language",
|
|
|
|
|
"startedBefore",
|
|
|
|
|
"autoConfig",
|
|
|
|
|
"autoConfigServer",
|
|
|
|
|
"elevateMode",
|
|
|
|
|
"elevateModeEnum",
|
|
|
|
|
"edition",
|
|
|
|
|
"cryptoEnabled",
|
|
|
|
|
"autoHide",
|
|
|
|
|
"serialKey",
|
|
|
|
|
"lastVersion",
|
|
|
|
|
"lastExpiringWarningTime",
|
|
|
|
|
"activationHasRun",
|
2020-02-25 17:00:30 +00:00
|
|
|
"minimizeToTray",
|
2020-02-27 00:40:58 +00:00
|
|
|
"ActivateEmail",
|
2020-03-31 10:09:50 +00:00
|
|
|
"loadFromSystemScope",
|
|
|
|
|
"groupServerChecked",
|
|
|
|
|
"useExternalConfig",
|
|
|
|
|
"configFile",
|
|
|
|
|
"useInternalConfig",
|
|
|
|
|
"groupClientChecked",
|
|
|
|
|
"serverHostname",
|
2020-07-27 16:21:46 +00:00
|
|
|
"tlsCertPath",
|
|
|
|
|
"tlsKeyLength",
|
2021-10-04 15:51:12 +00:00
|
|
|
"preventSleep",
|
2022-01-26 12:07:28 +00:00
|
|
|
"languageSync",
|
2022-07-04 09:51:05 +00:00
|
|
|
"invertScrollDirection",
|
2022-09-13 15:31:45 +00:00
|
|
|
"eliteBackersUrl",
|
|
|
|
|
"guid",
|
|
|
|
|
"licenseRegistryUrl",
|
2022-09-22 08:12:13 +00:00
|
|
|
"licenseNextCheck",
|
|
|
|
|
"initiateConnectionFromServer",
|
|
|
|
|
"clientHostMode",
|
|
|
|
|
"serverClientMode"
|
2020-02-12 16:28:31 +00:00
|
|
|
};
|
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
static const char* logLevelNames[] =
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
"INFO",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
"DEBUG1",
|
|
|
|
|
"DEBUG2"
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|
|
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
AppConfig::AppConfig() :
|
2016-12-28 11:50:32 +00:00
|
|
|
m_ScreenName(),
|
|
|
|
|
m_Port(24800),
|
|
|
|
|
m_Interface(),
|
|
|
|
|
m_LogLevel(0),
|
2022-09-22 08:12:13 +00:00
|
|
|
m_LogToFile(),
|
2016-12-28 11:50:32 +00:00
|
|
|
m_WizardLastRun(0),
|
|
|
|
|
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
2022-09-22 08:12:13 +00:00
|
|
|
m_StartedBefore(),
|
2016-12-28 11:50:32 +00:00
|
|
|
m_AutoConfig(true),
|
2022-09-22 08:12:13 +00:00
|
|
|
m_AutoConfigServer(),
|
2016-12-28 11:50:32 +00:00
|
|
|
m_ElevateMode(defaultElevateMode),
|
2022-09-22 08:12:13 +00:00
|
|
|
m_Edition(kUnregistered),
|
2016-12-28 11:50:32 +00:00
|
|
|
m_CryptoEnabled(false),
|
|
|
|
|
m_AutoHide(false),
|
2018-09-04 20:32:24 +00:00
|
|
|
m_LastExpiringWarningTime(0),
|
2020-04-23 17:11:20 +00:00
|
|
|
m_ActivationHasRun(),
|
2022-09-22 08:12:13 +00:00
|
|
|
m_MinimizeToTray(false),
|
2020-04-23 17:11:20 +00:00
|
|
|
m_ServerGroupChecked(),
|
|
|
|
|
m_UseExternalConfig(),
|
|
|
|
|
m_UseInternalConfig(),
|
|
|
|
|
m_ClientGroupChecked(),
|
2020-04-23 18:07:50 +00:00
|
|
|
m_LoadFromSystemScope()
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
auto writer = ConfigWriter::make();
|
|
|
|
|
|
|
|
|
|
//Register this class to receive global load and saves
|
|
|
|
|
writer->registerClass(this);
|
2021-02-04 17:10:27 +00:00
|
|
|
writer->globalLoad();
|
|
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
//User settings exist and the load from system scope variable is true
|
2021-02-04 17:10:27 +00:00
|
|
|
if (writer->hasSetting(settingName(kLoadSystemSettings), ConfigWriter::kUser)) {
|
|
|
|
|
setLoadFromSystemScope(m_LoadFromSystemScope);
|
2020-04-23 17:11:20 +00:00
|
|
|
}
|
2020-02-25 17:00:30 +00:00
|
|
|
//If user setting don't exist but system ones do, load the system settings
|
2021-02-04 17:10:27 +00:00
|
|
|
else if (writer->hasSetting(settingName(kScreenName), ConfigWriter::kSystem)) {
|
|
|
|
|
setLoadFromSystemScope(true);
|
2020-02-13 09:21:02 +00:00
|
|
|
}
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-30 14:03:49 +00:00
|
|
|
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
|
|
|
|
|
|
|
|
|
int AppConfig::port() const { return m_Port; }
|
|
|
|
|
|
2016-10-12 09:41:44 +00:00
|
|
|
const QString &AppConfig::networkInterface() const { return m_Interface; }
|
2016-09-30 14:03:49 +00:00
|
|
|
|
|
|
|
|
int AppConfig::logLevel() const { return m_LogLevel; }
|
|
|
|
|
|
|
|
|
|
bool AppConfig::logToFile() const { return m_LogToFile; }
|
|
|
|
|
|
|
|
|
|
const QString &AppConfig::logFilename() const { return m_LogFilename; }
|
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
QString AppConfig::synergyLogDir() const
|
|
|
|
|
{
|
2018-06-07 15:22:49 +00:00
|
|
|
// by default log to home dir
|
|
|
|
|
return QDir::home().absolutePath() + "/";
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::synergyProgramDir() const
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
// synergy binaries should be in the same dir.
|
|
|
|
|
return QCoreApplication::applicationDirPath() + "/";
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::persistLogDir()
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
QDir dir = synergyLogDir();
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
// persist the log directory
|
|
|
|
|
if (!dir.exists())
|
|
|
|
|
{
|
|
|
|
|
dir.mkpath(dir.path());
|
|
|
|
|
}
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-18 13:14:12 +00:00
|
|
|
const QString AppConfig::logFilenameCmd() const
|
2014-06-18 12:59:30 +00:00
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
QString filename = m_LogFilename;
|
2014-06-18 12:59:30 +00:00
|
|
|
#if defined(Q_OS_WIN)
|
2016-12-28 11:50:32 +00:00
|
|
|
// wrap in quotes in case username contains spaces.
|
|
|
|
|
filename = QString("\"%1\"").arg(filename);
|
2014-06-18 12:59:30 +00:00
|
|
|
#endif
|
2016-12-28 11:50:32 +00:00
|
|
|
return filename;
|
2014-06-18 12:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
QString AppConfig::logLevelText() const
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
return logLevelNames[logLevel()];
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-30 14:03:49 +00:00
|
|
|
ProcessMode AppConfig::processMode() const { return m_ProcessMode; }
|
|
|
|
|
|
|
|
|
|
bool AppConfig::wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; }
|
|
|
|
|
|
|
|
|
|
const QString &AppConfig::language() const { return m_Language; }
|
|
|
|
|
|
|
|
|
|
bool AppConfig::startedBefore() const { return m_StartedBefore; }
|
|
|
|
|
|
2018-09-04 21:10:56 +00:00
|
|
|
bool AppConfig::autoConfig() const {
|
2021-02-15 11:44:46 +00:00
|
|
|
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
|
2018-09-04 21:10:56 +00:00
|
|
|
return m_AutoConfig;
|
|
|
|
|
#else
|
|
|
|
|
// always disable auto config for enterprise edition.
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2018-09-04 20:32:24 +00:00
|
|
|
QString AppConfig::autoConfigServer() const { return m_AutoConfigServer; }
|
|
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
void AppConfig::loadSettings()
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
2020-04-27 11:53:39 +00:00
|
|
|
m_ScreenName = loadSetting(kScreenName, QHostInfo::localHostName()).toString();
|
2021-02-22 11:33:18 +00:00
|
|
|
if (m_ScreenName.isEmpty()) {
|
|
|
|
|
m_ScreenName = QHostInfo::localHostName();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 11:53:39 +00:00
|
|
|
m_Port = loadSetting(kPort, 24800).toInt();
|
|
|
|
|
m_Interface = loadSetting(kInterfaceSetting).toString();
|
|
|
|
|
m_LogLevel = loadSetting(kLogLevel, 0).toInt();
|
|
|
|
|
m_LogToFile = loadSetting(kLogToFile, false).toBool();
|
|
|
|
|
m_LogFilename = loadSetting(kLogFilename, synergyLogDir() + "synergy.log").toString();
|
2021-02-04 17:10:27 +00:00
|
|
|
m_WizardLastRun = loadCommonSetting(kWizardLastRun, 0).toInt();
|
2020-04-27 11:53:39 +00:00
|
|
|
m_Language = loadSetting(kLanguage, QLocale::system().name()).toString();
|
|
|
|
|
m_StartedBefore = loadSetting(kStartedBefore, false).toBool();
|
|
|
|
|
m_AutoConfig = loadSetting(kAutoConfig, false).toBool();
|
|
|
|
|
m_AutoConfigServer = loadSetting(kAutoConfigServer, "").toString();
|
2020-02-12 16:28:31 +00:00
|
|
|
|
|
|
|
|
{ //Scope related code together
|
2020-04-27 11:53:39 +00:00
|
|
|
// TODO Investigate why kElevateModeEnum isn't loaded fully
|
|
|
|
|
QVariant elevateMode = loadSetting(kElevateModeEnum);
|
2020-02-12 16:28:31 +00:00
|
|
|
if (!elevateMode.isValid()) {
|
2020-04-27 11:53:39 +00:00
|
|
|
elevateMode = loadSetting(kElevateModeSetting,
|
|
|
|
|
QVariant(static_cast<int>(defaultElevateMode)));
|
2020-02-12 16:28:31 +00:00
|
|
|
}
|
|
|
|
|
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
2016-12-28 11:50:32 +00:00
|
|
|
}
|
2020-02-12 16:28:31 +00:00
|
|
|
|
2020-04-27 11:53:39 +00:00
|
|
|
m_ActivateEmail = loadSetting(kActivateEmail, "").toString();
|
|
|
|
|
m_CryptoEnabled = loadSetting(kCryptoEnabled, true).toBool();
|
|
|
|
|
m_AutoHide = loadSetting(kAutoHide, false).toBool();
|
|
|
|
|
m_lastVersion = loadSetting(kLastVersion, "Unknown").toString();
|
|
|
|
|
m_LastExpiringWarningTime = loadSetting(kLastExpireWarningTime, 0).toInt();
|
|
|
|
|
m_ActivationHasRun = loadSetting(kActivationHasRun, false).toBool();
|
|
|
|
|
m_MinimizeToTray = loadSetting(kMinimizeToTray, false).toBool();
|
2021-02-04 17:10:27 +00:00
|
|
|
m_LoadFromSystemScope = loadCommonSetting(kLoadSystemSettings, false).toBool();
|
2020-04-27 11:53:39 +00:00
|
|
|
m_ServerGroupChecked = loadSetting(kGroupServerCheck, false).toBool();
|
|
|
|
|
m_UseExternalConfig = loadSetting(kUseExternalConfig, false).toBool();
|
|
|
|
|
m_ConfigFile = loadSetting(kConfigFile, QDir::homePath() + "/" + synergyConfigName).toString();
|
|
|
|
|
m_UseInternalConfig = loadSetting(kUseInternalConfig, false).toBool();
|
2021-04-15 14:59:03 +00:00
|
|
|
m_ClientGroupChecked = loadSetting(kGroupClientCheck, false).toBool();
|
2020-04-27 11:53:39 +00:00
|
|
|
m_ServerHostname = loadSetting(kServerHostname).toString();
|
2021-05-31 08:53:49 +00:00
|
|
|
m_PreventSleep = loadSetting(kPreventSleep, false).toBool();
|
2021-10-04 15:51:12 +00:00
|
|
|
m_LanguageSync = loadSetting(kLanguageSync, false).toBool();
|
2022-01-26 12:07:28 +00:00
|
|
|
m_InvertScrollDirection = loadSetting(kInvertScrollDirection, false).toBool();
|
2022-07-04 09:51:05 +00:00
|
|
|
m_eliteBackersUrl = loadCommonSetting(kEliteBackersUrl, "https://api2.prod.symless.com/credits/elite-backers").toString();
|
2022-09-13 15:31:45 +00:00
|
|
|
m_guid = loadCommonSetting(kGuid, QUuid::createUuid()).toString();
|
|
|
|
|
m_licenseRegistryUrl = loadCommonSetting(kLicenseRegistryUrl, "https://api2.prod.symless.com/license/register").toString();
|
|
|
|
|
m_licenseNextCheck = loadCommonSetting(kLicenseNextCheck, 0).toULongLong();
|
2022-09-22 08:12:13 +00:00
|
|
|
m_ClientHostMode = loadSetting(kClientHostMode, true).toBool();
|
|
|
|
|
m_ServerClientMode = loadSetting(kServerClientMode, true).toBool();
|
|
|
|
|
m_InitiateConnectionFromServer = loadSetting(kInitiateConnectionFromServer, false).toBool();
|
2020-02-12 16:28:31 +00:00
|
|
|
|
2020-09-10 12:30:33 +00:00
|
|
|
//only change the serial key if the settings being loaded contains a key
|
2021-02-04 17:10:27 +00:00
|
|
|
bool updateSerial = ConfigWriter::make()
|
|
|
|
|
->hasSetting(settingName(kLoadSystemSettings),ConfigWriter::kCurrent);
|
2020-09-10 12:30:33 +00:00
|
|
|
//if the setting exists and is not empty
|
|
|
|
|
updateSerial = updateSerial && !loadSetting(kSerialKey, "").toString().trimmed().isEmpty();
|
|
|
|
|
|
|
|
|
|
if (updateSerial) {
|
|
|
|
|
m_Serialkey = loadSetting(kSerialKey, "").toString().trimmed();
|
2020-10-07 07:54:34 +00:00
|
|
|
m_Edition = static_cast<Edition>(loadSetting(kEditionSetting, kUnregistered).toInt());
|
2020-09-10 12:30:33 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-27 16:21:46 +00:00
|
|
|
//Set the default path of the TLS certificate file in the users DIR
|
|
|
|
|
QString certificateFilename = QString("%1/%2/%3").arg(m_CoreInterface.getProfileDir(),
|
|
|
|
|
"SSL",
|
|
|
|
|
"Synergy.pem");
|
|
|
|
|
|
|
|
|
|
m_TLSCertificatePath = loadSetting(kTLSCertPath, certificateFilename).toString();
|
2020-07-28 12:00:20 +00:00
|
|
|
m_TLSKeyLength = loadSetting(kTLSKeyLength, "2048").toString();
|
2020-04-23 17:11:20 +00:00
|
|
|
|
2020-11-19 14:21:07 +00:00
|
|
|
if (getCryptoEnabled()) {
|
|
|
|
|
generateCertificate();
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::saveSettings()
|
|
|
|
|
{
|
2021-03-23 07:49:52 +00:00
|
|
|
setCommonSetting(kWizardLastRun, m_WizardLastRun);
|
2021-02-05 17:32:26 +00:00
|
|
|
setCommonSetting(kLoadSystemSettings, m_LoadFromSystemScope);
|
2022-06-07 11:44:49 +00:00
|
|
|
setCommonSetting(kGroupClientCheck, m_ClientGroupChecked);
|
|
|
|
|
setCommonSetting(kGroupServerCheck, m_ServerGroupChecked);
|
2022-07-04 09:51:05 +00:00
|
|
|
setCommonSetting(kEliteBackersUrl, m_eliteBackersUrl);
|
2022-09-13 15:31:45 +00:00
|
|
|
setCommonSetting(kGuid, m_guid);
|
|
|
|
|
setCommonSetting(kLicenseRegistryUrl, m_licenseRegistryUrl);
|
|
|
|
|
setCommonSetting(kLicenseNextCheck, m_licenseNextCheck);
|
2021-02-05 17:32:26 +00:00
|
|
|
|
2021-02-05 15:14:52 +00:00
|
|
|
if (isWritable()) {
|
|
|
|
|
setSetting(kScreenName, m_ScreenName);
|
|
|
|
|
setSetting(kPort, m_Port);
|
|
|
|
|
setSetting(kInterfaceSetting, m_Interface);
|
|
|
|
|
setSetting(kLogLevel, m_LogLevel);
|
|
|
|
|
setSetting(kLogToFile, m_LogToFile);
|
|
|
|
|
setSetting(kLogFilename, m_LogFilename);
|
|
|
|
|
setSetting(kLanguage, m_Language);
|
|
|
|
|
setSetting(kStartedBefore, m_StartedBefore);
|
|
|
|
|
setSetting(kAutoConfig, m_AutoConfig);
|
|
|
|
|
setSetting(kAutoConfigServer, m_AutoConfigServer);
|
|
|
|
|
// Refer to enum ElevateMode declaration for insight in to why this
|
|
|
|
|
// flag is mapped this way
|
|
|
|
|
setSetting(kElevateModeSetting, m_ElevateMode == ElevateAlways);
|
|
|
|
|
setSetting(kElevateModeEnum, static_cast<int>(m_ElevateMode));
|
|
|
|
|
setSetting(kEditionSetting, m_Edition);
|
|
|
|
|
setSetting(kCryptoEnabled, m_CryptoEnabled);
|
|
|
|
|
setSetting(kAutoHide, m_AutoHide);
|
|
|
|
|
setSetting(kSerialKey, m_Serialkey);
|
|
|
|
|
setSetting(kLastVersion, m_lastVersion);
|
|
|
|
|
setSetting(kLastExpireWarningTime, m_LastExpiringWarningTime);
|
|
|
|
|
setSetting(kActivationHasRun, m_ActivationHasRun);
|
|
|
|
|
setSetting(kMinimizeToTray, m_MinimizeToTray);
|
|
|
|
|
setSetting(kUseExternalConfig, m_UseExternalConfig);
|
|
|
|
|
setSetting(kConfigFile, m_ConfigFile);
|
|
|
|
|
setSetting(kUseInternalConfig, m_UseInternalConfig);
|
|
|
|
|
setSetting(kServerHostname, m_ServerHostname);
|
2021-05-31 08:53:49 +00:00
|
|
|
setSetting(kPreventSleep, m_PreventSleep);
|
2021-10-04 15:51:12 +00:00
|
|
|
setSetting(kLanguageSync, m_LanguageSync);
|
2022-01-26 12:07:28 +00:00
|
|
|
setSetting(kInvertScrollDirection, m_InvertScrollDirection);
|
2022-09-22 08:12:13 +00:00
|
|
|
setSetting(kClientHostMode, m_ClientHostMode);
|
|
|
|
|
setSetting(kServerClientMode, m_ServerClientMode);
|
2021-02-05 15:14:52 +00:00
|
|
|
}
|
2020-02-12 16:28:31 +00:00
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
m_unsavedChanges = false;
|
2016-09-30 15:04:49 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-07 15:22:49 +00:00
|
|
|
#ifndef SYNERGY_ENTERPRISE
|
2016-09-30 15:04:49 +00:00
|
|
|
bool AppConfig::activationHasRun() const
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
return m_ActivationHasRun;
|
2016-09-30 15:04:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppConfig& AppConfig::activationHasRun(bool value)
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
m_ActivationHasRun = value;
|
|
|
|
|
return *this;
|
2013-04-11 16:51:17 +00:00
|
|
|
}
|
2018-06-07 15:22:49 +00:00
|
|
|
#endif
|
2013-04-11 16:51:17 +00:00
|
|
|
|
2016-10-26 14:57:38 +00:00
|
|
|
QString AppConfig::lastVersion() const
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
return m_lastVersion;
|
2016-10-26 14:57:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setLastVersion(const QString& version) {
|
|
|
|
|
setSettingModified(m_lastVersion, version);
|
2016-10-26 14:57:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setScreenName(const QString &s) {
|
|
|
|
|
setSettingModified(m_ScreenName, s);
|
2021-01-20 11:27:46 +00:00
|
|
|
emit screenNameChanged();
|
2020-03-31 14:18:57 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setPort(int i) {
|
|
|
|
|
setSettingModified(m_Port, i);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setNetworkInterface(const QString &s) {
|
|
|
|
|
setSettingModified(m_Interface, s);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setLogLevel(int i) {
|
|
|
|
|
setSettingModified(m_LogLevel, i);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setLogToFile(bool b) {
|
|
|
|
|
setSettingModified(m_LogToFile, b);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setLogFilename(const QString &s) {
|
|
|
|
|
setSettingModified(m_LogFilename, s);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setWizardHasRun() {
|
|
|
|
|
setSettingModified(m_WizardLastRun, kWizardVersion);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setLanguage(const QString& language) {
|
|
|
|
|
setSettingModified(m_Language, language);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setStartedBefore(bool b) {
|
|
|
|
|
setSettingModified(m_StartedBefore, b);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setElevateMode(ElevateMode em) {
|
|
|
|
|
setSettingModified(m_ElevateMode, em);
|
|
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2014-11-28 10:51:52 +00:00
|
|
|
void AppConfig::setAutoConfig(bool autoConfig)
|
2014-08-26 11:22:09 +00:00
|
|
|
{
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_AutoConfig, autoConfig);
|
2020-04-01 09:21:33 +00:00
|
|
|
emit zeroConfToggled();
|
2014-08-26 11:22:09 +00:00
|
|
|
}
|
2014-10-27 17:10:12 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setAutoConfigServer(const QString& autoConfigServer)
|
2018-09-04 20:32:24 +00:00
|
|
|
{
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_AutoConfigServer, autoConfigServer);
|
2018-09-04 20:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-07 15:22:49 +00:00
|
|
|
#ifndef SYNERGY_ENTERPRISE
|
2016-10-14 16:38:31 +00:00
|
|
|
void AppConfig::setEdition(Edition e) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_Edition, e);
|
2021-02-04 17:10:27 +00:00
|
|
|
setCommonSetting(kEditionSetting, m_Edition);
|
2016-10-04 12:41:27 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2016-10-14 16:38:31 +00:00
|
|
|
Edition AppConfig::edition() const { return m_Edition; }
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setSerialKey(const QString& serial) {
|
|
|
|
|
setSettingModified(m_Serialkey, serial);
|
2021-02-04 17:10:27 +00:00
|
|
|
setCommonSetting(kSerialKey, m_Serialkey);
|
2016-09-30 14:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::clearSerialKey()
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
m_Serialkey.clear();
|
2016-09-30 14:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 15:31:45 +00:00
|
|
|
QString AppConfig::serialKey() const { return m_Serialkey; }
|
2016-09-30 14:03:49 +00:00
|
|
|
|
|
|
|
|
int AppConfig::lastExpiringWarningTime() const { return m_LastExpiringWarningTime; }
|
|
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setLastExpiringWarningTime(int newValue) {
|
|
|
|
|
setSettingModified(m_LastExpiringWarningTime, newValue);
|
|
|
|
|
}
|
2018-06-07 15:22:49 +00:00
|
|
|
#endif
|
2016-09-30 14:03:49 +00:00
|
|
|
|
|
|
|
|
QString AppConfig::synergysName() const { return m_SynergysName; }
|
|
|
|
|
|
|
|
|
|
QString AppConfig::synergycName() const { return m_SynergycName; }
|
|
|
|
|
|
2016-06-07 16:20:22 +00:00
|
|
|
ElevateMode AppConfig::elevateMode()
|
2014-10-27 17:10:12 +00:00
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
return m_ElevateMode;
|
2014-10-27 17:10:12 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setCryptoEnabled(bool newValue) {
|
2020-11-10 11:26:37 +00:00
|
|
|
if (m_CryptoEnabled != newValue && newValue){
|
|
|
|
|
generateCertificate();
|
|
|
|
|
}
|
2021-02-01 19:21:46 +00:00
|
|
|
else {
|
|
|
|
|
emit sslToggled();
|
|
|
|
|
}
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_CryptoEnabled, newValue);
|
2016-10-06 10:29:34 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-11-06 13:16:56 +00:00
|
|
|
bool AppConfig::isCryptoAvailable() const {
|
|
|
|
|
bool result {true};
|
|
|
|
|
|
2022-09-13 15:31:45 +00:00
|
|
|
#if !defined(SYNERGY_ENTERPRISE) && !defined(SYNERGY_BUSINESS)
|
|
|
|
|
result = (edition() == kPro ||
|
|
|
|
|
edition() == kPro_China ||
|
|
|
|
|
edition() == kBusiness ||
|
|
|
|
|
edition() == kUltimate);
|
2018-06-07 15:22:49 +00:00
|
|
|
#endif
|
2020-11-06 13:16:56 +00:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getCryptoEnabled() const {
|
|
|
|
|
return isCryptoAvailable() && m_CryptoEnabled;
|
2016-09-30 16:01:43 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setAutoHide(bool b) {
|
2020-11-20 01:38:57 +00:00
|
|
|
setSettingModified(m_AutoHide, b);
|
2020-03-31 14:18:57 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
|
|
|
|
bool AppConfig::getAutoHide() { return m_AutoHide; }
|
2018-01-30 22:32:00 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setMinimizeToTray(bool newValue) {
|
|
|
|
|
setSettingModified(m_MinimizeToTray, newValue);
|
|
|
|
|
}
|
2018-01-30 22:32:00 +00:00
|
|
|
|
2022-01-26 12:07:28 +00:00
|
|
|
bool AppConfig::getInvertScrollDirection() const {
|
|
|
|
|
return m_InvertScrollDirection;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 09:51:05 +00:00
|
|
|
void AppConfig::setEliteBackersUrl(const QString& newValue) {
|
|
|
|
|
setSettingModified(m_eliteBackersUrl, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 15:31:45 +00:00
|
|
|
void AppConfig::setLicenseNextCheck(unsigned long long time) {
|
|
|
|
|
setSettingModified(m_licenseNextCheck, time);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 09:51:05 +00:00
|
|
|
const QString& AppConfig::getEliteBackersUrl() const {
|
|
|
|
|
return m_eliteBackersUrl;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 15:31:45 +00:00
|
|
|
const QString& AppConfig::getLicenseRegistryUrl() const {
|
|
|
|
|
return m_licenseRegistryUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long long AppConfig::getLicenseNextCheck() const {
|
|
|
|
|
return m_licenseNextCheck;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString& AppConfig::getGuid() const {
|
|
|
|
|
return m_guid;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 06:30:24 +00:00
|
|
|
bool AppConfig::getLanguageSync() const { return m_LanguageSync; }
|
|
|
|
|
|
2022-01-26 12:07:28 +00:00
|
|
|
void AppConfig::setInvertScrollDirection(bool newValue) {
|
|
|
|
|
setSettingModified(m_InvertScrollDirection, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 06:30:24 +00:00
|
|
|
void AppConfig::setLanguageSync(bool newValue) {
|
|
|
|
|
setSettingModified(m_LanguageSync, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 08:53:49 +00:00
|
|
|
bool AppConfig::getPreventSleep() const { return m_PreventSleep; }
|
|
|
|
|
|
2022-09-22 08:12:13 +00:00
|
|
|
bool AppConfig::getClientHostMode() const {
|
|
|
|
|
return (m_ClientHostMode && getInitiateConnectionFromServer());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getServerClientMode() const {
|
|
|
|
|
return (m_ServerClientMode && getInitiateConnectionFromServer());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getInitiateConnectionFromServer() const {
|
|
|
|
|
return m_InitiateConnectionFromServer;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 08:53:49 +00:00
|
|
|
void AppConfig::setPreventSleep(bool newValue) {
|
|
|
|
|
setSettingModified(m_PreventSleep, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-30 22:32:00 +00:00
|
|
|
bool AppConfig::getMinimizeToTray() { return m_MinimizeToTray; }
|
2020-02-12 16:28:31 +00:00
|
|
|
|
|
|
|
|
QString AppConfig::settingName(AppConfig::Setting name) {
|
|
|
|
|
return m_SynergySettingsName[name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
void AppConfig::setSetting(AppConfig::Setting name, T value) {
|
2020-04-23 17:11:20 +00:00
|
|
|
ConfigWriter::make()->setSetting(settingName(name), value);
|
2020-02-12 16:28:31 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-04 17:10:27 +00:00
|
|
|
template<typename T>
|
|
|
|
|
void AppConfig::setCommonSetting(AppConfig::Setting name, T value) {
|
|
|
|
|
ConfigWriter::make()->setSetting(settingName(name), value, ConfigWriter::kUser);
|
|
|
|
|
ConfigWriter::make()->setSetting(settingName(name), value, ConfigWriter::kSystem);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 16:28:31 +00:00
|
|
|
QVariant AppConfig::loadSetting(AppConfig::Setting name, const QVariant& defaultValue) {
|
2020-04-23 17:11:20 +00:00
|
|
|
return ConfigWriter::make()->loadSetting(settingName(name), defaultValue);
|
2020-02-12 16:28:31 +00:00
|
|
|
}
|
2020-02-25 17:00:30 +00:00
|
|
|
|
2021-02-04 17:10:27 +00:00
|
|
|
QVariant AppConfig::loadCommonSetting(AppConfig::Setting name, const QVariant& defaultValue) const {
|
|
|
|
|
QVariant result(defaultValue);
|
|
|
|
|
QString setting(settingName(name));
|
|
|
|
|
auto& writer = *ConfigWriter::make();
|
|
|
|
|
|
|
|
|
|
if (writer.hasSetting(setting)) {
|
|
|
|
|
result = writer.loadSetting(setting, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
else if (writer.getScope() == ConfigWriter::kSystem ) {
|
|
|
|
|
if (writer.hasSetting(setting, ConfigWriter::kUser)) {
|
|
|
|
|
result = writer.loadSetting(setting, defaultValue, ConfigWriter::kUser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (writer.hasSetting(setting, ConfigWriter::kSystem)){
|
|
|
|
|
result = writer.loadSetting(setting, defaultValue, ConfigWriter::kSystem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 16:32:06 +00:00
|
|
|
void AppConfig::loadScope(ConfigWriter::Scope scope) {
|
2021-02-04 17:10:27 +00:00
|
|
|
auto writer = ConfigWriter::make();
|
2020-02-25 17:00:30 +00:00
|
|
|
|
2021-02-01 19:21:46 +00:00
|
|
|
if (writer->getScope() != scope) {
|
2022-10-12 16:32:06 +00:00
|
|
|
setDefaultValues();
|
2021-02-01 19:21:46 +00:00
|
|
|
writer->setScope(scope);
|
|
|
|
|
if (writer->hasSetting(settingName(kScreenName), writer->getScope())) {
|
|
|
|
|
//If the user already has settings, then load them up now.
|
|
|
|
|
writer->globalLoad();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-25 17:00:30 +00:00
|
|
|
|
2022-10-12 16:32:06 +00:00
|
|
|
void AppConfig::setDefaultValues()
|
|
|
|
|
{
|
|
|
|
|
m_InitiateConnectionFromServer = false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 19:21:46 +00:00
|
|
|
void AppConfig::setLoadFromSystemScope(bool value) {
|
2020-02-25 17:00:30 +00:00
|
|
|
|
2021-02-01 19:21:46 +00:00
|
|
|
if (value) {
|
2021-02-04 17:10:27 +00:00
|
|
|
loadScope(ConfigWriter::kSystem);
|
2021-02-01 19:21:46 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2021-02-04 17:10:27 +00:00
|
|
|
loadScope(ConfigWriter::kUser);
|
2021-02-01 19:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* It's very imprortant to set this variable after loadScope
|
|
|
|
|
* because during scope loading this variable can be rewritten with old value
|
|
|
|
|
*/
|
|
|
|
|
m_LoadFromSystemScope = value;
|
2020-02-25 17:00:30 +00:00
|
|
|
}
|
2020-02-27 00:40:58 +00:00
|
|
|
|
2021-02-04 17:10:27 +00:00
|
|
|
bool AppConfig::isWritable() const {
|
|
|
|
|
return ConfigWriter::make()->isWritable();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-27 00:40:58 +00:00
|
|
|
bool AppConfig::isSystemScoped() const {
|
2021-02-04 17:10:27 +00:00
|
|
|
return ConfigWriter::make()->getScope() == ConfigWriter::kSystem;
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getServerGroupChecked() const {
|
|
|
|
|
return m_ServerGroupChecked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getUseExternalConfig() const {
|
|
|
|
|
return m_UseExternalConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 09:03:37 +00:00
|
|
|
const QString& AppConfig::getConfigFile() const {
|
2020-03-31 10:09:50 +00:00
|
|
|
return m_ConfigFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getUseInternalConfig() const {
|
|
|
|
|
return m_UseInternalConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getClientGroupChecked() const {
|
|
|
|
|
return m_ClientGroupChecked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::getServerHostname() const {
|
|
|
|
|
return m_ServerHostname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setServerGroupChecked(bool newValue) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_ServerGroupChecked, newValue);
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setUseExternalConfig(bool newValue) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_UseExternalConfig, newValue);
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setConfigFile(const QString& newValue) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_ConfigFile, newValue);
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setUseInternalConfig(bool newValue) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_UseInternalConfig, newValue);
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setClientGroupChecked(bool newValue) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_ClientGroupChecked, newValue);
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setServerHostname(const QString& newValue) {
|
2020-03-31 14:18:57 +00:00
|
|
|
setSettingModified(m_ServerHostname, newValue);
|
2020-03-31 10:09:50 +00:00
|
|
|
}
|
2020-03-31 14:18:57 +00:00
|
|
|
|
2022-09-22 08:12:13 +00:00
|
|
|
void AppConfig::setClientHostMode(bool newValue) {
|
|
|
|
|
setSettingModified(m_ClientHostMode, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setServerClientMode(bool newValue) {
|
|
|
|
|
setSettingModified(m_ServerClientMode, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
template<typename T>
|
|
|
|
|
void AppConfig::setSettingModified(T &variable, const T& newValue) {
|
|
|
|
|
if (variable != newValue)
|
|
|
|
|
{
|
|
|
|
|
variable = newValue;
|
2020-04-23 17:11:20 +00:00
|
|
|
m_unsavedChanges = true;
|
2020-03-31 14:18:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 16:21:46 +00:00
|
|
|
void AppConfig::setTLSCertPath(const QString& path) {
|
|
|
|
|
m_TLSCertificatePath = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::getTLSCertPath() const {
|
|
|
|
|
return m_TLSCertificatePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::getTLSKeyLength() const {
|
|
|
|
|
return m_TLSKeyLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setTLSKeyLength(const QString& length) {
|
2020-11-10 11:26:37 +00:00
|
|
|
if (m_TLSKeyLength != length) {
|
|
|
|
|
m_TLSKeyLength = length;
|
|
|
|
|
generateCertificate(true);
|
|
|
|
|
}
|
2020-07-27 16:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-10 11:26:37 +00:00
|
|
|
void AppConfig::generateCertificate(bool forceGeneration) const {
|
|
|
|
|
SslCertificate sslCertificate;
|
|
|
|
|
sslCertificate.generateCertificate(getTLSCertPath(), getTLSKeyLength(), forceGeneration);
|
|
|
|
|
emit sslToggled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|