//-----------------------------------------------------------------------------
void USER_IMPL::SetLogin(const std::string & l)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
assert(login.empty() && "Login is already set");
login = l;
id = userIDGenerator.GetNextID();
//-----------------------------------------------------------------------------
int USER_IMPL::ReadConf()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_CONF conf;
if (store->RestoreUserConf(&conf, login))
//-----------------------------------------------------------------------------
int USER_IMPL::ReadStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_STAT stat;
if (store->RestoreUserStat(&stat, login))
//-----------------------------------------------------------------------------
int USER_IMPL::WriteConf()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_CONF conf(property.GetConf());
printfd(__FILE__, "USER::WriteConf()\n");
//-----------------------------------------------------------------------------
int USER_IMPL::WriteStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_STAT stat(property.GetStat());
if (store->SaveUserStat(stat, login))
//-----------------------------------------------------------------------------
int USER_IMPL::WriteMonthStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
time_t tt = stgTime - 3600;
struct tm t1;
localtime_r(&tt, &t1);
//-----------------------------------------------------------------------------
int USER_IMPL::Authorize(uint32_t ip, uint32_t dirs, const AUTH * auth)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
/*
* Authorize user. It only means that user will be authorized. Nothing more.
* User can be connected or disconnected while authorized.
//-----------------------------------------------------------------------------
void USER_IMPL::Unauthorize(const AUTH * auth, const std::string & reason)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
/*
* Authorizer tries to unauthorize user, that was not authorized by it
*/
//-----------------------------------------------------------------------------
bool USER_IMPL::IsAuthorizedBy(const AUTH * auth) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
// Is this user authorized by specified authorizer?
return authorizedBy.find(auth) != authorizedBy.end();
}
* Connect user to Internet. This function is differ from Authorize() !!!
*/
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!fakeConnect)
{
* Disconnect user from Internet. This function is differ from UnAuthorize() !!!
*/
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!lastIPForDisconnect)
{
void USER_IMPL::PrintUser() const
{
//return;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::cout << "============================================================" << std::endl;
std::cout << "id=" << id << std::endl;
std::cout << "login=" << login << std::endl;
//-----------------------------------------------------------------------------
void USER_IMPL::Run()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (stgTime > static_cast<time_t>(lastWriteStat + settings->GetStatWritePeriod()))
{
//-----------------------------------------------------------------------------
void USER_IMPL::UpdatePingTime(time_t t)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
//printfd(__FILE__, "UpdatePingTime(%d) %s\n", t, login.c_str());
if (t)
pingTime = t;
//-----------------------------------------------------------------------------
bool USER_IMPL::IsInetable()
{
-//STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+//STG_LOCKER lock(&mutex);
if (disabled || passive)
return false;
//-----------------------------------------------------------------------------
std::string USER_IMPL::GetEnabledDirs() const
{
-//STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+//STG_LOCKER lock(&mutex);
std::string dirs = "";
for(int i = 0; i < DIR_NUM; i++)
void USER_IMPL::AddTraffStatU(int dir, uint32_t ip, uint32_t len)
#endif
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!connected || tariff == NULL)
return;
void USER_IMPL::AddTraffStatD(int dir, uint32_t ip, uint32_t len)
#endif
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!connected || tariff == NULL)
return;
//-----------------------------------------------------------------------------
void USER_IMPL::AddCurrIPBeforeNotifier(CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.AddBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelCurrIPBeforeNotifier(const CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.DelBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::AddCurrIPAfterNotifier(CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.AddAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelCurrIPAfterNotifier(const CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.DelAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::AddConnectedBeforeNotifier(CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.AddBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelConnectedBeforeNotifier(const CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.DelBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::AddConnectedAfterNotifier(CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.AddAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelConnectedAfterNotifier(const CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.DelAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::OnAdd()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::string scriptOnAdd = settings->GetScriptsDir() + "/OnUserAdd";
//-----------------------------------------------------------------------------
void USER_IMPL::OnDelete()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::string scriptOnDel = settings->GetScriptsDir() + "/OnUserDel";
TRAFF_STAT ts;
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
ts.swap(traffStat);
}
if (!hard)
{
printfd(__FILE__, "USER::WriteDetailStat() - pushing detail stat to queue\n");
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
traffStatSaved.second.swap(ts);
traffStatSaved.first = lastWriteDetailedStat;
}
//-----------------------------------------------------------------------------
double USER_IMPL::GetPassiveTimePart() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
static int daysInMonth[12] =
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
//-----------------------------------------------------------------------------
void USER_IMPL::SetPassiveTimeAsNewUser()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
time_t t = stgTime;
struct tm tm;
//-----------------------------------------------------------------------------
void USER_IMPL::MidnightResetSessionStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (connected)
{
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessNewMonth()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
// Reset traff
if (connected)
{
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessDayFeeSpread()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (passive.ConstData() || tariff == NULL)
return;
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessDayFee()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (tariff == NULL)
return;
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessDailyFee()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (passive.ConstData() || tariff == NULL)
return;
//-----------------------------------------------------------------------------
int USER_IMPL::AddMessage(STG_MSG * msg)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (SendMessage(*msg))
{
//-----------------------------------------------------------------------------
std::string USER_IMPL::GetParamValue(const std::string & name) const
{
- if (name == "id")
+ std::string lowerName = ToLower(name);
+ if (lowerName == "id")
{
std::ostringstream stream;
stream << id;
return stream.str();
}
- if (name == "login") return login;
- if (name == "currIP") return currIP.ToString();
- if (name == "enabledDirs") return GetEnabledDirs();
- if (property.Exists(name))
- return property.GetPropertyValue(name);
+ if (lowerName == "login") return login;
+ if (lowerName == "currip") return currIP.ToString();
+ if (lowerName == "enableddirs") return GetEnabledDirs();
+ if (lowerName == "tariff") return property.tariffName;
+ if (property.Exists(lowerName))
+ return property.GetPropertyValue(lowerName);
else
{
WriteServLog("User’s parameter '%s' does not exist.", name.c_str());