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