]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Added corporations management.
[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 AUTH_BY
81 {
82
83 typedef std::vector<std::string> INFO;
84 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
85
86 } // namespace AUTH_BY
87
88 namespace SERVER_INFO
89 {
90
91 struct INFO
92 {
93     std::string version;
94     int         tariffNum;
95     int         tariffType;
96     int         usersNum;
97     std::string uname;
98     int         dirNum;
99     std::string dirName[DIR_NUM];
100 };
101 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
102
103 } // namespace SERVER_INFO
104
105 namespace RAW_XML
106 {
107
108 typedef void (* CALLBACK)(bool result, const std::string & reason, const std::string & response, void * data);
109
110 }
111
112 namespace GET_USER
113 {
114
115 struct STAT
116 {
117     long long  su[DIR_NUM];
118     long long  sd[DIR_NUM];
119     long long  mu[DIR_NUM];
120     long long  md[DIR_NUM];
121     double     freeMb;
122 };
123
124 struct INFO
125 {
126     std::string login;
127     std::string password;
128     double      cash;
129     double      credit;
130     time_t      creditExpire;
131     double      lastCash;
132     double      prepaidTraff;
133     int         down;
134     int         passive;
135     int         disableDetailStat;
136     int         connected;
137     int         alwaysOnline;
138     uint32_t    ip;
139     std::string ips;
140     std::string tariff;
141     std::string group;
142     std::string note;
143     std::string email;
144     std::string name;
145     std::string address;
146     std::string phone;
147     STAT        stat;
148     std::string userData[USERDATA_NUM];
149 };
150
151 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
152
153 } // namespace GET_USER
154
155 namespace GET_USERS
156 {
157
158 typedef std::vector<GET_USER::INFO> INFO;
159 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
160
161 } // namespace GET_USERS
162
163 namespace GET_ADMIN
164 {
165
166 typedef ADMIN_CONF INFO;
167 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
168
169 }
170
171 namespace GET_ADMINS
172 {
173
174 typedef std::vector<GET_ADMIN::INFO> INFO;
175 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
176
177 }
178
179 namespace GET_TARIFF
180 {
181
182 typedef TARIFF_DATA INFO;
183 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
184
185 }
186
187 namespace GET_TARIFFS
188 {
189
190 typedef std::vector<GET_TARIFF::INFO> INFO;
191 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
192
193 }
194
195 namespace GET_SERVICE
196 {
197
198 typedef SERVICE_CONF INFO;
199 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
200
201 }
202
203 namespace GET_SERVICES
204 {
205
206 typedef std::vector<GET_SERVICE::INFO> INFO;
207 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
208
209 }
210
211 namespace GET_CORP
212 {
213
214 typedef CORP_CONF INFO;
215 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
216
217 }
218
219 namespace GET_CORPORATIONS
220 {
221
222 typedef std::vector<GET_CORP::INFO> INFO;
223 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
224
225 }
226
227 } // namespace STG
228
229 #endif