]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
Merge branch 'naffanya-dev'
[stg.git] / include / stg / user_conf.h
1  /*
2  $Revision: 1.12 $
3  $Date: 2010/03/11 14:42:05 $
4  $Author: faust $
5  */
6
7 #ifndef USER_CONF_H
8 #define USER_CONF_H
9
10 #include <string>
11 #include <vector>
12 #include "const.h"
13 #include "user_ips.h"
14 #include "resetable.h"
15 #include "os_int.h"
16
17 //-----------------------------------------------------------------------------
18 struct USER_CONF
19 {
20     USER_CONF()
21         : password(),
22           passive(0),
23           disabled(0),
24           disabledDetailStat(0),
25           alwaysOnline(0),
26           tariffName(),
27           address(),
28           phone(),
29           email(),
30           note(),
31           realName(),
32           corp(),
33           services(),
34           group(),
35           credit(0),
36           nextTariff(),
37           userdata(USERDATA_NUM),
38           creditExpire(0),
39           ips()
40     {}
41
42     std::string              password;
43     int                      passive;
44     int                      disabled;
45     int                      disabledDetailStat;
46     int                      alwaysOnline;
47     std::string              tariffName;
48     std::string              address;
49     std::string              phone;
50     std::string              email;
51     std::string              note;
52     std::string              realName;
53     std::string              corp;
54     std::vector<std::string> services;
55     std::string              group;
56     double                   credit;
57     std::string              nextTariff;
58     std::vector<std::string> userdata;
59     time_t                   creditExpire;
60     USER_IPS                 ips;
61 };
62 //-----------------------------------------------------------------------------
63 struct USER_CONF_RES
64 {
65     USER_CONF_RES()
66         : password(),
67           passive(),
68           disabled(),
69           disabledDetailStat(),
70           alwaysOnline(),
71           tariffName(),
72           address(),
73           phone(),
74           email(),
75           note(),
76           realName(),
77           corp(),
78           group(),
79           credit(),
80           nextTariff(),
81           userdata(USERDATA_NUM),
82           services(),
83           creditExpire(),
84           ips()
85     {
86     }
87
88     USER_CONF_RES & operator=(const USER_CONF & uc)
89     {
90         userdata.resize(USERDATA_NUM);
91         password     = uc.password;
92         passive      = uc.passive;
93         disabled     = uc.disabled;
94         disabledDetailStat = uc.disabledDetailStat;
95         alwaysOnline = uc.alwaysOnline;
96         tariffName   = uc.tariffName;
97         address      = uc.address;
98         phone        = uc.phone;
99         email        = uc.email;
100         note         = uc.note;
101         realName     = uc.realName;
102         corp         = uc.corp;
103         group        = uc.group;
104         credit       = uc.credit;
105         nextTariff   = uc.nextTariff;
106         for (size_t i = 0; i < USERDATA_NUM; i++) userdata[i]  = uc.userdata[i];
107         services     = uc.services;
108         creditExpire = uc.creditExpire;
109         ips          = uc.ips;
110         return *this;
111     }
112     USER_CONF GetData() const
113     {
114         USER_CONF uc;
115         uc.password     = password.data();
116         uc.passive      = passive.data();
117         uc.disabled     = disabled.data();
118         uc.disabledDetailStat = disabledDetailStat.data();
119         uc.alwaysOnline = alwaysOnline.data();
120         uc.tariffName   = tariffName.data();
121         uc.address      = address.data();
122         uc.phone        = phone.data();
123         uc.email        = email.data();
124         uc.note         = note.data();
125         uc.realName     = realName.data();
126         uc.corp         = corp.data();
127         uc.group        = group.data();
128         uc.credit       = credit.data();
129         uc.nextTariff   = nextTariff.data();
130         for (size_t i = 0; i < USERDATA_NUM; i++)
131             {
132             uc.userdata[i]  = userdata[i].data();
133             }
134         uc.services     = services.data();
135         uc.creditExpire = creditExpire.data();
136         uc.ips          = ips.data();
137         return uc;
138     }
139     //-------------------------------------------------------------------------
140
141     RESETABLE<std::string>               password;
142     RESETABLE<int>                       passive;
143     RESETABLE<int>                       disabled;
144     RESETABLE<int>                       disabledDetailStat;
145     RESETABLE<int>                       alwaysOnline;
146     RESETABLE<std::string>               tariffName;
147     RESETABLE<std::string>               address;
148     RESETABLE<std::string>               phone;
149     RESETABLE<std::string>               email;
150     RESETABLE<std::string>               note;
151     RESETABLE<std::string>               realName;
152     RESETABLE<std::string>               corp;
153     RESETABLE<std::string>               group;
154     RESETABLE<double>                    credit;
155     RESETABLE<std::string>               nextTariff;
156     std::vector<RESETABLE<std::string> > userdata;
157     RESETABLE<std::vector<std::string> > services;
158     RESETABLE<time_t>                    creditExpire;
159     RESETABLE<USER_IPS>                  ips;
160 };
161 //-----------------------------------------------------------------------------
162 #endif