]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
a16b392984454fe0679baad959f7457492068331
[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         : userdata(USERDATA_NUM)
55     {}
56     USER_CONF_RES & operator=(const USER_CONF & uc)
57     {
58         userdata.resize(USERDATA_NUM);
59         password     = uc.password;
60         passive      = uc.passive;
61         disabled     = uc.disabled;
62         disabledDetailStat = uc.disabledDetailStat;
63         alwaysOnline = uc.alwaysOnline;
64         tariffName   = uc.tariffName;
65         address      = uc.address;
66         phone        = uc.phone;
67         email        = uc.email;
68         note         = uc.note;
69         realName     = uc.realName;
70         corp         = uc.corp;
71         group        = uc.group;
72         credit       = uc.credit;
73         nextTariff   = uc.nextTariff;
74         for (size_t i = 0; i < USERDATA_NUM; i++) userdata[i]  = uc.userdata[i];
75         services     = uc.services;
76         creditExpire = uc.creditExpire;
77         ips          = uc.ips;
78         return *this;
79     }
80     USER_CONF GetData() const
81     {
82         USER_CONF uc;
83         uc.password     = password.data();
84         uc.passive      = passive.data();
85         uc.disabled     = disabled.data();
86         uc.disabledDetailStat = disabledDetailStat.data();
87         uc.alwaysOnline = alwaysOnline.data();
88         uc.tariffName   = tariffName.data();
89         uc.address      = address.data();
90         uc.phone        = phone.data();
91         uc.email        = email.data();
92         uc.note         = note.data();
93         uc.realName     = realName.data();
94         uc.corp         = corp.data();
95         uc.group        = group.data();
96         uc.credit       = credit.data();
97         uc.nextTariff   = nextTariff.data();
98         for (size_t i = 0; i < USERDATA_NUM; i++)
99             {
100             uc.userdata[i]  = userdata[i].data();
101             }
102         uc.services     = services.data();
103         uc.creditExpire = creditExpire.data();
104         uc.ips          = ips.data();
105         return uc;
106     }
107     //-------------------------------------------------------------------------
108
109     RESETABLE<std::string>               password;
110     RESETABLE<int>                       passive;
111     RESETABLE<int>                       disabled;
112     RESETABLE<int>                       disabledDetailStat;
113     RESETABLE<int>                       alwaysOnline;
114     RESETABLE<std::string>               tariffName;
115     RESETABLE<std::string>               address;
116     RESETABLE<std::string>               phone;
117     RESETABLE<std::string>               email;
118     RESETABLE<std::string>               note;
119     RESETABLE<std::string>               realName;
120     RESETABLE<std::string>               corp;
121     RESETABLE<std::string>               group;
122     RESETABLE<double>                    credit;
123     RESETABLE<std::string>               nextTariff;
124     std::vector<RESETABLE<std::string> > userdata;
125     RESETABLE<std::vector<std::string> > services;
126     RESETABLE<time_t>                    creditExpire;
127     RESETABLE<USER_IPS>                  ips;
128 };
129 //-----------------------------------------------------------------------------
130 #endif