1 #ifndef __RPC_CONFIG_H__
2 #define __RPC_CONFIG_H__
10 #include <xmlrpc-c/base.hpp>
11 #include <xmlrpc-c/registry.hpp>
12 #include <xmlrpc-c/server_abyss.hpp>
15 #include "base_plugin.h"
16 #include "admin_conf.h"
18 #define RPC_CONFIG_VERSION "Stargazer RPC v. 0.2"
20 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();