1 #ifndef __RPC_CONFIG_H__
2 #define __RPC_CONFIG_H__
8 #include <xmlrpc-c/base.hpp>
9 #include <xmlrpc-c/registry.hpp>
10 #include <xmlrpc-c/server_abyss.hpp>
15 #include "base_plugin.h"
16 #include "base_store.h"
17 #include "base_settings.h"
18 #include "admin_conf.h"
19 #include "../../../admin.h"
20 #include "../../../admins.h"
21 #include "../../../users.h"
22 #include "../../../tariffs.h"
23 #include "../../../traffcounter.h"
24 #include "../../../settings.h"
26 #define RPC_CONFIG_VERSION "Stargazer RPC v. 0.2"
28 extern "C" BASE_PLUGIN * GetPlugin();
30 class RPC_CONFIG_SETTINGS
33 RPC_CONFIG_SETTINGS();
34 virtual ~RPC_CONFIG_SETTINGS() {};
35 const std::string & GetStrError() const { return errorStr; };
36 int ParseSettings(const MODULE_SETTINGS & s);
37 uint16_t GetPort() const { return port; };
38 double GetCookieTimeout() const { return cookieTimeout; };
40 int ParseIntInRange(const std::string & str,
56 class RPC_CONFIG :public BASE_PLUGIN
60 virtual ~RPC_CONFIG();
62 void SetUsers(USERS * u) { users = u; };
63 void SetTariffs(TARIFFS * t) { tariffs = t; };
64 void SetAdmins(ADMINS * a) { admins = a; };
65 void SetStore(BASE_STORE * s) { store = s; };
66 void SetTraffcounter(TRAFFCOUNTER *) {};
67 void SetStgSettings(const SETTINGS * s) { stgSettings = s; };
68 void SetSettings(const MODULE_SETTINGS & s) { settings = s; };
73 int Reload() { return 0; };
74 bool IsRunning() { return running && !stopped; };
76 const string & GetStrError() const { return errorStr; };
77 const string GetVersion() const { return RPC_CONFIG_VERSION; };
78 uint16_t GetStartPosition() const { return 220; };
79 uint16_t GetStopPosition() const { return 220; };
81 bool GetAdminInfo(const std::string & cookie,
83 bool CheckAdmin(const std::string & login,
84 const std::string & password,
85 std::string * cookie);
86 bool LogoutAdmin(const std::string & cookie);
89 mutable string errorStr;
90 RPC_CONFIG_SETTINGS rpcConfigSettings;
95 MODULE_SETTINGS settings;
96 const SETTINGS * stgSettings;
97 xmlrpc_c::registry rpcRegistry;
98 xmlrpc_c::serverAbyss * rpcServer;
102 std::map<std::string,
105 static void * Run(void *);
106 std::string GetCookie() const;
107 void InitiateRegistry();