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