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.
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.
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
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19 * Author : Maksym Mamontov <stg@madf.info>
22 #ifndef __STG_SGCONFIG_PARSER_USERS_H__
23 #define __STG_SGCONFIG_PARSER_USERS_H__
27 #include "stg/user_conf.h"
28 #include "stg/user_stat.h"
29 #include "stg/common.h"
30 #include "stg/resetable.h"
45 class GET_USERS: public BASE_PARSER
48 class FACTORY : public BASE_PARSER::FACTORY
51 explicit FACTORY(USERS & users) : m_users(users) {}
52 virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USERS(admin, m_users); }
53 static void Register(REGISTRY & registry, USERS & users)
54 { registry[ToLower(tag)] = new FACTORY(users); }
59 static const char * tag;
61 GET_USERS(const ADMIN & admin, USERS & users)
62 : BASE_PARSER(admin, tag), m_users(users),
63 m_lastUserUpdateTime(0) {}
64 int Start(void * data, const char * el, const char ** attr);
68 time_t m_lastUserUpdateTime;
73 class GET_USER: public BASE_PARSER
76 class FACTORY : public BASE_PARSER::FACTORY
79 explicit FACTORY(const USERS & users) : m_users(users) {}
80 virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USER(admin, m_users); }
81 static void Register(REGISTRY & registry, const USERS & users)
82 { registry[ToLower(tag)] = new FACTORY(users); }
84 const USERS & m_users;
87 static const char * tag;
89 GET_USER(const ADMIN & admin, const USERS & users)
90 : BASE_PARSER(admin, tag), m_users(users) {}
91 int Start(void * data, const char * el, const char ** attr);
94 const USERS & m_users;
100 class ADD_USER: public BASE_PARSER
103 class FACTORY : public BASE_PARSER::FACTORY
106 explicit FACTORY(USERS & users) : m_users(users) {}
107 virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_USER(admin, m_users); }
108 static void Register(REGISTRY & registry, USERS & users)
109 { registry[ToLower(tag)] = new FACTORY(users); }
114 static const char * tag;
116 ADD_USER(const ADMIN & admin, USERS & users)
117 : BASE_PARSER(admin, tag), m_users(users) {}
118 int Start(void * data, const char * el, const char ** attr);
127 class CHG_USER: public BASE_PARSER
130 class FACTORY : public BASE_PARSER::FACTORY
133 FACTORY(USERS & users, STORE & store, const TARIFFS & tariffs)
134 : m_users(users), m_store(store), m_tariffs(tariffs)
136 virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_USER(admin, m_users, m_store, m_tariffs); }
137 static void Register(REGISTRY & registry, USERS & users, STORE & store, const TARIFFS & tariffs)
138 { registry[ToLower(tag)] = new FACTORY(users, store, tariffs); }
142 const TARIFFS & m_tariffs;
145 static const char * tag;
147 CHG_USER(const ADMIN & admin, USERS & users,
148 STORE & store, const TARIFFS & tariffs)
149 : BASE_PARSER(admin, tag),
153 m_cashMustBeAdded(false) {}
155 int Start(void * data, const char * el, const char ** attr);
160 const TARIFFS & m_tariffs;
163 RESETABLE<uint64_t> m_upr[DIR_NUM];
164 RESETABLE<uint64_t> m_downr[DIR_NUM];
165 std::string m_cashMsg;
167 bool m_cashMustBeAdded;
173 class DEL_USER: public BASE_PARSER
176 class FACTORY : public BASE_PARSER::FACTORY
179 explicit FACTORY(USERS & users) : m_users(users) {}
180 virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_USER(admin, m_users); }
181 static void Register(REGISTRY & registry, USERS & users)
182 { registry[ToLower(tag)] = new FACTORY(users); }
187 static const char * tag;
189 DEL_USER(const ADMIN & admin, USERS & users)
190 : BASE_PARSER(admin, tag), m_users(users), res(0), u(NULL) {}
191 int Start(void * data, const char * el, const char ** attr);
192 int End(void * data, const char * el);
202 class CHECK_USER: public BASE_PARSER
205 class FACTORY : public BASE_PARSER::FACTORY
208 explicit FACTORY(const USERS & users) : m_users(users) {}
209 virtual BASE_PARSER * create(const ADMIN & admin) { return new CHECK_USER(admin, m_users); }
210 static void Register(REGISTRY & registry, const USERS & users)
211 { registry[ToLower(tag)] = new FACTORY(users); }
213 const USERS & m_users;
216 static const char * tag;
218 CHECK_USER(const ADMIN & admin, const USERS & users)
219 : BASE_PARSER(admin, tag), m_users(users) {}
220 int Start(void * data, const char * el, const char ** attr);
221 int End(void * data, const char * el);
224 const USERS & m_users;
226 void CreateAnswer(const char * error);
227 void CreateAnswer() {} // dummy
230 } // namespace PARSER