From: Naffanya Date: Sun, 8 Dec 2013 17:01:54 +0000 (+0200) Subject: Removing GetUserParam from rscript X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/810c900ba1bcb412f12eda3a39561b0ff5a72b35?hp=30eb6cd56d43fe69026617228478c7c373739a09 Removing GetUserParam from rscript --- diff --git a/include/stg/user.h b/include/stg/user.h index 365c71ef..b7024859 100644 --- a/include/stg/user.h +++ b/include/stg/user.h @@ -96,7 +96,7 @@ public: virtual time_t GetLastWriteStatTime() const = 0; virtual bool IsInetable() = 0; - virtual std::string GetEnabledDirs() = 0; + virtual std::string GetEnabledDirs() const = 0; virtual void OnAdd() = 0; virtual void OnDelete() = 0; diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index d5fab222..fc733a67 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -426,7 +426,8 @@ for(it = rsSettings.GetUserParams().begin(); it != rsSettings.GetUserParams().end(); ++it) { - std::string parameter(GetUserParam(rsu.user, *it)); +// std::string parameter(GetUserParam(rsu.user, *it)); + std::string parameter(rsu.user->GetParamValue(it->c_str())); if (params.length() + parameter.length() > RS_PARAMS_LEN - 1) break; params += parameter + " "; @@ -515,85 +516,85 @@ for (size_t i = 0; i < netRouters.size(); ++i) return std::vector(); } //----------------------------------------------------------------------------- -std::string REMOTE_SCRIPT::GetUserParam(USER_PTR u, const std::string & paramName) const -{ -std::string value = ""; -if (strcasecmp(paramName.c_str(), "cash") == 0) - strprintf(&value, "%f", u->GetProperty().cash.Get()); -else -if (strcasecmp(paramName.c_str(), "freeMb") == 0) - strprintf(&value, "%f", u->GetProperty().freeMb.Get()); -else -if (strcasecmp(paramName.c_str(), "passive") == 0) - strprintf(&value, "%d", u->GetProperty().passive.Get()); -else -if (strcasecmp(paramName.c_str(), "disabled") == 0) - strprintf(&value, "%d", u->GetProperty().disabled.Get()); -else -if (strcasecmp(paramName.c_str(), "alwaysOnline") == 0) - strprintf(&value, "%d", u->GetProperty().alwaysOnline.Get()); -else -if (strcasecmp(paramName.c_str(), "tariffName") == 0 || - strcasecmp(paramName.c_str(), "tariff") == 0) - value = "\"" + u->GetProperty().tariffName.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "nextTariff") == 0) - value = "\"" + u->GetProperty().nextTariff.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "address") == 0) - value = "\"" + u->GetProperty().address.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "note") == 0) - value = "\"" + u->GetProperty().note.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "group") == 0) - value = "\"" + u->GetProperty().group.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "email") == 0) - value = "\"" + u->GetProperty().email.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "realName") == 0) - value = "\"" + u->GetProperty().realName.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "credit") == 0) - strprintf(&value, "%f", u->GetProperty().credit.Get()); -else -if (strcasecmp(paramName.c_str(), "userdata0") == 0) - value = "\"" + u->GetProperty().userdata0.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata1") == 0) - value = "\"" + u->GetProperty().userdata1.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata2") == 0) - value = "\"" + u->GetProperty().userdata2.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata3") == 0) - value = "\"" + u->GetProperty().userdata3.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata4") == 0) - value = "\"" + u->GetProperty().userdata4.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata5") == 0) - value = "\"" + u->GetProperty().userdata5.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata6") == 0) - value = "\"" + u->GetProperty().userdata6.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata7") == 0) - value = "\"" + u->GetProperty().userdata7.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata8") == 0) - value = "\"" + u->GetProperty().userdata8.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "userdata9") == 0) - value = "\"" + u->GetProperty().userdata9.Get() + "\""; -else -if (strcasecmp(paramName.c_str(), "enabledDirs") == 0) - value = u->GetEnabledDirs(); -else - printfd(__FILE__, "Unknown value name: %s\n", paramName.c_str()); -return value; -} +//std::string REMOTE_SCRIPT::GetUserParam(USER_PTR u, const std::string & paramName) const +//{ +//std::string value = ""; +//if (strcasecmp(paramName.c_str(), "cash") == 0) +// strprintf(&value, "%f", u->GetProperty().cash.Get()); +//else +//if (strcasecmp(paramName.c_str(), "freeMb") == 0) +// strprintf(&value, "%f", u->GetProperty().freeMb.Get()); +//else +//if (strcasecmp(paramName.c_str(), "passive") == 0) +// strprintf(&value, "%d", u->GetProperty().passive.Get()); +//else +//if (strcasecmp(paramName.c_str(), "disabled") == 0) +// strprintf(&value, "%d", u->GetProperty().disabled.Get()); +//else +//if (strcasecmp(paramName.c_str(), "alwaysOnline") == 0) +// strprintf(&value, "%d", u->GetProperty().alwaysOnline.Get()); +//else +//if (strcasecmp(paramName.c_str(), "tariffName") == 0 || +// strcasecmp(paramName.c_str(), "tariff") == 0) +// value = "\"" + u->GetProperty().tariffName.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "nextTariff") == 0) +// value = "\"" + u->GetProperty().nextTariff.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "address") == 0) +// value = "\"" + u->GetProperty().address.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "note") == 0) +// value = "\"" + u->GetProperty().note.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "group") == 0) +// value = "\"" + u->GetProperty().group.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "email") == 0) +// value = "\"" + u->GetProperty().email.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "realName") == 0) +// value = "\"" + u->GetProperty().realName.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "credit") == 0) +// strprintf(&value, "%f", u->GetProperty().credit.Get()); +//else +//if (strcasecmp(paramName.c_str(), "userdata0") == 0) +// value = "\"" + u->GetProperty().userdata0.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata1") == 0) +// value = "\"" + u->GetProperty().userdata1.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata2") == 0) +// value = "\"" + u->GetProperty().userdata2.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata3") == 0) +// value = "\"" + u->GetProperty().userdata3.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata4") == 0) +// value = "\"" + u->GetProperty().userdata4.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata5") == 0) +// value = "\"" + u->GetProperty().userdata5.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata6") == 0) +// value = "\"" + u->GetProperty().userdata6.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata7") == 0) +// value = "\"" + u->GetProperty().userdata7.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata8") == 0) +// value = "\"" + u->GetProperty().userdata8.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "userdata9") == 0) +// value = "\"" + u->GetProperty().userdata9.Get() + "\""; +//else +//if (strcasecmp(paramName.c_str(), "enabledDirs") == 0) +// value = u->GetEnabledDirs(); +//else +// printfd(__FILE__, "Unknown value name: %s\n", paramName.c_str()); +//return value; +//} //----------------------------------------------------------------------------- void REMOTE_SCRIPT::SetUserNotifiers(USER_PTR u) { diff --git a/projects/stargazer/plugins/other/rscript/rscript.h b/projects/stargazer/plugins/other/rscript/rscript.h index 8d22b458..003aac2d 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.h +++ b/projects/stargazer/plugins/other/rscript/rscript.h @@ -213,7 +213,7 @@ private: std::vector IP2Routers(uint32_t ip); bool GetUsers(); - std::string GetUserParam(USER_PTR u, const std::string & paramName) const; +// std::string GetUserParam(USER_PTR u, const std::string & paramName) const; void SetUserNotifiers(USER_PTR u); void UnSetUserNotifiers(USER_PTR u); diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index ac4dc9a9..f3228738 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -823,7 +823,7 @@ if (settings->GetShowFeeInCash() || tariff == NULL) return (cash - tariff->GetFee() >= -credit); } //----------------------------------------------------------------------------- -std::string USER_IMPL::GetEnabledDirs() +std::string USER_IMPL::GetEnabledDirs() const { //STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -1478,10 +1478,11 @@ if (name == "id") { std::ostringstream stream; stream << id; - return stream.str();; + return stream.str(); } if (name == "login") return login; if (name == "ip") return currIP.ToString(); +if (name == "enabledDirs") return GetEnabledDirs(); return property.GetPropertyValue(name); } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h index d240f0c8..eacf91ee 100644 --- a/projects/stargazer/user_impl.h +++ b/projects/stargazer/user_impl.h @@ -211,7 +211,8 @@ public: void ProcessNewMonth(); bool IsInetable(); - std::string GetEnabledDirs(); + + std::string GetEnabledDirs() const; void OnAdd(); void OnDelete();