1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
class XMLRPCClientSocket;
class XMLRPCListenSocket;
class XMLRPCServiceInterface;
class XMLRPCClientSocket : public ClientSocket, public BufferedSocket
{
protected:
Anope::string query;
public:
XMLRPCClientSocket(ListenSocket *ls, const sockaddrs &addr) : ClientSocket(ls, addr), BufferedSocket() { }
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, "XMLRPCServiceInterface", 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;
};
|