]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
Version bump
[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, RESETABLE<std::string>()),
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 (int i = 0; i < USERDATA_NUM; i++)
104             {
105             userdata[i]  = uc.userdata[i];
106             }
107         creditExpire = uc.creditExpire;
108         ips          = uc.ips;
109         return *this;
110     };
111     operator USER_CONF() const
112     {
113         USER_CONF uc;
114         uc.password     = password;
115         uc.passive      = passive;
116         uc.disabled     = disabled;
117         uc.disabledDetailStat = disabledDetailStat;
118         uc.alwaysOnline = alwaysOnline;
119         uc.tariffName   = tariffName;
120         uc.address      = address;
121         uc.phone        = phone;
122         uc.email        = email;
123         uc.note         = note;
124         uc.realName     = realName;
125         uc.group        = group;
126         uc.credit       = credit;
127         uc.nextTariff   = nextTariff;
128         for (int i = 0; i < USERDATA_NUM; i++)
129             {
130             uc.userdata[i]  = userdata[i];
131             }
132         uc.creditExpire = creditExpire;
133         uc.ips          = ips;
134         return uc;
135     }
136     //-------------------------------------------------------------------------
137
138     RESETABLE<std::string>               password;
139     RESETABLE<int>                       passive;
140     RESETABLE<int>                       disabled;
141     RESETABLE<int>                       disabledDetailStat;
142     RESETABLE<int>                       alwaysOnline;
143     RESETABLE<std::string>               tariffName;
144     RESETABLE<std::string>               address;
145     RESETABLE<std::string>               phone;
146     RESETABLE<std::string>               email;
147     RESETABLE<std::string>               note;
148     RESETABLE<std::string>               realName;
149     RESETABLE<std::string>               group;
150     RESETABLE<double>                    credit;
151     RESETABLE<std::string>               nextTariff;
152     std::vector<RESETABLE<std::string> > userdata;
153     RESETABLE<time_t>                    creditExpire;
154     RESETABLE<USER_IPS>                  ips;
155 };
156 //-----------------------------------------------------------------------------
157 #endif
158