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