Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
35 andreas 25
#define V_MAJOR     1
303 andreas 26
#define V_MINOR     4
27
#define V_PATCH     0
370 andreas 28
#define V_ADD       "b3"
2 andreas 29
 
134 andreas 30
#ifndef V_SERIAL
370 andreas 31
#define V_SERIAL    "20231010TP140B"
134 andreas 32
#endif
33
 
21 andreas 34
/**
35
 * @def TPANEL_VERSION
36
 * Defines the version of this application.
37
 */
35 andreas 38
#define TPANEL_VERSION      ((V_MAJOR * 0x10000) + (V_MINOR * 0x100) + V_PATCH)
2 andreas 39
 
24 andreas 40
#define VERSION_STRING() _GET_X_VERSION(V_MAJOR, V_MINOR, V_PATCH)
41
#define _GET_X_VERSION(a, b, c) _GET_VERSION(a, b, c)
171 andreas 42
//#define _GET_VERSION(a, b, c) ( #a "." #b "." #c )          // Release version
43
#define _GET_VERSION(a, b, c) ( #a "." #b "." #c V_ADD)     // Beta version
24 andreas 44
 
303 andreas 45
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
46
typedef unsigned short          ushort;         /* Sys V compatibility */
47
typedef unsigned int            uint;           /* Sys V compatibility */
48
#endif
49
 
21 andreas 50
/**
51
 * @brief The TConfig class manages the configurations.
52
 *
53
 * The class contains methods to read a config file, parse it's content and
54
 * hold the configuration options in the class. All public methods are static.
55
 */
2 andreas 56
class TConfig
57
{
35 andreas 58
    public:
59
        TConfig(const std::string& path);
23 andreas 60
        bool reReadConfig();
2 andreas 61
 
71 andreas 62
        typedef enum SYSTEMRESOURCE_t
63
        {
64
            BASE,
65
            BORDERS,
66
            FONTS,
67
            IMAGES,
68
            SLIDERS,
69
            SOUNDS
70
        }SYSTEMRESOURCE_t;
71
 
127 andreas 72
        typedef enum SIP_FIREWALL_t
73
        {
74
            SIP_NO_FIREWALL,
75
            SIP_NAT_ADDRESS,    // Currently not configurable
76
            SIP_STUN,
77
            SIP_ICE,
78
            SIP_UPNP
79
        }SIP_FIREWALL_t;
80
 
316 andreas 81
        static bool setTemporary(bool tmp);
208 andreas 82
        static bool getTemporary() { return mTemporary; }
192 andreas 83
        static void reset();
35 andreas 84
        static void setProgName(const std::string& pname);
85
        static std::string& getProgName();
86
        static std::string& getConfigPath();
87
        static std::string& getConfigFileName();
88
        static std::string& getProjectPath();
197 andreas 89
        static std::string getSystemProjectPath();
71 andreas 90
        static std::string getSystemPath(SYSTEMRESOURCE_t sres);
35 andreas 91
        static std::string& getLogFile();
92
        static std::string& getLogLevel();
59 andreas 93
        static uint getLogLevelBits();
35 andreas 94
        static bool isLongFormat();
257 andreas 95
        static bool getLogFileEnabled() { return mLogFileEnabled; }
96
        static void setLogFileEnabled(bool lf) { mLogFileEnabled = lf; }
35 andreas 97
        static bool showBanner();
24 andreas 98
        static bool getScale();
120 andreas 99
        static bool getToolbarForce();
151 andreas 100
        static bool getToolbarSuppress();
35 andreas 101
        static bool getProfiling();
175 andreas 102
        static size_t getButttonCache();
51 andreas 103
        static std::string& getPassword1();
104
        static std::string& getPassword2();
105
        static std::string& getPassword3();
106
        static std::string& getPassword4();
71 andreas 107
        static std::string& getSystemSound();
108
        static bool getSystemSoundState();
141 andreas 109
        static int getSystemVolume();
110
        static int getSystemGain();
134 andreas 111
        static bool getRotationFixed();
112
        static void setRotationFixed(bool fix);
113
        static void setSystemChannel(int ch);
114
        static std::string& getUUID();
71 andreas 115
        static std::string& getSingleBeepSound();
116
        static std::string& getDoubleBeepSound();
112 andreas 117
        static std::string& getFtpUser();
118
        static std::string& getFtpPassword();
115 andreas 119
        static std::string& getFtpSurface();
116 andreas 120
        static bool getFtpPassive();
115 andreas 121
        static time_t getFtpDownloadTime();
2 andreas 122
 
35 andreas 123
        static std::string& getController();
11 andreas 124
        static int getSystem();
35 andreas 125
        static int getPort();
126
        static int getChannel();
127
        static std::string& getPanelType();
128
        static std::string& getFirmVersion();
21 andreas 129
        static bool certCheck();
116 andreas 130
        static bool isInitialized() { return mInitialized; }
141 andreas 131
        static bool getMuteState() { return mMute; }
132
        static void setMuteState(bool state) { mMute = state; }
2 andreas 133
 
23 andreas 134
        static bool saveProjectPath(const std::string& path);
135
        static bool saveLogFile(const std::string& file);
136
        static bool saveLogLevel(const std::string& level);
59 andreas 137
        static bool saveLogLevel(uint level);
23 andreas 138
        static bool saveController(const std::string& cnt);
139
        static bool savePort(int port);
140
        static bool saveChannel(int channel);
141
        static bool savePanelType(const std::string& pt);
142
        static bool saveSettings();
143
        static void saveFormat(bool format);
24 andreas 144
        static void saveScale(bool scale);
118 andreas 145
        static void saveBanner(bool banner);
120 andreas 146
        static void saveToolbarForce(bool tb);
151 andreas 147
        static void saveToolbarSuppress(bool tb);
35 andreas 148
        static void saveProfiling(bool prof);
175 andreas 149
        static void saveButtonCache(size_t size);
51 andreas 150
        static void savePassword1(const std::string& pw);
151
        static void savePassword2(const std::string& pw);
152
        static void savePassword3(const std::string& pw);
153
        static void savePassword4(const std::string& pw);
71 andreas 154
        static void saveSystemSoundFile(const std::string& snd);
155
        static void saveSystemSoundState(bool state);
141 andreas 156
        static void saveSingleBeepFile(const std::string& snd);
157
        static void saveDoubleBeepFile(const std::string& snd);
158
        static void saveSystemVolume(int volume);
159
        static void saveSystemGain(int gain);
112 andreas 160
        static void saveFtpUser(const std::string& user);
161
        static void saveFtpPassword(const std::string& pw);
115 andreas 162
        static void saveFtpSurface(const std::string& fname);
116 andreas 163
        static void saveFtpPassive(bool mode);
115 andreas 164
        static void saveFtpDownloadTime(time_t t);
23 andreas 165
 
104 andreas 166
        // SIP management
167
        static std::string& getSIPproxy();
168
        static void setSIPproxy(const std::string& address);
169
        static int getSIPport();
170
        static void setSIPport(int port);
127 andreas 171
        static int getSIPportTLS();
172
        static void setSIPportTLS(int port);
104 andreas 173
        static std::string& getSIPstun();
174
        static void setSIPstun(const std::string& address);
175
        static std::string& getSIPdomain();
176
        static void setSIPdomain(const std::string& domain);
177
        static std::string& getSIPuser();
178
        static void setSIPuser(const std::string& user);
179
        static std::string& getSIPpassword();
180
        static void setSIPpassword(const std::string& pw);
181
        static bool getSIPstatus();
127 andreas 182
        static bool getSIPnetworkIPv4();
183
        static void setSIPnetworkIPv4(bool state);
184
        static bool getSIPnetworkIPv6();
185
        static void setSIPnetworkIPv6(bool state);
186
        static SIP_FIREWALL_t getSIPfirewall();
187
        static std::string getSIPfirewallStr();
188
        static void setSIPfirewall(SIP_FIREWALL_t fw);
104 andreas 189
        static void setSIPstatus(bool state);
139 andreas 190
        static void setSIPiphone(bool state);
191
        static bool getSIPiphone();
104 andreas 192
 
35 andreas 193
    private:
59 andreas 194
        static uint logLevelStrToBits(const std::string& level);
195
        static std::string logLevelBitsToString(uint level);
127 andreas 196
        static std::string sipFirewallToString(SIP_FIREWALL_t fw);
197
        static SIP_FIREWALL_t sipFirewallStrToEnum(const std::string& str);
35 andreas 198
        bool findConfig();
199
        bool readConfig();
200
        std::vector<std::string> split(const std::string& str, const std::string& seps, const bool trimEmpty);
71 andreas 201
        static int caseCompare(const std::string& str1, const std::string& str2);
118 andreas 202
        static std::string makeConfigDefault(const std::string& log, const std::string& project);
2 andreas 203
 
35 andreas 204
        std::string mPath;
205
        std::string mCFile;
90 andreas 206
        std::vector<std::string> mCfgPaths;
116 andreas 207
        static bool mInitialized;
134 andreas 208
        static int mChannel;        // If the channel was changed by a command, this variable holds the new value.
141 andreas 209
        static bool mMute;          // Holds the mute status. This is temporary!
192 andreas 210
        static bool mTemporary;     // If TRUE the temporary parameter table is used
257 andreas 211
        static bool mLogFileEnabled;// if TRUE the logging is written into the logfile, if there is a valid name.
21 andreas 212
#ifdef __ANDROID__
213
        std::string mRoot;
214
#endif
2 andreas 215
};
216
 
217
#endif