]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Merge branch 'fix-gts-auth-errors'
[stg.git] / stglibs / srvconf.lib / include / stg / servconf_types.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 : Maxim Mamontov <faust@stargazer.dp.ua>
19  */
20
21 #ifndef __STG_STGLIBS_SRVCONF_TYPES_H__
22 #define __STG_STGLIBS_SRVCONF_TYPES_H__
23
24 #include "stg/const.h" // DIR_NUM
25 #include "stg/os_int.h" // uint32_t, etc...
26
27 #include <string>
28 #include <vector>
29 #include <ctime>
30
31 #define  STG_HEADER     "SG04"
32 #define  OK_HEADER      "OKHD"
33 #define  ERR_HEADER     "ERHD"
34 #define  OK_LOGIN       "OKLG"
35 #define  ERR_LOGIN      "ERLG"
36 #define  OK_LOGINS      "OKLS"
37 #define  ERR_LOGINS     "ERLS"
38
39 #define  ENC_MSG_LEN    (8)
40
41 struct ADMIN_CONF;
42 struct TARIFF_DATA;
43 struct SERVICE_CONF;
44 struct CORP_CONF;
45
46 namespace STG
47 {
48
49 enum status
50 {
51 st_ok = 0,
52 st_conn_fail,
53 st_send_fail,
54 st_recv_fail,
55 st_header_err,
56 st_login_err,
57 st_logins_err,
58 st_data_err,
59 st_unknown_err,
60 st_dns_err,
61 st_xml_parse_error,
62 st_data_error
63 };
64
65 enum CONF_STATE
66 {
67 confHdr = 0,
68 confLogin,
69 confLoginCipher,
70 confData
71 };
72
73 namespace SIMPLE
74 {
75
76 typedef void (* CALLBACK)(bool result, const std::string & reason, void * data);
77
78 } // namespace SIMPLE
79
80 namespace GET_CONTAINER
81 {
82
83 template <typename INFO>
84 struct CALLBACK
85 {
86 typedef void (* TYPE)(bool result, const std::string & reason, const std::vector<INFO> & info, void * data);
87 };
88
89 }
90
91 namespace AUTH_BY
92 {
93
94 typedef std::vector<std::string> INFO;
95 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
96
97 } // namespace AUTH_BY
98
99 namespace SERVER_INFO
100 {
101
102 struct INFO
103 {
104     std::string version;
105     int         tariffNum;
106     int         tariffType;
107     int         usersNum;
108     std::string uname;
109     int         dirNum;
110     std::string dirName[DIR_NUM];
111 };
112 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
113
114 } // namespace SERVER_INFO
115
116 namespace RAW_XML
117 {
118
119 typedef void (* CALLBACK)(bool result, const std::string & reason, const std::string & response, void * data);
120
121 }
122
123 namespace GET_USER
124 {
125
126 struct STAT
127 {
128     long long  su[DIR_NUM];
129     long long  sd[DIR_NUM];
130     long long  mu[DIR_NUM];
131     long long  md[DIR_NUM];
132     double     freeMb;
133 };
134
135 struct INFO
136 {
137     std::string login;
138     std::string password;
139     double      cash;
140     double      credit;
141     time_t      creditExpire;
142     double      lastCash;
143     double      prepaidTraff;
144     int         down;
145     int         passive;
146     int         disableDetailStat;
147     int         connected;
148     int         alwaysOnline;
149     uint32_t    ip;
150     std::string ips;
151     std::string tariff;
152     std::string group;
153     std::string note;
154     std::string email;
155     std::string name;
156     std::string address;
157     std::string phone;
158     STAT        stat;
159     std::string userData[USERDATA_NUM];
160 };
161
162 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
163
164 } // namespace GET_USER
165
166 namespace GET_ADMIN
167 {
168
169 typedef ADMIN_CONF INFO;
170 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
171
172 }
173
174 namespace GET_TARIFF
175 {
176
177 typedef TARIFF_DATA INFO;
178 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
179
180 }
181
182 namespace GET_SERVICE
183 {
184
185 typedef SERVICE_CONF INFO;
186 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
187
188 }
189
190 namespace GET_CORP
191 {
192
193 typedef CORP_CONF INFO;
194 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
195
196 }
197
198 } // namespace STG
199
200 #endif