]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
d0415c42b47f36f18e55983f9d59df0ba853bd02
[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         : passive(0),
22           disabled(0),
23           disabledDetailStat(0),
24           alwaysOnline(0),
25           credit(0),
26           userdata(USERDATA_NUM),
27           creditExpire(0)
28     {}
29
30     std::string              password;
31     int                      passive;
32     int                      disabled;
33     int                      disabledDetailStat;
34     int                      alwaysOnline;
35     std::string              tariffName;
36     std::string              address;
37     std::string              phone;
38     std::string              email;
39     std::string              note;
40     std::string              realName;
41     std::string              corp;
42     std::vector<std::string> services;
43     std::string              group;
44     double                   credit;
45     std::string              nextTariff;
46     std::vector<std::string> userdata;
47     time_t                   creditExpire;
48     USER_IPS                 ips;
49 };
50 //-----------------------------------------------------------------------------
51 struct USER_CONF_RES
52 {
53     USER_CONF_RES()
54     {
55     }
56
57     USER_CONF_RES & operator=(const USER_CONF & uc)
58     {
59         userdata.resize(USERDATA_NUM);
60         password     = uc.password;
61         passive      = uc.passive;
62         disabled     = uc.disabled;
63         disabledDetailStat = uc.disabledDetailStat;
64         alwaysOnline = uc.alwaysOnline;
65         tariffName   = uc.tariffName;
66         address      = uc.address;
67         phone        = uc.phone;
68         email        = uc.email;
69         note         = uc.note;
70         realName     = uc.realName;
71         corp         = uc.corp;
72         group        = uc.group;
73         credit       = uc.credit;
74         nextTariff   = uc.nextTariff;
75         for (size_t i = 0; i < USERDATA_NUM; i++) userdata[i]  = uc.userdata[i];
76         services     = uc.services;
77         creditExpire = uc.creditExpire;
78         ips          = uc.ips;
79         return *this;
80     }
81     USER_CONF GetData() const
82     {
83         USER_CONF uc;
84         uc.password     = password.data();
85         uc.passive      = passive.data();
86         uc.disabled     = disabled.data();
87         uc.disabledDetailStat = disabledDetailStat.data();
88         uc.alwaysOnline = alwaysOnline.data();
89         uc.tariffName   = tariffName.data();
90         uc.address      = address.data();
91         uc.phone        = phone.data();
92         uc.email        = email.data();
93         uc.note         = note.data();
94         uc.realName     = realName.data();
95         uc.corp         = corp.data();
96         uc.group        = group.data();
97         uc.credit       = credit.data();
98         uc.nextTariff   = nextTariff.data();
99         for (size_t i = 0; i < USERDATA_NUM; i++)
100             {
101             uc.userdata[i]  = userdata[i].data();
102             }
103         uc.services     = services.data();
104         uc.creditExpire = creditExpire.data();
105         uc.ips          = ips.data();
106         return uc;
107     }
108     //-------------------------------------------------------------------------
109
110     RESETABLE<std::string>               password;
111     RESETABLE<int>                       passive;
112     RESETABLE<int>                       disabled;
113     RESETABLE<int>                       disabledDetailStat;
114     RESETABLE<int>                       alwaysOnline;
115     RESETABLE<std::string>               tariffName;
116     RESETABLE<std::string>               address;
117     RESETABLE<std::string>               phone;
118     RESETABLE<std::string>               email;
119     RESETABLE<std::string>               note;
120     RESETABLE<std::string>               realName;
121     RESETABLE<std::string>               corp;
122     RESETABLE<std::string>               group;
123     RESETABLE<double>                    credit;
124     RESETABLE<std::string>               nextTariff;
125     std::vector<RESETABLE<std::string> > userdata;
126     RESETABLE<std::vector<std::string> > services;
127     RESETABLE<time_t>                    creditExpire;
128     RESETABLE<USER_IPS>                  ips;
129 };
130 //-----------------------------------------------------------------------------
131 #endif