2 |
andreas |
1 |
/*
|
101 |
andreas |
2 |
* Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
|
2 |
andreas |
3 |
*
|
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
|
6 |
* the Free Software Foundation; either version 3 of the License, or
|
|
|
7 |
* (at your option) any later version.
|
|
|
8 |
*
|
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
* GNU General Public License for more details.
|
|
|
13 |
*
|
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
|
15 |
* along with this program; if not, write to the Free Software Foundation,
|
|
|
16 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
17 |
*/
|
|
|
18 |
#ifndef __TCONFIG_H__
|
|
|
19 |
#define __TCONFIG_H__
|
|
|
20 |
|
|
|
21 |
#include <string>
|
|
|
22 |
#include <vector>
|
|
|
23 |
#include <algorithm>
|
|
|
24 |
#include "terror.h"
|
|
|
25 |
|
35 |
andreas |
26 |
#define V_MAJOR 1
|
113 |
andreas |
27 |
#define V_MINOR 3
|
|
|
28 |
#define V_PATCH 0
|
2 |
andreas |
29 |
|
21 |
andreas |
30 |
/**
|
|
|
31 |
* @def TPANEL_VERSION
|
|
|
32 |
* Defines the version of this application.
|
|
|
33 |
*/
|
35 |
andreas |
34 |
#define TPANEL_VERSION ((V_MAJOR * 0x10000) + (V_MINOR * 0x100) + V_PATCH)
|
2 |
andreas |
35 |
|
24 |
andreas |
36 |
#define VERSION_STRING() _GET_X_VERSION(V_MAJOR, V_MINOR, V_PATCH)
|
|
|
37 |
#define _GET_X_VERSION(a, b, c) _GET_VERSION(a, b, c)
|
|
|
38 |
#define _GET_VERSION(a, b, c) ( #a "." #b "." #c)
|
|
|
39 |
|
21 |
andreas |
40 |
/**
|
|
|
41 |
* @brief The TConfig class manages the configurations.
|
|
|
42 |
*
|
|
|
43 |
* The class contains methods to read a config file, parse it's content and
|
|
|
44 |
* hold the configuration options in the class. All public methods are static.
|
|
|
45 |
*/
|
2 |
andreas |
46 |
class TConfig
|
|
|
47 |
{
|
35 |
andreas |
48 |
public:
|
|
|
49 |
TConfig(const std::string& path);
|
23 |
andreas |
50 |
bool reReadConfig();
|
2 |
andreas |
51 |
|
71 |
andreas |
52 |
typedef enum SYSTEMRESOURCE_t
|
|
|
53 |
{
|
|
|
54 |
BASE,
|
|
|
55 |
BORDERS,
|
|
|
56 |
FONTS,
|
|
|
57 |
IMAGES,
|
|
|
58 |
SLIDERS,
|
|
|
59 |
SOUNDS
|
|
|
60 |
}SYSTEMRESOURCE_t;
|
|
|
61 |
|
35 |
andreas |
62 |
static void setProgName(const std::string& pname);
|
|
|
63 |
static std::string& getProgName();
|
|
|
64 |
static std::string& getConfigPath();
|
|
|
65 |
static std::string& getConfigFileName();
|
|
|
66 |
static std::string& getProjectPath();
|
71 |
andreas |
67 |
static std::string getSystemPath(SYSTEMRESOURCE_t sres);
|
35 |
andreas |
68 |
static std::string& getLogFile();
|
|
|
69 |
static std::string& getLogLevel();
|
59 |
andreas |
70 |
static uint getLogLevelBits();
|
35 |
andreas |
71 |
static bool isLongFormat();
|
|
|
72 |
static bool showBanner();
|
24 |
andreas |
73 |
static bool getScale();
|
120 |
andreas |
74 |
static bool getToolbarForce();
|
35 |
andreas |
75 |
static bool getProfiling();
|
51 |
andreas |
76 |
static std::string& getPassword1();
|
|
|
77 |
static std::string& getPassword2();
|
|
|
78 |
static std::string& getPassword3();
|
|
|
79 |
static std::string& getPassword4();
|
71 |
andreas |
80 |
static std::string& getSystemSound();
|
|
|
81 |
static bool getSystemSoundState();
|
|
|
82 |
static std::string& getSingleBeepSound();
|
|
|
83 |
static std::string& getDoubleBeepSound();
|
112 |
andreas |
84 |
static std::string& getFtpUser();
|
|
|
85 |
static std::string& getFtpPassword();
|
115 |
andreas |
86 |
static std::string& getFtpSurface();
|
116 |
andreas |
87 |
static bool getFtpPassive();
|
115 |
andreas |
88 |
static time_t getFtpDownloadTime();
|
2 |
andreas |
89 |
|
35 |
andreas |
90 |
static std::string& getController();
|
11 |
andreas |
91 |
static int getSystem();
|
35 |
andreas |
92 |
static int getPort();
|
|
|
93 |
static int getChannel();
|
|
|
94 |
static std::string& getPanelType();
|
|
|
95 |
static std::string& getFirmVersion();
|
21 |
andreas |
96 |
static bool certCheck();
|
116 |
andreas |
97 |
static bool isInitialized() { return mInitialized; }
|
2 |
andreas |
98 |
|
23 |
andreas |
99 |
static bool saveProjectPath(const std::string& path);
|
|
|
100 |
static bool saveLogFile(const std::string& file);
|
|
|
101 |
static bool saveLogLevel(const std::string& level);
|
59 |
andreas |
102 |
static bool saveLogLevel(uint level);
|
23 |
andreas |
103 |
static bool saveController(const std::string& cnt);
|
|
|
104 |
static bool savePort(int port);
|
|
|
105 |
static bool saveChannel(int channel);
|
|
|
106 |
static bool savePanelType(const std::string& pt);
|
|
|
107 |
static bool saveSettings();
|
|
|
108 |
static void saveFormat(bool format);
|
24 |
andreas |
109 |
static void saveScale(bool scale);
|
118 |
andreas |
110 |
static void saveBanner(bool banner);
|
120 |
andreas |
111 |
static void saveToolbarForce(bool tb);
|
35 |
andreas |
112 |
static void saveProfiling(bool prof);
|
51 |
andreas |
113 |
static void savePassword1(const std::string& pw);
|
|
|
114 |
static void savePassword2(const std::string& pw);
|
|
|
115 |
static void savePassword3(const std::string& pw);
|
|
|
116 |
static void savePassword4(const std::string& pw);
|
71 |
andreas |
117 |
static void saveSystemSoundFile(const std::string& snd);
|
|
|
118 |
static void saveSystemSoundState(bool state);
|
112 |
andreas |
119 |
static void saveFtpUser(const std::string& user);
|
|
|
120 |
static void saveFtpPassword(const std::string& pw);
|
115 |
andreas |
121 |
static void saveFtpSurface(const std::string& fname);
|
116 |
andreas |
122 |
static void saveFtpPassive(bool mode);
|
115 |
andreas |
123 |
static void saveFtpDownloadTime(time_t t);
|
23 |
andreas |
124 |
|
104 |
andreas |
125 |
// SIP management
|
|
|
126 |
static std::string& getSIPproxy();
|
|
|
127 |
static void setSIPproxy(const std::string& address);
|
|
|
128 |
static int getSIPport();
|
|
|
129 |
static void setSIPport(int port);
|
|
|
130 |
static std::string& getSIPstun();
|
|
|
131 |
static void setSIPstun(const std::string& address);
|
|
|
132 |
static std::string& getSIPdomain();
|
|
|
133 |
static void setSIPdomain(const std::string& domain);
|
|
|
134 |
static std::string& getSIPuser();
|
|
|
135 |
static void setSIPuser(const std::string& user);
|
|
|
136 |
static std::string& getSIPpassword();
|
|
|
137 |
static void setSIPpassword(const std::string& pw);
|
|
|
138 |
static bool getSIPstatus();
|
|
|
139 |
static void setSIPstatus(bool state);
|
|
|
140 |
|
35 |
andreas |
141 |
protected:
|
71 |
andreas |
142 |
static bool isTrue(const std::string& boolean);
|
23 |
andreas |
143 |
|
35 |
andreas |
144 |
private:
|
59 |
andreas |
145 |
static uint logLevelStrToBits(const std::string& level);
|
|
|
146 |
static std::string logLevelBitsToString(uint level);
|
35 |
andreas |
147 |
bool findConfig();
|
|
|
148 |
bool readConfig();
|
|
|
149 |
std::vector<std::string> split(const std::string& str, const std::string& seps, const bool trimEmpty);
|
71 |
andreas |
150 |
static int caseCompare(const std::string& str1, const std::string& str2);
|
118 |
andreas |
151 |
static std::string makeConfigDefault(const std::string& log, const std::string& project);
|
2 |
andreas |
152 |
|
35 |
andreas |
153 |
std::string mPath;
|
|
|
154 |
std::string mCFile;
|
90 |
andreas |
155 |
std::vector<std::string> mCfgPaths;
|
116 |
andreas |
156 |
static bool mInitialized;
|
21 |
andreas |
157 |
#ifdef __ANDROID__
|
|
|
158 |
std::string mRoot;
|
|
|
159 |
#endif
|
2 |
andreas |
160 |
};
|
|
|
161 |
|
|
|
162 |
#endif
|