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>
23 $Date: 2010/09/10 06:38:26 $
36 #include "stg/store.h"
37 #include "stg/notifer.h"
38 #include "stg/user_ips.h"
41 extern "C" PLUGIN * GetPlugin();
45 //-----------------------------------------------------------------------------
47 class CHG_BEFORE_NOTIFIER : public PROPERTY_NOTIFIER_BASE<T> {
49 CHG_BEFORE_NOTIFIER(AUTH_AO & a, USER_PTR u) : user(u), auth(a) {}
50 CHG_BEFORE_NOTIFIER(const CHG_BEFORE_NOTIFIER<T> & rvalue)
51 : user(rvalue.user), auth(rvalue.auth)
53 void Notify(const T & oldValue, const T & newValue);
54 USER_PTR GetUser() const { return user; }
57 CHG_BEFORE_NOTIFIER<T> & operator=(const CHG_BEFORE_NOTIFIER<T> & rvalue);
62 //-----------------------------------------------------------------------------
64 class CHG_AFTER_NOTIFIER : public PROPERTY_NOTIFIER_BASE<T> {
66 CHG_AFTER_NOTIFIER(AUTH_AO & a, USER_PTR u) : user(u), auth(a) {}
67 CHG_AFTER_NOTIFIER(const CHG_AFTER_NOTIFIER<T> & rvalue)
68 : user(rvalue.user), auth(rvalue.auth)
70 void Notify(const T & oldValue, const T & newValue);
71 USER_PTR GetUser() const { return user; }
74 CHG_AFTER_NOTIFIER<T> & operator=(const CHG_AFTER_NOTIFIER<T> & rvalue);
79 //-----------------------------------------------------------------------------
80 class AUTH_AO : public AUTH {
85 void SetUsers(USERS * u) { users = u; }
89 int Reload() { return 0; }
90 bool IsRunning() { return isRunning; }
91 void SetSettings(const MODULE_SETTINGS &) {}
92 int ParseSettings() { return 0; }
93 const std::string & GetStrError() const { return errorStr; }
94 const std::string GetVersion() const;
95 uint16_t GetStartPosition() const { return 70; }
96 uint16_t GetStopPosition() const { return 70; }
98 void AddUser(USER_PTR u);
99 void DelUser(USER_PTR u);
101 int SendMessage(const STG_MSG & msg, uint32_t ip) const;
104 AUTH_AO(const AUTH_AO & rvalue);
105 AUTH_AO & operator=(const AUTH_AO & rvalue);
108 void SetUserNotifiers(USER_PTR u);
109 void UnSetUserNotifiers(USER_PTR u);
110 void UpdateUserAuthorization(CONST_USER_PTR u) const;
112 mutable std::string errorStr;
114 std::list<USER_PTR> usersList;
116 MODULE_SETTINGS settings;
118 list<CHG_BEFORE_NOTIFIER<int> > BeforeChgAONotifierList;
119 list<CHG_AFTER_NOTIFIER<int> > AfterChgAONotifierList;
121 list<CHG_BEFORE_NOTIFIER<USER_IPS> > BeforeChgIPNotifierList;
122 list<CHG_AFTER_NOTIFIER<USER_IPS> > AfterChgIPNotifierList;
124 class ADD_USER_NONIFIER: public NOTIFIER_BASE<USER_PTR> {
126 ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {}
127 virtual ~ADD_USER_NONIFIER() {}
128 void Notify(const USER_PTR & user) { auth.AddUser(user); }
131 ADD_USER_NONIFIER(const ADD_USER_NONIFIER & rvalue);
132 ADD_USER_NONIFIER & operator=(const ADD_USER_NONIFIER & rvalue);
137 class DEL_USER_NONIFIER: public NOTIFIER_BASE<USER_PTR> {
139 DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {}
140 virtual ~DEL_USER_NONIFIER() {}
141 void Notify(const USER_PTR & user) { auth.DelUser(user); }
144 DEL_USER_NONIFIER(const DEL_USER_NONIFIER & rvalue);
145 DEL_USER_NONIFIER & operator=(const DEL_USER_NONIFIER & rvalue);
150 friend class CHG_BEFORE_NOTIFIER<int>;
151 friend class CHG_AFTER_NOTIFIER<int>;
152 friend class CHG_BEFORE_NOTIFIER<USER_IPS>;
153 friend class CHG_AFTER_NOTIFIER<USER_IPS>;
156 //-----------------------------------------------------------------------------