}
//-----------------------------------------------------------------------------
AUTH_AO::AUTH_AO()
+ : users(NULL),
+ isRunning(false),
+ onAddUserNotifier(*this),
+ onDelUserNotifier(*this)
{
-isRunning = false;
}
//-----------------------------------------------------------------------------
void AUTH_AO::SetUsers(USERS * u)
list<user_iter>::iterator users_iter;
-onAddUserNotifier.SetAuthorizator(this);
-onDelUserNotifier.SetAuthorizator(this);
+/*onAddUserNotifier.SetAuthorizator(this);
+onDelUserNotifier.SetAuthorizator(this);*/
users->AddNotifierUserAdd(&onAddUserNotifier);
users->AddNotifierUserDel(&onDelUserNotifier);
void AUTH_AO::SetUserNotifiers(user_iter u)
{
// ---------- AlwaysOnline -------------------
-CHG_BEFORE_NOTIFIER<int> BeforeChgAONotifier;
-CHG_AFTER_NOTIFIER<int> AfterChgAONotifier;
+CHG_BEFORE_NOTIFIER<int> BeforeChgAONotifier(*this, u);
+CHG_AFTER_NOTIFIER<int> AfterChgAONotifier(*this, u);
-BeforeChgAONotifier.SetAuthorizator(this);
-BeforeChgAONotifier.SetUser(u);
+/*BeforeChgAONotifier.SetAuthorizator(this);
+BeforeChgAONotifier.SetUser(u);*/
BeforeChgAONotifierList.push_front(BeforeChgAONotifier);
-AfterChgAONotifier.SetAuthorizator(this);
-AfterChgAONotifier.SetUser(u);
+/*AfterChgAONotifier.SetAuthorizator(this);
+AfterChgAONotifier.SetUser(u);*/
AfterChgAONotifierList.push_front(AfterChgAONotifier);
u->property.alwaysOnline.AddBeforeNotifier(&(*BeforeChgAONotifierList.begin()));
// ---------- AlwaysOnline end ---------------
// ---------- IP -------------------
-CHG_BEFORE_NOTIFIER<USER_IPS> BeforeChgIPNotifier;
-CHG_AFTER_NOTIFIER<USER_IPS> AfterChgIPNotifier;
+CHG_BEFORE_NOTIFIER<USER_IPS> BeforeChgIPNotifier(*this, u);
+CHG_AFTER_NOTIFIER<USER_IPS> AfterChgIPNotifier(*this, u);
-BeforeChgIPNotifier.SetAuthorizator(this);
-BeforeChgIPNotifier.SetUser(u);
+/*BeforeChgIPNotifier.SetAuthorizator(this);
+BeforeChgIPNotifier.SetUser(u);*/
BeforeChgIPNotifierList.push_front(BeforeChgIPNotifier);
-AfterChgIPNotifier.SetAuthorizator(this);
-AfterChgIPNotifier.SetUser(u);
+/*AfterChgIPNotifier.SetAuthorizator(this);
+AfterChgIPNotifier.SetUser(u);*/
AfterChgIPNotifierList.push_front(AfterChgIPNotifier);
u->property.ips.AddBeforeNotifier(&(*BeforeChgIPNotifierList.begin()));
template <typename varParamType>
void CHG_BEFORE_NOTIFIER<varParamType>::Notify(const varParamType &, const varParamType &)
{
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(*auth, &AUTH_AO::Unauthorize, user);
+EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::Unauthorize, user);
}
//-----------------------------------------------------------------------------
template <typename varParamType>
void CHG_AFTER_NOTIFIER<varParamType>::Notify(const varParamType &, const varParamType &)
{
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(*auth, &AUTH_AO::UpdateUserAuthorization, user);
+EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::UpdateUserAuthorization, user);
}
//-----------------------------------------------------------------------------
class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE<varParamType>
{
public:
+ CHG_BEFORE_NOTIFIER(AUTH_AO & a, user_iter u) : user(u), auth(a) {}
void Notify(const varParamType & oldValue, const varParamType & newValue);
- void SetUser(user_iter u) { user = u; }
+ //void SetUser(user_iter u) { user = u; }
user_iter GetUser() {return user; }
- void SetAuthorizator(const AUTH_AO * a) { auth = a; }
+ //void SetAuthorizator(const AUTH_AO * a) { auth = a; }
private:
user_iter user;
- const AUTH_AO * auth;
+ const AUTH_AO & auth;
};
//-----------------------------------------------------------------------------
template <typename varParamType>
class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE<varParamType>
{
public:
+ CHG_AFTER_NOTIFIER(AUTH_AO & a, user_iter u) : user(u), auth(a) {}
void Notify(const varParamType & oldValue, const varParamType & newValue);
- void SetUser(user_iter u) { user = u; }
+ //void SetUser(user_iter u) { user = u; }
user_iter GetUser() {return user; }
- void SetAuthorizator(const AUTH_AO * a) { auth = a; }
+ //void SetAuthorizator(const AUTH_AO * a) { auth = a; }
private:
user_iter user;
- const AUTH_AO * auth;
+ const AUTH_AO & auth;
};
//-----------------------------------------------------------------------------
class AUTH_AO_SETTINGS
class ADD_USER_NONIFIER: public NOTIFIER_BASE<user_iter>
{
public:
- ADD_USER_NONIFIER(){};
+ ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {};
virtual ~ADD_USER_NONIFIER(){};
- void SetAuthorizator(AUTH_AO * a) { auth = a; }
+ //void SetAuthorizator(AUTH_AO * a) { auth = a; }
void Notify(const user_iter & user)
{
- auth->AddUser(user);
+ auth.AddUser(user);
}
private:
- AUTH_AO * auth;
+ AUTH_AO & auth;
} onAddUserNotifier;
class DEL_USER_NONIFIER: public NOTIFIER_BASE<user_iter>
{
public:
- DEL_USER_NONIFIER(){};
+ DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {};
virtual ~DEL_USER_NONIFIER(){};
- void SetAuthorizator(AUTH_AO * a) { auth = a; }
+ //void SetAuthorizator(AUTH_AO * a) { auth = a; }
void Notify(const user_iter & user)
{
- auth->DelUser(user);
+ auth.DelUser(user);
}
private:
- AUTH_AO * auth;
+ AUTH_AO & auth;
} onDelUserNotifier;
};