]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig/configproto.h
Removed unused variables.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / configproto.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  */
20
21  /*
22  $Revision: 1.14 $
23  $Date: 2010/10/04 20:24:14 $
24  $Author: faust $
25  */
26
27
28 #ifndef CONFIGPROTO_H
29 #define CONFIGPROTO_H
30
31 #include <string>
32 #include <list>
33 #include <vector>
34
35 #include "stg/module_settings.h"
36 #include "stg/os_int.h"
37
38 #include <expat.h>
39 #include <pthread.h>
40
41 #define  STG_HEADER     "SG04"
42 #define  OK_HEADER      "OKHD"
43 #define  ERR_HEADER     "ERHD"
44 #define  OK_LOGIN       "OKLG"
45 #define  ERR_LOGIN      "ERLG"
46 #define  OK_LOGINS      "OKLS"
47 #define  ERR_LOGINS     "ERLS"
48
49 class BASE_PARSER;
50 class USERS;
51 class ADMINS;
52 class ADMIN;
53 class TARIFFS;
54 class PLUGIN_LOGGER;
55 class STORE;
56 class SETTINGS;
57
58 //-----------------------------------------------------------------------------
59 class CONFIGPROTO {
60 public:
61     CONFIGPROTO(PLUGIN_LOGGER & l);
62     ~CONFIGPROTO();
63
64     void            SetPort(uint16_t port);
65     void            SetAdmins(ADMINS * a);
66     void            SetUsers(USERS * u);
67     void            SetTariffs(TARIFFS * t);
68     void            SetStore(STORE * s);
69     void            SetStgSettings(const SETTINGS * s);
70     uint32_t        GetAdminIP() const { return adminIP; }
71     int             Prepare();
72     int             Stop();
73     const std::string & GetStrError() const { return errorStr; }
74     void            Run();
75
76 private:
77     CONFIGPROTO(const CONFIGPROTO & rvalue);
78     CONFIGPROTO & operator=(const CONFIGPROTO & rvalue);
79
80     int             RecvHdr(int sock);
81     int             RecvLogin(int sock);
82     int             SendLoginAnswer(int sock);
83     int             SendHdrAnswer(int sock, int err);
84     int             RecvLoginS(int sock);
85     int             SendLoginSAnswer(int sock, int err);
86     int             RecvData(int sock);
87     int             SendDataAnswer(int sock);
88     void            SendError(const char * text);
89     void            WriteLogAccessFailed(uint32_t ip);
90
91     int             ParseCommand();
92
93     std::list<std::string>      answerList;
94     std::list<std::string>      requestList;
95     uint32_t                    adminIP;
96     std::string                 adminLogin;
97     std::string                 adminPassword;
98     uint16_t                    port;
99     pthread_t                   thrReciveSendConf;
100     bool                        nonstop;
101     int                         state;
102     ADMIN *                     currAdmin;
103     PLUGIN_LOGGER &             logger;
104
105     int                         listenSocket;
106
107     ADMINS *                    admins;
108
109     BASE_PARSER *               currParser;
110     std::vector<BASE_PARSER *>  dataParser;
111
112     XML_Parser                  xmlParser;
113
114     std::string                 errorStr;
115
116     friend void ParseXMLStart(void *data, const char *el, const char **attr);
117     friend void ParseXMLEnd(void *data, const char *el);
118 };
119 //-----------------------------------------------------------------------------
120 #endif //CONFIGPROTO_H