if (currParser)
{
printfd(__FILE__, "Parser reset\n");
- currParser->Reset();
+ //currParser->Reset();
currParser = NULL;
}
void CONFIGPROTO::SetAdmins(ADMINS * a)
{
admins = a;
-for (size_t i = 0; i < dataParser.size(); i++)
- dataParser[i]->SetAdmins(a);
-}
-//-----------------------------------------------------------------------------
-void CONFIGPROTO::SetUsers(USERS * u)
-{
-for (size_t i = 0; i < dataParser.size(); i++)
- dataParser[i]->SetUsers(u);
-}
-//-----------------------------------------------------------------------------
-void CONFIGPROTO::SetTariffs(TARIFFS * t)
-{
-for (size_t i = 0; i < dataParser.size(); i++)
- dataParser[i]->SetTariffs(t);
-}
-//-----------------------------------------------------------------------------
-void CONFIGPROTO::SetStore(STORE * s)
-{
-for (size_t i = 0; i < dataParser.size(); i++)
- dataParser[i]->SetStore(s);
-}
-//-----------------------------------------------------------------------------
-void CONFIGPROTO::SetStgSettings(const SETTINGS * s)
-{
-for (size_t i = 0; i < dataParser.size(); i++)
- dataParser[i]->SetStgSettings(s);
}
//-----------------------------------------------------------------------------
void SetPort(uint16_t p) { port = p; }
void SetAdmins(ADMINS * a);
- void SetUsers(USERS * u);
- void SetTariffs(TARIFFS * t);
- void SetStore(STORE * s);
- void SetStgSettings(const SETTINGS * s);
uint32_t GetAdminIP() const { return adminIP; }
int Prepare();
int Stop();
#include "parser.h"
-#include "stg/tariffs.h"
-#include "stg/admin.h"
-#include "stg/users.h"
-#include "stg/user_property.h"
-#include "stg/settings.h"
-#include "stg/logger.h"
-#include "stg/version.h"
-#include "stg/store.h"
-
#include <cstring>
-#include <cstdio> // sprintf
//-----------------------------------------------------------------------------
// BASE PARSER
//-----------------------------------------------------------------------------
-int BASE_PARSER::Start(void *, const char *el, const char **)
+int BASE_PARSER::Start(void *, const char * el, const char **)
{
-if (strcasecmp(el, tag.c_str()) == 0)
- return 0;
+ if (strcasecmp(el, m_tag.c_str()) == 0)
+ return 0;
-return -1;
+ return -1;
}
//-----------------------------------------------------------------------------
-int BASE_PARSER::End(void *, const char *el)
+int BASE_PARSER::End(void *, const char * el)
{
-if (strcasecmp(el, tag.c_str()) == 0)
+ if (m_depth == 1)
{
- CreateAnswer();
- return 0;
+ if (strcasecmp(el, m_tag.c_str()) != 0)
+ return -1;
+ CreateAnswer();
}
-return -1;
+ --m_depth;
+ return 0;
}
#ifndef PARSER_H
#define PARSER_H
-#include "stg/message.h"
-#include "stg/tariff_conf.h"
-#include "stg/resetable.h"
-#include "stg/const.h"
-
#include <string>
-#include <vector>
-class TARIFFS;
-class SETTINGS;
-class STORE;
-class ADMINS;
class ADMIN;
-class USERS;
-class USER;
-class USER_STAT_RES;
-class USER_CONF_RES;
-
-//-----------------------------------------------------------------------------
-class BASE_PARSER {
-public:
- BASE_PARSER(const ADMIN & admin, const std::string & t)
- : strError(),
- admins(NULL),
- users(NULL),
- tariffs(NULL),
- store(NULL),
- settings(NULL),
- currAdmin(admin),
- depth(0),
- tag(t)
- {}
- virtual ~BASE_PARSER() {}
- virtual int Start(void *data, const char *el, const char **attr);
- virtual int End(void *data, const char *el);
-
- virtual void Reset() { answer.clear(); depth = 0; }
-
- void SetUsers(USERS * u) { users = u; }
- void SetAdmins(ADMINS * a) { admins = a; }
- void SetTariffs(TARIFFS * t) { tariffs = t; }
- void SetStore(STORE * s) { store = s; }
- void SetStgSettings(const SETTINGS * s) { settings = s; }
- const std::string & GetStrError() const { return strError; }
- const std::string & GetAnswer() const { return answer; }
- const std::string & GetTag() const { return tag; }
- std::string GetOpenTag() const { return "<" + tag + ">"; }
- std::string GetCloseTag() const { return "</" + tag + ">"; }
-
-protected:
- BASE_PARSER(const BASE_PARSER & rvalue);
- BASE_PARSER & operator=(const BASE_PARSER & rvalue);
-
- std::string strError;
- ADMINS * admins;
- USERS * users;
- TARIFFS * tariffs;
- STORE * store;
- const SETTINGS * settings;
- const ADMIN & currAdmin;
- int depth;
- std::string answer;
- std::string tag;
-
-private:
- virtual void CreateAnswer() = 0;
+class BASE_PARSER
+{
+ public:
+ BASE_PARSER(const ADMIN & admin, const std::string & t)
+ : m_currAdmin(admin),
+ m_depth(0),
+ m_tag(t)
+ {}
+ virtual ~BASE_PARSER() {}
+ virtual int Start(void * data, const char * el, const char ** attr);
+ virtual int End(void * data, const char * el);
+
+ const std::string & GetAnswer() const { return m_answer; }
+ const std::string & GetTag() const { return m_tag; }
+ std::string GetOpenTag() const { return "<" + m_tag + ">"; }
+ std::string GetCloseTag() const { return "</" + m_tag + ">"; }
+
+ protected:
+ BASE_PARSER(const BASE_PARSER & rvalue);
+ BASE_PARSER & operator=(const BASE_PARSER & rvalue);
+
+ const ADMIN & m_currAdmin;
+ size_t m_depth;
+ std::string m_answer;
+ std::string m_tag;
+
+ private:
+ virtual void CreateAnswer() = 0;
};
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
+
#endif //PARSER_H
void GET_ADMINS::CreateAnswer()
{
- const PRIV * priv = currAdmin.GetPriv();
+ const PRIV * priv = m_currAdmin.GetPriv();
if (!priv->adminChg)
{
- answer = "<Error Result=\"Error. Access denied.\"/>";
+ m_answer = "<Error Result=\"Error. Access denied.\"/>";
return;
}
- answer.clear();
+ m_answer.clear();
- answer += GetOpenTag();
+ m_answer += GetOpenTag();
ADMIN_CONF ac;
int h = m_admins.OpenSearch();
(ac.priv.userAddDel << 8) +
(ac.priv.adminChg << 10) +
(ac.priv.tariffChg << 12);
- answer += "<admin login=\"" + ac.login + "\" priv=\"" + x2str(p) + "\"/>";
+ m_answer += "<admin login=\"" + ac.login + "\" priv=\"" + x2str(p) + "\"/>";
}
m_admins.CloseSearch(h);
- answer += GetCloseTag();
+ m_answer += GetCloseTag();
}
int DEL_ADMIN::Start(void *, const char * el, const char ** attr)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
admin = attr[1];
return 0;
void DEL_ADMIN::CreateAnswer()
{
- if (m_admins.Del(admin, &currAdmin) == 0)
- answer = "<" + tag + " Result=\"Ok\"/>";
+ if (m_admins.Del(admin, &m_currAdmin) == 0)
+ m_answer = "<" + m_tag + " Result=\"Ok\"/>";
else
- answer = "<" + tag + " Result=\"Error. " + m_admins.GetStrError() + "\"/>";
+ m_answer = "<" + m_tag + " Result=\"Error. " + m_admins.GetStrError() + "\"/>";
}
int ADD_ADMIN::Start(void *, const char *el, const char **attr)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
admin = attr[1];
return 0;
void ADD_ADMIN::CreateAnswer()
{
- if (m_admins.Add(admin, &currAdmin) == 0)
- answer = "<" + tag + " Result=\"Ok\"/>";
+ if (m_admins.Add(admin, &m_currAdmin) == 0)
+ m_answer = "<" + m_tag + " Result=\"Ok\"/>";
else
- answer = "<" + tag + " Result=\"Error. " + m_admins.GetStrError() + "\"/>";
+ m_answer = "<" + m_tag + " Result=\"Error. " + m_admins.GetStrError() + "\"/>";
}
int CHG_ADMIN::Start(void *, const char * el, const char ** attr)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
for (size_t i = 0; i < 6; i += 2)
{
if (m_admins.Find(login, &origAdmin))
{
- answer = "<" + tag + " Result = \"Admin '" + login + "' is not found.\"/>";
+ m_answer = "<" + m_tag + " Result = \"Admin '" + login + "' is not found.\"/>";
return;
}
int p = 0;
if (str2x(privAsString.data().c_str(), p) < 0)
{
- answer = "<" + tag + " Result = \"Incorrect parameter Priv.\"/>";
+ m_answer = "<" + m_tag + " Result = \"Incorrect parameter Priv.\"/>";
return;
}
conf.priv.FromInt(p);
}
- if (m_admins.Change(conf, &currAdmin) != 0)
- answer = "<" + tag + " Result = \"" + m_admins.GetStrError() + "\"/>";
+ if (m_admins.Change(conf, &m_currAdmin) != 0)
+ m_answer = "<" + m_tag + " Result = \"" + m_admins.GetStrError() + "\"/>";
else
- answer = "<" + tag + " Result = \"Ok\"/>";
+ m_answer = "<" + m_tag + " Result = \"Ok\"/>";
}
else
- answer = "<" + tag + " Result = \"Incorrect parameter login.\"/>";
+ m_answer = "<" + m_tag + " Result = \"Incorrect parameter login.\"/>";
}
int AUTH_BY::Start(void * /*data*/, const char *el, const char **attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
if (!attr[1])
CONST_USER_PTR u;
if (m_users.FindByName(m_login, &u))
{
- answer = "<AuthorizedBy result=\"error\" reason=\"User not found.\"/>";
+ m_answer = "<AuthorizedBy result=\"error\" reason=\"User not found.\"/>";
return;
}
- answer = "<AuthorizedBy result=\"ok\">";
+ m_answer = "<AuthorizedBy result=\"ok\">";
std::vector<std::string> list(u->GetAuthorizers());
for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
- answer += "<Auth name=\"" + *it + "\"/>";
- answer += "</AuthorizedBy>";
+ m_answer += "<Auth name=\"" + *it + "\"/>";
+ m_answer += "</AuthorizedBy>";
}
int SEND_MESSAGE::Start(void *, const char *el, const char **attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
for (size_t i = 0; i < 14; i++)
int SEND_MESSAGE::End(void *, const char *el)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
m_result = res_unknown;
switch (m_result)
{
case res_ok:
- answer = "<SendMessageResult value=\"ok\"/>";
+ m_answer = "<SendMessageResult value=\"ok\"/>";
break;
case res_params_error:
- answer = "<SendMessageResult value=\"Parameters error.\"/>";
+ m_answer = "<SendMessageResult value=\"Parameters error.\"/>";
break;
case res_unknown:
- answer = "<SendMessageResult value=\"Unknown user.\"/>";
+ m_answer = "<SendMessageResult value=\"Unknown user.\"/>";
break;
}
}
void GET_TARIFFS::CreateAnswer()
{
- answer = GetOpenTag();
+ m_answer = GetOpenTag();
std::list<TARIFF_DATA> dataList;
m_tariffs.GetTariffsData(&dataList);
std::list<TARIFF_DATA>::const_iterator it = dataList.begin();
for (; it != dataList.end(); ++it)
{
- answer += "<tariff name=\"" + it->tariffConf.name + "\">";
+ m_answer += "<tariff name=\"" + it->tariffConf.name + "\">";
for (size_t i = 0; i < DIR_NUM; i++)
- answer += "<Time" + x2str(i) + " value=\"" +
+ m_answer += "<Time" + x2str(i) + " value=\"" +
x2str(it->dirPrice[i].hDay) + ":" + x2str(it->dirPrice[i].mDay) + "-" +
x2str(it->dirPrice[i].hNight) + ":" + x2str(it->dirPrice[i].mNight) + "\"/>";
- answer += "<PriceDayA value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceDayA, pt_mega) + "\"/>" +
+ m_answer += "<PriceDayA value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceDayA, pt_mega) + "\"/>" +
"<PriceDayB value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceDayB, pt_mega) + "\"/>" +
"<PriceNightA value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceNightA, pt_mega) + "\"/>" +
"<PriceNightB value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceNightB, pt_mega) + "\"/>" +
"</tariff>";
}
- answer += GetCloseTag();
+ m_answer += GetCloseTag();
}
int ADD_TARIFF::Start(void *, const char * el, const char ** attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
if (attr[1] == NULL)
void ADD_TARIFF::CreateAnswer()
{
- if (m_tariffs.Add(tariff, &currAdmin) == 0)
- answer = "<" + tag + " Result=\"Ok\"/>";
+ if (m_tariffs.Add(tariff, &m_currAdmin) == 0)
+ m_answer = "<" + m_tag + " Result=\"Ok\"/>";
else
- answer = "<" + tag + " Result=\"Error. " + m_tariffs.GetStrError() + "\"/>";
+ m_answer = "<" + m_tag + " Result=\"Error. " + m_tariffs.GetStrError() + "\"/>";
}
int DEL_TARIFF::Start(void *, const char * el, const char ** attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
if (attr[1] == NULL)
void DEL_TARIFF::CreateAnswer()
{
if (m_users.TariffInUse(tariff))
- answer = "<" + tag + " Result=\"Error. Tariff \'" + tariff + "\' cannot be deleted, it is in use.\"/>";
- else if (m_tariffs.Del(tariff, &currAdmin) == 0)
- answer = "<" + tag + " Result=\"Ok\"/>";
+ m_answer = "<" + m_tag + " Result=\"Error. Tariff \'" + tariff + "\' cannot be deleted, it is in use.\"/>";
+ else if (m_tariffs.Del(tariff, &m_currAdmin) == 0)
+ m_answer = "<" + m_tag + " Result=\"Ok\"/>";
else
- answer = "<" + tag + " Result=\"Error. " + m_tariffs.GetStrError() + "\"/>";
+ m_answer = "<" + m_tag + " Result=\"Error. " + m_tariffs.GetStrError() + "\"/>";
}
int CHG_TARIFF::Start(void *, const char * el, const char ** attr)
{
- depth++;
+ m_depth++;
- if (depth == 1)
+ if (m_depth == 1)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
td.tariffConf.name = attr[1];
return 0;
return -1;
}
-int CHG_TARIFF::End(void *, const char * el)
-{
- if (depth == 1)
- {
- if (strcasecmp(el, tag.c_str()) != 0)
- return -1;
- CreateAnswer();
- }
-
- --depth;
- return 0;
-}
-
void CHG_TARIFF::CreateAnswer()
{
if (!td.tariffConf.name.data().empty())
{
TARIFF_DATA tariffData = td.GetData();
- if (m_tariffs.Chg(tariffData, &currAdmin) == 0)
- answer = "<" + tag + " Result=\"ok\"/>";
+ if (m_tariffs.Chg(tariffData, &m_currAdmin) == 0)
+ m_answer = "<" + m_tag + " Result=\"ok\"/>";
else
- answer = "<" + tag + " Result=\"Change tariff error! " + m_tariffs.GetStrError() + "\"/>";
+ m_answer = "<" + m_tag + " Result=\"Change tariff error! " + m_tariffs.GetStrError() + "\"/>";
}
else
- answer = "<" + tag + " Result=\"Change tariff error!\"/>";
+ m_answer = "<" + m_tag + " Result=\"Change tariff error!\"/>";
}
CHG_TARIFF(const ADMIN & admin, TARIFFS & tariffs)
: BASE_PARSER(admin, "SetTariff"), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
- int End(void * data, const char * el);
private:
TARIFF_DATA_RES td;
int USER_INFO::Start(void * /*data*/, const char *el, const char **attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
if (!attr[1])
CONST_USER_PTR u;
if (m_users.FindByName(m_login, &u))
{
- answer = "<UserInfo result=\"error\"/>";
+ m_answer = "<UserInfo result=\"error\"/>";
return;
}
- answer = "<UserInfo lastAuthTime=\"" + x2str(u->GetAuthorizedModificationTime()) + "\"" +
+ m_answer = "<UserInfo lastAuthTime=\"" + x2str(u->GetAuthorizedModificationTime()) + "\"" +
" lastDisconnectTime=\"" + x2str(u->GetConnectedModificationTime()) + "\"" +
" connected=\"" + (u->GetConnected() ? "true" : "false") + "\"" +
" lastDisconnectReason=\"" + u->GetLastDisconnectReason() + "\">";
std::vector<std::string> list(u->GetAuthorizers());
for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
- answer += "<Auth name=\"" + *it + "\"/>";
- answer += "</UserInfo>";
+ m_answer += "<Auth name=\"" + *it + "\"/>";
+ m_answer += "</UserInfo>";
}
#include <string>
+class USERS;
+
namespace STG
{
namespace PARSER
int GET_USERS::Start(void *, const char * el, const char ** attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
while (attr && *attr && *(attr + 1))
assert(h);
if (m_lastUserUpdateTime > 0)
- answer = "<" + tag + " LastUpdate=\"" + x2str(time(NULL)) + "\">";
+ m_answer = "<" + m_tag + " LastUpdate=\"" + x2str(time(NULL)) + "\">";
else
- answer = GetOpenTag();
+ m_answer = GetOpenTag();
USER_PTR u;
while (m_users.SearchNext(h, &u) == 0)
- answer += UserToXML(*u, true, currAdmin.GetPriv()->userConf || currAdmin.GetPriv()->userPasswd, m_lastUserUpdateTime);
+ m_answer += UserToXML(*u, true, m_currAdmin.GetPriv()->userConf || m_currAdmin.GetPriv()->userPasswd, m_lastUserUpdateTime);
m_users.CloseSearch(h);
- answer += GetCloseTag();
+ m_answer += GetCloseTag();
}
int GET_USER::Start(void *, const char * el, const char ** attr)
{
- if (strcasecmp(el, tag.c_str()) != 0)
+ if (strcasecmp(el, m_tag.c_str()) != 0)
return -1;
if (attr[1] == NULL)
CONST_USER_PTR u;
if (m_users.FindByName(m_login, &u))
- answer = "<" + tag + " result=\"error\" reason=\"User not found.\"/>";
+ m_answer = "<" + m_tag + " result=\"error\" reason=\"User not found.\"/>";
else
- answer = UserToXML(*u, false, currAdmin.GetPriv()->userConf || currAdmin.GetPriv()->userPasswd);
+ m_answer = UserToXML(*u, false, m_currAdmin.GetPriv()->userConf || m_currAdmin.GetPriv()->userPasswd);
}
int ADD_USER::Start(void *, const char * el, const char ** attr)
{
- depth++;
+ m_depth++;
- if (depth == 1)
+ if (m_depth == 1)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
return 0;
}
else
return -1;
}
-int ADD_USER::End(void *, const char *el)
-{
- if (depth == 1)
- {
- if (strcasecmp(el, tag.c_str()) == 0)
- return -1;
- CreateAnswer();
- }
-
- --depth;
- return 0;
-}
-
void ADD_USER::CreateAnswer()
{
if (m_users.Exists(m_login))
- answer = "<" + tag + " result=\"error\" reason=\"User '" + m_login + "' exists.\"/>";
- else if (m_users.Add(m_login, &currAdmin) == 0)
- answer = "<" + tag + " result=\"ok\"/>";
+ m_answer = "<" + m_tag + " result=\"error\" reason=\"User '" + m_login + "' exists.\"/>";
+ else if (m_users.Add(m_login, &m_currAdmin) == 0)
+ m_answer = "<" + m_tag + " result=\"ok\"/>";
else
- answer = "<" + tag + " result=\"error\" reason=\"Access denied\"/>";
+ m_answer = "<" + m_tag + " result=\"error\" reason=\"Access denied\"/>";
}
int CHG_USER::Start(void *, const char * el, const char ** attr)
{
- depth++;
+ m_depth++;
- if (depth == 1)
+ if (m_depth == 1)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
return 0;
}
else
return -1;
}
-int CHG_USER::End(void *, const char *el)
-{
- if (depth == 1)
- {
- if (strcasecmp(el, tag.c_str()) != 0)
- return -1;
-
- CreateAnswer();
- }
-
- depth--;
- return 0;
-}
-
void CHG_USER::CreateAnswer()
{
if (ApplyChanges() == 0)
- answer = "<" + tag + " result=\"ok\"/>";
+ m_answer = "<" + m_tag + " result=\"ok\"/>";
else
- answer = "<" + tag + " result=\"error\"/>";
+ m_answer = "<" + m_tag + " result=\"error\"/>";
}
int CHG_USER::ApplyChanges()
if (check && alwaysOnline && !onlyOneIP)
{
printfd(__FILE__, "Requested change leads to a forbidden state: AlwaysOnline with multiple IP's\n");
- GetStgLogger()("%s Requested change leads to a forbidden state: AlwaysOnline with multiple IP's", currAdmin.GetLogStr().c_str());
+ GetStgLogger()("%s Requested change leads to a forbidden state: AlwaysOnline with multiple IP's", m_currAdmin.GetLogStr().c_str());
return -1;
}
if (m_users.IsIPInUse(ip, m_login, &user))
{
printfd(__FILE__, "Trying to assign an IP %s to '%s' that is already in use by '%s'\n", inet_ntostring(ip).c_str(), m_login.c_str(), user->GetLogin().c_str());
- GetStgLogger()("%s trying to assign an IP %s to '%s' that is currently in use by '%s'", currAdmin.GetLogStr().c_str(), inet_ntostring(ip).c_str(), m_login.c_str(), user->GetLogin().c_str());
+ GetStgLogger()("%s trying to assign an IP %s to '%s' that is currently in use by '%s'", m_currAdmin.GetLogStr().c_str(), inet_ntostring(ip).c_str(), m_login.c_str(), user->GetLogin().c_str());
return -1;
}
}
if (!m_ucr.ips.empty())
- if (!u->GetProperty().ips.Set(m_ucr.ips.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().ips.Set(m_ucr.ips.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.alwaysOnline.empty())
if (!u->GetProperty().alwaysOnline.Set(m_ucr.alwaysOnline.const_data(),
- &currAdmin, m_login, store))
+ &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.address.empty())
- if (!u->GetProperty().address.Set(m_ucr.address.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().address.Set(m_ucr.address.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.creditExpire.empty())
if (!u->GetProperty().creditExpire.Set(m_ucr.creditExpire.const_data(),
- &currAdmin, m_login, store))
+ &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.credit.empty())
- if (!u->GetProperty().credit.Set(m_ucr.credit.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().credit.Set(m_ucr.credit.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_usr.freeMb.empty())
- if (!u->GetProperty().freeMb.Set(m_usr.freeMb.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().freeMb.Set(m_usr.freeMb.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.disabled.empty())
- if (!u->GetProperty().disabled.Set(m_ucr.disabled.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().disabled.Set(m_ucr.disabled.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.disabledDetailStat.empty())
- if (!u->GetProperty().disabledDetailStat.Set(m_ucr.disabledDetailStat.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().disabledDetailStat.Set(m_ucr.disabledDetailStat.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.email.empty())
- if (!u->GetProperty().email.Set(m_ucr.email.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().email.Set(m_ucr.email.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.group.empty())
- if (!u->GetProperty().group.Set(m_ucr.group.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().group.Set(m_ucr.group.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.note.empty())
- if (!u->GetProperty().note.Set(m_ucr.note.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().note.Set(m_ucr.note.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
std::vector<USER_PROPERTY_LOGGED<std::string> *> userdata;
for (int i = 0; i < (int)userdata.size(); i++)
if (!m_ucr.userdata[i].empty())
- if(!userdata[i]->Set(m_ucr.userdata[i].const_data(), &currAdmin, m_login, store))
+ if(!userdata[i]->Set(m_ucr.userdata[i].const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.passive.empty())
- if (!u->GetProperty().passive.Set(m_ucr.passive.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().passive.Set(m_ucr.passive.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.password.empty())
- if (!u->GetProperty().password.Set(m_ucr.password.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().password.Set(m_ucr.password.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.phone.empty())
- if (!u->GetProperty().phone.Set(m_ucr.phone.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().phone.Set(m_ucr.phone.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!m_ucr.realName.empty())
- if (!u->GetProperty().realName.Set(m_ucr.realName.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().realName.Set(m_ucr.realName.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (m_cashMustBeAdded)
{
if (!u->GetProperty().cash.Set(m_usr.cash.const_data() + u->GetProperty().cash,
- &currAdmin,
+ &m_currAdmin,
m_login,
- store,
+ &m_store,
m_cashMsg))
return -1;
else
- if (!u->GetProperty().cash.Set(m_usr.cash.const_data(), &currAdmin, m_login, store, m_cashMsg))
+ if (!u->GetProperty().cash.Set(m_usr.cash.const_data(), &m_currAdmin, m_login, &m_store, m_cashMsg))
return -1;
}
{
if (m_tariffs.FindByName(m_ucr.tariffName.const_data()))
{
- if (!u->GetProperty().tariffName.Set(m_ucr.tariffName.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().tariffName.Set(m_ucr.tariffName.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
u->ResetNextTariff();
}
{
if (m_tariffs.FindByName(m_ucr.nextTariff.const_data()))
{
- if (!u->GetProperty().nextTariff.Set(m_ucr.nextTariff.const_data(), &currAdmin, m_login, store))
+ if (!u->GetProperty().nextTariff.Set(m_ucr.nextTariff.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
}
else
}
if (upCount)
- if (!u->GetProperty().up.Set(up, &currAdmin, m_login, store))
+ if (!u->GetProperty().up.Set(up, &m_currAdmin, m_login, &m_store))
return -1;
if (downCount)
- if (!u->GetProperty().down.Set(down, &currAdmin, m_login, store))
+ if (!u->GetProperty().down.Set(down, &m_currAdmin, m_login, &m_store))
return -1;
u->WriteConf();
int DEL_USER::Start(void *, const char *el, const char **attr)
{
res = 0;
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
if (attr[0] == NULL || attr[1] == NULL)
{
int DEL_USER::End(void *, const char *el)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
if (!res)
- m_users.Del(u->GetLogin(), &currAdmin);
+ m_users.Del(u->GetLogin(), &m_currAdmin);
return 0;
}
void DEL_USER::CreateAnswer()
{
if (res)
- answer = "<" + tag + " value=\"error\" reason=\"User not found\"/>";
+ m_answer = "<" + m_tag + " value=\"error\" reason=\"User not found\"/>";
else
- answer = "<" + tag + " value=\"ok\"/>";
+ m_answer = "<" + m_tag + " value=\"ok\"/>";
}
int CHECK_USER::Start(void *, const char *el, const char **attr)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
{
if (attr[0] == NULL || attr[1] == NULL ||
attr[2] == NULL || attr[3] == NULL)
int CHECK_USER::End(void *, const char *el)
{
- if (strcasecmp(el, tag.c_str()) == 0)
+ if (strcasecmp(el, m_tag.c_str()) == 0)
return 0;
return -1;
}
void CHECK_USER::CreateAnswer(const char * error)
{
if (error)
- answer = "<" + tag + " value=\"Err\" reason=\"" + error + "\"/>";
+ m_answer = "<" + m_tag + " value=\"Err\" reason=\"" + error + "\"/>";
else
- answer = "<" + tag + " value=\"Ok\"/>";
+ m_answer = "<" + m_tag + " value=\"Ok\"/>";
}
class USER;
class TARIFFS;
class ADMIN;
+class STORE;
namespace STG
{
ADD_USER(const ADMIN & admin, USERS & users)
: BASE_PARSER(admin, "AddUser"), m_users(users) {}
int Start(void * data, const char * el, const char ** attr);
- int End(void * data, const char * el);
private:
USERS & m_users;
class CHG_USER: public BASE_PARSER
{
public:
- CHG_USER(const ADMIN & admin, USERS & users, const TARIFFS & tariffs)
+ CHG_USER(const ADMIN & admin, USERS & users,
+ STORE & store, const TARIFFS & tariffs)
: BASE_PARSER(admin, "SetUser"),
m_users(users),
+ m_store(store),
m_tariffs(tariffs),
m_cashMustBeAdded(false),
m_res(0) {}
int Start(void * data, const char * el, const char ** attr);
- int End(void * data, const char * el);
private:
USERS & m_users;
+ STORE & m_store;
const TARIFFS & m_tariffs;
USER_STAT_RES m_usr;
USER_CONF_RES m_ucr;
STG_CONFIG();
virtual ~STG_CONFIG(){}
- void SetUsers(USERS * users) { config.SetUsers(users); }
- void SetTariffs(TARIFFS * tariffs) { config.SetTariffs(tariffs); }
+ void SetUsers(USERS *) {}
+ void SetTariffs(TARIFFS *) {}
void SetAdmins(ADMINS * admins) { config.SetAdmins(admins); }
- void SetStore(STORE * store) { config.SetStore(store); }
- void SetStgSettings(const SETTINGS * settings) { config.SetStgSettings(settings); }
+ void SetStore(STORE *) {}
+ void SetStgSettings(const SETTINGS *) {}
void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
int ParseSettings();