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