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>
13 #include "base_plugin.h"
14 #include "base_store.h"
15 #include "base_settings.h"
16 #include "admin_conf.h"
17 #include "../../../admin.h"
18 #include "../../../admins.h"
19 #include "../../../users.h"
20 #include "../../../tariffs.h"
21 #include "../../../traffcounter.h"
22 #include "../../../settings.h"
24 #define RPC_CONFIG_VERSION "Stargazer RPC v. 0.2"
26 extern "C" BASE_PLUGIN * GetPlugin();
28 class RPC_CONFIG_SETTINGS
31 RPC_CONFIG_SETTINGS();
32 virtual ~RPC_CONFIG_SETTINGS() {};
33 const std::string & GetStrError() const { return errorStr; };
34 int ParseSettings(const MODULE_SETTINGS & s);
35 uint16_t GetPort() const { return port; };
36 double GetCookieTimeout() const { return cookieTimeout; };
38 int ParseIntInRange(const std::string & str,
54 class RPC_CONFIG :public BASE_PLUGIN
58 virtual ~RPC_CONFIG();
60 void SetUsers(USERS * u) { users = u; };
61 void SetTariffs(TARIFFS * t) { tariffs = t; };
62 void SetAdmins(ADMINS * a) { admins = a; };
63 void SetStore(BASE_STORE * s) { store = s; };
64 void SetTraffcounter(TRAFFCOUNTER *) {};
65 void SetStgSettings(const SETTINGS * s) { stgSettings = s; };
66 void SetSettings(const MODULE_SETTINGS & s) { settings = s; };
71 int Reload() { return 0; };
72 bool IsRunning() { return running && !stopped; };
74 const string & GetStrError() const { return errorStr; };
75 const string GetVersion() const { return RPC_CONFIG_VERSION; };
76 uint16_t GetStartPosition() const { return 220; };
77 uint16_t GetStopPosition() const { return 220; };
79 bool GetAdminInfo(const std::string & cookie,
81 bool CheckAdmin(const std::string & login,
82 const std::string & password,
83 std::string * cookie);
84 bool LogoutAdmin(const std::string & cookie);
87 mutable string errorStr;
88 RPC_CONFIG_SETTINGS rpcConfigSettings;
93 MODULE_SETTINGS settings;
94 const SETTINGS * stgSettings;
95 xmlrpc_c::registry rpcRegistry;
96 xmlrpc_c::serverAbyss * rpcServer;
100 std::map<std::string,
103 static void * Run(void *);
104 std::string GetCookie() const;
105 void InitiateRegistry();