]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Removing GetUserParam from rscript
[stg.git] / projects / stargazer / user_impl.cpp
index ac8399cabe77cf7149267dcdc71562eab1ac7563..f3228738b92913039488bb568f4f845699ac717b 100644 (file)
@@ -588,6 +588,7 @@ if (!fakeConnect)
             }
 
         std::string scriptOnConnectParams;
+
         strprintf(&scriptOnConnectParams,
                 "%s \"%s\" \"%s\" \"%f\" \"%d\" \"%s\"",
                 scriptOnConnect.c_str(),
@@ -597,6 +598,13 @@ if (!fakeConnect)
                 id,
                 dirsStr);
 
+        std::vector<std::string>::const_iterator it(settings->GetScriptParams().begin());
+        while (it != settings->GetScriptParams().end())
+            {
+            scriptOnConnectParams += " \"" + GetParamValue(it->c_str()) + "\"";
+            ++it;
+            }
+
         ScriptExec(scriptOnConnectParams.c_str());
         }
     else
@@ -654,6 +662,13 @@ if (!fakeDisconnect)
                 id,
                 dirsStr);
 
+        std::vector<std::string>::const_iterator it(settings->GetScriptParams().begin());
+        while (it != settings->GetScriptParams().end())
+            {
+            scriptOnDisonnectParams += " \"" + GetParamValue(it->c_str()) + "\"";
+            ++it;
+            }
+
         ScriptExec(scriptOnDisonnectParams.c_str());
         }
     else
@@ -808,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__);
 
@@ -1457,6 +1472,20 @@ while (it != messages.end())
     }
 }
 //-----------------------------------------------------------------------------
+std::string USER_IMPL::GetParamValue(const std::string & name) const
+{
+if (name == "id")
+    {
+    std::ostringstream stream;
+    stream << id;
+    return stream.str();
+    }
+if (name == "login")        return login;
+if (name == "ip")           return currIP.ToString();
+if (name == "enabledDirs")  return GetEnabledDirs();
+return property.GetPropertyValue(name);
+}
+//-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void CHG_PASSIVE_NOTIFIER::Notify(const int & oldPassive, const int & newPassive)