1 /* 2 * barrier -- mouse and keyboard sharing utility 3 * Copyright (C) 2012-2016 Symless Ltd. 4 * Copyright (C) 2008 Volker Lanz (vl@fidra.de) 5 * 6 * This package is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * found in the file LICENSE that should have accompanied this file. 9 * 10 * This package is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #if !defined(APPCONFIG_H) 20 21 #define APPCONFIG_H 22 23 #include <QObject> 24 #include <QString> 25 #include "ElevateMode.h" 26 27 // this should be incremented each time a new page is added. this is 28 // saved to settings when the user finishes running the wizard. if 29 // the saved wizard version is lower than this number, the wizard 30 // will be displayed. each version incrememnt should be described 31 // here... 32 // 33 // 1: first version 34 // 2: added language page 35 // 3: added premium page and removed 36 // 4: ssl plugin 'ns' v1.0 37 // 5: ssl plugin 'ns' v1.1 38 // 6: ssl plugin 'ns' v1.2 39 // 7: serial key activation 40 // 8: Visual Studio 2015 support 41 // 9: synergy->barrier and de-commercialized 42 // 43 const int kWizardVersion = 9; 44 45 class QSettings; 46 class SettingsDialog; 47 48 enum ProcessMode { 49 Service, 50 Desktop 51 }; 52 53 class AppConfig: public QObject 54 { 55 Q_OBJECT 56 57 friend class SettingsDialog; 58 friend class MainWindow; 59 friend class SetupWizard; 60 61 public: 62 AppConfig(QSettings* settings); 63 ~AppConfig(); 64 65 public: 66 const QString& screenName() const; 67 int port() const; 68 const QString& networkInterface() const; 69 int logLevel() const; 70 bool logToFile() const; 71 const QString& logFilename() const; 72 const QString logFilenameCmd() const; 73 QString logLevelText() const; 74 ProcessMode processMode() const; 75 bool wizardShouldRun() const; 76 const QString& language() const; 77 bool startedBefore() const; 78 bool autoConfig() const; 79 void setAutoConfig(bool autoConfig); 80 bool autoConfigPrompted(); 81 void setAutoConfigPrompted(bool prompted); 82 83 QString barriersName() const; 84 QString barriercName() const; 85 QString barrierProgramDir() const; 86 QString barrierLogDir() const; 87 88 void persistLogDir(); 89 ElevateMode elevateMode(); 90 91 void setCryptoEnabled(bool e); 92 bool getCryptoEnabled() const; 93 94 void setAutoHide(bool b); 95 bool getAutoHide(); 96 97 void setMinimizeToTray(bool b); 98 bool getMinimizeToTray(); 99 100 void saveSettings(); 101 102 protected: 103 QSettings& settings(); 104 void setScreenName(const QString& s); 105 void setPort(int i); 106 void setNetworkInterface(const QString& s); 107 void setLogLevel(int i); 108 void setLogToFile(bool b); 109 void setLogFilename(const QString& s); 110 void setWizardHasRun(); 111 void setLanguage(const QString language); 112 void setStartedBefore(bool b); 113 void setElevateMode(ElevateMode em); 114 void loadSettings(); 115 116 private: 117 QSettings* m_pSettings; 118 QString m_ScreenName; 119 int m_Port; 120 QString m_Interface; 121 int m_LogLevel; 122 bool m_LogToFile; 123 QString m_LogFilename; 124 int m_WizardLastRun; 125 ProcessMode m_ProcessMode; 126 QString m_Language; 127 bool m_StartedBefore; 128 bool m_AutoConfig; 129 ElevateMode m_ElevateMode; 130 bool m_AutoConfigPrompted; 131 bool m_CryptoEnabled; 132 bool m_AutoHide; 133 bool m_MinimizeToTray; 134 135 static const char m_BarriersName[]; 136 static const char m_BarriercName[]; 137 static const char m_BarrierLogDir[]; 138 }; 139 140 #endif 141