X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/c963a109219ed101fa42f501b16f90d7b7b4f3f2..30723e4545227800cd3b43f2423f6760b1e4e22d:/projects/stargazer/plugins/authorization/ao/ao.cpp diff --git a/projects/stargazer/plugins/authorization/ao/ao.cpp b/projects/stargazer/plugins/authorization/ao/ao.cpp index b59bd58c..f1b05dbc 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.cpp +++ b/projects/stargazer/plugins/authorization/ao/ao.cpp @@ -24,14 +24,17 @@ $Date: 2010/03/04 12:29:06 $ $Author: faust $ */ -#include #include -#include + +#include +#include // for_each +#include // mem_fun_ref #include "ao.h" #include "user.h" #include "users.h" -#include "../../../user_property.h" +#include "user_property.h" +#include "common.h" #include "../../../eventloop.h" class AO_CREATOR @@ -61,7 +64,6 @@ AO_CREATOR aoc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -// ëÌÁÓÓ ÄÌÑ ÐÏÉÓËÁ ÀÚÅÒÁ × ÓÐÉÓËÅ ÎÏÔÉÆÉËÁÔÏÒÏ× template class IS_CONTAINS_USER: public binary_function { @@ -94,44 +96,23 @@ AUTH_AO::AUTH_AO() { } //----------------------------------------------------------------------------- -void AUTH_AO::SetUsers(USERS * u) -{ -users = u; -} -//----------------------------------------------------------------------------- -void AUTH_AO::SetSettings(const MODULE_SETTINGS & s) -{ -settings = s; -} -//----------------------------------------------------------------------------- -int AUTH_AO::ParseSettings() -{ -return 0; -} -//----------------------------------------------------------------------------- -const string & AUTH_AO::GetStrError() const -{ -return errorStr; -} -//----------------------------------------------------------------------------- int AUTH_AO::Start() { GetUsers(); -list::iterator users_iter; - -/*onAddUserNotifier.SetAuthorizator(this); -onDelUserNotifier.SetAuthorizator(this);*/ users->AddNotifierUserAdd(&onAddUserNotifier); users->AddNotifierUserDel(&onDelUserNotifier); -users_iter = usersList.begin(); -while (users_iter != usersList.end()) +/*list::iterator it = usersList.begin(); +while (it != usersList.end()) { - UpdateUserAuthorization(*users_iter); - ++users_iter; - } + UpdateUserAuthorization(*it); + ++it; + }*/ +std::for_each(usersList.begin(), usersList.end(), std::bind1st(std::mem_fun(&AUTH_AO::UpdateUserAuthorization), this)); + isRunning = true; + return 0; } //----------------------------------------------------------------------------- @@ -155,33 +136,13 @@ isRunning = false; return 0; } //----------------------------------------------------------------------------- -bool AUTH_AO::IsRunning() -{ -return isRunning; -} -//----------------------------------------------------------------------------- -uint16_t AUTH_AO::GetStartPosition() const -{ -return 70; -} -//----------------------------------------------------------------------------- -uint16_t AUTH_AO::GetStopPosition() const -{ -return 70; -} -//----------------------------------------------------------------------------- void AUTH_AO::SetUserNotifiers(USER_PTR u) { // ---------- AlwaysOnline ------------------- CHG_BEFORE_NOTIFIER BeforeChgAONotifier(*this, u); CHG_AFTER_NOTIFIER AfterChgAONotifier(*this, u); -/*BeforeChgAONotifier.SetAuthorizator(this); -BeforeChgAONotifier.SetUser(u);*/ BeforeChgAONotifierList.push_front(BeforeChgAONotifier); - -/*AfterChgAONotifier.SetAuthorizator(this); -AfterChgAONotifier.SetUser(u);*/ AfterChgAONotifierList.push_front(AfterChgAONotifier); u->GetProperty().alwaysOnline.AddBeforeNotifier(&(*BeforeChgAONotifierList.begin())); @@ -192,12 +153,7 @@ u->GetProperty().alwaysOnline.AddAfterNotifier(&(*AfterChgAONotifierList.begin() CHG_BEFORE_NOTIFIER BeforeChgIPNotifier(*this, u); CHG_AFTER_NOTIFIER AfterChgIPNotifier(*this, u); -/*BeforeChgIPNotifier.SetAuthorizator(this); -BeforeChgIPNotifier.SetUser(u);*/ BeforeChgIPNotifierList.push_front(BeforeChgIPNotifier); - -/*AfterChgIPNotifier.SetAuthorizator(this); -AfterChgIPNotifier.SetUser(u);*/ AfterChgIPNotifierList.push_front(AfterChgIPNotifier); u->GetProperty().ips.AddBeforeNotifier(&(*BeforeChgIPNotifierList.begin())); @@ -274,12 +230,8 @@ if (!h) return; } -while (1) +while (users->SearchNext(h, &u)) { - if (users->SearchNext(h, &u)) - { - break; - } usersList.push_back(u); SetUserNotifiers(u); } @@ -317,8 +269,9 @@ void AUTH_AO::DelUser(USER_PTR u) { Unauthorize(u); UnSetUserNotifiers(u); +usersList.remove(u); -list::iterator users_iter; +/*list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) @@ -329,7 +282,7 @@ while (users_iter != usersList.end()) break; } ++users_iter; - } + }*/ } //----------------------------------------------------------------------------- int AUTH_AO::SendMessage(const STG_MSG &, uint32_t) const