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