]> git.stg.codes - stg.git/commitdiff
Public interfaces: part 4
authorMaksym Mamontov <madf@madf.info>
Fri, 21 Feb 2020 16:54:23 +0000 (18:54 +0200)
committerMaksym Mamontov <madf@madf.info>
Fri, 21 Feb 2020 16:54:23 +0000 (18:54 +0200)
16 files changed:
stargazer/plugins/configuration/rpcconfig/admins_methods.cpp
stargazer/plugins/configuration/rpcconfig/admins_methods.h
stargazer/plugins/configuration/rpcconfig/info_methods.cpp
stargazer/plugins/configuration/rpcconfig/info_methods.h
stargazer/plugins/configuration/rpcconfig/messages_methods.cpp
stargazer/plugins/configuration/rpcconfig/messages_methods.h
stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
stargazer/plugins/configuration/rpcconfig/rpcconfig.h
stargazer/plugins/configuration/rpcconfig/tariff_helper.cpp
stargazer/plugins/configuration/rpcconfig/tariff_helper.h
stargazer/plugins/configuration/rpcconfig/tariffs_methods.cpp
stargazer/plugins/configuration/rpcconfig/tariffs_methods.h
stargazer/plugins/configuration/rpcconfig/user_helper.cpp
stargazer/plugins/configuration/rpcconfig/user_helper.h
stargazer/plugins/configuration/rpcconfig/users_methods.cpp
stargazer/plugins/configuration/rpcconfig/users_methods.h

index 643f6e74561b07148684da47843eb12c17d230bb..a6ed8f1a314e30d23df4114ecbe0fef8a20cf55e 100644 (file)
@@ -1,9 +1,14 @@
-#include <ostream> // xmlrpc-c devs have missed something :)
-
-#include "stg/common.h"
 #include "admins_methods.h"
 #include "rpcconfig.h"
 
+#include "stg/common.h"
+
+#include "stg/admins.h"
+#include "stg/admin.h"
+#include "stg/admin_conf.h"
+
+#include <ostream> // xmlrpc-c devs have missed something :)
+
 //------------------------------------------------------------------------------
 
 void METHOD_ADMIN_GET::execute(xmlrpc_c::paramList const & paramList,
@@ -23,7 +28,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(login, &admin))
     {
@@ -36,7 +41,7 @@ structVal["result"] = xmlrpc_c::value_boolean(true);
 structVal["login"] = xmlrpc_c::value_string(admin->GetLogin());
 structVal["password"] = xmlrpc_c::value_string(admin->GetPassword());
 
-const PRIV * priv = admin->GetPriv();
+const auto priv = admin->GetPriv();
 
 structVal["user_stat"] = xmlrpc_c::value_boolean(priv->userStat);
 structVal["user_conf"] = xmlrpc_c::value_boolean(priv->userConf);
@@ -67,7 +72,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -103,7 +108,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -138,7 +143,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * loggedAdmin;
+STG::Admin * loggedAdmin;
 
 if (admins->Find(adminInfo.admin, &loggedAdmin))
     {
@@ -146,7 +151,7 @@ if (admins->Find(adminInfo.admin, &loggedAdmin))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(login, &admin))
     {
@@ -154,7 +159,7 @@ if (admins->Find(login, &admin))
     return;
     }
 
-ADMIN_CONF conf;
+STG::AdminConf conf;
 
 conf.priv = *admin->GetPriv();
 conf.password = admin->GetPassword();
@@ -233,7 +238,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN_CONF ac;
+STG::AdminConf ac;
 int h = admins->OpenSearch();
 
 while (admins->SearchNext(h, &ac) == 0)
index e97757186da8fa7503512808a296c2f3073cf5b1..43c8073a10ad894400e4d5e48d1ffccfce5be214 100644 (file)
@@ -1,18 +1,21 @@
-#ifndef __ADMINS_METHODS_H__
-#define __ADMINS_METHODS_H__
+#pragma once
 
 #include <xmlrpc-c/base.hpp>
 #include <xmlrpc-c/registry.hpp>
 
-#include "stg/admins.h"
-#include "stg/admin.h"
+namespace STG
+{
+
+struct Admins;
+
+}
 
 class RPC_CONFIG;
 
 class METHOD_ADMIN_GET : public xmlrpc_c::method {
 public:
     METHOD_ADMIN_GET(RPC_CONFIG * c,
-                     ADMINS * a)
+                     STG::Admins * a)
         : config(c),
           admins(a)
     {
@@ -26,13 +29,13 @@ private:
     METHOD_ADMIN_GET & operator=(const METHOD_ADMIN_GET & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
+    STG::Admins * admins;
 };
 
 class METHOD_ADMIN_ADD : public xmlrpc_c::method {
 public:
     METHOD_ADMIN_ADD(RPC_CONFIG * c,
-                     ADMINS * a)
+                     STG::Admins * a)
         : config(c),
           admins(a)
     {
@@ -46,13 +49,13 @@ private:
     METHOD_ADMIN_ADD & operator=(const METHOD_ADMIN_ADD & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
+    STG::Admins * admins;
 };
 
 class METHOD_ADMIN_DEL : public xmlrpc_c::method {
 public:
     METHOD_ADMIN_DEL(RPC_CONFIG * c,
-                     ADMINS * a)
+                     STG::Admins * a)
         : config(c),
           admins(a)
     {
@@ -66,13 +69,13 @@ private:
     METHOD_ADMIN_DEL & operator=(const METHOD_ADMIN_DEL & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
+    STG::Admins * admins;
 };
 
 class METHOD_ADMIN_CHG : public xmlrpc_c::method {
 public:
     METHOD_ADMIN_CHG(RPC_CONFIG * c,
-                     ADMINS * a)
+                     STG::Admins * a)
         : config(c),
           admins(a)
     {
@@ -86,13 +89,13 @@ private:
     METHOD_ADMIN_CHG & operator=(const METHOD_ADMIN_CHG & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
+    STG::Admins * admins;
 };
 
 class METHOD_ADMINS_GET : public xmlrpc_c::method {
 public:
     METHOD_ADMINS_GET(RPC_CONFIG * c,
-                      ADMINS * a)
+                      STG::Admins * a)
         : config(c),
           admins(a)
     {
@@ -106,7 +109,5 @@ private:
     METHOD_ADMINS_GET & operator=(const METHOD_ADMINS_GET & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
+    STG::Admins * admins;
 };
-
-#endif
index 7d3afacaecaf1134682bb99c2bc3839f350d6bea..e0c371cde1db11ada4ca53000fd59833466b1a02 100644 (file)
@@ -1,11 +1,15 @@
-#include <sys/utsname.h>
-
-#include <ostream> // xmlrpc-c devs have missed something :)
+#include "info_methods.h"
+#include "rpcconfig.h"
 
+#include "stg/users.h"
+#include "stg/tariffs.h"
 #include "stg/version.h"
 #include "stg/common.h"
-#include "info_methods.h"
-#include "rpcconfig.h"
+#include "stg/const.h"
+
+#include <ostream> // xmlrpc-c devs have missed something :)
+
+#include <sys/utsname.h>
 
 void METHOD_INFO::execute(xmlrpc_c::paramList const & paramList,
                           xmlrpc_c::value *   const   retvalPtr)
index f781b9be2700848d0fe9acfadd724bc435a78192..709a0666ad6d22b37d9e536e62adab68731a9450 100644 (file)
@@ -1,24 +1,28 @@
-#ifndef __INFO_METHODS_H__
-#define __INFO_METHODS_H__
+#pragma once
+
+#include <xmlrpc-c/base.hpp>
+#include <xmlrpc-c/registry.hpp>
 
 #include <string>
 #include <vector>
 
-#include <xmlrpc-c/base.hpp>
-#include <xmlrpc-c/registry.hpp>
+namespace STG
+{
 
-#include "stg/users.h"
-#include "stg/tariffs.h"
+struct Settings;
+struct Users;
+struct Tariffs;
+
+}
 
 // Forward declaration
 class RPC_CONFIG;
-class SETTINGS;
 
 class METHOD_INFO : public xmlrpc_c::method
 {
 public:
-    METHOD_INFO(TARIFFS * t,
-                USERS * u,
+    METHOD_INFO(STG::Tariffs * t,
+                STG::Users * u,
                 size_t df,
                 const std::vector<std::string> & dn)
         : tariffs(t),
@@ -35,8 +39,8 @@ private:
     METHOD_INFO(const METHOD_INFO & rvalue);
     METHOD_INFO & operator=(const METHOD_INFO & rvalue);
 
-    TARIFFS * tariffs;
-    USERS * users;
+    STG::Tariffs * tariffs;
+    STG::Users * users;
     size_t dayFee;
     const std::vector<std::string> & dirNames;
 };
@@ -76,5 +80,3 @@ private:
 
     RPC_CONFIG * config;
 };
-
-#endif
index 917961484cfe5014356e11fe5af8b272605dd052..854b2767262b7a3f1bff89f10fdf660f0bf9c4b8 100644 (file)
@@ -1,9 +1,12 @@
-#include <ostream> // xmlrpc-c devs have missed something :)
+#include "messages_methods.h"
+#include "rpcconfig.h"
 
+#include "stg/users.h"
+#include "stg/user.h"
 #include "stg/message.h"
 #include "stg/common.h"
-#include "messages_methods.h"
-#include "rpcconfig.h"
+
+#include <ostream> // xmlrpc-c devs have missed something :)
 
 extern volatile time_t stgTime;
 
@@ -25,7 +28,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-STG_MSG message;
+STG::Message message;
 
 std::map<std::string, xmlrpc_c::value>::iterator it;
 
@@ -81,7 +84,8 @@ message.header.lastSendTime = 0;
 std::vector<xmlrpc_c::value>::iterator lit;
 for (lit = logins.begin(); lit != logins.end(); ++lit)
     {
-    USER_PTR ui;
+    using UserPtr = STG::User*;
+    UserPtr 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());
index 7188d0bf97f6233a8541391f459614831e3c93f8..210ef693029f446156510d7c39ff0ee8e007695a 100644 (file)
@@ -1,17 +1,21 @@
-#ifndef __MESSAGES_METHODS_H__
-#define __MESSAGES_METHODS_H__
+#pragma once
 
 #include <xmlrpc-c/base.hpp>
 #include <xmlrpc-c/registry.hpp>
 
-#include "stg/users.h"
+namespace STG
+{
+
+struct Users;
+
+}
 
 class RPC_CONFIG;
 
 class METHOD_MESSAGE_SEND : public xmlrpc_c::method {
 public:
     METHOD_MESSAGE_SEND(RPC_CONFIG * c,
-                     USERS * u)
+                     STG::Users * u)
         : config(c),
           users(u)
     {
@@ -25,7 +29,5 @@ private:
     METHOD_MESSAGE_SEND & operator=(const METHOD_MESSAGE_SEND & rvalue);
 
     RPC_CONFIG * config;
-    USERS * users;
+    STG::Users * users;
 };
-
-#endif
index 8bd0242dbc6b74047ca8378ad4a76516a96477c5..629c7c37127bb183d83767a537381bc2a547290e 100644 (file)
@@ -1,15 +1,17 @@
-
 #include "rpcconfig.h"
+
 #include "info_methods.h"
 #include "users_methods.h"
 #include "tariffs_methods.h"
 #include "admins_methods.h"
 #include "messages_methods.h"
 
-#include "stg/common.h"
+#include "stg/admins.h"
 #include "stg/admin.h"
 #include "stg/module_settings.h"
 #include "stg/settings.h"
+#include "stg/common.h"
+#include "stg/const.h"
 
 #include <algorithm>
 #include <vector>
@@ -31,11 +33,11 @@ RPC_CONFIG_SETTINGS::RPC_CONFIG_SETTINGS()
 {
 }
 
-int RPC_CONFIG_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
+int RPC_CONFIG_SETTINGS::ParseSettings(const STG::ModuleSettings & s)
 {
-PARAM_VALUE pv;
+STG::ParamValue pv;
 pv.param = "Port";
-std::vector<PARAM_VALUE>::const_iterator pvi;
+std::vector<STG::ParamValue>::const_iterator pvi;
 pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv);
 if (pvi == s.moduleParams.end() || pvi->value.empty())
     {
@@ -71,7 +73,7 @@ else
 return 0;
 }
 
-extern "C" Plugin* GetPlugin()
+extern "C" STG::Plugin* GetPlugin()
 {
     static RPC_CONFIG plugin;
     return &plugin;
@@ -87,7 +89,7 @@ RPC_CONFIG::RPC_CONFIG()
       running(false),
       stopped(true),
       dayFee(0),
-      logger(PluginLogger::get("conf_rpc"))
+      logger(STG::PluginLogger::get("conf_rpc"))
 {
 }
 
@@ -107,7 +109,7 @@ if (ret)
 return ret;
 }
 
-void RPC_CONFIG::SetStgSettings(const SETTINGS * s)
+void RPC_CONFIG::SetStgSettings(const STG::Settings * s)
 {
     dayFee = s->GetDayFee();
     dirNames.erase(dirNames.begin(), dirNames.end());
@@ -255,7 +257,7 @@ bool RPC_CONFIG::CheckAdmin(const std::string & login,
                             const std::string & password,
                             std::string * cookie)
 {
-ADMIN * admin = NULL;
+STG::Admin * admin = NULL;
 
 if (!admins->Correct(login, password, &admin))
     {
index e45ed4f1f82fccf63ebf78fda08731398bb59341..e7c800d5a9c6f640d6510bb9f2aad3b793812c43 100644 (file)
@@ -1,7 +1,13 @@
-#ifndef __RPC_CONFIG_H__
-#define __RPC_CONFIG_H__
+#pragma once
 
-#include <pthread.h>
+#include "stg/plugin.h"
+#include "stg/admin_conf.h"
+#include "stg/module_settings.h"
+#include "stg/logger.h"
+
+#include <xmlrpc-c/base.hpp>
+#include <xmlrpc-c/registry.hpp>
+#include <xmlrpc-c/server_abyss.hpp>
 
 #include <ctime>
 #include <cstdint>
 #include <map>
 #include <vector>
 
-#include <xmlrpc-c/base.hpp>
-#include <xmlrpc-c/registry.hpp>
-#include <xmlrpc-c/server_abyss.hpp>
-
-#include "stg/plugin.h"
-#include "stg/admin_conf.h"
-#include "stg/module_settings.h"
-#include "stg/logger.h"
+#include <pthread.h>
 
 #define RPC_CONFIG_VERSION "Stargazer RPC v. 0.2"
 
-class ADMINS;
-class TARIFFS;
-class USERS;
-class STORE;
+namespace STG
+{
+
+struct Admins;
+struct Tariffs;
+struct Users;
+struct Store;
+
+}
 
 class RPC_CONFIG_SETTINGS
 {
@@ -31,7 +35,7 @@ public:
                          RPC_CONFIG_SETTINGS();
     virtual              ~RPC_CONFIG_SETTINGS() {}
     const std::string &  GetStrError() const { return errorStr; }
-    int                  ParseSettings(const MODULE_SETTINGS & s);
+    int                  ParseSettings(const STG::ModuleSettings & s);
     uint16_t             GetPort() const { return port; }
     double               GetCookieTimeout() const { return cookieTimeout; }
 
@@ -51,32 +55,32 @@ struct ADMIN_INFO
 
     std::string admin;
     time_t      accessTime;
-    PRIV        priviledges;
+    STG::Priv        priviledges;
 };
 
-class RPC_CONFIG : public PLUGIN
+class RPC_CONFIG : public STG::Plugin
 {
 public:
     RPC_CONFIG();
-    virtual ~RPC_CONFIG();
-
-    void                SetUsers(USERS * u) { users = u; }
-    void                SetTariffs(TARIFFS * t) { tariffs = t; }
-    void                SetAdmins(ADMINS * a) { admins = a; }
-    void                SetStore(STORE * s) { store = s; }
-    void                SetStgSettings(const SETTINGS * s);
-    void                SetSettings(const MODULE_SETTINGS & s) { settings = s; }
-    int                 ParseSettings();
-
-    int                 Start();
-    int                 Stop();
-    int                 Reload(const MODULE_SETTINGS & /*ms*/) { return 0; }
-    bool                IsRunning() { return running && !stopped; }
-
-    const std::string & GetStrError() const { return errorStr; }
-    std::string         GetVersion() const { return RPC_CONFIG_VERSION; }
-    uint16_t            GetStartPosition() const { return 20; }
-    uint16_t            GetStopPosition() const { return 20; }
+    ~RPC_CONFIG() override;
+
+    void                SetUsers(STG::Users * u) override { users = u; }
+    void                SetTariffs(STG::Tariffs * t) override { tariffs = t; }
+    void                SetAdmins(STG::Admins * a) override { admins = a; }
+    void                SetStore(STG::Store * s) override { store = s; }
+    void                SetStgSettings(const STG::Settings * s) override;
+    void                SetSettings(const STG::ModuleSettings & s) override { settings = s; }
+    int                 ParseSettings() override;
+
+    int                 Start() override;
+    int                 Stop() override;
+    int                 Reload(const STG::ModuleSettings & /*ms*/) override { return 0; }
+    bool                IsRunning() override { return running && !stopped; }
+
+    const std::string & GetStrError() const override { return errorStr; }
+    std::string         GetVersion() const override { return RPC_CONFIG_VERSION; }
+    uint16_t            GetStartPosition() const override { return 20; }
+    uint16_t            GetStopPosition() const override { return 20; }
 
     bool                GetAdminInfo(const std::string & cookie,
                                      ADMIN_INFO * info);
@@ -95,11 +99,11 @@ private:
 
     mutable std::string     errorStr;
     RPC_CONFIG_SETTINGS     rpcConfigSettings;
-    USERS *                 users;
-    ADMINS *                admins;
-    TARIFFS *               tariffs;
-    STORE *                 store;
-    MODULE_SETTINGS         settings;
+    STG::Users *                 users;
+    STG::Admins *                admins;
+    STG::Tariffs *               tariffs;
+    STG::Store *                 store;
+    STG::ModuleSettings         settings;
     int                     fd;
     xmlrpc_c::registry      rpcRegistry;
     xmlrpc_c::serverAbyss * rpcServer;
@@ -110,7 +114,5 @@ private:
              ADMIN_INFO>    cookies;
     size_t                  dayFee;
     std::vector<std::string> dirNames;
-    PLUGIN_LOGGER           logger;
+    STG::PluginLogger           logger;
 };
-
-#endif
index 7c023e25fd37c3a4bf96abddab964e2d3b652173..a6ec1feb89aa5744146e3c7cc726a57743e1e5ae 100644 (file)
@@ -1,7 +1,10 @@
-#include <ostream> // xmlrpc-c devs have missed something :)
-
 #include "tariff_helper.h"
+
+#include "stg/tariff_conf.h"
 #include "stg/common.h"
+#include "stg/const.h"
+
+#include <ostream> // xmlrpc-c devs have missed something :)
 
 void TARIFF_HELPER::GetTariffInfo(xmlrpc_c::value * info) const
 {
@@ -13,8 +16,8 @@ structVal["fee"] = xmlrpc_c::value_double(data.tariffConf.fee);
 structVal["freemb"] = xmlrpc_c::value_double(data.tariffConf.free);
 structVal["passivecost"] = xmlrpc_c::value_double(data.tariffConf.passiveCost);
 structVal["traffType"] = xmlrpc_c::value_int(data.tariffConf.traffType);
-structVal["period"] = xmlrpc_c::value_string(TARIFF::PeriodToString(data.tariffConf.period));
-structVal["changePolicy"] = xmlrpc_c::value_string(TARIFF::ChangePolicyToString(data.tariffConf.changePolicy));
+structVal["period"] = xmlrpc_c::value_string(STG::Tariff::toString(data.tariffConf.period));
+structVal["changePolicy"] = xmlrpc_c::value_string(STG::Tariff::toString(data.tariffConf.changePolicy));
 structVal["changePolicyTimeout"] = xmlrpc_c::value_string(formatTime(data.tariffConf.changePolicyTimeout));
 
 std::vector<xmlrpc_c::value> prices(DIR_NUM);
@@ -66,17 +69,17 @@ if ((it = structVal.find("passivecost")) != structVal.end())
 
 if ((it = structVal.find("traffType")) != structVal.end())
     {
-    data.tariffConf.traffType = static_cast<TARIFF::TRAFF_TYPE>(xmlrpc_c::value_int(it->second).cvalue());
+    data.tariffConf.traffType = static_cast<STG::Tariff::TraffType>(xmlrpc_c::value_int(it->second).cvalue());
     }
 
 if ((it = structVal.find("period")) != structVal.end())
     {
-    data.tariffConf.period = TARIFF::StringToPeriod(xmlrpc_c::value_string(it->second));
+    data.tariffConf.period = STG::Tariff::parsePeriod(xmlrpc_c::value_string(it->second));
     }
 
 if ((it = structVal.find("changePolicy")) != structVal.end())
     {
-    data.tariffConf.changePolicy = TARIFF::StringToChangePolicy(xmlrpc_c::value_string(it->second));
+    data.tariffConf.changePolicy = STG::Tariff::parseChangePolicy(xmlrpc_c::value_string(it->second));
     }
 
 if ((it = structVal.find("changePolicyTimeout")) != structVal.end())
index a30b992a0069d646e2d0b89e75d4387e8fbdc48f..9f68a74d2a486cae416d295e889a9b73e1ffdde9 100644 (file)
@@ -1,22 +1,23 @@
-#ifndef __TARIFF_HELPER_H__
-#define __TARIFF_HELPER_H__
+#pragma once
 
 #include <xmlrpc-c/base.hpp>
-#include "stg/tariff_conf.h"
+
+namespace STG
+{
+
+struct TariffData;
+
+}
 
 class TARIFF_HELPER
 {
 public:
-    explicit TARIFF_HELPER(TARIFF_DATA & td)
+    explicit TARIFF_HELPER(STG::TariffData & td)
         : data(td)
     {}
 
     void GetTariffInfo(xmlrpc_c::value * info) const;
     bool SetTariffInfo(const xmlrpc_c::value & info);
 private:
-    TARIFF_DATA & data;
+    STG::TariffData & data;
 };
-
-#endif
-
-
index bbb0a5be704ce7f3474475aef15f4bcf973c53b4..4a912cae31ff4b9f8ffcd978fdd970e1f4e6ffc5 100644 (file)
@@ -3,7 +3,10 @@
 #include "tariffs_methods.h"
 #include "rpcconfig.h"
 #include "tariff_helper.h"
+
 #include "stg/tariffs.h"
+#include "stg/tariff.h"
+#include "stg/tariff_conf.h"
 #include "stg/users.h"
 #include "stg/admins.h"
 #include "stg/admin.h"
@@ -25,7 +28,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-const TARIFF * tariff = tariffs->FindByName(name);
+const auto tariff = tariffs->FindByName(name);
 
 if (!tariff)
     {
@@ -34,7 +37,7 @@ if (!tariff)
     return;
     }
 
-TARIFF_DATA td(tariff->GetTariffData());
+auto td = tariff->GetTariffData();
 
 TARIFF_HELPER helper(td);
 
@@ -57,7 +60,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -65,7 +68,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-const TARIFF * tariff = tariffs->FindByName(name);
+const auto tariff = tariffs->FindByName(name);
 
 if (!tariff)
     {
@@ -73,7 +76,7 @@ if (!tariff)
     return;
     }
 
-TARIFF_DATA td(tariff->GetTariffData());
+auto td = tariff->GetTariffData();
 
 TARIFF_HELPER helper(td);
 
@@ -107,13 +110,13 @@ if (config->GetAdminInfo(cookie, &adminInfo))
 std::vector<xmlrpc_c::value> tariffsInfo;
 
 
-std::vector<TARIFF_DATA> dataList;
+std::vector<STG::TariffData> dataList;
 tariffs->GetTariffsData(&dataList);
 auto it = dataList.begin();
 for (; it != dataList.end(); ++it)
     {
     xmlrpc_c::value info;
-    TARIFF_DATA td(*it); // 'cause TARIFF_HELPER work in both ways and take not const referense
+    auto td = *it; // 'cause TARIFF_HELPER work in both ways and take not const referense
     TARIFF_HELPER helper(td);
     helper.GetTariffInfo(&info);
     tariffsInfo.push_back(info);
@@ -137,7 +140,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -169,7 +172,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
index d43840d0db2d7cb6534d4647e5c1306f26c2bb2c..4f4d6680cdf8c90b5fd266edea961de83e1e9e2b 100644 (file)
@@ -1,18 +1,23 @@
-#ifndef __TARIFFS_METHODS_H__
-#define __TARIFFS_METHODS_H__
+#pragma once
 
 #include <xmlrpc-c/base.hpp>
 #include <xmlrpc-c/registry.hpp>
 
+namespace STG
+{
+
+struct Tariffs;
+struct Users;
+struct Admins;
+
+}
+
 class RPC_CONFIG;
-class TARIFFS;
-class USERS;
-class ADMINS;
 
 class METHOD_TARIFF_GET : public xmlrpc_c::method {
 public:
     METHOD_TARIFF_GET(RPC_CONFIG * c,
-                      TARIFFS * t)
+                      STG::Tariffs * t)
         : config(c),
           tariffs(t)
     {
@@ -26,14 +31,14 @@ private:
     METHOD_TARIFF_GET & operator=(const METHOD_TARIFF_GET & rvalue);
 
     RPC_CONFIG * config;
-    TARIFFS * tariffs;
+    STG::Tariffs * tariffs;
 };
 
 class METHOD_TARIFF_CHG : public xmlrpc_c::method {
 public:
     METHOD_TARIFF_CHG(RPC_CONFIG * c,
-                      ADMINS * a,
-                      TARIFFS * t)
+                      STG::Admins * a,
+                      STG::Tariffs * t)
         : config(c),
           admins(a),
           tariffs(t)
@@ -48,14 +53,14 @@ private:
     METHOD_TARIFF_CHG & operator=(const METHOD_TARIFF_CHG & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    TARIFFS * tariffs;
+    STG::Admins * admins;
+    STG::Tariffs * tariffs;
 };
 
 class METHOD_TARIFFS_GET : public xmlrpc_c::method {
 public:
     METHOD_TARIFFS_GET(RPC_CONFIG * c,
-                      TARIFFS * t)
+                      STG::Tariffs * t)
         : config(c),
           tariffs(t)
     {
@@ -69,14 +74,14 @@ private:
     METHOD_TARIFFS_GET & operator=(const METHOD_TARIFFS_GET & rvalue);
 
     RPC_CONFIG * config;
-    TARIFFS * tariffs;
+    STG::Tariffs * tariffs;
 };
 
 class METHOD_TARIFF_ADD : public xmlrpc_c::method {
 public:
     METHOD_TARIFF_ADD(RPC_CONFIG * c,
-                      ADMINS * a,
-                      TARIFFS * t)
+                      STG::Admins * a,
+                      STG::Tariffs * t)
         : config(c),
           admins(a),
           tariffs(t)
@@ -91,16 +96,16 @@ private:
     METHOD_TARIFF_ADD & operator=(const METHOD_TARIFF_ADD & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    TARIFFS * tariffs;
+    STG::Admins * admins;
+    STG::Tariffs * tariffs;
 };
 
 class METHOD_TARIFF_DEL : public xmlrpc_c::method {
 public:
     METHOD_TARIFF_DEL(RPC_CONFIG * c,
-                      ADMINS * a,
-                      TARIFFS * t,
-                      USERS * u)
+                      STG::Admins * a,
+                      STG::Tariffs * t,
+                      STG::Users * u)
         : config(c),
           admins(a),
           tariffs(t),
@@ -116,9 +121,7 @@ private:
     METHOD_TARIFF_DEL & operator=(const METHOD_TARIFF_DEL & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    TARIFFS * tariffs;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Tariffs * tariffs;
+    STG::Users * users;
 };
-
-#endif
index 84ba514724a11cb007d024cf111446717e83f86d..7a7a9b906fd349450dbea5c817f9233237885f6c 100644 (file)
@@ -1,12 +1,17 @@
-#include <cmath>
+#include "user_helper.h"
 
 #include "stg/tariffs.h"
+#include "stg/tariff.h"
 #include "stg/admin.h"
 #include "stg/store.h"
+#include "stg/users.h"
+#include "stg/user.h"
 #include "stg/user_ips.h"
-#include "stg/common.h"
 #include "stg/user_property.h"
-#include "user_helper.h"
+#include "stg/common.h"
+#include "stg/const.h"
+
+#include <cmath>
 
 //------------------------------------------------------------------------------
 
@@ -20,62 +25,62 @@ structVal["login"] = xmlrpc_c::value_string(ptr->GetLogin());
 
 if (!hidePassword)
     {
-    structVal["password"] = xmlrpc_c::value_string(ptr->GetProperty().password.Get());
+    structVal["password"] = xmlrpc_c::value_string(ptr->GetProperties().password.Get());
     }
 else
     {
     structVal["password"] = xmlrpc_c::value_string("++++++++");
     }
 
-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());
+structVal["cash"] = xmlrpc_c::value_double(ptr->GetProperties().cash.Get());
+structVal["freemb"] = xmlrpc_c::value_double(ptr->GetProperties().freeMb.Get());
+structVal["credit"] = xmlrpc_c::value_double(ptr->GetProperties().credit.Get());
 
-if (ptr->GetProperty().nextTariff.Get() != "")
+if (ptr->GetProperties().nextTariff.Get() != "")
     {
     structVal["tariff"] = xmlrpc_c::value_string(
-            ptr->GetProperty().tariffName.Get() +
+            ptr->GetProperties().tariffName.Get() +
             "/" +
-            ptr->GetProperty().nextTariff.Get()
+            ptr->GetProperties().nextTariff.Get()
             );
     }
 else
     {
-    structVal["tariff"] = xmlrpc_c::value_string(ptr->GetProperty().tariffName.Get());
+    structVal["tariff"] = xmlrpc_c::value_string(ptr->GetProperties().tariffName.Get());
     }
 
-structVal["note"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().note, "KOI8-RU", "UTF-8"));
+structVal["note"] = xmlrpc_c::value_string(IconvString(ptr->GetProperties().note, "KOI8-RU", "UTF-8"));
 
-structVal["phone"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().phone, "KOI8-RU", "UTF-8"));
+structVal["phone"] = xmlrpc_c::value_string(IconvString(ptr->GetProperties().phone, "KOI8-RU", "UTF-8"));
 
-structVal["address"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().address, "KOI8-RU", "UTF-8"));
+structVal["address"] = xmlrpc_c::value_string(IconvString(ptr->GetProperties().address, "KOI8-RU", "UTF-8"));
 
-structVal["email"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().email, "KOI8-RU", "UTF-8"));
+structVal["email"] = xmlrpc_c::value_string(IconvString(ptr->GetProperties().email, "KOI8-RU", "UTF-8"));
 
 std::vector<xmlrpc_c::value> userdata;
 
-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")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata0.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata1.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata2.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata3.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata4.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata5.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata6.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata7.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata8.Get(), "KOI8-RU", "UTF-8")));
+userdata.push_back(xmlrpc_c::value_string(IconvString(ptr->GetProperties().userdata9.Get(), "KOI8-RU", "UTF-8")));
 
 structVal["userdata"] = xmlrpc_c::value_array(userdata);
 
-structVal["name"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().realName, "KOI8-RU", "UTF-8"));
+structVal["name"] = xmlrpc_c::value_string(IconvString(ptr->GetProperties().realName, "KOI8-RU", "UTF-8"));
 
-structVal["group"] = xmlrpc_c::value_string(IconvString(ptr->GetProperty().group, "KOI8-RU", "UTF-8"));
+structVal["group"] = xmlrpc_c::value_string(IconvString(ptr->GetProperties().group, "KOI8-RU", "UTF-8"));
 
 structVal["status"] = xmlrpc_c::value_boolean(ptr->GetConnected());
-structVal["aonline"] = xmlrpc_c::value_boolean(ptr->GetProperty().alwaysOnline.Get());
+structVal["aonline"] = xmlrpc_c::value_boolean(ptr->GetProperties().alwaysOnline.Get());
 structVal["currip"] = xmlrpc_c::value_string(inet_ntostring(ptr->GetCurrIP()));
 structVal["pingtime"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetPingTime()));
-structVal["ips"] = xmlrpc_c::value_string(ptr->GetProperty().ips.Get().GetIpStr());
+structVal["ips"] = xmlrpc_c::value_string(ptr->GetProperties().ips.Get().toString());
 
 std::map<std::string, xmlrpc_c::value> traffInfo;
 std::vector<xmlrpc_c::value> mu(DIR_NUM);
@@ -83,14 +88,10 @@ std::vector<xmlrpc_c::value> md(DIR_NUM);
 std::vector<xmlrpc_c::value> su(DIR_NUM);
 std::vector<xmlrpc_c::value> sd(DIR_NUM);
 
-DIR_TRAFF upload;
-DIR_TRAFF download;
-DIR_TRAFF supload;
-DIR_TRAFF sdownload;
-download = ptr->GetProperty().down.Get();
-upload = ptr->GetProperty().up.Get();
-sdownload = ptr->GetSessionUpload();
-supload = ptr->GetSessionDownload();
+auto upload = ptr->GetProperties().up.Get();
+auto download = ptr->GetProperties().down.Get();
+auto supload = ptr->GetSessionUpload();
+auto sdownload = ptr->GetSessionDownload();
 
 for (int j = 0; j < DIR_NUM; j++)
     {
@@ -107,13 +108,13 @@ traffInfo["sd"] = xmlrpc_c::value_array(sd);
 
 structVal["traff"] = xmlrpc_c::value_struct(traffInfo);
 
-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(static_cast<int>(ptr->GetProperty().lastCashAddTime.Get()));
-structVal["lastactivitytime"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetProperty().lastActivityTime.Get()));
-structVal["creditexpire"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetProperty().creditExpire.Get()));
+structVal["down"] = xmlrpc_c::value_boolean(ptr->GetProperties().disabled.Get());
+structVal["disableddetailstat"] = xmlrpc_c::value_boolean(ptr->GetProperties().disabledDetailStat.Get());
+structVal["passive"] = xmlrpc_c::value_boolean(ptr->GetProperties().passive.Get());
+structVal["lastcash"] = xmlrpc_c::value_double(ptr->GetProperties().lastCashAdd.Get());
+structVal["lasttimecash"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetProperties().lastCashAddTime.Get()));
+structVal["lastactivitytime"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetProperties().lastActivityTime.Get()));
+structVal["creditexpire"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetProperties().creditExpire.Get()));
 
 *info = xmlrpc_c::value_struct(structVal);
 }
@@ -121,10 +122,10 @@ structVal["creditexpire"] = xmlrpc_c::value_int(static_cast<int>(ptr->GetPropert
 //------------------------------------------------------------------------------
 
 bool USER_HELPER::SetUserInfo(const xmlrpc_c::value & info,
-                              const ADMIN * admin,
+                              const STG::Admin& admin,
                               const std::string & login,
-                              const STORE & store,
-                              TARIFFS * tariffs)
+                              const STG::Store & store,
+                              STG::Tariffs * tariffs)
 {
 std::map<std::string, xmlrpc_c::value> structVal(
     static_cast<std::map<std::string, xmlrpc_c::value> >(xmlrpc_c::value_struct(info))
@@ -133,17 +134,17 @@ std::map<std::string, xmlrpc_c::value> structVal(
 std::map<std::string, xmlrpc_c::value>::iterator it;
 
 bool check = false;
-bool alwaysOnline = ptr->GetProperty().alwaysOnline;
+bool alwaysOnline = ptr->GetProperties().alwaysOnline;
 if ((it = structVal.find("aonline")) != structVal.end())
     {
     check = true;
     alwaysOnline = xmlrpc_c::value_boolean(it->second);
     }
-bool onlyOneIP = ptr->GetProperty().ips.ConstData().OnlyOneIP();
+bool onlyOneIP = ptr->GetProperties().ips.ConstData().onlyOneIP();
 if ((it = structVal.find("ips")) != structVal.end())
     {
     check = true;
-    onlyOneIP = StrToIPS(xmlrpc_c::value_string(it->second)).OnlyOneIP();
+    onlyOneIP = STG::UserIPs::parse(xmlrpc_c::value_string(it->second)).onlyOneIP();
     }
 
 if (check && alwaysOnline && !onlyOneIP)
@@ -154,12 +155,12 @@ if (check && alwaysOnline && !onlyOneIP)
 
 if ((it = structVal.find("ips")) != structVal.end())
     {
-    USER_IPS ips;
-    ips = StrToIPS(xmlrpc_c::value_string(it->second));
+    auto ips = STG::UserIPs::parse(xmlrpc_c::value_string(it->second));
 
-    for (size_t i = 0; i < ips.Count(); ++i)
+    for (size_t i = 0; i < ips.count(); ++i)
         {
-        CONST_USER_PTR user;
+        using ConstUserPtr = const STG::User*;
+        ConstUserPtr user;
         uint32_t ip = ips[i].ip;
         if (users.IsIPInUse(ip, login, &user))
             {
@@ -168,191 +169,143 @@ if ((it = structVal.find("ips")) != structVal.end())
             }
         }
 
-    if (!ptr->GetProperty().ips.Set(ips,
-                                admin,
-                                login,
-                                &store))
+    if (!ptr->GetProperties().ips.Set(ips, admin, login, store))
         return true;
     }
 
 if ((it = structVal.find("aonline")) != structVal.end())
     {
     bool value(xmlrpc_c::value_boolean(it->second));
-    if (ptr->GetProperty().alwaysOnline.Get() != value)
-        if (!ptr->GetProperty().alwaysOnline.Set(value,
-                                             admin,
-                                             login,
-                                             &store))
+    if (ptr->GetProperties().alwaysOnline.Get() != value)
+        if (!ptr->GetProperties().alwaysOnline.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("password")) != structVal.end())
     {
     std::string value(xmlrpc_c::value_string(it->second));
-    if (ptr->GetProperty().password.Get() != value)
-        if (!ptr->GetProperty().password.Set(value,
-                                         admin,
-                                         login,
-                                         &store))
+    if (ptr->GetProperties().password.Get() != value)
+        if (!ptr->GetProperties().password.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("address")) != structVal.end())
     {
     std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU"));
-    if (ptr->GetProperty().address.Get() != value)
-        if (!ptr->GetProperty().address.Set(value,
-                                        admin,
-                                        login,
-                                        &store))
+    if (ptr->GetProperties().address.Get() != value)
+        if (!ptr->GetProperties().address.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("phone")) != structVal.end())
     {
     std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU"));
-    if (ptr->GetProperty().phone.Get() != value)
-        if (!ptr->GetProperty().phone.Set(value,
-                                      admin,
-                                      login,
-                                      &store))
+    if (ptr->GetProperties().phone.Get() != value)
+        if (!ptr->GetProperties().phone.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("email")) != structVal.end())
     {
     std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU"));
-    if (ptr->GetProperty().email.Get() != value)
-        if (!ptr->GetProperty().email.Set(value,
-                                      admin,
-                                      login,
-                                      &store))
+    if (ptr->GetProperties().email.Get() != value)
+        if (!ptr->GetProperties().email.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("cash")) != structVal.end())
     {
     double value(xmlrpc_c::value_double(it->second));
-    if (std::fabs(ptr->GetProperty().cash.Get() - value) > 1.0e-3)
-        if (!ptr->GetProperty().cash.Set(value,
-                                     admin,
-                                     login,
-                                     &store))
+    if (std::fabs(ptr->GetProperties().cash.Get() - value) > 1.0e-3)
+        if (!ptr->GetProperties().cash.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("creditexpire")) != structVal.end())
     {
     time_t value(xmlrpc_c::value_int(it->second));
-    if (ptr->GetProperty().creditExpire.Get() != value)
-        if (!ptr->GetProperty().creditExpire.Set(value,
-                                             admin,
-                                             login,
-                                             &store))
+    if (ptr->GetProperties().creditExpire.Get() != value)
+        if (!ptr->GetProperties().creditExpire.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("credit")) != structVal.end())
     {
     double value(xmlrpc_c::value_double(it->second));
-    if (std::fabs(ptr->GetProperty().credit.Get() - value) > 1.0e-3)
-        if (!ptr->GetProperty().credit.Set(value,
-                                       admin,
-                                       login,
-                                       &store))
+    if (std::fabs(ptr->GetProperties().credit.Get() - value) > 1.0e-3)
+        if (!ptr->GetProperties().credit.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("freemb")) != structVal.end())
     {
     double value(xmlrpc_c::value_double(it->second));
-    if (std::fabs(ptr->GetProperty().freeMb.Get() - value) > 1.0e-3)
-        if (!ptr->GetProperty().freeMb.Set(value,
-                                       admin,
-                                       login,
-                                       &store))
+    if (std::fabs(ptr->GetProperties().freeMb.Get() - value) > 1.0e-3)
+        if (!ptr->GetProperties().freeMb.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("down")) != structVal.end())
     {
     bool value(xmlrpc_c::value_boolean(it->second));
-    if (ptr->GetProperty().disabled.Get() != value)
-        if (!ptr->GetProperty().disabled.Set(value,
-                                         admin,
-                                         login,
-                                         &store))
+    if (ptr->GetProperties().disabled.Get() != value)
+        if (!ptr->GetProperties().disabled.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("passive")) != structVal.end())
     {
     bool value(xmlrpc_c::value_boolean(it->second));
-    if (ptr->GetProperty().passive.Get() != value)
-        if (!ptr->GetProperty().passive.Set(value,
-                                        admin,
-                                        login,
-                                        &store))
+    if (ptr->GetProperties().passive.Get() != value)
+        if (!ptr->GetProperties().passive.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("disableddetailstat")) != structVal.end())
     {
     bool value(xmlrpc_c::value_boolean(it->second));
-    if (ptr->GetProperty().disabledDetailStat.Get() != value)
-        if (!ptr->GetProperty().disabledDetailStat.Set(value,
-                                                   admin,
-                                                   login,
-                                                   &store))
+    if (ptr->GetProperties().disabledDetailStat.Get() != value)
+        if (!ptr->GetProperties().disabledDetailStat.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("name")) != structVal.end())
     {
     std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU"));
-    if (ptr->GetProperty().realName.Get() != value)
-        if (!ptr->GetProperty().realName.Set(value,
-                                         admin,
-                                         login,
-                                         &store))
+    if (ptr->GetProperties().realName.Get() != value)
+        if (!ptr->GetProperties().realName.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("group")) != structVal.end())
     {
     std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU"));
-    if (ptr->GetProperty().group.Get() != value)
-        if (!ptr->GetProperty().group.Set(value,
-                                      admin,
-                                      login,
-                                      &store))
+    if (ptr->GetProperties().group.Get() != value)
+        if (!ptr->GetProperties().group.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("note")) != structVal.end())
     {
     std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU"));
-    if (ptr->GetProperty().note.Get() != value)
-        if (!ptr->GetProperty().note.Set(value,
-                                     admin,
-                                     login,
-                                     &store))
+    if (ptr->GetProperties().note.Get() != value)
+        if (!ptr->GetProperties().note.Set(value, admin, login, store))
             return true;
     }
 
 if ((it = structVal.find("userdata")) != structVal.end())
     {
-    std::vector<USER_PROPERTY_LOGGED<std::string> *> userdata;
-    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<STG::UserPropertyLogged<std::string> *> userdata;
+    userdata.push_back(ptr->GetProperties().userdata0.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata1.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata2.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata3.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata4.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata5.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata6.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata7.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata8.GetPointer());
+    userdata.push_back(ptr->GetProperties().userdata9.GetPointer());
 
     std::vector<xmlrpc_c::value> udata(
         xmlrpc_c::value_array(it->second).vectorValueValue()
@@ -362,10 +315,7 @@ if ((it = structVal.find("userdata")) != structVal.end())
         {
         std::string value(IconvString(xmlrpc_c::value_string(udata[i]), "UTF-8", "KOI8-RU"));
         if (userdata[i]->Get() != value)
-            if (!userdata[i]->Set(value,
-                                  admin,
-                                  login,
-                                  &store))
+            if (!userdata[i]->Set(value, admin, login, store))
                 return true;
         }
     }
@@ -376,8 +326,7 @@ if ((it = structVal.find("traff")) != structVal.end())
         static_cast<std::map<std::string, xmlrpc_c::value> >(xmlrpc_c::value_struct(it->second))
         );
 
-    DIR_TRAFF dtData;
-    dtData = ptr->GetProperty().up.Get();
+    auto dtData = ptr->GetProperties().up.Get();
     if ((it = traff.find("mu")) != traff.end())
         {
         std::vector<xmlrpc_c::value> data(xmlrpc_c::value_array(it->second).vectorValueValue());
@@ -390,13 +339,10 @@ if ((it = structVal.find("traff")) != structVal.end())
             else
                 dtData[i] = value;
             }
-        if (!ptr->GetProperty().up.Set(dtData,
-                                   admin,
-                                   login,
-                                   &store))
+        if (!ptr->GetProperties().up.Set(dtData, admin, login, store))
             return true;
         }
-    dtData = ptr->GetProperty().down.Get();
+    dtData = ptr->GetProperties().down.Get();
     if ((it = traff.find("md")) != traff.end())
         {
         std::vector<xmlrpc_c::value> data(xmlrpc_c::value_array(it->second).vectorValueValue());
@@ -409,10 +355,7 @@ if ((it = structVal.find("traff")) != structVal.end())
             else
                 dtData[i] = value;
             }
-        if (!ptr->GetProperty().down.Set(dtData,
-                                     admin,
-                                     login,
-                                     &store))
+        if (!ptr->GetProperties().down.Set(dtData, admin, login, store))
             return true;
         }
     }
@@ -428,35 +371,29 @@ if ((it = structVal.find("tariff")) != structVal.end())
         tariff = tariff.substr(0, pos);
         }
 
-    const TARIFF * newTariff = tariffs->FindByName(tariff);
+    const auto newTariff = tariffs->FindByName(tariff);
     if (newTariff)
         {
-        const TARIFF * currentTariff = ptr->GetTariff();
+        const auto currentTariff = ptr->GetTariff();
         std::string message = currentTariff->TariffChangeIsAllowed(*newTariff, stgTime);
         if (message.empty())
             {
-            if (ptr->GetProperty().tariffName.Get() != tariff)
+            if (ptr->GetProperties().tariffName.Get() != tariff)
                 {
-                if (!ptr->GetProperty().tariffName.Set(tariff,
-                                                   admin,
-                                                   login,
-                                                   &store))
+                if (!ptr->GetProperties().tariffName.Set(tariff, admin, login, store))
                     return true;
                 }
             }
         else
             {
-                PluginLogger::get("conf_rpc")("Tariff change is prohibited for user %s. %s", ptr->GetLogin().c_str(), message.c_str());
+                STG::PluginLogger::get("conf_rpc")("Tariff change is prohibited for user %s. %s", ptr->GetLogin().c_str(), message.c_str());
             }
         }
 
     if (nextTariff != "" &&
         tariffs->FindByName(nextTariff))
-        if (ptr->GetProperty().nextTariff.Get() != nextTariff)
-            if (!ptr->GetProperty().nextTariff.Set(tariff,
-                                               admin,
-                                               login,
-                                               &store))
+        if (ptr->GetProperties().nextTariff.Get() != nextTariff)
+            if (!ptr->GetProperties().nextTariff.Set(tariff, admin, login, store))
                 return true;
     }
 
index 4e1dd7966f0a584be40ffc972779d2cdc9bfd525..5457c953322bbc7f74ea696f269373b8423fb955 100644 (file)
@@ -1,20 +1,25 @@
-#ifndef __USER_HELPER_H__
-#define __USER_HELPER_H__
+#pragma once
 
 #include <string>
 
 #include <xmlrpc-c/base.hpp>
 
-#include "stg/users.h"
+namespace STG
+{
+
+struct Admin;
+struct Store;
+struct Tariffs;
+struct User;
+struct Users;
 
-class ADMIN;
-class STORE;
-class TARIFFS;
+}
 
 class USER_HELPER
 {
 public:
-    USER_HELPER(USER_PTR & p, USERS & us)
+    using UserPtr = STG::User*;
+    USER_HELPER(UserPtr & p, STG::Users & us)
         : ptr(p),
           users(us)
     {
@@ -23,13 +28,11 @@ public:
     void GetUserInfo(xmlrpc_c::value * info,
                      bool hidePassword = false);
     bool SetUserInfo(const xmlrpc_c::value & info,
-                     const ADMIN * admin,
+                     const STG::Admin& admin,
                      const std::string & login,
-                     const STORE & store,
-                     TARIFFS * tariffs);
+                     const STG::Store & store,
+                     STG::Tariffs * tariffs);
 private:
-    USER_PTR & ptr;
-    USERS & users;
+    UserPtr & ptr;
+    STG::Users & users;
 };
-
-#endif
index 3565a14e1757ef93039a9479b78deb7afb320cc0..f20448544c42cd32c9c78d114bbcbf221401169b 100644 (file)
@@ -1,15 +1,18 @@
-#include <cerrno>
+#include "users_methods.h"
+#include "rpcconfig.h"
+#include "user_helper.h"
 
 #include "stg/users.h"
 #include "stg/admins.h"
 #include "stg/tariffs.h"
-#include "stg/user_ips.h"
-#include "stg/common.h"
+#include "stg/tariff.h"
+#include "stg/user.h"
 #include "stg/user_property.h"
+#include "stg/common.h"
 
-#include "users_methods.h"
-#include "rpcconfig.h"
-#include "user_helper.h"
+#include <cerrno>
+
+using UserPtr = STG::User*;
 
 //------------------------------------------------------------------------------
 
@@ -30,7 +33,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
@@ -67,7 +70,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin = NULL;
+STG::Admin * admin = NULL;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -75,7 +78,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
@@ -88,7 +91,7 @@ if (users->FindByName(login, &u))
     *retvalPtr = xmlrpc_c::value_boolean(true);
     return;
     }
-    
+
 *retvalPtr = xmlrpc_c::value_boolean(false);
 return;
 }
@@ -110,7 +113,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -118,7 +121,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (!users->FindByName(login, &u))
     {
@@ -153,7 +156,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
 bool hidePassword = !adminInfo.priviledges.userConf ||
                     !adminInfo.priviledges.userPasswd;
 
-USER_PTR u;
+UserPtr u;
 
 int h = users->OpenSearch();
 if (!h)
@@ -200,7 +203,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -208,7 +211,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
@@ -220,11 +223,11 @@ USER_HELPER uhelper(u, *users);
 
 if (!adminInfo.priviledges.userConf || !adminInfo.priviledges.userPasswd)
     {
-    uhelper.SetUserInfo(info, admin, login, *store, tariffs);
+    uhelper.SetUserInfo(info, *admin, login, *store, tariffs);
     }
 else
     {
-    uhelper.SetUserInfo(info, admin, login, *store, tariffs);
+    uhelper.SetUserInfo(info, *admin, login, *store, tariffs);
     }
 
 u->WriteConf();
@@ -252,7 +255,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -260,7 +263,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
@@ -268,10 +271,10 @@ if (users->FindByName(login, &u))
     return;
     }
 
-double cash = u->GetProperty().cash.Get();
+double cash = u->GetProperties().cash.Get();
 cash += amount;
 
-if (!u->GetProperty().cash.Set(cash, admin, login, store, comment))
+if (!u->GetProperties().cash.Set(cash, *admin, login, *store, comment))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
@@ -301,7 +304,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -309,7 +312,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
@@ -317,7 +320,7 @@ if (users->FindByName(login, &u))
     return;
     }
 
-if (!u->GetProperty().cash.Set(cash, admin, login, store, comment))
+if (!u->GetProperties().cash.Set(cash, *admin, login, *store, comment))
     {
     *retvalPtr = xmlrpc_c::value_boolean(false);
     return;
@@ -348,7 +351,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-ADMIN * admin;
+STG::Admin * admin;
 
 if (admins->Find(adminInfo.admin, &admin))
     {
@@ -356,7 +359,7 @@ if (admins->Find(adminInfo.admin, &admin))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
@@ -368,11 +371,7 @@ if (tariffs->FindByName(tariff))
     {
     if (delayed)
         {
-        if (u->GetProperty().nextTariff.Set(tariff,
-                                            admin,
-                                            login,
-                                            store,
-                                            comment))
+        if (u->GetProperties().nextTariff.Set(tariff, *admin, login, *store, comment))
             {
             u->WriteConf();
             *retvalPtr = xmlrpc_c::value_boolean(true);
@@ -381,18 +380,14 @@ if (tariffs->FindByName(tariff))
         }
     else
         {
-        const TARIFF * newTariff = tariffs->FindByName(tariff);
+        const auto newTariff = tariffs->FindByName(tariff);
         if (newTariff)
             {
-            const TARIFF * currentTariff = u->GetTariff();
+            const auto currentTariff = u->GetTariff();
             std::string message = currentTariff->TariffChangeIsAllowed(*newTariff, stgTime);
             if (message.empty())
                 {
-                if (u->GetProperty().tariffName.Set(tariff,
-                                            admin,
-                                            login,
-                                            store,
-                                            comment))
+                if (u->GetProperties().tariffName.Set(tariff, *admin, login, *store, comment))
                     {
                     u->ResetNextTariff();
                     u->WriteConf();
@@ -402,7 +397,7 @@ if (tariffs->FindByName(tariff))
                 }
             else
                 {
-                    PluginLogger::get("conf_rpc")("Tariff change is prohibited for user %s. %s", u->GetLogin().c_str(), message.c_str());
+                    STG::PluginLogger::get("conf_rpc")("Tariff change is prohibited for user %s. %s", u->GetLogin().c_str(), message.c_str());
                 }
             }
         }
@@ -421,11 +416,11 @@ typedef std::vector<xmlrpc_c::value> ValueVector;
 ValueVector subnetsStr = paramList.getArray(1);
 paramList.verifyEnd(2);
 
-std::vector<IP_MASK> subnets;
+std::vector<STG::IPMask> subnets;
 
 for (ValueVector::const_iterator it(subnetsStr.begin()); it != subnetsStr.end(); ++it)
     {
-    IP_MASK ipm;
+    STG::IPMask ipm;
     if (ParseNet(xmlrpc_c::value_string(*it), ipm))
         {
         printfd(__FILE__, "METHOD_GET_ONLINE_IPS::execute(): Failed to parse subnet ('%s')\n", std::string(xmlrpc_c::value_string(*it)).c_str());
@@ -448,7 +443,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
 
 ValueVector ips;
 
-USER_PTR u;
+UserPtr u;
 
 int handle = users->OpenSearch();
 if (!handle)
@@ -469,7 +464,7 @@ while (1)
         {
         uint32_t ip = u->GetCurrIP();
 
-        for (std::vector<IP_MASK>::const_iterator it(subnets.begin()); it != subnets.end(); ++it)
+        for (std::vector<STG::IPMask>::const_iterator it(subnets.begin()); it != subnets.end(); ++it)
             {
             if ((it->ip & it->mask) == (ip & it->mask))
                 {
@@ -485,7 +480,7 @@ structVal["ips"] = xmlrpc_c::value_array(ips);
 *retvalPtr = xmlrpc_c::value_struct(structVal);
 }
 
-bool METHOD_GET_ONLINE_IPS::ParseNet(const std::string & net, IP_MASK & ipm) const
+bool METHOD_GET_ONLINE_IPS::ParseNet(const std::string & net, STG::IPMask & ipm) const
 {
 size_t pos = net.find_first_of('/');
 
@@ -540,7 +535,7 @@ if (config->GetAdminInfo(cookie, &adminInfo))
     return;
     }
 
-USER_PTR u;
+UserPtr u;
 
 if (users->FindByName(login, &u))
     {
index d1ec33a4ade340f07e1612e1b9641de38417db8d..f03e98890944e96a5b0357c1b9865b028dc40bf7 100644 (file)
@@ -1,20 +1,25 @@
-#ifndef __USERS_METHODS_H__
-#define __USERS_METHODS_H__
+#pragma once
 
 #include <xmlrpc-c/base.hpp>
 #include <xmlrpc-c/registry.hpp>
 
+namespace STG
+{
+
+struct Admins;
+struct Tariffs;
+struct Users;
+struct Store;
+struct IPMask;
+
+}
+
 class RPC_CONFIG;
-class ADMINS;
-class TARIFFS;
-class USERS;
-class STORE;
-struct IP_MASK;
 
 class METHOD_USER_GET : public xmlrpc_c::method {
 public:
     METHOD_USER_GET(RPC_CONFIG * c,
-                    USERS * u)
+                    STG::Users * u)
         : config(c),
           users(u)
     {
@@ -28,14 +33,14 @@ private:
     METHOD_USER_GET & operator=(const METHOD_USER_GET & rvalue);
 
     RPC_CONFIG * config;
-    USERS * users;
+    STG::Users * users;
 };
 
 class METHOD_USER_ADD : public xmlrpc_c::method {
 public:
     METHOD_USER_ADD(RPC_CONFIG * c,
-                    ADMINS * a,
-                    USERS * u)
+                    STG::Admins * a,
+                    STG::Users * u)
         : config(c),
           admins(a),
           users(u)
@@ -50,15 +55,15 @@ private:
     METHOD_USER_ADD & operator=(const METHOD_USER_ADD & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Users * users;
 };
 
 class METHOD_USER_DEL : public xmlrpc_c::method {
 public:
     METHOD_USER_DEL(RPC_CONFIG * c,
-                    ADMINS * a,
-                    USERS * u)
+                    STG::Admins * a,
+                    STG::Users * u)
         : config(c),
           admins(a),
           users(u)
@@ -73,14 +78,14 @@ private:
     METHOD_USER_DEL & operator=(const METHOD_USER_DEL & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Users * users;
 };
 
 class METHOD_USERS_GET : public xmlrpc_c::method {
 public:
     METHOD_USERS_GET(RPC_CONFIG * c,
-                     USERS * u)
+                     STG::Users * u)
         : config(c),
           users(u)
     {
@@ -94,16 +99,16 @@ private:
     METHOD_USERS_GET & operator=(const METHOD_USERS_GET & rvalue);
 
     RPC_CONFIG * config;
-    USERS * users;
+    STG::Users * users;
 };
 
 class METHOD_USER_CHG : public xmlrpc_c::method {
 public:
     METHOD_USER_CHG(RPC_CONFIG * c,
-                    ADMINS * a,
-                    TARIFFS * t,
-                    STORE * s,
-                    USERS * u)
+                    STG::Admins * a,
+                    STG::Tariffs * t,
+                    STG::Store * s,
+                    STG::Users * u)
         : config(c),
           admins(a),
           tariffs(t),
@@ -120,18 +125,18 @@ private:
     METHOD_USER_CHG & operator=(const METHOD_USER_CHG & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    TARIFFS * tariffs;
-    STORE * store;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Tariffs * tariffs;
+    STG::Store * store;
+    STG::Users * users;
 };
 
 class METHOD_USER_CASH_ADD : public xmlrpc_c::method {
 public:
     METHOD_USER_CASH_ADD(RPC_CONFIG * c,
-                         ADMINS * a,
-                         STORE * s,
-                         USERS * u)
+                         STG::Admins * a,
+                         STG::Store * s,
+                         STG::Users * u)
         : config(c),
           admins(a),
           store(s),
@@ -147,17 +152,17 @@ private:
     METHOD_USER_CASH_ADD & operator=(const METHOD_USER_CASH_ADD & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    STORE * store;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Store * store;
+    STG::Users * users;
 };
 
 class METHOD_USER_CASH_SET : public xmlrpc_c::method {
 public:
     METHOD_USER_CASH_SET(RPC_CONFIG * c,
-                         ADMINS * a,
-                         STORE * s,
-                         USERS * u)
+                         STG::Admins * a,
+                         STG::Store * s,
+                         STG::Users * u)
         : config(c),
           admins(a),
           store(s),
@@ -173,18 +178,18 @@ private:
     METHOD_USER_CASH_SET & operator=(const METHOD_USER_CASH_SET & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    STORE * store;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Store * store;
+    STG::Users * users;
 };
 
 class METHOD_USER_TARIFF_CHANGE : public xmlrpc_c::method {
 public:
     METHOD_USER_TARIFF_CHANGE(RPC_CONFIG * c,
-                              ADMINS * a,
-                              TARIFFS * t,
-                              STORE * s,
-                              USERS * u)
+                              STG::Admins * a,
+                              STG::Tariffs * t,
+                              STG::Store * s,
+                              STG::Users * u)
         : config(c),
           admins(a),
           tariffs(t),
@@ -201,16 +206,16 @@ private:
     METHOD_USER_TARIFF_CHANGE & operator=(const METHOD_USER_TARIFF_CHANGE & rvalue);
 
     RPC_CONFIG * config;
-    ADMINS * admins;
-    TARIFFS * tariffs;
-    STORE * store;
-    USERS * users;
+    STG::Admins * admins;
+    STG::Tariffs * tariffs;
+    STG::Store * store;
+    STG::Users * users;
 };
 
 class METHOD_GET_ONLINE_IPS : public xmlrpc_c::method {
 public:
     METHOD_GET_ONLINE_IPS(RPC_CONFIG * c,
-                          USERS * u)
+                          STG::Users * u)
         : config(c),
           users(u)
     {
@@ -224,15 +229,15 @@ private:
     METHOD_GET_ONLINE_IPS & operator=(const METHOD_GET_ONLINE_IPS & rvalue);
 
     RPC_CONFIG * config;
-    USERS * users;
+    STG::Users * users;
 
-    bool ParseNet(const std::string & net, IP_MASK & ipm) const;
+    bool ParseNet(const std::string & net, STG::IPMask & ipm) const;
 };
 
 class METHOD_GET_USER_AUTH_BY : public xmlrpc_c::method {
 public:
     METHOD_GET_USER_AUTH_BY(RPC_CONFIG * c,
-                            USERS * u)
+                            STG::Users * u)
         : config(c),
           users(u)
     {
@@ -246,7 +251,5 @@ private:
     METHOD_GET_USER_AUTH_BY & operator=(const METHOD_GET_ONLINE_IPS & rvalue);
 
     RPC_CONFIG * config;
-    USERS * users;
+    STG::Users * users;
 };
-
-#endif