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(const ADMIN & admin, USERS & users)
 
  51                     : m_admin(admin), m_users(users)
 
  53                 virtual BASE_PARSER * create() { return new GET_USERS(m_admin, m_users); }
 
  55                 const ADMIN & m_admin;
 
  59         GET_USERS(const ADMIN & admin, USERS & users)
 
  60             : BASE_PARSER(admin, "GetUsers"), m_users(users),
 
  61               m_lastUserUpdateTime(0) {}
 
  62         int Start(void * data, const char * el, const char ** attr);
 
  66         time_t m_lastUserUpdateTime;
 
  71 class GET_USER: public BASE_PARSER
 
  74         class FACTORY : public BASE_PARSER::FACTORY
 
  77                 FACTORY(const ADMIN & admin, const USERS & users)
 
  78                     : m_admin(admin), m_users(users)
 
  80                 virtual BASE_PARSER * create() { return new GET_USER(m_admin, m_users); }
 
  82                 const ADMIN & m_admin;
 
  83                 const USERS & m_users;
 
  86         GET_USER(const ADMIN & admin, const USERS & users)
 
  87             : BASE_PARSER(admin, "GetUser"), m_users(users) {}
 
  88         int Start(void * data, const char * el, const char ** attr);
 
  91         const USERS & m_users;
 
  97 class ADD_USER: public BASE_PARSER
 
 100         class FACTORY : public BASE_PARSER::FACTORY
 
 103                 FACTORY(const ADMIN & admin, USERS & users)
 
 104                     : m_admin(admin), m_users(users)
 
 106                 virtual BASE_PARSER * create() { return new ADD_USER(m_admin, m_users); }
 
 108                 const ADMIN & m_admin;
 
 112         ADD_USER(const ADMIN & admin, USERS & users)
 
 113             : BASE_PARSER(admin, "AddUser"), m_users(users) {}
 
 114         int Start(void * data, const char * el, const char ** attr);
 
 123 class CHG_USER: public BASE_PARSER
 
 126         class FACTORY : public BASE_PARSER::FACTORY
 
 129                 FACTORY(const ADMIN & admin, USERS & users, STORE & store, const TARIFFS & tariffs)
 
 130                     : m_admin(admin), m_users(users), m_store(store), m_tariffs(tariffs)
 
 132                 virtual BASE_PARSER * create() { return new CHG_USER(m_admin, m_users, m_store, m_tariffs); }
 
 134                 const ADMIN & m_admin;
 
 137                 const TARIFFS & m_tariffs;
 
 140         CHG_USER(const ADMIN & admin, USERS & users,
 
 141                  STORE & store, const TARIFFS & tariffs)
 
 142             : BASE_PARSER(admin, "SetUser"),
 
 146               m_cashMustBeAdded(false),
 
 149         int Start(void * data, const char * el, const char ** attr);
 
 154         const TARIFFS & m_tariffs;
 
 157         RESETABLE<uint64_t> m_upr[DIR_NUM];
 
 158         RESETABLE<uint64_t> m_downr[DIR_NUM];
 
 159         std::string m_cashMsg;
 
 161         bool m_cashMustBeAdded;
 
 168 class DEL_USER: public BASE_PARSER
 
 171         class FACTORY : public BASE_PARSER::FACTORY
 
 174                 FACTORY(const ADMIN & admin, USERS & users)
 
 175                     : m_admin(admin), m_users(users)
 
 177                 virtual BASE_PARSER * create() { return new DEL_USER(m_admin, m_users); }
 
 179                 const ADMIN & m_admin;
 
 183         DEL_USER(const ADMIN & admin, USERS & users)
 
 184             : BASE_PARSER(admin, "DelUser"), m_users(users), res(0), u(NULL) {}
 
 185         int Start(void * data, const char * el, const char ** attr);
 
 186         int End(void * data, const char * el);
 
 196 class CHECK_USER: public BASE_PARSER
 
 199         class FACTORY : public BASE_PARSER::FACTORY
 
 202                 FACTORY(const ADMIN & admin, const USERS & users)
 
 203                     : m_admin(admin), m_users(users)
 
 205                 virtual BASE_PARSER * create() { return new CHECK_USER(m_admin, m_users); }
 
 207                 const ADMIN & m_admin;
 
 208                 const USERS & m_users;
 
 211         CHECK_USER(const ADMIN & admin, const USERS & users)
 
 212             : BASE_PARSER(admin, "CheckUser"), m_users(users) {}
 
 213         int Start(void * data, const char * el, const char ** attr);
 
 214         int End(void * data, const char * el);
 
 217         const USERS & m_users;
 
 219         void CreateAnswer(const char * error);
 
 220         void CreateAnswer() {} // dummy
 
 223 } // namespace PARSER