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