]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
Fixed merge issues.
[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           service(),
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> service;
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           group(),
78           credit(),
79           nextTariff(),
80           userdata(USERDATA_NUM),
81           creditExpire(),
82           ips()
83     {
84     }
85
86     USER_CONF_RES & operator=(const USER_CONF & uc)
87     {
88         userdata.resize(USERDATA_NUM);
89         password     = uc.password;
90         passive      = uc.passive;
91         disabled     = uc.disabled;
92         disabledDetailStat = uc.disabledDetailStat;
93         alwaysOnline = uc.alwaysOnline;
94         tariffName   = uc.tariffName;
95         address      = uc.address;
96         phone        = uc.phone;
97         email        = uc.email;
98         note         = uc.note;
99         realName     = uc.realName;
100         group        = uc.group;
101         credit       = uc.credit;
102         nextTariff   = uc.nextTariff;
103         for (size_t i = 0; i < USERDATA_NUM; i++) userdata[i]  = uc.userdata[i];
104         creditExpire = uc.creditExpire;
105         ips          = uc.ips;
106         return *this;
107     }
108     USER_CONF GetData() const
109     {
110         USER_CONF uc;
111         uc.password     = password.data();
112         uc.passive      = passive.data();
113         uc.disabled     = disabled.data();
114         uc.disabledDetailStat = disabledDetailStat.data();
115         uc.alwaysOnline = alwaysOnline.data();
116         uc.tariffName   = tariffName.data();
117         uc.address      = address.data();
118         uc.phone        = phone.data();
119         uc.email        = email.data();
120         uc.note         = note.data();
121         uc.realName     = realName.data();
122         uc.group        = group.data();
123         uc.credit       = credit.data();
124         uc.nextTariff   = nextTariff.data();
125         for (int i = 0; i < USERDATA_NUM; i++)
126             {
127             uc.userdata[i]  = userdata[i].data();
128             }
129         uc.creditExpire = creditExpire.data();
130         uc.ips          = ips.data();
131         return uc;
132     }
133     //-------------------------------------------------------------------------
134
135     RESETABLE<std::string>               password;
136     RESETABLE<int>                       passive;
137     RESETABLE<int>                       disabled;
138     RESETABLE<int>                       disabledDetailStat;
139     RESETABLE<int>                       alwaysOnline;
140     RESETABLE<std::string>               tariffName;
141     RESETABLE<std::string>               address;
142     RESETABLE<std::string>               phone;
143     RESETABLE<std::string>               email;
144     RESETABLE<std::string>               note;
145     RESETABLE<std::string>               realName;
146     RESETABLE<std::string>               group;
147     RESETABLE<double>                    credit;
148     RESETABLE<std::string>               nextTariff;
149     std::vector<RESETABLE<std::string> > userdata;
150     RESETABLE<time_t>                    creditExpire;
151     RESETABLE<USER_IPS>                  ips;
152 };
153 //-----------------------------------------------------------------------------
154 #endif