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 : Maxim Mamontov <faust@stargazer.dp.ua>
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/resetable.h"
44 class GET_USERS: public BASE_PARSER
47 class FACTORY : public BASE_PARSER::FACTORY
50 FACTORY(USERS & users) : m_users(users) {}
51 virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USERS(admin, m_users); }
52 static void Register(REGISTRY & registry, USERS & users)
53 { registry[tag] = new FACTORY(users); }
58 static const char * tag;
60 GET_USERS(const ADMIN & admin, USERS & users)
61 : BASE_PARSER(admin, tag), m_users(users),
62 m_lastUserUpdateTime(0) {}
63 int Start(void * data, const char * el, const char ** attr);
67 time_t m_lastUserUpdateTime;
72 class GET_USER: public BASE_PARSER
75 class FACTORY : public BASE_PARSER::FACTORY
78 FACTORY(const USERS & users) : m_users(users) {}
79 virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USER(admin, m_users); }
80 static void Register(REGISTRY & registry, const USERS & users)
81 { registry[tag] = new FACTORY(users); }
83 const USERS & m_users;
86 static const char * tag;
88 GET_USER(const ADMIN & admin, const USERS & users)
89 : BASE_PARSER(admin, tag), m_users(users) {}
90 int Start(void * data, const char * el, const char ** attr);
93 const USERS & m_users;
99 class ADD_USER: public BASE_PARSER
102 class FACTORY : public BASE_PARSER::FACTORY
105 FACTORY(USERS & users) : m_users(users) {}
106 virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_USER(admin, m_users); }
107 static void Register(REGISTRY & registry, USERS & users)
108 { registry[tag] = new FACTORY(users); }
113 static const char * tag;
115 ADD_USER(const ADMIN & admin, USERS & users)
116 : BASE_PARSER(admin, tag), m_users(users) {}
117 int Start(void * data, const char * el, const char ** attr);
126 class CHG_USER: public BASE_PARSER
129 class FACTORY : public BASE_PARSER::FACTORY
132 FACTORY(USERS & users, STORE & store, const TARIFFS & tariffs)
133 : m_users(users), m_store(store), m_tariffs(tariffs)
135 virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_USER(admin, m_users, m_store, m_tariffs); }
136 static void Register(REGISTRY & registry, USERS & users, STORE & store, const TARIFFS & tariffs)
137 { registry[tag] = new FACTORY(users, store, tariffs); }
141 const TARIFFS & m_tariffs;
144 static const char * tag;
146 CHG_USER(const ADMIN & admin, USERS & users,
147 STORE & store, const TARIFFS & tariffs)
148 : BASE_PARSER(admin, tag),
152 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;
174 class DEL_USER: public BASE_PARSER
177 class FACTORY : public BASE_PARSER::FACTORY
180 FACTORY(USERS & users) : m_users(users) {}
181 virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_USER(admin, m_users); }
182 static void Register(REGISTRY & registry, USERS & users)
183 { registry[tag] = new FACTORY(users); }
188 static const char * tag;
190 DEL_USER(const ADMIN & admin, USERS & users)
191 : BASE_PARSER(admin, tag), m_users(users), res(0), u(NULL) {}
192 int Start(void * data, const char * el, const char ** attr);
193 int End(void * data, const char * el);
203 class CHECK_USER: public BASE_PARSER
206 class FACTORY : public BASE_PARSER::FACTORY
209 FACTORY(const USERS & users) : m_users(users) {}
210 virtual BASE_PARSER * create(const ADMIN & admin) { return new CHECK_USER(admin, m_users); }
211 static void Register(REGISTRY & registry, const USERS & users)
212 { registry[tag] = new FACTORY(users); }
214 const USERS & m_users;
217 static const char * tag;
219 CHECK_USER(const ADMIN & admin, const USERS & users)
220 : BASE_PARSER(admin, tag), m_users(users) {}
221 int Start(void * data, const char * el, const char ** attr);
222 int End(void * data, const char * el);
225 const USERS & m_users;
227 void CreateAnswer(const char * error);
228 void CreateAnswer() {} // dummy
231 } // namespace PARSER