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
98 andreas 27
#define V_MINOR     2
101 andreas 28
#define V_PATCH     1
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();
35 andreas 74
        static bool getProfiling();
51 andreas 75
        static std::string& getPassword1();
76
        static std::string& getPassword2();
77
        static std::string& getPassword3();
78
        static std::string& getPassword4();
71 andreas 79
        static std::string& getSystemSound();
80
        static bool getSystemSoundState();
81
        static std::string& getSingleBeepSound();
82
        static std::string& getDoubleBeepSound();
2 andreas 83
 
35 andreas 84
        static std::string& getController();
11 andreas 85
        static int getSystem();
35 andreas 86
        static int getPort();
87
        static int getChannel();
88
        static std::string& getPanelType();
89
        static std::string& getFirmVersion();
21 andreas 90
        static bool certCheck();
2 andreas 91
 
23 andreas 92
        static bool saveProjectPath(const std::string& path);
93
        static bool saveLogFile(const std::string& file);
94
        static bool saveLogLevel(const std::string& level);
59 andreas 95
        static bool saveLogLevel(uint level);
23 andreas 96
        static bool saveController(const std::string& cnt);
97
        static bool savePort(int port);
98
        static bool saveChannel(int channel);
99
        static bool savePanelType(const std::string& pt);
100
        static bool saveSettings();
101
        static void saveFormat(bool format);
24 andreas 102
        static void saveScale(bool scale);
35 andreas 103
        static void saveProfiling(bool prof);
51 andreas 104
        static void savePassword1(const std::string& pw);
105
        static void savePassword2(const std::string& pw);
106
        static void savePassword3(const std::string& pw);
107
        static void savePassword4(const std::string& pw);
71 andreas 108
        static void saveSystemSoundFile(const std::string& snd);
109
        static void saveSystemSoundState(bool state);
23 andreas 110
 
104 andreas 111
        // SIP management
112
        static std::string& getSIPproxy();
113
        static void setSIPproxy(const std::string& address);
114
        static int getSIPport();
115
        static void setSIPport(int port);
116
        static std::string& getSIPstun();
117
        static void setSIPstun(const std::string& address);
118
        static std::string& getSIPdomain();
119
        static void setSIPdomain(const std::string& domain);
120
        static std::string& getSIPuser();
121
        static void setSIPuser(const std::string& user);
122
        static std::string& getSIPpassword();
123
        static void setSIPpassword(const std::string& pw);
124
        static bool getSIPstatus();
125
        static void setSIPstatus(bool state);
126
 
35 andreas 127
    protected:
71 andreas 128
        static bool isTrue(const std::string& boolean);
23 andreas 129
 
35 andreas 130
    private:
59 andreas 131
        static uint logLevelStrToBits(const std::string& level);
132
        static std::string logLevelBitsToString(uint level);
35 andreas 133
        bool findConfig();
134
        bool readConfig();
135
        std::vector<std::string> split(const std::string& str, const std::string& seps, const bool trimEmpty);
71 andreas 136
        static int caseCompare(const std::string& str1, const std::string& str2);
2 andreas 137
 
35 andreas 138
        std::string mPath;
139
        std::string mCFile;
90 andreas 140
        std::vector<std::string> mCfgPaths;
21 andreas 141
#ifdef __ANDROID__
142
        std::string mRoot;
143
#endif
2 andreas 144
};
145
 
146
#endif