]> git.stg.codes - stg.git/commitdiff
Fix compilation issues for XML RPC interface
authorMaxim Mamontov <faust.madf@gmail.com>
Sat, 19 Mar 2011 15:52:40 +0000 (17:52 +0200)
committerMaxim Mamontov <faust.madf@gmail.com>
Sat, 19 Mar 2011 15:52:40 +0000 (17:52 +0200)
projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp
projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp
projects/stargazer/plugins/configuration/rpcconfig/info_methods.h
projects/stargazer/plugins/configuration/rpcconfig/messages_methods.cpp
projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h
projects/stargazer/plugins/configuration/rpcconfig/tariffs_methods.cpp
projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp
projects/stargazer/plugins/configuration/rpcconfig/user_helper.h
projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp

index 4eae81fd32f414578fd8fd4549cdd16a250d4acd..f36debc4dfa08e18c69778fbfa5b4c1be6dc271d 100644 (file)
@@ -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<std::string, xmlrpc_c::value> structVal(
index fdb56048f5b112d4626dd1a473213dd2aff9661f..a689cd99de2fa8370c7e791ca771aa78ed003dfd 100644 (file)
@@ -1,8 +1,9 @@
-#include "info_methods.h"
-
 #include <sys/utsname.h>
+
+#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<xmlrpc_c::value> 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));
     }
 
index b381d16ca24e92a978eb2a5dd16cd47b37f4ac40..a404839bb827010afef84efc5a0b74dca7405f2e 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef __INFO_METHODS_H__
 #define __INFO_METHODS_H__
 
+#include <string>
+#include <vector>
+
 #include <xmlrpc-c/base.hpp>
 #include <xmlrpc-c/registry.hpp>
 
@@ -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<std::string> & 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<std::string> & dirNames;
 };
 
 class METHOD_LOGIN : public xmlrpc_c::method
index 281041e75767cad92690ef2228422eda0edf5ae9..b64e661599aa3f02c62b418b3ccc406c51d8b9f7 100644 (file)
@@ -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<xmlrpc_c::value>::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());
index 7d764a7d3519d9418b2eb471dd3c8e1299b1d6d5..af7419854c4a64f7e255f46702415686af7a0514 100644 (file)
@@ -1,10 +1,14 @@
 #include <cstdlib>
 #include <csignal>
 
+#include <vector>
+#include <algorithm>
+
 #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<PARAM_VALUE>::const_iterator pvi;
+std::vector<PARAM_VALUE>::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);
 
index 34da6613936ef5a79eeb4179abc1ff92f9982f5b..a597135a08b464bd15847e588d5537516c1fdb14 100644 (file)
@@ -6,6 +6,7 @@
 #include <ctime>
 #include <string>
 #include <map>
+#include <vector>
 
 #include <xmlrpc-c/base.hpp>
 #include <xmlrpc-c/registry.hpp>
@@ -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<std::string,
              ADMIN_INFO>    cookies;
+    size_t                  dayFee;
+    std::vector<std::string> dirNames;
 };
 
 #endif
index 16e25eb89d5dfebfe4edfc55a9f3d4a54fac3f9f..10985cced4f65c70498895a7ebd584965dca6253 100644 (file)
@@ -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))
     {
index 3c91d65a1a707e706db0ba509ce23a98eb27f89b..a557b677f7e75a4e249e45b1745eee1eb84a502f 100644 (file)
@@ -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<std::string, xmlrpc_c::value> 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<xmlrpc_c::value> 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<std::string, xmlrpc_c::value> traffInfo;
 std::vector<xmlrpc_c::value> 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<std::string, xmlrpc_c::value>::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<USER_PROPERTY_LOGGED<string> *> 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<xmlrpc_c::value> 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<xmlrpc_c::value> 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<xmlrpc_c::value> 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))
index 63d1da0756aa4428d97f7548f3fa1ba11b4ebdb4..ddc784441acb7a55725eee94d408f9bd0af0c7f1 100644 (file)
@@ -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
index 35166c8154ed315a395205a84bfd04e32e003f03..d16d883f480d4be0ead41f829cec7bb15e393621 100644 (file)
@@ -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<xmlrpc_c::value> ips;
 
-user_iter u;
+USER_PTR u;
 
 int handle = users->OpenSearch();
 if (!handle)