]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Added services 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
45 namespace STG
46 {
47
48 enum status
49 {
50 st_ok = 0,
51 st_conn_fail,
52 st_send_fail,
53 st_recv_fail,
54 st_header_err,
55 st_login_err,
56 st_logins_err,
57 st_data_err,
58 st_unknown_err,
59 st_dns_err,
60 st_xml_parse_error,
61 st_data_error
62 };
63
64 enum CONF_STATE
65 {
66 confHdr = 0,
67 confLogin,
68 confLoginCipher,
69 confData
70 };
71
72 namespace SIMPLE
73 {
74
75 typedef void (* CALLBACK)(bool result, const std::string & reason, void * data);
76
77 } // namespace SIMPLE
78
79 namespace AUTH_BY
80 {
81
82 typedef std::vector<std::string> INFO;
83 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
84
85 } // namespace AUTH_BY
86
87 namespace SERVER_INFO
88 {
89
90 struct INFO
91 {
92     std::string version;
93     int         tariffNum;
94     int         tariffType;
95     int         usersNum;
96     std::string uname;
97     int         dirNum;
98     std::string dirName[DIR_NUM];
99 };
100 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
101
102 } // namespace SERVER_INFO
103
104 namespace RAW_XML
105 {
106
107 typedef void (* CALLBACK)(bool result, const std::string & reason, const std::string & response, void * data);
108
109 }
110
111 namespace GET_USER
112 {
113
114 struct STAT
115 {
116     long long  su[DIR_NUM];
117     long long  sd[DIR_NUM];
118     long long  mu[DIR_NUM];
119     long long  md[DIR_NUM];
120     double     freeMb;
121 };
122
123 struct INFO
124 {
125     std::string login;
126     std::string password;
127     double      cash;
128     double      credit;
129     time_t      creditExpire;
130     double      lastCash;
131     double      prepaidTraff;
132     int         down;
133     int         passive;
134     int         disableDetailStat;
135     int         connected;
136     int         alwaysOnline;
137     uint32_t    ip;
138     std::string ips;
139     std::string tariff;
140     std::string group;
141     std::string note;
142     std::string email;
143     std::string name;
144     std::string address;
145     std::string phone;
146     STAT        stat;
147     std::string userData[USERDATA_NUM];
148 };
149
150 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
151
152 } // namespace GET_USER
153
154 namespace GET_USERS
155 {
156
157 typedef std::vector<GET_USER::INFO> INFO;
158 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
159
160 } // namespace GET_USERS
161
162 namespace GET_ADMIN
163 {
164
165 typedef ADMIN_CONF INFO;
166 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
167
168 }
169
170 namespace GET_ADMINS
171 {
172
173 typedef std::vector<GET_ADMIN::INFO> INFO;
174 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
175
176 }
177
178 namespace GET_TARIFF
179 {
180
181 typedef TARIFF_DATA INFO;
182 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
183
184 }
185
186 namespace GET_TARIFFS
187 {
188
189 typedef std::vector<GET_TARIFF::INFO> INFO;
190 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
191
192 }
193
194 namespace GET_SERVICE
195 {
196
197 typedef SERVICE_CONF INFO;
198 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
199
200 }
201
202 namespace GET_SERVICES
203 {
204
205 typedef std::vector<GET_SERVICE::INFO> INFO;
206 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
207
208 }
209
210 } // namespace STG
211
212 #endif