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
|
|
|
|
|
|
|
|
#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-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-02-13 09:21:02 +00:00
|
|
|
AppConfig::AppConfig(QSettings* userSettings, QSettings* systemSettings) :
|
2020-02-25 17:00:30 +00:00
|
|
|
m_pSettings(nullptr),
|
|
|
|
|
m_pUserSettings(userSettings),
|
|
|
|
|
m_pSystemSettings(systemSettings),
|
2016-12-28 11:50:32 +00:00
|
|
|
m_ScreenName(),
|
|
|
|
|
m_Port(24800),
|
|
|
|
|
m_Interface(),
|
|
|
|
|
m_LogLevel(0),
|
|
|
|
|
m_WizardLastRun(0),
|
|
|
|
|
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
|
|
|
|
m_AutoConfig(true),
|
|
|
|
|
m_ElevateMode(defaultElevateMode),
|
|
|
|
|
m_CryptoEnabled(false),
|
|
|
|
|
m_AutoHide(false),
|
2018-09-04 20:32:24 +00:00
|
|
|
m_LastExpiringWarningTime(0),
|
2018-01-30 22:32:00 +00:00
|
|
|
m_AutoConfigServer(),
|
2020-03-31 14:18:57 +00:00
|
|
|
m_MinimizeToTray(false),
|
|
|
|
|
m_SettingModified(false)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
|
|
2020-02-25 17:00:30 +00:00
|
|
|
//If user setting don't exist but system ones do, load the system settings
|
2020-02-13 09:21:02 +00:00
|
|
|
if (!settingsExist(userSettings) && settingsExist(systemSettings))
|
|
|
|
|
{
|
|
|
|
|
m_pSettings = systemSettings;
|
2020-02-25 17:00:30 +00:00
|
|
|
} else { // Otherwise just load to user scope
|
2020-02-13 09:21:02 +00:00
|
|
|
m_pSettings = userSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-25 17:00:30 +00:00
|
|
|
Q_ASSERT(m_pSettings);
|
|
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
loadSettings();
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppConfig::~AppConfig()
|
|
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
saveSettings();
|
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 {
|
|
|
|
|
#ifndef SYNERGY_ENTERPRISE
|
|
|
|
|
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-02-25 17:00:30 +00:00
|
|
|
void AppConfig::loadSettings(bool ignoreSystem)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
2020-02-12 16:28:31 +00:00
|
|
|
m_ScreenName = loadSetting(ScreenName, QHostInfo::localHostName()).toString();
|
|
|
|
|
m_Port = loadSetting(Port, 24800).toInt();
|
|
|
|
|
m_Interface = loadSetting(InterfaceSetting).toString();
|
|
|
|
|
m_LogLevel = loadSetting(LogLevel, 0).toInt();
|
|
|
|
|
m_LogToFile = loadSetting(LogToFile, false).toBool();
|
|
|
|
|
m_LogFilename = loadSetting(LogFilename,synergyLogDir() + "synergy.log").toString();
|
|
|
|
|
m_WizardLastRun = loadSetting(WizardLastRun,0).toInt();
|
|
|
|
|
m_Language = loadSetting(Language, QLocale::system().name()).toString();
|
|
|
|
|
m_StartedBefore = loadSetting(StartedBefore, false).toBool();
|
|
|
|
|
m_AutoConfig = loadSetting(AutoConfig, false).toBool();
|
|
|
|
|
m_AutoConfigServer = loadSetting(AutoConfigServer,"").toString();
|
|
|
|
|
|
|
|
|
|
{ //Scope related code together
|
|
|
|
|
// TODO Investigate why ElevateModeEnum isn't loaded fully
|
|
|
|
|
QVariant elevateMode = loadSetting(ElevateModeEnum);
|
|
|
|
|
if (!elevateMode.isValid()) {
|
|
|
|
|
elevateMode = loadSetting(ElevateModeSetting,
|
|
|
|
|
QVariant(static_cast<int>(defaultElevateMode)));
|
|
|
|
|
}
|
|
|
|
|
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
2016-12-28 11:50:32 +00:00
|
|
|
}
|
2020-02-12 16:28:31 +00:00
|
|
|
|
|
|
|
|
m_Edition = static_cast<Edition>(loadSetting(EditionSetting, kUnregistered).toInt());
|
|
|
|
|
m_ActivateEmail = loadSetting(ActivateEmail, "").toString();
|
|
|
|
|
m_CryptoEnabled = loadSetting(CryptoEnabled, true).toBool();
|
|
|
|
|
m_AutoHide = loadSetting(AutoHide, false).toBool();
|
|
|
|
|
m_Serialkey = loadSetting(SerialKey, "").toString().trimmed();
|
|
|
|
|
m_lastVersion = loadSetting(LastVersion, "Unknown").toString();
|
|
|
|
|
m_LastExpiringWarningTime = loadSetting(LastExpireWarningTime, 0).toInt();
|
|
|
|
|
m_ActivationHasRun = loadSetting(ActivationHasRun, false).toBool();
|
|
|
|
|
m_MinimizeToTray = loadSetting(MinimizeToTray, false).toBool();
|
2020-02-25 17:00:30 +00:00
|
|
|
m_LoadFromSystemScope = loadSetting(LoadSystemSettings, false).toBool();
|
2020-03-31 10:09:50 +00:00
|
|
|
m_ServerGroupChecked = loadSetting(GroupServerCheck, false).toBool();
|
|
|
|
|
m_UseExternalConfig = loadSetting(UseExternalConfig, false).toBool();
|
|
|
|
|
m_ConfigFile = loadSetting(ConfigFile, QDir::homePath() + "/" + synergyConfigName).toString();
|
|
|
|
|
m_UseInternalConfig = loadSetting(UseInternalConfig, false).toBool();
|
|
|
|
|
m_ClientGroupChecked = loadSetting(GroupClientCheck, true).toBool();
|
|
|
|
|
m_ServerHostname = loadSetting(ServerHostname).toString();
|
2020-02-12 16:28:31 +00:00
|
|
|
|
2020-02-25 17:00:30 +00:00
|
|
|
//If this is user scope and the user chose switch to global but ignoreSystem is not set.
|
|
|
|
|
if (settings().scope() == QSettings::UserScope &&
|
|
|
|
|
m_LoadFromSystemScope &&
|
|
|
|
|
!ignoreSystem)
|
|
|
|
|
{
|
|
|
|
|
//Switch to global scope and reload settings
|
|
|
|
|
switchToGlobal();
|
|
|
|
|
loadSettings();
|
|
|
|
|
}
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::saveSettings()
|
|
|
|
|
{
|
2020-02-12 16:28:31 +00:00
|
|
|
setSetting(ScreenName, m_ScreenName);
|
|
|
|
|
setSetting(Port, m_Port);
|
|
|
|
|
setSetting(InterfaceSetting, m_Interface);
|
|
|
|
|
setSetting(LogLevel, m_LogLevel);
|
|
|
|
|
setSetting(LogToFile, m_LogToFile);
|
|
|
|
|
setSetting(LogFilename, m_LogFilename);
|
|
|
|
|
setSetting(WizardLastRun, kWizardVersion);
|
|
|
|
|
setSetting(Language, m_Language);
|
|
|
|
|
setSetting(StartedBefore, m_StartedBefore);
|
|
|
|
|
setSetting(AutoConfig, m_AutoConfig);
|
|
|
|
|
setSetting(AutoConfigServer, m_AutoConfigServer);
|
2016-12-28 11:50:32 +00:00
|
|
|
// Refer to enum ElevateMode declaration for insight in to why this
|
|
|
|
|
// flag is mapped this way
|
2020-02-12 16:28:31 +00:00
|
|
|
setSetting(ElevateModeSetting, m_ElevateMode == ElevateAlways);
|
|
|
|
|
setSetting(ElevateModeEnum, static_cast<int>(m_ElevateMode));
|
|
|
|
|
setSetting(EditionSetting, m_Edition);
|
|
|
|
|
setSetting(CryptoEnabled, m_CryptoEnabled);
|
|
|
|
|
setSetting(AutoHide, m_AutoHide);
|
|
|
|
|
setSetting(SerialKey, m_Serialkey);
|
|
|
|
|
setSetting(LastVersion, m_lastVersion);
|
|
|
|
|
setSetting(LastExpireWarningTime, m_LastExpiringWarningTime);
|
|
|
|
|
setSetting(ActivationHasRun, m_ActivationHasRun);
|
|
|
|
|
setSetting(MinimizeToTray, m_MinimizeToTray);
|
2020-02-27 00:40:58 +00:00
|
|
|
setSetting(LoadSystemSettings, m_LoadFromSystemScope);
|
2020-03-31 10:09:50 +00:00
|
|
|
setSetting(GroupServerCheck, m_ServerGroupChecked);
|
|
|
|
|
setSetting(UseExternalConfig, m_UseExternalConfig);
|
|
|
|
|
setSetting(ConfigFile, m_ConfigFile);
|
|
|
|
|
setSetting(UseInternalConfig, m_UseInternalConfig);
|
|
|
|
|
setSetting(GroupClientCheck, m_ClientGroupChecked);
|
|
|
|
|
setSetting(ServerHostname, m_ServerHostname);
|
2020-02-12 16:28:31 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
settings().sync();
|
2020-03-31 14:18:57 +00:00
|
|
|
m_SettingModified = 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
|
|
|
}
|
|
|
|
|
|
2016-09-30 14:03:49 +00:00
|
|
|
QSettings &AppConfig::settings() { return *m_pSettings; }
|
|
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
void AppConfig::setScreenName(const QString &s) {
|
|
|
|
|
setSettingModified(m_ScreenName, s);
|
|
|
|
|
}
|
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);
|
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);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::serialKey() { return m_Serialkey; }
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
setSettingModified(m_CryptoEnabled, newValue);
|
|
|
|
|
emit sslToggled(m_CryptoEnabled);
|
2016-10-06 10:29:34 +00:00
|
|
|
}
|
2016-09-30 14:03:49 +00:00
|
|
|
|
2016-10-18 17:45:15 +00:00
|
|
|
bool AppConfig::getCryptoEnabled() const {
|
2018-06-07 15:22:49 +00:00
|
|
|
return
|
|
|
|
|
#ifndef SYNERGY_ENTERPRISE
|
|
|
|
|
(edition() == kPro) &&
|
|
|
|
|
#endif
|
|
|
|
|
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) {
|
|
|
|
|
setSettingModified(m_MinimizeToTray, b);
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
bool AppConfig::getMinimizeToTray() { return m_MinimizeToTray; }
|
2020-02-12 16:28:31 +00:00
|
|
|
|
|
|
|
|
bool AppConfig::settingsExist(QSettings* settings) {
|
|
|
|
|
//Use screen name as the test to see if the settings have been saved to this location
|
|
|
|
|
return settings->contains(settingName(ScreenName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::settingName(AppConfig::Setting name) {
|
|
|
|
|
return m_SynergySettingsName[name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
void AppConfig::setSetting(AppConfig::Setting name, T value) {
|
|
|
|
|
settings().setValue(settingName(name), value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant AppConfig::loadSetting(AppConfig::Setting name, const QVariant& defaultValue) {
|
|
|
|
|
return settings().value(settingName(name), defaultValue);
|
|
|
|
|
}
|
2020-02-25 17:00:30 +00:00
|
|
|
|
|
|
|
|
AppConfig::SaveChoice AppConfig::checkGlobalSave() {
|
2020-02-27 00:40:58 +00:00
|
|
|
if (isSystemScoped()) {
|
2020-02-25 17:00:30 +00:00
|
|
|
|
|
|
|
|
QMessageBox query;
|
|
|
|
|
query.setWindowTitle(tr("Save global settings."));
|
|
|
|
|
query.setText(tr("This will overwrite the settings of anybody else that uses this computer."));
|
|
|
|
|
|
|
|
|
|
query.addButton(QMessageBox::Save);
|
|
|
|
|
const auto* pBtnCancel = query.addButton(QMessageBox::Cancel);
|
|
|
|
|
const auto* pBtnSaveLocal = query.addButton(tr("Save to user"), QMessageBox::ActionRole);
|
|
|
|
|
|
|
|
|
|
query.setDefaultButton(QMessageBox::Cancel);
|
|
|
|
|
|
|
|
|
|
query.exec();
|
|
|
|
|
|
|
|
|
|
if(query.clickedButton() == pBtnSaveLocal)
|
|
|
|
|
{
|
|
|
|
|
return SaveToUser;
|
|
|
|
|
}
|
|
|
|
|
else if(query.clickedButton() == pBtnCancel)
|
|
|
|
|
{
|
|
|
|
|
return Cancel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Save;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::switchToGlobal(bool global) {
|
|
|
|
|
m_settings_lock.lock();
|
|
|
|
|
if (global)
|
|
|
|
|
{
|
|
|
|
|
m_pSettings = m_pSystemSettings;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_pSettings = m_pUserSettings;
|
|
|
|
|
}
|
|
|
|
|
m_settings_lock.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppConfig::setLoadFromSystemScope(bool value) {
|
2020-02-27 00:40:58 +00:00
|
|
|
if (value && !isSystemScoped())
|
2020-02-25 17:00:30 +00:00
|
|
|
{
|
|
|
|
|
m_LoadFromSystemScope = value;
|
|
|
|
|
saveSettings(); //Save user prefs
|
|
|
|
|
switchToGlobal(); //Switch the the System Scope
|
|
|
|
|
loadSettings(); //Load the settings.
|
|
|
|
|
}
|
2020-02-27 00:40:58 +00:00
|
|
|
else if (!value && isSystemScoped())
|
2020-02-25 17:00:30 +00:00
|
|
|
{
|
|
|
|
|
switchToGlobal(false); // Switch to UserScope
|
|
|
|
|
loadSettings(true); // Load user settings ignoring System scope setting
|
|
|
|
|
m_LoadFromSystemScope = value; // Set the user pref
|
|
|
|
|
saveSettings(); // Save user prefs
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-27 00:40:58 +00:00
|
|
|
|
|
|
|
|
bool AppConfig::isSystemScoped() const {
|
|
|
|
|
return m_pSettings->scope() == QSettings::SystemScope;
|
|
|
|
|
}
|
2020-03-31 10:09:50 +00:00
|
|
|
|
|
|
|
|
bool AppConfig::unsavedChanges() {
|
|
|
|
|
return m_SettingModified;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getServerGroupChecked() const {
|
|
|
|
|
return m_ServerGroupChecked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppConfig::getUseExternalConfig() const {
|
|
|
|
|
return m_UseExternalConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppConfig::getConfigFile() const {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
void AppConfig::setSettingModified(T &variable, const T& newValue) {
|
|
|
|
|
if (variable != newValue)
|
|
|
|
|
{
|
|
|
|
|
variable = newValue;
|
|
|
|
|
m_SettingModified = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|