]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig/parser_users.h
Removed unused stuff.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_users.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
20  */
21
22 #ifndef __STG_SGCONFIG_PARSER_USERS_H__
23 #define __STG_SGCONFIG_PARSER_USERS_H__
24
25 #include "parser.h"
26
27 #include "stg/user_conf.h"
28 #include "stg/user_stat.h"
29 #include "stg/resetable.h"
30
31 #include <string>
32
33 class USERS;
34 class USER;
35 class TARIFFS;
36 class ADMIN;
37 class STORE;
38
39 namespace STG
40 {
41 namespace PARSER
42 {
43
44 class GET_USERS: public BASE_PARSER
45 {
46     public:
47         GET_USERS(const ADMIN & admin, USERS & users)
48             : BASE_PARSER(admin, "GetUsers"), m_users(users),
49               m_lastUserUpdateTime(0) {}
50         int Start(void * data, const char * el, const char ** attr);
51
52     private:
53         USERS & m_users;
54         time_t m_lastUserUpdateTime;
55
56         void CreateAnswer();
57 };
58
59 class GET_USER: public BASE_PARSER
60 {
61     public:
62         GET_USER(const ADMIN & admin, const USERS & users)
63             : BASE_PARSER(admin, "GetUser"), m_users(users) {}
64         int Start(void * data, const char * el, const char ** attr);
65
66     private:
67         const USERS & m_users;
68         std::string m_login;
69
70         void CreateAnswer();
71 };
72
73 class ADD_USER: public BASE_PARSER
74 {
75     public:
76         ADD_USER(const ADMIN & admin, USERS & users)
77             : BASE_PARSER(admin, "AddUser"), m_users(users) {}
78         int Start(void * data, const char * el, const char ** attr);
79
80     private:
81         USERS & m_users;
82         std::string m_login;
83
84         void CreateAnswer();
85 };
86
87 class CHG_USER: public BASE_PARSER
88 {
89     public:
90         CHG_USER(const ADMIN & admin, USERS & users,
91                  STORE & store, const TARIFFS & tariffs)
92             : BASE_PARSER(admin, "SetUser"),
93               m_users(users),
94               m_store(store),
95               m_tariffs(tariffs),
96               m_cashMustBeAdded(false),
97               m_res(0) {}
98
99         int Start(void * data, const char * el, const char ** attr);
100
101     private:
102         USERS & m_users;
103         STORE & m_store;
104         const TARIFFS & m_tariffs;
105         USER_STAT_RES m_usr;
106         USER_CONF_RES m_ucr;
107         RESETABLE<uint64_t> m_upr[DIR_NUM];
108         RESETABLE<uint64_t> m_downr[DIR_NUM];
109         std::string m_cashMsg;
110         std::string m_login;
111         bool m_cashMustBeAdded;
112         int m_res;
113
114         int ApplyChanges();
115         void CreateAnswer();
116 };
117
118 class DEL_USER: public BASE_PARSER
119 {
120     public:
121         DEL_USER(const ADMIN & admin, USERS & users)
122             : BASE_PARSER(admin, "DelUser"), m_users(users), res(0), u(NULL) {}
123         int Start(void * data, const char * el, const char ** attr);
124         int End(void * data, const char * el);
125
126     private:
127         USERS & m_users;
128         int res;
129         USER * u;
130
131         void CreateAnswer();
132 };
133
134 class CHECK_USER: public BASE_PARSER
135 {
136     public:
137         CHECK_USER(const ADMIN & admin, const USERS & users)
138             : BASE_PARSER(admin, "CheckUser"), m_users(users) {}
139         int Start(void * data, const char * el, const char ** attr);
140         int End(void * data, const char * el);
141
142     private:
143         const USERS & m_users;
144
145         void CreateAnswer(const char * error);
146 };
147
148 }
149 }
150
151 #endif