From: Maxim Mamontov Date: Sat, 19 Mar 2011 15:52:40 +0000 (+0200) Subject: Fix compilation issues for XML RPC interface X-Git-Tag: 2.407-rc3~144 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/91b5ae18ae465d0887785aab6dc0eb7abc0d5488 Fix compilation issues for XML RPC interface --- diff --git a/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp index 4eae81fd..f36debc4 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp @@ -1,6 +1,7 @@ #include "admins_methods.h" #include "rpcconfig.h" +#include "common.h" //------------------------------------------------------------------------------ @@ -21,7 +22,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(login, &admin)) { @@ -31,10 +32,10 @@ if (admins->FindAdmin(login, &admin)) } structVal["result"] = xmlrpc_c::value_boolean(true); -structVal["login"] = xmlrpc_c::value_string(admin.GetLogin()); -structVal["password"] = xmlrpc_c::value_string(admin.GetPassword()); +structVal["login"] = xmlrpc_c::value_string(admin->GetLogin()); +structVal["password"] = xmlrpc_c::value_string(admin->GetPassword()); -const PRIV * priv = admin.GetPriv(); +const PRIV * priv = admin->GetPriv(); structVal["user_stat"] = xmlrpc_c::value_boolean(priv->userStat); structVal["user_conf"] = xmlrpc_c::value_boolean(priv->userConf); @@ -65,7 +66,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -102,7 +103,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -137,7 +138,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN loggedAdmin; +ADMIN * loggedAdmin; if (admins->FindAdmin(adminInfo.admin, &loggedAdmin)) { @@ -145,7 +146,7 @@ if (admins->FindAdmin(adminInfo.admin, &loggedAdmin)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(login, &admin)) { @@ -155,8 +156,8 @@ if (admins->FindAdmin(login, &admin)) ADMIN_CONF conf; -conf.priv = *admin.GetPriv(); -conf.password = admin.GetPassword(); +conf.priv = *admin->GetPriv(); +conf.password = admin->GetPassword(); conf.login = login; std::map structVal( diff --git a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp index fdb56048..a689cd99 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp @@ -1,8 +1,9 @@ -#include "info_methods.h" - #include + +#include "info_methods.h" #include "version.h" #include "rpcconfig.h" +#include "common.h" void METHOD_INFO::execute(xmlrpc_c::paramList const & paramList, xmlrpc_c::value * const retvalPtr) @@ -30,14 +31,14 @@ structVal["tariff"] = xmlrpc_c::value_int(2); structVal["users_num"] = xmlrpc_c::value_int(users->GetUserNum()); structVal["uname"] = xmlrpc_c::value_string(un); structVal["dir_num"] = xmlrpc_c::value_int(DIR_NUM); -structVal["day_fee"] = xmlrpc_c::value_int(settings->GetDayFee()); +structVal["day_fee"] = xmlrpc_c::value_int(dayFee); std::vector dirnameVal; for (int i = 0; i< DIR_NUM; i++) { - string dn2e; - Encode12str(dn2e, settings->GetDirName(i)); + std::string dn2e; + Encode12str(dn2e, dirNames[i]); dirnameVal.push_back(xmlrpc_c::value_string(dn2e)); } diff --git a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h index b381d16c..a404839b 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h @@ -1,6 +1,9 @@ #ifndef __INFO_METHODS_H__ #define __INFO_METHODS_H__ +#include +#include + #include #include @@ -16,10 +19,12 @@ class METHOD_INFO : public xmlrpc_c::method public: METHOD_INFO(TARIFFS * t, USERS * u, - const SETTINGS * s) + size_t df, + const std::vector & dn) : tariffs(t), users(u), - settings(s) + dayFee(df), + dirNames(dn) { } @@ -28,7 +33,8 @@ public: private: TARIFFS * tariffs; USERS * users; - const SETTINGS * settings; + size_t dayFee; + const std::vector & dirNames; }; class METHOD_LOGIN : public xmlrpc_c::method diff --git a/projects/stargazer/plugins/configuration/rpcconfig/messages_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/messages_methods.cpp index 281041e7..b64e6615 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/messages_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/messages_methods.cpp @@ -3,6 +3,9 @@ #include "rpcconfig.h" #include "stg_message.h" #include "utils.h" +#include "common.h" + +extern const volatile time_t stgTime; //------------------------------------------------------------------------------ @@ -78,7 +81,7 @@ message.header.lastSendTime = 0; std::vector::iterator lit; for (lit = logins.begin(); lit != logins.end(); ++lit) { - user_iter ui; + USER_PTR ui; if (users->FindByName(xmlrpc_c::value_string(*lit), &ui)) { printfd(__FILE__, "METHOD_MESSAGE_SEND::execute(): 'User '%s' not found'\n", std::string(xmlrpc_c::value_string(*lit)).c_str()); diff --git a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp index 7d764a7d..af741985 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp @@ -1,10 +1,14 @@ #include #include +#include +#include + #include "rpcconfig.h" #include "admin.h" #include "module_settings.h" +#include "../../../settings.h" #include "common.h" #include "info_methods.h" @@ -64,10 +68,10 @@ int RPC_CONFIG_SETTINGS::ParseSettings(const MODULE_SETTINGS & s) { int p; PARAM_VALUE pv; -vector::const_iterator pvi; +std::vector::const_iterator pvi; pv.param = "Port"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi == s.moduleParams.end()) { errorStr = "Parameter \'Port\' not found."; @@ -83,7 +87,7 @@ if (ParseIntInRange(pvi->value[0], 2, 65535, &p)) port = p; pv.param = "CookieTimeout"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi == s.moduleParams.end()) { cookieTimeout = 1800; // 30 * 60 @@ -101,7 +105,7 @@ else return 0; } -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return rpcc.GetPlugin(); } @@ -111,10 +115,10 @@ RPC_CONFIG::RPC_CONFIG() admins(NULL), tariffs(NULL), store(NULL), - stgSettings(NULL), rpcServer(NULL), running(false), - stopped(true) + stopped(true), + dayFee(0) { } @@ -134,6 +138,15 @@ if (ret) return ret; } +void RPC_CONFIG::SetStgSettings(const SETTINGS * settings) +{ + dayFee = settings->GetDayFee(); + dirNames.erase(dirNames.begin(), dirNames.end()); + for (size_t i = 0; i < DIR_NUM; ++i) { + dirNames.push_back(settings->GetDirName(i)); + } +} + int RPC_CONFIG::Start() { InitiateRegistry(); @@ -225,7 +238,7 @@ bool RPC_CONFIG::CheckAdmin(const std::string & login, const std::string & password, std::string * cookie) { -ADMIN admin; +ADMIN * admin = NULL; if (!admins->AdminCorrect(login, password, &admin)) { @@ -235,7 +248,7 @@ if (!admins->AdminCorrect(login, password, &admin)) ADMIN_INFO info; time(&info.accessTime); info.admin = login; -info.priviledges = *admin.GetPriv(); +info.priviledges = *admin->GetPriv(); *cookie = GetCookie(); cookies[*cookie] = info; @@ -278,7 +291,8 @@ void RPC_CONFIG::InitiateRegistry() xmlrpc_c::methodPtr const methodInfoPtr(new METHOD_INFO( tariffs, users, - stgSettings + dayFee, + dirNames )); rpcRegistry.addMethod("stargazer.info", methodInfoPtr); diff --git a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h index 34da6613..a597135a 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -62,7 +63,7 @@ public: void SetAdmins(ADMINS * a) { admins = a; } void SetStore(STORE * s) { store = s; } void SetTraffcounter(TRAFFCOUNTER *) {} - void SetStgSettings(const SETTINGS * s) { stgSettings = s; } + void SetStgSettings(const SETTINGS * s); void SetSettings(const MODULE_SETTINGS & s) { settings = s; } int ParseSettings(); @@ -95,7 +96,6 @@ private: TARIFFS * tariffs; STORE * store; MODULE_SETTINGS settings; - const SETTINGS * stgSettings; xmlrpc_c::registry rpcRegistry; xmlrpc_c::serverAbyss * rpcServer; bool running; @@ -103,6 +103,8 @@ private: pthread_t tid; std::map cookies; + size_t dayFee; + std::vector dirNames; }; #endif diff --git a/projects/stargazer/plugins/configuration/rpcconfig/tariffs_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/tariffs_methods.cpp index 16e25eb8..10985cce 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/tariffs_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/tariffs_methods.cpp @@ -32,9 +32,7 @@ if (!tariff) return; } -TARIFF_DATA td; - -tariff->GetTariffData(&td); +TARIFF_DATA td(tariff->GetTariffData()); TARIFF_HELPER helper(td); @@ -57,7 +55,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -73,9 +71,7 @@ if (!tariff) return; } -TARIFF_DATA td; - -tariff->GetTariffData(&td); +TARIFF_DATA td(tariff->GetTariffData()); TARIFF_HELPER helper(td); @@ -140,7 +136,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -172,7 +168,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp index 3c91d65a..a557b677 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp @@ -7,6 +7,8 @@ #include "utils.h" #include "common.h" +#include "../../../user_property.h" + //------------------------------------------------------------------------------ void USER_HELPER::GetUserInfo(xmlrpc_c::value * info, @@ -17,66 +19,66 @@ std::string enc; std::map structVal; structVal["result"] = xmlrpc_c::value_boolean(true); -structVal["login"] = xmlrpc_c::value_string(iter->GetLogin()); +structVal["login"] = xmlrpc_c::value_string(ptr->GetLogin()); if (!hidePassword) { - structVal["password"] = xmlrpc_c::value_string(iter->property.password.Get()); + structVal["password"] = xmlrpc_c::value_string(ptr->GetProperty().password.Get()); } else { structVal["password"] = xmlrpc_c::value_string("++++++++"); } -structVal["cash"] = xmlrpc_c::value_double(iter->property.cash.Get()); -structVal["freemb"] = xmlrpc_c::value_double(iter->property.freeMb.Get()); -structVal["credit"] = xmlrpc_c::value_double(iter->property.credit.Get()); +structVal["cash"] = xmlrpc_c::value_double(ptr->GetProperty().cash.Get()); +structVal["freemb"] = xmlrpc_c::value_double(ptr->GetProperty().freeMb.Get()); +structVal["credit"] = xmlrpc_c::value_double(ptr->GetProperty().credit.Get()); -if (iter->property.nextTariff.Get() != "") +if (ptr->GetProperty().nextTariff.Get() != "") { structVal["tariff"] = xmlrpc_c::value_string( - iter->property.tariffName.Get() + + ptr->GetProperty().tariffName.Get() + "/" + - iter->property.nextTariff.Get() + ptr->GetProperty().nextTariff.Get() ); } else { - structVal["tariff"] = xmlrpc_c::value_string(iter->property.tariffName.Get()); + structVal["tariff"] = xmlrpc_c::value_string(ptr->GetProperty().tariffName.Get()); } -structVal["note"] = xmlrpc_c::value_string(IconvString(iter->property.note, "KOI8-RU", "UTF-8")); +structVal["note"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().note, "KOI8-RU", "UTF-8")); -structVal["phone"] = xmlrpc_c::value_string(IconvString(iter->property.phone, "KOI8-RU", "UTF-8")); +structVal["phone"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().phone, "KOI8-RU", "UTF-8")); -structVal["address"] = xmlrpc_c::value_string(IconvString(iter->property.address, "KOI8-RU", "UTF-8")); +structVal["address"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().address, "KOI8-RU", "UTF-8")); -structVal["email"] = xmlrpc_c::value_string(IconvString(iter->property.email, "KOI8-RU", "UTF-8")); +structVal["email"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().email, "KOI8-RU", "UTF-8")); std::vector userdata; -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata0.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata1.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata2.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata3.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata4.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata5.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata6.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata7.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata8.Get(), "KOI8-RU", "UTF-8"))); -userdata.push_back(xmlrpc_c::value_string(IconvString(iter->property.userdata9.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata0.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata1.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata2.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata3.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata4.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata5.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata6.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata7.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata8.Get(), "KOI8-RU", "UTF-8"))); +userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperty().userdata9.Get(), "KOI8-RU", "UTF-8"))); structVal["userdata"] = xmlrpc_c::value_array(userdata); -structVal["name"] = xmlrpc_c::value_string(IconvString(iter->property.realName, "KOI8-RU", "UTF-8")); +structVal["name"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().realName, "KOI8-RU", "UTF-8")); -structVal["group"] = xmlrpc_c::value_string(IconvString(iter->property.group, "KOI8-RU", "UTF-8")); +structVal["group"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().group, "KOI8-RU", "UTF-8")); -structVal["status"] = xmlrpc_c::value_boolean(iter->GetConnected()); -structVal["aonline"] = xmlrpc_c::value_boolean(iter->property.alwaysOnline.Get()); -structVal["currip"] = xmlrpc_c::value_string(inet_ntostring(iter->GetCurrIP())); -structVal["pingtime"] = xmlrpc_c::value_int(iter->GetPingTime()); -structVal["ips"] = xmlrpc_c::value_string(iter->property.ips.Get().GetIpStr()); +structVal["status"] = xmlrpc_c::value_boolean(ptr->GetConnected()); +structVal["aonline"] = xmlrpc_c::value_boolean(ptr->GetProperty().alwaysOnline.Get()); +structVal["currip"] = xmlrpc_c::value_string(inet_ntostring(ptr->GetCurrIP())); +structVal["pingtime"] = xmlrpc_c::value_int(ptr->GetPingTime()); +structVal["ips"] = xmlrpc_c::value_string(ptr->GetProperty().ips.Get().GetIpStr()); std::map traffInfo; std::vector mu(DIR_NUM); @@ -88,10 +90,10 @@ DIR_TRAFF upload; DIR_TRAFF download; DIR_TRAFF supload; DIR_TRAFF sdownload; -download = iter->property.down.Get(); -upload = iter->property.up.Get(); -sdownload = iter->GetSessionUpload(); -supload = iter->GetSessionDownload(); +download = ptr->GetProperty().down.Get(); +upload = ptr->GetProperty().up.Get(); +sdownload = ptr->GetSessionUpload(); +supload = ptr->GetSessionDownload(); for (int j = 0; j < DIR_NUM; j++) { @@ -113,13 +115,13 @@ traffInfo["sd"] = xmlrpc_c::value_array(sd); structVal["traff"] = xmlrpc_c::value_struct(traffInfo); -structVal["down"] = xmlrpc_c::value_boolean(iter->property.disabled.Get()); -structVal["disableddetailstat"] = xmlrpc_c::value_boolean(iter->property.disabledDetailStat.Get()); -structVal["passive"] = xmlrpc_c::value_boolean(iter->property.passive.Get()); -structVal["lastcash"] = xmlrpc_c::value_double(iter->property.lastCashAdd.Get()); -structVal["lasttimecash"] = xmlrpc_c::value_int(iter->property.lastCashAddTime.Get()); -structVal["lastactivitytime"] = xmlrpc_c::value_int(iter->property.lastActivityTime.Get()); -structVal["creditexpire"] = xmlrpc_c::value_int(iter->property.creditExpire.Get()); +structVal["down"] = xmlrpc_c::value_boolean(ptr->GetProperty().disabled.Get()); +structVal["disableddetailstat"] = xmlrpc_c::value_boolean(ptr->GetProperty().disabledDetailStat.Get()); +structVal["passive"] = xmlrpc_c::value_boolean(ptr->GetProperty().passive.Get()); +structVal["lastcash"] = xmlrpc_c::value_double(ptr->GetProperty().lastCashAdd.Get()); +structVal["lasttimecash"] = xmlrpc_c::value_int(ptr->GetProperty().lastCashAddTime.Get()); +structVal["lastactivitytime"] = xmlrpc_c::value_int(ptr->GetProperty().lastActivityTime.Get()); +structVal["creditexpire"] = xmlrpc_c::value_int(ptr->GetProperty().creditExpire.Get()); *info = xmlrpc_c::value_struct(structVal); } @@ -127,7 +129,7 @@ structVal["creditexpire"] = xmlrpc_c::value_int(iter->property.creditExpire.Get( //------------------------------------------------------------------------------ bool USER_HELPER::SetUserInfo(const xmlrpc_c::value & info, - const ADMIN & admin, + const ADMIN * admin, const std::string & login, const STORE & store, TARIFFS * tariffs) @@ -141,8 +143,8 @@ std::map::iterator it; if ((it = structVal.find("password")) != structVal.end()) { std::string value(xmlrpc_c::value_string(it->second)); - if (iter->property.password.Get() != value) - if (!iter->property.password.Set(value, + if (ptr->GetProperty().password.Get() != value) + if (!ptr->GetProperty().password.Set(value, admin, login, &store)) @@ -153,7 +155,7 @@ if ((it = structVal.find("ips")) != structVal.end()) { USER_IPS ips; ips = StrToIPS(xmlrpc_c::value_string(it->second)); - if (!iter->property.ips.Set(ips, + if (!ptr->GetProperty().ips.Set(ips, admin, login, &store)) @@ -163,8 +165,8 @@ if ((it = structVal.find("ips")) != structVal.end()) if ((it = structVal.find("address")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); - if (iter->property.address.Get() != value) - if (!iter->property.address.Set(value, + if (ptr->GetProperty().address.Get() != value) + if (!ptr->GetProperty().address.Set(value, admin, login, &store)) @@ -174,8 +176,8 @@ if ((it = structVal.find("address")) != structVal.end()) if ((it = structVal.find("phone")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); - if (iter->property.phone.Get() != value) - if (!iter->property.phone.Set(value, + if (ptr->GetProperty().phone.Get() != value) + if (!ptr->GetProperty().phone.Set(value, admin, login, &store)) @@ -185,8 +187,8 @@ if ((it = structVal.find("phone")) != structVal.end()) if ((it = structVal.find("email")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); - if (iter->property.email.Get() != value) - if (!iter->property.email.Set(value, + if (ptr->GetProperty().email.Get() != value) + if (!ptr->GetProperty().email.Set(value, admin, login, &store)) @@ -196,8 +198,8 @@ if ((it = structVal.find("email")) != structVal.end()) if ((it = structVal.find("cash")) != structVal.end()) { double value(xmlrpc_c::value_double(it->second)); - if (iter->property.cash.Get() != value) - if (!iter->property.cash.Set(value, + if (ptr->GetProperty().cash.Get() != value) + if (!ptr->GetProperty().cash.Set(value, admin, login, &store)) @@ -207,8 +209,8 @@ if ((it = structVal.find("cash")) != structVal.end()) if ((it = structVal.find("creditexpire")) != structVal.end()) { time_t value(xmlrpc_c::value_int(it->second)); - if (iter->property.creditExpire.Get() != value) - if (!iter->property.creditExpire.Set(value, + if (ptr->GetProperty().creditExpire.Get() != value) + if (!ptr->GetProperty().creditExpire.Set(value, admin, login, &store)) @@ -218,8 +220,8 @@ if ((it = structVal.find("creditexpire")) != structVal.end()) if ((it = structVal.find("credit")) != structVal.end()) { double value(xmlrpc_c::value_double(it->second)); - if (iter->property.credit.Get() != value) - if (!iter->property.credit.Set(value, + if (ptr->GetProperty().credit.Get() != value) + if (!ptr->GetProperty().credit.Set(value, admin, login, &store)) @@ -229,8 +231,8 @@ if ((it = structVal.find("credit")) != structVal.end()) if ((it = structVal.find("freemb")) != structVal.end()) { double value(xmlrpc_c::value_double(it->second)); - if (iter->property.freeMb.Get() != value) - if (!iter->property.freeMb.Set(value, + if (ptr->GetProperty().freeMb.Get() != value) + if (!ptr->GetProperty().freeMb.Set(value, admin, login, &store)) @@ -240,8 +242,8 @@ if ((it = structVal.find("freemb")) != structVal.end()) if ((it = structVal.find("down")) != structVal.end()) { bool value(xmlrpc_c::value_boolean(it->second)); - if (iter->property.disabled.Get() != value) - if (!iter->property.disabled.Set(value, + if (ptr->GetProperty().disabled.Get() != value) + if (!ptr->GetProperty().disabled.Set(value, admin, login, &store)) @@ -251,8 +253,8 @@ if ((it = structVal.find("down")) != structVal.end()) if ((it = structVal.find("passive")) != structVal.end()) { bool value(xmlrpc_c::value_boolean(it->second)); - if (iter->property.passive.Get() != value) - if (!iter->property.passive.Set(value, + if (ptr->GetProperty().passive.Get() != value) + if (!ptr->GetProperty().passive.Set(value, admin, login, &store)) @@ -262,8 +264,8 @@ if ((it = structVal.find("passive")) != structVal.end()) if ((it = structVal.find("aonline")) != structVal.end()) { bool value(xmlrpc_c::value_boolean(it->second)); - if (iter->property.alwaysOnline.Get() != value) - if (!iter->property.alwaysOnline.Set(value, + if (ptr->GetProperty().alwaysOnline.Get() != value) + if (!ptr->GetProperty().alwaysOnline.Set(value, admin, login, &store)) @@ -273,8 +275,8 @@ if ((it = structVal.find("aonline")) != structVal.end()) if ((it = structVal.find("disableddetailstat")) != structVal.end()) { bool value(xmlrpc_c::value_boolean(it->second)); - if (iter->property.disabledDetailStat.Get() != value) - if (!iter->property.disabledDetailStat.Set(value, + if (ptr->GetProperty().disabledDetailStat.Get() != value) + if (!ptr->GetProperty().disabledDetailStat.Set(value, admin, login, &store)) @@ -284,8 +286,8 @@ if ((it = structVal.find("disableddetailstat")) != structVal.end()) if ((it = structVal.find("name")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); - if (iter->property.realName.Get() != value) - if (!iter->property.realName.Set(value, + if (ptr->GetProperty().realName.Get() != value) + if (!ptr->GetProperty().realName.Set(value, admin, login, &store)) @@ -295,8 +297,8 @@ if ((it = structVal.find("name")) != structVal.end()) if ((it = structVal.find("group")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); - if (iter->property.group.Get() != value) - if (!iter->property.group.Set(value, + if (ptr->GetProperty().group.Get() != value) + if (!ptr->GetProperty().group.Set(value, admin, login, &store)) @@ -306,8 +308,8 @@ if ((it = structVal.find("group")) != structVal.end()) if ((it = structVal.find("note")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); - if (iter->property.note.Get() != value) - if (!iter->property.note.Set(value, + if (ptr->GetProperty().note.Get() != value) + if (!ptr->GetProperty().note.Set(value, admin, login, &store)) @@ -317,16 +319,16 @@ if ((it = structVal.find("note")) != structVal.end()) if ((it = structVal.find("userdata")) != structVal.end()) { std::vector *> userdata; - userdata.push_back(iter->property.userdata0.GetPointer()); - userdata.push_back(iter->property.userdata1.GetPointer()); - userdata.push_back(iter->property.userdata2.GetPointer()); - userdata.push_back(iter->property.userdata3.GetPointer()); - userdata.push_back(iter->property.userdata4.GetPointer()); - userdata.push_back(iter->property.userdata5.GetPointer()); - userdata.push_back(iter->property.userdata6.GetPointer()); - userdata.push_back(iter->property.userdata7.GetPointer()); - userdata.push_back(iter->property.userdata8.GetPointer()); - userdata.push_back(iter->property.userdata9.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata0.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata1.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata2.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata3.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata4.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata5.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata6.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata7.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata8.GetPointer()); + userdata.push_back(ptr->GetProperty().userdata9.GetPointer()); std::vector udata( xmlrpc_c::value_array(it->second).vectorValueValue() @@ -351,7 +353,7 @@ if ((it = structVal.find("traff")) != structVal.end()) ); DIR_TRAFF dtData; - dtData = iter->property.up.Get(); + dtData = ptr->GetProperty().up.Get(); if ((it = traff.find("mu")) != traff.end()) { std::vector data(xmlrpc_c::value_array(it->second).vectorValueValue()); @@ -364,13 +366,13 @@ if ((it = structVal.find("traff")) != structVal.end()) else dtData[i] = value; } - if (!iter->property.up.Set(dtData, + if (!ptr->GetProperty().up.Set(dtData, admin, login, &store)) return true; } - dtData = iter->property.down.Get(); + dtData = ptr->GetProperty().down.Get(); if ((it = traff.find("md")) != traff.end()) { std::vector data(xmlrpc_c::value_array(it->second).vectorValueValue()); @@ -383,7 +385,7 @@ if ((it = structVal.find("traff")) != structVal.end()) else dtData[i] = value; } - if (!iter->property.down.Set(dtData, + if (!ptr->GetProperty().down.Set(dtData, admin, login, &store)) @@ -403,8 +405,8 @@ if ((it = structVal.find("tariff")) != structVal.end()) } if (tariffs->FindByName(tariff)) - if (iter->property.tariffName.Get() != tariff) - if (!iter->property.tariffName.Set(tariff, + if (ptr->GetProperty().tariffName.Get() != tariff) + if (!ptr->GetProperty().tariffName.Set(tariff, admin, login, &store)) @@ -412,8 +414,8 @@ if ((it = structVal.find("tariff")) != structVal.end()) if (nextTariff != "" && tariffs->FindByName(nextTariff)) - if (iter->property.nextTariff.Get() != nextTariff) - if (!iter->property.nextTariff.Set(tariff, + if (ptr->GetProperty().nextTariff.Get() != nextTariff) + if (!ptr->GetProperty().nextTariff.Set(tariff, admin, login, &store)) diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h index 63d1da07..ddc78444 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h @@ -14,20 +14,20 @@ class TARIFFS; class USER_HELPER { public: - USER_HELPER(user_iter & it) - : iter(it) + USER_HELPER(USER_PTR & p) + : ptr(p) { } void GetUserInfo(xmlrpc_c::value * info, bool hidePassword = false); bool SetUserInfo(const xmlrpc_c::value & info, - const ADMIN & admin, + const ADMIN * admin, const std::string & login, const STORE & store, TARIFFS * tariffs); private: - user_iter & iter; + USER_PTR & ptr; }; #endif diff --git a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp index 35166c81..d16d883f 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp @@ -5,6 +5,7 @@ #include "users.h" #include "admins.h" #include "tariffs.h" +#include "../../../user_property.h" #include "rpcconfig.h" #include "user_helper.h" @@ -32,7 +33,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -70,7 +71,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin = NULL; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -78,7 +79,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -114,7 +115,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -122,7 +123,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -158,7 +159,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) bool hidePassword = !adminInfo.priviledges.userConf || !adminInfo.priviledges.userPasswd; -user_iter u; +USER_PTR u; int h = users->OpenSearch(); if (!h) @@ -206,7 +207,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -214,7 +215,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -259,7 +260,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -267,7 +268,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -275,10 +276,10 @@ if (users->FindByName(login, &u)) return; } -double cash = u->property.cash.Get(); +double cash = u->GetProperty().cash.Get(); cash += amount; -if (!u->property.cash.Set(cash, admin, login, store, comment)) +if (!u->GetProperty().cash.Set(cash, admin, login, store, comment)) { *retvalPtr = xmlrpc_c::value_boolean(false); return; @@ -309,7 +310,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -317,7 +318,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -325,7 +326,7 @@ if (users->FindByName(login, &u)) return; } -if (!u->property.cash.Set(cash, admin, login, store, comment)) +if (!u->GetProperty().cash.Set(cash, admin, login, store, comment)) { *retvalPtr = xmlrpc_c::value_boolean(false); return; @@ -357,7 +358,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -ADMIN admin; +ADMIN * admin; if (admins->FindAdmin(adminInfo.admin, &admin)) { @@ -365,7 +366,7 @@ if (admins->FindAdmin(adminInfo.admin, &admin)) return; } -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { @@ -377,10 +378,10 @@ if (tariffs->FindByName(tariff)) { if (delayed) { - if (u->property.nextTariff.Set(tariff, - admin, - login, - store)) + if (u->GetProperty().nextTariff.Set(tariff, + admin, + login, + store)) { u->WriteConf(); *retvalPtr = xmlrpc_c::value_boolean(true); @@ -389,10 +390,10 @@ if (tariffs->FindByName(tariff)) } else { - if (u->property.tariffName.Set(tariff, - admin, - login, - store)) + if (u->GetProperty().tariffName.Set(tariff, + admin, + login, + store)) { u->WriteConf(); *retvalPtr = xmlrpc_c::value_boolean(true); @@ -442,7 +443,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) std::vector ips; -user_iter u; +USER_PTR u; int handle = users->OpenSearch(); if (!handle)