From d01f302f0da31eb088608c33a3e15c5fdee8ca84 Mon Sep 17 00:00:00 2001 From: Naffanya Date: Thu, 25 Jul 2013 01:17:39 +0300 Subject: [PATCH] Method GetParamValue and correction method Connect(user_imp) --- include/stg/user.h | 2 +- projects/stargazer/user_impl.cpp | 136 ++++++++++++++++--------------- projects/stargazer/user_impl.h | 2 +- 3 files changed, 72 insertions(+), 68 deletions(-) diff --git a/include/stg/user.h b/include/stg/user.h index b0115555..365c71ef 100644 --- a/include/stg/user.h +++ b/include/stg/user.h @@ -101,7 +101,7 @@ public: virtual void OnAdd() = 0; virtual void OnDelete() = 0; - virtual const std::string & GetParamValue(const std::string & name) const = 0; + virtual std::string GetParamValue(const std::string & name) const = 0; }; typedef USER * USER_PTR; diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index 95989c45..55b5ffe7 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -588,14 +588,21 @@ if (!fakeConnect) } std::string scriptOnConnectParams; - strprintf(&scriptOnConnectParams, - "%s \"%s\" \"%s\" \"%f\" \"%d\" \"%s\"", - scriptOnConnect.c_str(), - login.c_str(), - inet_ntostring(currIP).c_str(), - cash.ConstData(), - id, - dirsStr); + + std::vector::const_iterator it(settings->GetScriptParams().begin()); + while (it != settings->GetScriptParams().end()) + { + scriptOnConnectParams += GetParamValue(it->c_str()); + } + +// strprintf(&scriptOnConnectParams, +// "%s \"%s\" \"%s\" \"%f\" \"%d\" \"%s\"", +// scriptOnConnect.c_str(), +// login.c_str(), +// inet_ntostring(currIP).c_str(), +// cash.ConstData(), +// id, +// dirsStr); ScriptExec(scriptOnConnectParams.c_str()); } @@ -1457,119 +1464,116 @@ while (it != messages.end()) } } //----------------------------------------------------------------------------- -const std::string & USER_IMPL::GetParamValue(const std::string & name) const +std::string USER_IMPL::GetParamValue(const std::string & name) const { - std::string value; - - if (name=="cash") + if (name == "cash") { - value=property.cash; + return static_cast(property.cash); } - if (name=="freeMb") + if (name == "freeMb") { - value=property.freeMb; + return static_cast(property.freeMb); } - if (name=="passive") + if (name == "passive") { - value=property.passive; + return static_cast(property.passive); } - if (name=="disabled") + if (name == "disabled") { - value=property.disabled; + return static_cast(property.disabled); } - if (name=="alwaysOnline") + if (name == "alwaysOnline") { - value=property.alwaysOnline; + return static_cast(property.alwaysOnline); } - if (name=="tariffName") + if (name == "tariffName") { - value=property.tariffName; + return property.tariffName; } - if (name=="nextTariff") + if (name == "nextTariff") { - value=property.nextTariff; + return property.nextTariff; } - if (name=="address") + if (name == "address") { - value=property.address; + return property.address; } - if (name=="note") + if (name == "note") { - value=property.note; + return property.note; } - if (name=="group") + if (name == "group") { - value=property.group; + return property.group; } - if (name=="email") + if (name == "email") { - value=property.email; + return property.email; } - if (name=="phone") + if (name == "phone") { - value=property.phone; + return property.phone; } - if (name=="realName") + if (name == "realName") { - value=property.realName; + return property.realName; } - if (name=="credit") + if (name == "credit") { - value=property.credit; + return static_cast(property.credit); } - if (name=="userdata0") + if (name == "userdata0") { - value=property.userdata0; + return property.userdata0; } - if (name=="userdata1") + if (name == "userdata1") { - value=property.userdata1; + return property.userdata1; } - if (name=="userdata2") + if (name == "userdata2") { - value=property.userdata2; + return property.userdata2; } - if (name=="userdata3") + if (name == "userdata3") { - value=property.userdata3; + return property.userdata3; } - if (name=="userdata4") + if (name == "userdata4") { - value=property.userdata4; + return property.userdata4; } - if (name=="userdata5") + if (name == "userdata5") { - value=property.userdata5; + return property.userdata5; } - if (name=="userdata6") + if (name == "userdata6") { - value=property.userdata6; + return property.userdata6; } - if (name=="userdata7") + if (name == "userdata7") { - value=property.userdata7; + return property.userdata7; } - if (name=="userdata8") + if (name == "userdata8") { - value=property.userdata8; + return property.userdata8; } - if (name=="userdata9") + if (name == "userdata9") { - value=property.userdata9; + return property.userdata9; } - if (name=="id") + if (name == "id") { - value=id; + return static_cast(id); } - if (name=="login") + if (name == "login") { - value=login; + return login; } - if (name=="ip") + if (name == "ip") { - value=currIP; + return static_cast(currIP); } - return value; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h index 5fe02bb3..d240f0c8 100644 --- a/projects/stargazer/user_impl.h +++ b/projects/stargazer/user_impl.h @@ -216,7 +216,7 @@ public: void OnAdd(); void OnDelete(); - virtual const std::string & GetParamValue(const std::string & name) const; + virtual std::string GetParamValue(const std::string & name) const; private: USER_IMPL & operator=(const USER_IMPL & rvalue); -- 2.44.2