From f8c1b8f4f9bcb06242aa7d7360ea610764565c75 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 13 Feb 2025 01:28:28 +0000 Subject: Rework the RPC modules in preparation for the new JSON-RPC module. --- include/modules/rpc.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ include/modules/xmlrpc.h | 50 ------------------------------------------------ 2 files changed, 50 insertions(+), 50 deletions(-) create mode 100644 include/modules/rpc.h delete mode 100644 include/modules/xmlrpc.h (limited to 'include') diff --git a/include/modules/rpc.h b/include/modules/rpc.h new file mode 100644 index 000000000..b3c8afdb4 --- /dev/null +++ b/include/modules/rpc.h @@ -0,0 +1,50 @@ +/* + * + * (C) 2010-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +#include "httpd.h" + +class RPCRequest final +{ + std::map replies; + +public: + Anope::string name; + Anope::string id; + std::deque data; + HTTPReply &r; + + RPCRequest(HTTPReply &_r) : r(_r) { } + inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); } + inline const std::map &get_replies() { return this->replies; } +}; + +class RPCServiceInterface; + +class RPCEvent +{ +public: + virtual ~RPCEvent() = default; + virtual bool Run(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) = 0; +}; + +class RPCServiceInterface + : public Service +{ +public: + RPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "RPCServiceInterface", sname) { } + + virtual void Register(RPCEvent *event) = 0; + + virtual void Unregister(RPCEvent *event) = 0; + + virtual Anope::string Sanitize(const Anope::string &string) = 0; + + virtual void Reply(RPCRequest &request) = 0; +}; diff --git a/include/modules/xmlrpc.h b/include/modules/xmlrpc.h deleted file mode 100644 index 833792888..000000000 --- a/include/modules/xmlrpc.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * (C) 2010-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -#include "httpd.h" - -class XMLRPCRequest final -{ - std::map replies; - -public: - Anope::string name; - Anope::string id; - std::deque data; - HTTPReply &r; - - XMLRPCRequest(HTTPReply &_r) : r(_r) { } - inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); } - inline const std::map &get_replies() { return this->replies; } -}; - -class XMLRPCServiceInterface; - -class XMLRPCEvent -{ -public: - virtual ~XMLRPCEvent() = default; - virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) = 0; -}; - -class XMLRPCServiceInterface - : public Service -{ -public: - XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "XMLRPCServiceInterface", sname) { } - - virtual void Register(XMLRPCEvent *event) = 0; - - virtual void Unregister(XMLRPCEvent *event) = 0; - - virtual Anope::string Sanitize(const Anope::string &string) = 0; - - virtual void Reply(XMLRPCRequest &request) = 0; -}; -- cgit