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