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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if !defined(APPCONFIG_H)
|
|
|
|
|
|
|
|
|
|
#define APPCONFIG_H
|
|
|
|
|
|
2016-10-04 12:41:27 +00:00
|
|
|
#include <QObject>
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <QString>
|
2020-02-13 09:21:02 +00:00
|
|
|
#include <QVariant>
|
2016-06-10 14:33:30 +00:00
|
|
|
#include "ElevateMode.h"
|
2017-03-09 14:32:41 +00:00
|
|
|
#include <shared/EditionType.h>
|
2020-02-25 17:00:30 +00:00
|
|
|
#include <mutex>
|
2020-04-23 17:11:20 +00:00
|
|
|
#include "ConfigBase.h"
|
2021-02-01 19:21:46 +00:00
|
|
|
#include "ConfigWriter.h"
|
2020-07-27 16:21:46 +00:00
|
|
|
#include "CoreInterface.h"
|
2013-04-11 16:51:17 +00:00
|
|
|
|
|
|
|
|
// this should be incremented each time a new page is added. this is
|
|
|
|
|
// saved to settings when the user finishes running the wizard. if
|
|
|
|
|
// the saved wizard version is lower than this number, the wizard
|
2013-05-29 20:46:24 +00:00
|
|
|
// will be displayed. each version incrememnt should be described
|
|
|
|
|
// here...
|
|
|
|
|
//
|
|
|
|
|
// 1: first version
|
2013-06-04 17:37:27 +00:00
|
|
|
// 2: added language page
|
2014-10-14 16:20:57 +00:00
|
|
|
// 3: added premium page and removed
|
2015-07-23 22:56:38 +00:00
|
|
|
// 4: ssl plugin 'ns' v1.0
|
|
|
|
|
// 5: ssl plugin 'ns' v1.1
|
|
|
|
|
// 6: ssl plugin 'ns' v1.2
|
2016-07-20 17:09:39 +00:00
|
|
|
// 7: serial key activation
|
2016-06-24 17:27:03 +00:00
|
|
|
// 8: Visual Studio 2015 support
|
2013-05-29 20:46:24 +00:00
|
|
|
//
|
2016-06-24 17:27:03 +00:00
|
|
|
const int kWizardVersion = 8;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
class QSettings;
|
|
|
|
|
class SettingsDialog;
|
|
|
|
|
|
|
|
|
|
enum ProcessMode {
|
2016-12-28 11:50:32 +00:00
|
|
|
Service,
|
|
|
|
|
Desktop
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|
|
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
class AppConfig: public QObject, public GUI::Config::ConfigBase
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
2016-12-28 11:50:32 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
friend class SettingsDialog;
|
|
|
|
|
friend class MainWindow;
|
|
|
|
|
friend class SetupWizard;
|
|
|
|
|
|
|
|
|
|
public:
|
2020-04-23 17:11:20 +00:00
|
|
|
AppConfig();
|
2016-12-28 11:50:32 +00:00
|
|
|
|
|
|
|
|
public:
|
2021-02-04 17:10:27 +00:00
|
|
|
bool isWritable() const;
|
2020-02-27 00:40:58 +00:00
|
|
|
bool isSystemScoped() const;
|
|
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
const QString& screenName() const;
|
|
|
|
|
int port() const;
|
|
|
|
|
const QString& networkInterface() const;
|
|
|
|
|
int logLevel() const;
|
|
|
|
|
bool logToFile() const;
|
|
|
|
|
const QString& logFilename() const;
|
|
|
|
|
const QString logFilenameCmd() const;
|
|
|
|
|
QString logLevelText() const;
|
|
|
|
|
ProcessMode processMode() const;
|
|
|
|
|
bool wizardShouldRun() const;
|
|
|
|
|
const QString& language() const;
|
|
|
|
|
bool startedBefore() const;
|
|
|
|
|
bool autoConfig() const;
|
|
|
|
|
void setAutoConfig(bool autoConfig);
|
2018-09-04 20:32:24 +00:00
|
|
|
QString autoConfigServer() const;
|
2020-03-31 14:18:57 +00:00
|
|
|
void setAutoConfigServer(const QString& autoConfigServer);
|
2018-06-07 15:22:49 +00:00
|
|
|
#ifndef SYNERGY_ENTERPRISE
|
2016-12-28 11:50:32 +00:00
|
|
|
void setEdition(Edition);
|
|
|
|
|
Edition edition() const;
|
2020-03-31 14:18:57 +00:00
|
|
|
void setSerialKey(const QString& serial);
|
2016-12-28 11:50:32 +00:00
|
|
|
void clearSerialKey();
|
|
|
|
|
QString serialKey();
|
|
|
|
|
int lastExpiringWarningTime() const;
|
|
|
|
|
void setLastExpiringWarningTime(int t);
|
2018-06-07 15:22:49 +00:00
|
|
|
#endif
|
2016-12-28 11:50:32 +00:00
|
|
|
|
|
|
|
|
QString synergysName() const;
|
|
|
|
|
QString synergycName() const;
|
|
|
|
|
QString synergyProgramDir() const;
|
|
|
|
|
QString synergyLogDir() const;
|
|
|
|
|
|
|
|
|
|
void persistLogDir();
|
|
|
|
|
ElevateMode elevateMode();
|
|
|
|
|
|
2020-11-06 13:16:56 +00:00
|
|
|
bool isCryptoAvailable() const;
|
2016-12-28 11:50:32 +00:00
|
|
|
void setCryptoEnabled(bool e);
|
|
|
|
|
bool getCryptoEnabled() const;
|
|
|
|
|
|
|
|
|
|
void setAutoHide(bool b);
|
|
|
|
|
bool getAutoHide();
|
2018-06-07 15:22:49 +00:00
|
|
|
#ifndef SYNERGY_ENTERPRISE
|
2016-12-28 11:50:32 +00:00
|
|
|
bool activationHasRun() const;
|
|
|
|
|
AppConfig& activationHasRun(bool value);
|
2018-06-07 15:22:49 +00:00
|
|
|
#endif
|
2020-02-25 17:00:30 +00:00
|
|
|
/// @brief Sets the user preference to load from SystemScope.
|
|
|
|
|
/// @param [in] value
|
2021-02-01 19:21:46 +00:00
|
|
|
/// True - This will set the variable and load the global scope settings.
|
|
|
|
|
/// False - This will set the variable and load the user scope settings.
|
2020-02-25 17:00:30 +00:00
|
|
|
void setLoadFromSystemScope(bool value);
|
|
|
|
|
|
2020-03-31 10:09:50 +00:00
|
|
|
|
|
|
|
|
bool getServerGroupChecked() const;
|
|
|
|
|
bool getUseExternalConfig() const;
|
|
|
|
|
QString getConfigFile() const;
|
|
|
|
|
bool getUseInternalConfig() const;
|
|
|
|
|
bool getClientGroupChecked() const;
|
|
|
|
|
QString getServerHostname() const;
|
|
|
|
|
|
2020-07-27 16:21:46 +00:00
|
|
|
/// @brief Gets the current TLS certificate path
|
|
|
|
|
/// @return QString The path to the cert
|
|
|
|
|
QString getTLSCertPath() const;
|
|
|
|
|
|
|
|
|
|
/// @brief Get the key length to be used for the private key of a TLS cert
|
|
|
|
|
/// @return QString The key length in bits
|
|
|
|
|
QString getTLSKeyLength() const;
|
|
|
|
|
|
2020-03-31 10:09:50 +00:00
|
|
|
void setServerGroupChecked(bool);
|
|
|
|
|
void setUseExternalConfig(bool) ;
|
|
|
|
|
void setConfigFile(const QString&);
|
|
|
|
|
void setUseInternalConfig(bool) ;
|
|
|
|
|
void setClientGroupChecked(bool) ;
|
|
|
|
|
void setServerHostname(const QString&);
|
|
|
|
|
|
2020-07-27 16:21:46 +00:00
|
|
|
/// @brief Set the path to the TLS/SSL certificate file that will be used
|
|
|
|
|
/// @param [in] path The path to the Certificate
|
|
|
|
|
void setTLSCertPath(const QString& path);
|
|
|
|
|
|
|
|
|
|
/// @brief Sets the key length of the private key to use in a TLS connection
|
|
|
|
|
/// @param [in] QString length The key length eg: 1024, 2048, 4096
|
|
|
|
|
void setTLSKeyLength(const QString& length);
|
|
|
|
|
|
|
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
QString lastVersion() const;
|
|
|
|
|
|
2018-01-30 22:32:00 +00:00
|
|
|
void setMinimizeToTray(bool b);
|
|
|
|
|
bool getMinimizeToTray();
|
|
|
|
|
|
2020-04-23 17:11:20 +00:00
|
|
|
void saveSettings() override;
|
2020-03-31 14:18:57 +00:00
|
|
|
void setLastVersion(const QString& version);
|
|
|
|
|
|
2020-11-10 11:26:37 +00:00
|
|
|
/// @brief Generates TLS certificate
|
|
|
|
|
/// @param [in] bool forceGeneration Generate certificate even if it's exists.
|
|
|
|
|
void generateCertificate(bool forceGeneration=false) const;
|
2020-02-25 17:00:30 +00:00
|
|
|
|
2016-10-18 17:45:15 +00:00
|
|
|
protected:
|
2020-02-12 16:28:31 +00:00
|
|
|
/// @brief The enumeration to easily access the names of the setting inside m_SynergySettingsName
|
|
|
|
|
enum Setting {
|
2020-04-27 11:53:39 +00:00
|
|
|
kScreenName,
|
|
|
|
|
kPort,
|
|
|
|
|
kInterfaceSetting,
|
|
|
|
|
kLogLevel,
|
|
|
|
|
kLogToFile,
|
|
|
|
|
kLogFilename,
|
|
|
|
|
kWizardLastRun,
|
|
|
|
|
kLanguage,
|
|
|
|
|
kStartedBefore,
|
|
|
|
|
kAutoConfig,
|
|
|
|
|
kAutoConfigServer,
|
|
|
|
|
kElevateModeSetting,
|
|
|
|
|
kElevateModeEnum,
|
|
|
|
|
kEditionSetting,
|
|
|
|
|
kCryptoEnabled,
|
|
|
|
|
kAutoHide,
|
|
|
|
|
kSerialKey,
|
|
|
|
|
kLastVersion,
|
|
|
|
|
kLastExpireWarningTime,
|
|
|
|
|
kActivationHasRun,
|
|
|
|
|
kMinimizeToTray,
|
|
|
|
|
kActivateEmail,
|
|
|
|
|
kLoadSystemSettings,
|
|
|
|
|
kGroupServerCheck,
|
|
|
|
|
kUseExternalConfig,
|
|
|
|
|
kConfigFile,
|
|
|
|
|
kUseInternalConfig,
|
|
|
|
|
kGroupClientCheck,
|
|
|
|
|
kServerHostname,
|
2020-07-27 16:21:46 +00:00
|
|
|
kTLSCertPath,
|
|
|
|
|
kTLSKeyLength,
|
2020-02-12 16:28:31 +00:00
|
|
|
};
|
|
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
void setScreenName(const QString& s);
|
|
|
|
|
void setPort(int i);
|
|
|
|
|
void setNetworkInterface(const QString& s);
|
|
|
|
|
void setLogLevel(int i);
|
|
|
|
|
void setLogToFile(bool b);
|
|
|
|
|
void setLogFilename(const QString& s);
|
|
|
|
|
void setWizardHasRun();
|
2020-03-31 14:18:57 +00:00
|
|
|
void setLanguage(const QString& language);
|
2016-12-28 11:50:32 +00:00
|
|
|
void setStartedBefore(bool b);
|
|
|
|
|
void setElevateMode(ElevateMode em);
|
2020-02-25 17:00:30 +00:00
|
|
|
|
|
|
|
|
/// @brief loads the setting from the current scope
|
|
|
|
|
/// @param ignoreSystem should the load feature ignore the globalScope setting that was saved
|
2020-04-23 17:11:20 +00:00
|
|
|
void loadSettings() override;
|
2020-02-12 16:28:31 +00:00
|
|
|
static QString settingName(AppConfig::Setting name);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
|
|
|
|
private:
|
2020-04-23 17:11:20 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
QString m_ScreenName;
|
|
|
|
|
int m_Port;
|
|
|
|
|
QString m_Interface;
|
|
|
|
|
int m_LogLevel;
|
2020-04-27 12:09:26 +00:00
|
|
|
bool m_LogToFile;
|
2016-12-28 11:50:32 +00:00
|
|
|
QString m_LogFilename;
|
|
|
|
|
int m_WizardLastRun;
|
|
|
|
|
ProcessMode m_ProcessMode;
|
|
|
|
|
QString m_Language;
|
2020-04-27 12:09:26 +00:00
|
|
|
bool m_StartedBefore;
|
2016-12-28 11:50:32 +00:00
|
|
|
bool m_AutoConfig;
|
2018-09-04 20:32:24 +00:00
|
|
|
QString m_AutoConfigServer;
|
2016-12-28 11:50:32 +00:00
|
|
|
ElevateMode m_ElevateMode;
|
|
|
|
|
Edition m_Edition;
|
|
|
|
|
QString m_ActivateEmail;
|
|
|
|
|
bool m_CryptoEnabled;
|
|
|
|
|
bool m_AutoHide;
|
|
|
|
|
QString m_Serialkey;
|
|
|
|
|
QString m_lastVersion;
|
|
|
|
|
int m_LastExpiringWarningTime;
|
2020-04-27 12:09:26 +00:00
|
|
|
bool m_ActivationHasRun;
|
2018-01-30 22:32:00 +00:00
|
|
|
bool m_MinimizeToTray;
|
2020-03-31 10:09:50 +00:00
|
|
|
|
2020-04-27 12:09:26 +00:00
|
|
|
bool m_ServerGroupChecked;
|
|
|
|
|
bool m_UseExternalConfig;
|
2020-03-31 10:09:50 +00:00
|
|
|
QString m_ConfigFile;
|
2020-04-27 12:09:26 +00:00
|
|
|
bool m_UseInternalConfig;
|
|
|
|
|
bool m_ClientGroupChecked;
|
2020-03-31 10:09:50 +00:00
|
|
|
QString m_ServerHostname;
|
|
|
|
|
|
2020-07-27 16:21:46 +00:00
|
|
|
QString m_TLSCertificatePath; /// @brief The path to the TLS certificate file
|
|
|
|
|
QString m_TLSKeyLength; /// @brief The key length of the TLS cert to make
|
|
|
|
|
|
2020-04-27 12:09:26 +00:00
|
|
|
bool m_LoadFromSystemScope; /// @brief should the setting be loaded from SystemScope
|
2020-02-25 17:00:30 +00:00
|
|
|
/// If the user has settings but this is true then
|
|
|
|
|
/// system settings will be loaded instead of the users
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2020-07-27 16:21:46 +00:00
|
|
|
CoreInterface m_CoreInterface;
|
|
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
static const char m_SynergysName[];
|
|
|
|
|
static const char m_SynergycName[];
|
|
|
|
|
static const char m_SynergyLogDir[];
|
|
|
|
|
|
2020-02-12 16:28:31 +00:00
|
|
|
/// @brief Contains the string values of the settings names that will be saved
|
|
|
|
|
static const char* m_SynergySettingsName[];
|
|
|
|
|
|
2020-03-31 10:09:50 +00:00
|
|
|
/// @brief Contains the name of the default configuration filename
|
|
|
|
|
static const char synergyConfigName[];
|
|
|
|
|
|
2020-02-12 16:28:31 +00:00
|
|
|
/// @brief Sets the value of a setting
|
|
|
|
|
/// @param [in] name The Setting to be saved
|
|
|
|
|
/// @param [in] value The Value to be saved
|
|
|
|
|
template <typename T>
|
|
|
|
|
void setSetting(AppConfig::Setting name, T value);
|
|
|
|
|
|
2021-02-04 17:10:27 +00:00
|
|
|
/// @brief Sets the value of a common setting
|
|
|
|
|
/// which should have the same value for all scopes
|
|
|
|
|
/// @param [in] name The Setting to be saved
|
|
|
|
|
/// @param [in] value The Value to be saved
|
|
|
|
|
template <typename T>
|
|
|
|
|
void setCommonSetting(AppConfig::Setting name, T value);
|
|
|
|
|
|
2020-02-12 16:28:31 +00:00
|
|
|
/// @brief Loads a setting
|
|
|
|
|
/// @param [in] name The setting to be loaded
|
|
|
|
|
/// @param [in] defaultValue The default value of the setting
|
|
|
|
|
QVariant loadSetting(AppConfig::Setting name, const QVariant& defaultValue = QVariant());
|
|
|
|
|
|
2021-02-04 17:10:27 +00:00
|
|
|
/// @brief Loads a common setting
|
|
|
|
|
/// @param [in] name The setting to be loaded
|
|
|
|
|
/// @param [in] defaultValue The default value of the setting
|
|
|
|
|
QVariant loadCommonSetting(AppConfig::Setting name, const QVariant& defaultValue = QVariant()) const;
|
|
|
|
|
|
2020-02-25 17:00:30 +00:00
|
|
|
/// @brief As the settings will be accessible by multiple objects this lock will ensure that
|
|
|
|
|
/// it cant be modified by more that one object at a time if the setting is being switched
|
|
|
|
|
/// from system to user.
|
|
|
|
|
std::mutex m_settings_lock;
|
2020-02-13 09:21:02 +00:00
|
|
|
|
2020-03-31 14:18:57 +00:00
|
|
|
/// @brief Sets the setting in the config checking if it has changed and flagging that settings
|
|
|
|
|
/// needs to be saved if the setting was different
|
|
|
|
|
/// @param [in] variable the setting that will be changed
|
|
|
|
|
/// @param [in] newValue The new value of the setting
|
|
|
|
|
template <typename T>
|
|
|
|
|
void setSettingModified(T& variable,const T& newValue);
|
|
|
|
|
|
2021-02-01 19:21:46 +00:00
|
|
|
/// @brief This method loads config from specified scope
|
|
|
|
|
/// @param [in] scope which should be loaded.
|
|
|
|
|
void loadScope(GUI::Config::ConfigWriter::Scope scope) const;
|
|
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
signals:
|
2020-11-10 11:26:37 +00:00
|
|
|
void sslToggled() const;
|
2020-04-01 09:21:33 +00:00
|
|
|
void zeroConfToggled();
|
2021-01-20 11:27:46 +00:00
|
|
|
void screenNameChanged() const;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|