From 167dbb4ec68681f83c8c15116f57ef7b8f749dea Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Wed, 8 Dec 2010 15:16:06 +0200 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD?= =?utf8?q?=20=D0=BB=D0=B5=D0=B3=D0=BA=D0=B8=D0=B9=20=D1=80=D0=B5=D1=84?= =?utf8?q?=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE?= =?utf8?q?=D0=B4=D0=B0=20=D0=BF=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD=D0=B0=20?= =?utf8?q?=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?utf8?q?=D1=81=20rscriptd,=20=20=20=20=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8?= =?utf8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B8=D0=BD=D0=B8=D1=86?= =?utf8?q?=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B2?= =?utf8?q?=D0=BD=D1=83=D1=82=D1=80=D0=B5=D0=BD=D0=BD=D0=B8=D1=85=20=D0=B4?= =?utf8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BF=D1=80=D0=B8=20=D0=BA?= =?utf8?q?=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=B8=D1=80=D0=BE=D0=B2?= =?utf8?q?=D0=B0=D0=BD=D0=B8=D0=B8,=20=20=20=20=20=D1=83=D0=BA=D0=B0=D0=B7?= =?utf8?q?=D0=B0=D1=82=D0=B5=D0=BB=D0=B8=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD?= =?utf8?q?=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB?= =?utf8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../plugins/other/rscript/rscript.cpp | 22 +++++----- .../stargazer/plugins/other/rscript/rscript.h | 42 +++++++++---------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index 3b00b3f8..ed9702f7 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -209,7 +209,9 @@ REMOTE_SCRIPT::REMOTE_SCRIPT() nonstop(false), isRunning(false), users(NULL), - sock(0) + sock(0), + onAddUserNotifier(*this), + onDelUserNotifier(*this) { pthread_mutex_init(&mutex, NULL); } @@ -253,8 +255,8 @@ netRouters = rsSettings.GetSubnetsMap(); InitEncrypt(&ctx, rsSettings.GetPassword()); -onAddUserNotifier.SetRemoteScript(this); -onDelUserNotifier.SetRemoteScript(this); +//onAddUserNotifier.SetRemoteScript(this); +//onDelUserNotifier.SetRemoteScript(this); users->AddNotifierUserAdd(&onAddUserNotifier); users->AddNotifierUserDel(&onDelUserNotifier); @@ -640,13 +642,11 @@ return value; //----------------------------------------------------------------------------- void REMOTE_SCRIPT::SetUserNotifier(user_iter u) { -RS_CHG_AFTER_NOTIFIER AfterChgIPNotifier; +RS_CHG_AFTER_NOTIFIER afterChgIPNotifier(*this, u); -AfterChgIPNotifier.SetRemoteScript(this); -AfterChgIPNotifier.SetUser(u); -AfterChgIPNotifierList.push_front(AfterChgIPNotifier); +afterChgIPNotifierList.push_front(afterChgIPNotifier); -u->AddCurrIPAfterNotifier(&(*AfterChgIPNotifierList.begin())); +u->AddCurrIPAfterNotifier(&(*afterChgIPNotifierList.begin())); } //----------------------------------------------------------------------------- void REMOTE_SCRIPT::UnSetUserNotifier(user_iter u) @@ -654,7 +654,7 @@ void REMOTE_SCRIPT::UnSetUserNotifier(user_iter u) list >::iterator ipAIter; std::list >::iterator> toErase; -for (ipAIter = AfterChgIPNotifierList.begin(); ipAIter != AfterChgIPNotifierList.end(); ++ipAIter) +for (ipAIter = afterChgIPNotifierList.begin(); ipAIter != afterChgIPNotifierList.end(); ++ipAIter) { if (ipAIter->GetUser() == u) { @@ -667,14 +667,14 @@ std::list >::iterator>::iterator eIter; for (eIter = toErase.begin(); eIter != toErase.end(); ++eIter) { - AfterChgIPNotifierList.erase(*eIter); + afterChgIPNotifierList.erase(*eIter); } } //----------------------------------------------------------------------------- template void RS_CHG_AFTER_NOTIFIER::Notify(const varParamType & oldValue, const varParamType & newValue) { -rs->ChangedIP(user, oldValue, newValue); +rs.ChangedIP(user, oldValue, newValue); } //----------------------------------------------------------------------------- void REMOTE_SCRIPT::InitEncrypt(BLOWFISH_CTX * ctx, const string & password) const diff --git a/projects/stargazer/plugins/other/rscript/rscript.h b/projects/stargazer/plugins/other/rscript/rscript.h index ed08e2bc..ece1d8c5 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.h +++ b/projects/stargazer/plugins/other/rscript/rscript.h @@ -57,51 +57,47 @@ class REMOTE_SCRIPT; class RS_ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - RS_ADD_USER_NONIFIER() {}; - virtual ~RS_ADD_USER_NONIFIER() {}; - - void SetRemoteScript(REMOTE_SCRIPT * a) { rs = a; } + RS_ADD_USER_NONIFIER(REMOTE_SCRIPT & r) : rs(r) {} + virtual ~RS_ADD_USER_NONIFIER() {} void Notify(const user_iter & user); private: - REMOTE_SCRIPT * rs; + REMOTE_SCRIPT & rs; }; //----------------------------------------------------------------------------- class RS_DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - RS_DEL_USER_NONIFIER() {}; - virtual ~RS_DEL_USER_NONIFIER() {}; - - void SetRemoteScript(REMOTE_SCRIPT * a) { rs = a; } + RS_DEL_USER_NONIFIER(REMOTE_SCRIPT & r) : rs(r) {} + virtual ~RS_DEL_USER_NONIFIER() {} void Notify(const user_iter & user); private: - REMOTE_SCRIPT * rs; + REMOTE_SCRIPT & rs; }; //----------------------------------------------------------------------------- template class RS_CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: - void Notify(const varParamType & oldValue, const varParamType & newValue); - void SetUser(user_iter u) { user = u; } - user_iter GetUser() {return user; } - void SetRemoteScript(REMOTE_SCRIPT * a) { rs = a; } + RS_CHG_AFTER_NOTIFIER(REMOTE_SCRIPT & r, user_iter u) : user(u), rs(r) {} + void Notify(const varParamType & oldValue, const varParamType & newValue); + user_iter GetUser() {return user; } private: user_iter user; - REMOTE_SCRIPT * rs; + REMOTE_SCRIPT & rs; }; //----------------------------------------------------------------------------- struct RS_USER { - RS_USER(); - RS_USER(const std::vector & r, user_iter it); -time_t lastSentTime; -user_iter user; +RS_USER(); +RS_USER(const std::vector & r, user_iter it); + +time_t lastSentTime; +user_iter user; std::vector routers; -int shortPacketsCount; +int shortPacketsCount; }; //----------------------------------------------------------------------------- class RS_SETTINGS @@ -181,7 +177,7 @@ private: mutable BLOWFISH_CTX ctx; - std::list > AfterChgIPNotifierList; + std::list > afterChgIPNotifierList; std::map authorizedUsers; mutable std::string errorStr; @@ -224,13 +220,13 @@ class DisconnectUser : public std::unary_functionAddUser(user); +rs.AddUser(user); } //----------------------------------------------------------------------------- inline void RS_DEL_USER_NONIFIER::Notify(const user_iter & user) { printfd(__FILE__, "DEL_USER_NONIFIER\n"); -rs->DelUser(user); +rs.DelUser(user); } //----------------------------------------------------------------------------- -- 2.43.2