summaryrefslogtreecommitdiff
path: root/modules/extra/xmlrpc.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-11-06 11:19:09 -0400
committerAdam <Adam@anope.org>2010-12-12 19:30:14 -0500
commit8fbe36635c8acae23d7c0879aaa347265b96408d (patch)
tree898ff9790d763e91ccb24c5fe28da5e575499d7b /modules/extra/xmlrpc.h
parent5cd4fefb4c3c9e9a723c2b6b2e52859c5c7bb49e (diff)
Added m_xmlrpc and m_xmlrpc main, which allows remote programs to execute
remote RPC calls to Anope in realtime and receive responses
Diffstat (limited to 'modules/extra/xmlrpc.h')
-rw-r--r--modules/extra/xmlrpc.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/extra/xmlrpc.h b/modules/extra/xmlrpc.h
new file mode 100644
index 000000000..004d6aef5
--- /dev/null
+++ b/modules/extra/xmlrpc.h
@@ -0,0 +1,75 @@
+
+class XMLRPCClientSocket;
+class XMLRPCListenSocket;
+class XMLRPCServiceInterface;
+
+class XMLRPCClientSocket : public ClientSocket
+{
+ protected:
+ Anope::string query;
+
+ public:
+ bool logged_in;
+
+ XMLRPCClientSocket(ListenSocket *ls, int fd, const sockaddrs &addr) : ClientSocket(ls, fd, addr), logged_in(false) { }
+
+ virtual ~XMLRPCClientSocket() { }
+
+ virtual bool Read(const Anope::string &message) = 0;
+
+ virtual bool GetData(Anope::string &tag, Anope::string &data) = 0;
+
+ virtual void HandleMessage() = 0;
+};
+
+class XMLRPCListenSocket : public ListenSocket
+{
+ protected:
+ std::vector<Anope::string> allowed;
+
+ public:
+ Anope::string username;
+ Anope::string password;
+
+ XMLRPCListenSocket(const Anope::string &bindip, int port, bool ipv6, const Anope::string &u, const Anope::string &p, const std::vector<Anope::string> &a) : ListenSocket(bindip, port, ipv6), allowed(a), username(u), password(p) { }
+
+ virtual ~XMLRPCListenSocket() { }
+
+ virtual ClientSocket *OnAccept(int fd, const sockaddrs &addr) = 0;
+};
+
+class XMLRPCRequest
+{
+ std::map<Anope::string, Anope::string> replies;
+
+ public:
+ Anope::string name;
+ Anope::string id;
+ std::deque<Anope::string> data;
+
+ inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); }
+ inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; }
+};
+
+class XMLRPCEvent
+{
+ public:
+ virtual void Run(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request) = 0;
+};
+
+class XMLRPCServiceInterface : public Service
+{
+ public:
+ XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, sname) { }
+
+ virtual void Register(XMLRPCEvent *event) = 0;
+
+ virtual void Unregister(XMLRPCEvent *event) = 0;
+
+ virtual void Reply(XMLRPCClientSocket *source, XMLRPCRequest *request) = 0;
+
+ virtual Anope::string Sanitize(const Anope::string &string) = 0;
+
+ virtual void RunXMLRPC(XMLRPCClientSocket *source, XMLRPCRequest *request) = 0;
+};
+