/*
* Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
+ * Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
#include "stg/servconf.h"
#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"
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<std::string *>(data) += chunk;
return true;
int SERVCONF::RawXML(const std::string & request, RAW_XML::CALLBACK f, void * data)
{
+return pImpl->RawXML(request, f, data);
}
// -- Admins --
return pImpl->Exec<SIMPLE::PARSER>("DelAdmin", "<DelAdmin login=\"" + login + "\"/>", f, data);
}
+// -- Tariffs --
+
+int SERVCONF::GetTariffs(GET_TARIFFS::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_TARIFFS::PARSER>("<GetTariffs/>", f, data);
+}
+
+int SERVCONF::GetTariff(const std::string & name, GET_TARIFF::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_TARIFF::PARSER>("<GetTariff name=\"" + name + "\"/>", f, data);
+}
+
+int SERVCONF::ChgTariff(const TARIFF_DATA_RES & tariffData, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("SetTariff", "<SetTariff name=\"" + tariffData.tariffConf.name.data() + "\">" + CHG_TARIFF::Serialize(tariffData) + "</SetTariff>", f, data);
+}
+
+int SERVCONF::AddTariff(const std::string & name,
+ const TARIFF_DATA_RES & tariffData,
+ SIMPLE::CALLBACK f, void * data)
+{
+int res = pImpl->Exec<SIMPLE::PARSER>("AddTariff", "<AddTariff name=\"" + name + "\"/>", f, data);
+if (res != st_ok)
+ return res;
+return pImpl->Exec<SIMPLE::PARSER>("SetTariff", "<SetTariff name=\"" + name + "\">" + CHG_TARIFF::Serialize(tariffData) + "</SetTariff>", f, data);
+}
+
+int SERVCONF::DelTariff(const std::string & name, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("DelTariff", "<DelTariff name=\"" + name + "\"/>", f, data);
+}
+
// -- Users --
int SERVCONF::GetUsers(GET_USERS::CALLBACK f, void * data)
return pImpl->Exec<SIMPLE::PARSER>("CheckUser", "<CheckUser login=\"" + login + "\" password=\"" + password + "\"/>", f, data);
}
+// -- Services --
+
+int SERVCONF::GetServices(GET_SERVICES::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_SERVICES::PARSER>("<GetServices/>", f, data);
+}
+
+int SERVCONF::GetService(const std::string & name, GET_SERVICE::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_SERVICE::PARSER>("<GetService name=\"" + name + "\"/>", f, data);
+}
+
+int SERVCONF::ChgService(const SERVICE_CONF_RES & conf, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("SetService", "<SetService name=\"" + conf.name.data() + "\">" + CHG_SERVICE::Serialize(conf) + "</SetService>", f, data);
+}
+
+int SERVCONF::AddService(const std::string & name,
+ const SERVICE_CONF_RES & conf,
+ SIMPLE::CALLBACK f, void * data)
+{
+int res = pImpl->Exec<SIMPLE::PARSER>("AddService", "<AddService name=\"" + name + "\"/>", f, data);
+if (res != st_ok)
+ return res;
+return pImpl->Exec<SIMPLE::PARSER>("SetService", "<SetService name=\"" + name + "\">" + CHG_SERVICE::Serialize(conf) + "</SetService>", f, data);
+}
+
+int SERVCONF::DelService(const std::string & name, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("DelService", "<DelService name=\"" + name + "\"/>", f, data);
+}
+
+// -- Corporations --
+
+int SERVCONF::GetCorporations(GET_CORPORATIONS::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_CORPORATIONS::PARSER>("<GetCorporations/>", f, data);
+}
+
+int SERVCONF::GetCorp(const std::string & name, GET_CORP::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_CORP::PARSER>("<GetCorp name=\"" + name + "\"/>", f, data);
+}
+
+int SERVCONF::ChgCorp(const CORP_CONF_RES & conf, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("SetCorp", "<SetCorp name=\"" + conf.name.data() + "\">" + CHG_CORP::Serialize(conf) + "</SetCorp>", f, data);
+}
+
+int SERVCONF::AddCorp(const std::string & name,
+ const CORP_CONF_RES & conf,
+ SIMPLE::CALLBACK f, void * data)
+{
+int res = pImpl->Exec<SIMPLE::PARSER>("AddCorp", "<AddCorp name=\"" + name + "\"/>", f, data);
+if (res != st_ok)
+ return res;
+return pImpl->Exec<SIMPLE::PARSER>("SetCorp", "<SetCorp name=\"" + name + "\">" + CHG_CORP::Serialize(conf) + "</SetCorp>", f, data);
+}
+
+int SERVCONF::DelCorp(const std::string & name, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("DelCorp", "<DelCorp name=\"" + name + "\"/>", f, data);
+}
+
const std::string & SERVCONF::GetStrError() const
{
return pImpl->GetStrError();
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);