]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
Ticket 37. Int2TS() method changed to formatTime() function in the SaveTariff() function.
[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> service;
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         group        = uc.group;
71         credit       = uc.credit;
72         nextTariff   = uc.nextTariff;
73         for (int i = 0; i < USERDATA_NUM; i++)
74             {
75             userdata[i]  = uc.userdata[i];
76             }
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.group        = group.data();
96         uc.credit       = credit.data();
97         uc.nextTariff   = nextTariff.data();
98         for (int i = 0; i < USERDATA_NUM; i++)
99             {
100             uc.userdata[i]  = userdata[i].data();
101             }
102         uc.creditExpire = creditExpire.data();
103         uc.ips          = ips.data();
104         return uc;
105     }
106     //-------------------------------------------------------------------------
107
108     RESETABLE<std::string>               password;
109     RESETABLE<int>                       passive;
110     RESETABLE<int>                       disabled;
111     RESETABLE<int>                       disabledDetailStat;
112     RESETABLE<int>                       alwaysOnline;
113     RESETABLE<std::string>               tariffName;
114     RESETABLE<std::string>               address;
115     RESETABLE<std::string>               phone;
116     RESETABLE<std::string>               email;
117     RESETABLE<std::string>               note;
118     RESETABLE<std::string>               realName;
119     RESETABLE<std::string>               group;
120     RESETABLE<double>                    credit;
121     RESETABLE<std::string>               nextTariff;
122     std::vector<RESETABLE<std::string> > userdata;
123     RESETABLE<time_t>                    creditExpire;
124     RESETABLE<USER_IPS>                  ips;
125 };
126 //-----------------------------------------------------------------------------
127 #endif