3 #include "stg/plugin.h"
4 #include "stg/admin_conf.h"
5 #include "stg/module_settings.h"
6 #include "stg/logger.h"
8 #include <xmlrpc-c/base.hpp>
9 #include <xmlrpc-c/registry.hpp>
10 #include <xmlrpc-c/server_abyss.hpp>
20 #define RPC_CONFIG_VERSION "Stargazer RPC v. 0.2"
32 class RPC_CONFIG_SETTINGS
35 RPC_CONFIG_SETTINGS();
36 virtual ~RPC_CONFIG_SETTINGS() {}
37 const std::string & GetStrError() const { return errorStr; }
38 int ParseSettings(const STG::ModuleSettings & s);
39 uint16_t GetPort() const { return port; }
40 double GetCookieTimeout() const { return cookieTimeout; }
58 STG::Priv priviledges;
61 class RPC_CONFIG : public STG::Plugin
65 ~RPC_CONFIG() override;
67 void SetUsers(STG::Users * u) override { users = u; }
68 void SetTariffs(STG::Tariffs * t) override { tariffs = t; }
69 void SetAdmins(STG::Admins * a) override { admins = a; }
70 void SetStore(STG::Store * s) override { store = s; }
71 void SetStgSettings(const STG::Settings * s) override;
72 void SetSettings(const STG::ModuleSettings & s) override { settings = s; }
73 int ParseSettings() override;
77 int Reload(const STG::ModuleSettings & /*ms*/) override { return 0; }
78 bool IsRunning() override { return running && !stopped; }
80 const std::string & GetStrError() const override { return errorStr; }
81 std::string GetVersion() const override { return RPC_CONFIG_VERSION; }
82 uint16_t GetStartPosition() const override { return 20; }
83 uint16_t GetStopPosition() const override { return 20; }
85 bool GetAdminInfo(const std::string & cookie,
87 bool CheckAdmin(const std::string & login,
88 const std::string & password,
89 std::string * cookie);
90 bool LogoutAdmin(const std::string & cookie);
93 RPC_CONFIG(const RPC_CONFIG & rvalue);
94 RPC_CONFIG & operator=(const RPC_CONFIG & rvalue);
96 static void * Run(void *);
97 std::string GetCookie() const;
98 void InitiateRegistry();
100 mutable std::string errorStr;
101 RPC_CONFIG_SETTINGS rpcConfigSettings;
103 STG::Admins * admins;
104 STG::Tariffs * tariffs;
106 STG::ModuleSettings settings;
108 xmlrpc_c::registry rpcRegistry;
109 xmlrpc_c::serverAbyss * rpcServer;
113 std::map<std::string,
116 std::vector<std::string> dirNames;
117 STG::PluginLogger logger;