]> git.stg.codes - stg.git/blob - libs/srvconf/include/stg/servconf_types.h
Public interfaces: part 1
[stg.git] / libs / srvconf / 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 #pragma once
22
23 #include "stg/const.h" // DIR_NUM
24
25 #include <string>
26 #include <vector>
27 #include <array>
28 #include <ctime>
29 #include <cstdint>
30
31 namespace STG
32 {
33
34 struct AdminConf;
35 struct TariffData;
36 struct ServiceConf;
37 struct CorpConf;
38
39 enum status
40 {
41     st_ok = 0,
42     st_conn_fail,
43     st_send_fail,
44     st_recv_fail,
45     st_header_err,
46     st_login_err,
47     st_logins_err,
48     st_data_err,
49     st_unknown_err,
50     st_dns_err,
51     st_xml_parse_error,
52     st_data_error
53 };
54
55 namespace Simple
56 {
57
58 using Callback = void (*)(bool result, const std::string& reason, void* data);
59
60 } // namespace Simple
61
62 namespace GetContainer
63 {
64
65 template <typename T>
66 struct Callback
67 {
68     using Type = void (*)(bool result, const std::string& reason, const std::vector<T>& info, void* data);
69 };
70
71 } // namespace GetContainer
72
73 namespace AuthBy
74 {
75
76 using Info = std::vector<std::string>;
77 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
78
79 } // namespace AuthBy
80
81 namespace ServerInfo
82 {
83
84 struct Info
85 {
86     std::string version;
87     int         tariffNum;
88     int         tariffType;
89     int         usersNum;
90     std::string uname;
91     int         dirNum;
92     std::array<std::string, DIR_NUM> dirName;
93 };
94 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
95
96 } // namespace ServerInfo
97
98 namespace RawXML
99 {
100
101 using Callback = void (*)(bool result, const std::string& reason, const std::string& response, void* data);
102
103 } // namespace RawXML
104
105 namespace GetUser
106 {
107
108 struct Stat
109 {
110     std::array<long long, DIR_NUM> su;
111     std::array<long long, DIR_NUM> sd;
112     std::array<long long, DIR_NUM> mu;
113     std::array<long long, DIR_NUM> md;
114 };
115
116 struct Info
117 {
118     std::string login;
119     std::string password;
120     double      cash;
121     double      credit;
122     time_t      creditExpire;
123     double      lastCashAdd;
124     double      lastCashAddTime;
125     time_t      lastTimeCash;
126     double      prepaidTraff;
127     int         disabled;
128     int         passive;
129     int         disableDetailStat;
130     int         connected;
131     int         alwaysOnline;
132     uint32_t    ip;
133     std::string ips;
134     std::string tariff;
135     std::string group;
136     std::string note;
137     std::string email;
138     std::string name;
139     std::string address;
140     std::string phone;
141     std::string corp;
142     Stat        stat;
143     time_t      pingTime;
144     time_t      lastActivityTime;
145     std::array<std::string, USERDATA_NUM> userData;
146     std::vector<std::string> services;
147     std::vector<std::string> authBy;
148 };
149
150 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
151
152 } // namespace GetUser
153
154 namespace GetAdmin
155 {
156
157 using Info = AdminConf;
158 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
159
160 } // namespace GetAdmin
161
162 namespace GetTariff
163 {
164
165 using Info = TariffData;
166 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
167
168 } // namespace GetTariff
169
170 namespace GetService
171 {
172
173 using Info = ServiceConf;
174 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
175
176 } // namespace GetService
177
178 namespace GetCorp
179 {
180
181 using Info = CorpConf;
182 using Callback = void (*)(bool result, const std::string& reason, const Info& info, void* data);
183
184 } // namespace GetCorp
185
186 } // namespace STG