]> git.stg.codes - stg.git/blob - stglibs/srvconf.lib/include/stg/servconf_types.h
Fixed getting user's login.
[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      lastCashAdd;
144     double      lastCashAddTime;
145     time_t      lastTimeCash;
146     double      prepaidTraff;
147     int         disabled;
148     int         passive;
149     int         disableDetailStat;
150     int         connected;
151     int         alwaysOnline;
152     uint32_t    ip;
153     std::string ips;
154     std::string tariff;
155     std::string group;
156     std::string note;
157     std::string email;
158     std::string name;
159     std::string address;
160     std::string phone;
161     STAT        stat;
162     time_t      pingTime;
163     time_t      lastActivityTime;
164     ARRAY<std::string, USERDATA_NUM> userData;
165 };
166
167 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
168
169 } // namespace GET_USER
170
171 namespace GET_ADMIN
172 {
173
174 typedef ADMIN_CONF 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_SERVICE
188 {
189
190 typedef SERVICE_CONF INFO;
191 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
192
193 }
194
195 namespace GET_CORP
196 {
197
198 typedef CORP_CONF INFO;
199 typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
200
201 }
202
203 } // namespace STG
204
205 #endif