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