From 2a3474ec97141c99dea75c517615f1332edfc4de Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Tue, 7 Dec 2010 17:10:21 +0200 Subject: [PATCH] =?utf8?q?=D0=A1=D1=82=D0=B8=D0=BB=D0=B8=D1=81=D1=82=D0=B8?= =?utf8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2?= =?utf8?q?=D0=BA=D0=B8=20=D0=B8=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0?= =?utf8?q?=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BD=D0=B5=D0=B8?= =?utf8?q?=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2?= =?utf8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D1=87=D0=BB=D0=B5=D0=BD=D0=BE?= =?utf8?q?=D0=B2=20=D0=B2=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7?= =?utf8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=B5=20auth=5Fao?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../stargazer/plugins/authorization/ao/ao.cpp | 37 ++++++++++--------- .../stargazer/plugins/authorization/ao/ao.h | 30 ++++++++------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/projects/stargazer/plugins/authorization/ao/ao.cpp b/projects/stargazer/plugins/authorization/ao/ao.cpp index 44631609..1690611b 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.cpp +++ b/projects/stargazer/plugins/authorization/ao/ao.cpp @@ -85,8 +85,11 @@ return "Always Online authorizator v.1.0"; } //----------------------------------------------------------------------------- AUTH_AO::AUTH_AO() + : users(NULL), + isRunning(false), + onAddUserNotifier(*this), + onDelUserNotifier(*this) { -isRunning = false; } //----------------------------------------------------------------------------- void AUTH_AO::SetUsers(USERS * u) @@ -115,8 +118,8 @@ GetUsers(); list::iterator users_iter; -onAddUserNotifier.SetAuthorizator(this); -onDelUserNotifier.SetAuthorizator(this); +/*onAddUserNotifier.SetAuthorizator(this); +onDelUserNotifier.SetAuthorizator(this);*/ users->AddNotifierUserAdd(&onAddUserNotifier); users->AddNotifierUserDel(&onDelUserNotifier); @@ -168,15 +171,15 @@ return 70; void AUTH_AO::SetUserNotifiers(user_iter u) { // ---------- AlwaysOnline ------------------- -CHG_BEFORE_NOTIFIER BeforeChgAONotifier; -CHG_AFTER_NOTIFIER AfterChgAONotifier; +CHG_BEFORE_NOTIFIER BeforeChgAONotifier(*this, u); +CHG_AFTER_NOTIFIER 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())); @@ -184,15 +187,15 @@ u->property.alwaysOnline.AddAfterNotifier(&(*AfterChgAONotifierList.begin())); // ---------- AlwaysOnline end --------------- // ---------- IP ------------------- -CHG_BEFORE_NOTIFIER BeforeChgIPNotifier; -CHG_AFTER_NOTIFIER AfterChgIPNotifier; +CHG_BEFORE_NOTIFIER BeforeChgIPNotifier(*this, u); +CHG_AFTER_NOTIFIER 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())); @@ -336,13 +339,13 @@ return -1; template void CHG_BEFORE_NOTIFIER::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 void CHG_AFTER_NOTIFIER::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); } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/plugins/authorization/ao/ao.h b/projects/stargazer/plugins/authorization/ao/ao.h index f2912d14..2a9ff3e0 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.h +++ b/projects/stargazer/plugins/authorization/ao/ao.h @@ -45,28 +45,30 @@ template class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE { 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 class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE { 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 @@ -136,33 +138,33 @@ private: class ADD_USER_NONIFIER: public NOTIFIER_BASE { 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 { 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; }; -- 2.43.2