X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/cad325f5f0516da6b1d1d44c509ce194e2f08f46..474a9dc37f5085103d11cff3afa8642538f06a10:/stglibs/srvconf.lib/servconf.cpp?ds=inline diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index 01f21790..e80c3ffa 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -16,6 +16,7 @@ /* * Author : Boris Mikhailenko + * Author : Maxim Mamontov */ #include "stg/servconf.h" @@ -30,11 +31,23 @@ #include "parsers/get_admin.h" #include "parsers/chg_admin.h" +#include "parsers/get_tariffs.h" +#include "parsers/get_tariff.h" +#include "parsers/chg_tariff.h" + #include "parsers/auth_by.h" #include "parsers/get_users.h" #include "parsers/get_user.h" #include "parsers/chg_user.h" +#include "parsers/get_services.h" +#include "parsers/get_service.h" +#include "parsers/chg_service.h" + +#include "parsers/get_corporations.h" +#include "parsers/get_corp.h" +#include "parsers/chg_corp.h" + #include "parsers/base.h" #include "stg/common.h" @@ -99,7 +112,7 @@ if (XML_Parse(sc->parser, chunk.c_str(), chunk.length(), final) == XML_STATUS_ER return true; } -bool SERVCONF::IMPL::SimpleRecv(void * data, const std::string & chunk, bool final) +bool SERVCONF::IMPL::SimpleRecv(void * data, const std::string & chunk, bool /*final*/) { *static_cast(data) += chunk; return true; @@ -123,6 +136,7 @@ return pImpl->Exec("", f, data); int SERVCONF::RawXML(const std::string & request, RAW_XML::CALLBACK f, void * data) { +return pImpl->RawXML(request, f, data); } // -- Admins -- @@ -157,6 +171,38 @@ int SERVCONF::DelAdmin(const std::string & login, SIMPLE::CALLBACK f, void * dat return pImpl->Exec("DelAdmin", "", f, data); } +// -- Tariffs -- + +int SERVCONF::GetTariffs(GET_TARIFFS::CALLBACK f, void * data) +{ +return pImpl->Exec("", f, data); +} + +int SERVCONF::GetTariff(const std::string & name, GET_TARIFF::CALLBACK f, void * data) +{ +return pImpl->Exec("", f, data); +} + +int SERVCONF::ChgTariff(const TARIFF_DATA_RES & tariffData, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("SetTariff", "" + CHG_TARIFF::Serialize(tariffData) + "", f, data); +} + +int SERVCONF::AddTariff(const std::string & name, + const TARIFF_DATA_RES & tariffData, + SIMPLE::CALLBACK f, void * data) +{ +int res = pImpl->Exec("AddTariff", "", f, data); +if (res != st_ok) + return res; +return pImpl->Exec("SetTariff", "" + CHG_TARIFF::Serialize(tariffData) + "", f, data); +} + +int SERVCONF::DelTariff(const std::string & name, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("DelTariff", "", f, data); +} + // -- Users -- int SERVCONF::GetUsers(GET_USERS::CALLBACK f, void * data) @@ -202,6 +248,70 @@ int SERVCONF::CheckUser(const std::string & login, const std::string & password, return pImpl->Exec("CheckUser", "", f, data); } +// -- Services -- + +int SERVCONF::GetServices(GET_SERVICES::CALLBACK f, void * data) +{ +return pImpl->Exec("", f, data); +} + +int SERVCONF::GetService(const std::string & name, GET_SERVICE::CALLBACK f, void * data) +{ +return pImpl->Exec("", f, data); +} + +int SERVCONF::ChgService(const SERVICE_CONF_RES & conf, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("SetService", "" + CHG_SERVICE::Serialize(conf) + "", f, data); +} + +int SERVCONF::AddService(const std::string & name, + const SERVICE_CONF_RES & conf, + SIMPLE::CALLBACK f, void * data) +{ +int res = pImpl->Exec("AddService", "", f, data); +if (res != st_ok) + return res; +return pImpl->Exec("SetService", "" + CHG_SERVICE::Serialize(conf) + "", f, data); +} + +int SERVCONF::DelService(const std::string & name, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("DelService", "", f, data); +} + +// -- Corporations -- + +int SERVCONF::GetCorporations(GET_CORPORATIONS::CALLBACK f, void * data) +{ +return pImpl->Exec("", f, data); +} + +int SERVCONF::GetCorp(const std::string & name, GET_CORP::CALLBACK f, void * data) +{ +return pImpl->Exec("", f, data); +} + +int SERVCONF::ChgCorp(const CORP_CONF_RES & conf, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("SetCorp", "" + CHG_CORP::Serialize(conf) + "", f, data); +} + +int SERVCONF::AddCorp(const std::string & name, + const CORP_CONF_RES & conf, + SIMPLE::CALLBACK f, void * data) +{ +int res = pImpl->Exec("AddCorp", "", f, data); +if (res != st_ok) + return res; +return pImpl->Exec("SetCorp", "" + CHG_CORP::Serialize(conf) + "", f, data); +} + +int SERVCONF::DelCorp(const std::string & name, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("DelCorp", "", f, data); +} + const std::string & SERVCONF::GetStrError() const { return pImpl->GetStrError(); @@ -259,7 +369,7 @@ if ((ret = nt.Disconnect()) != st_ok) return st_ok; } -int SERVCONF::RawXML(const std::string & request, RAW_XML::CALLBACK f, void * data) +int SERVCONF::IMPL::RawXML(const std::string & request, RAW_XML::CALLBACK f, void * data) { std::string response; nt.SetRxCallback(&response, SimpleRecv);