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/common.h"
 
  30 #include "stg/resetable.h"
 
  45 class GET_USERS: public BASE_PARSER
 
  48         class FACTORY : public BASE_PARSER::FACTORY
 
  51                 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                 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                 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),
 
 156         int Start(void * data, const char * el, const char ** attr);
 
 161         const TARIFFS & m_tariffs;
 
 164         RESETABLE<uint64_t> m_upr[DIR_NUM];
 
 165         RESETABLE<uint64_t> m_downr[DIR_NUM];
 
 166         std::string m_cashMsg;
 
 168         bool m_cashMustBeAdded;
 
 175 class DEL_USER: public BASE_PARSER
 
 178         class FACTORY : public BASE_PARSER::FACTORY
 
 181                 FACTORY(USERS & users) : m_users(users) {}
 
 182                 virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_USER(admin, m_users); }
 
 183                 static void Register(REGISTRY & registry, USERS & users)
 
 184                 { registry[ToLower(tag)] = new FACTORY(users); }
 
 189         static const char * tag;
 
 191         DEL_USER(const ADMIN & admin, USERS & users)
 
 192             : BASE_PARSER(admin, tag), m_users(users), res(0), u(NULL) {}
 
 193         int Start(void * data, const char * el, const char ** attr);
 
 194         int End(void * data, const char * el);
 
 204 class CHECK_USER: public BASE_PARSER
 
 207         class FACTORY : public BASE_PARSER::FACTORY
 
 210                 FACTORY(const USERS & users) : m_users(users) {}
 
 211                 virtual BASE_PARSER * create(const ADMIN & admin) { return new CHECK_USER(admin, m_users); }
 
 212                 static void Register(REGISTRY & registry, const USERS & users)
 
 213                 { registry[ToLower(tag)] = new FACTORY(users); }
 
 215                 const USERS & m_users;
 
 218         static const char * tag;
 
 220         CHECK_USER(const ADMIN & admin, const USERS & users)
 
 221             : BASE_PARSER(admin, tag), m_users(users) {}
 
 222         int Start(void * data, const char * el, const char ** attr);
 
 223         int End(void * data, const char * el);
 
 226         const USERS & m_users;
 
 228         void CreateAnswer(const char * error);
 
 229         void CreateAnswer() {} // dummy
 
 232 } // namespace PARSER