]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/protocol.h
As we have an enum for type, why not ..use it?
[user/henk/code/inspircd.git] / include / protocol.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __PROTOCOL_H__
15 #define __PROTOCOL_H__
16
17 #include "hashcomp.h"
18
19 class InspIRCd;
20 class User;
21
22 typedef std::deque<std::string> parameterlist;
23
24 class ProtoServer
25 {
26  public:
27         std::string servername;
28         std::string parentname;
29         std::string gecos;
30         unsigned int usercount;
31         unsigned int opercount;
32         unsigned int latencyms;
33 };
34
35 typedef std::list<ProtoServer> ProtoServerList;
36
37 class ProtocolInterface : public Extensible
38 {
39  protected:
40         InspIRCd* ServerInstance;
41  public:
42         ProtocolInterface(InspIRCd* Instance) : ServerInstance(Instance) { }
43         virtual ~ProtocolInterface() { }
44
45         /** Send an ENCAP message to one or more linked servers.
46          * See the protocol documentation for the purpose of ENCAP.
47          * @param encap This is a list of string parameters, the first of which must be a server ID or glob matching servernames.
48          * The second must be a subcommand. All subsequent parameters are dependant on the subcommand.
49          * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
50          */
51         virtual void SendEncapsulatedData(parameterlist &encap) { }
52
53         /** Send metadata for an object to other linked servers.
54          * @param target The object to send metadata for.
55          * @param type The type of metadata to send (TYPE_USER, TYPE_CHANNEL, etc)
56          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
57          * @param data The string representation of the data
58          */
59         virtual void SendMetaData(void* target, TargetTypeFlags type, const std::string &key, const std::string &data) { }
60
61         /** Send a topic change for a channel
62          * @param channel The channel to change the topic for.
63          * @param topic The new topic to use for the channel.
64          */
65         virtual void SendTopic(Channel* channel, std::string &topic) { }
66
67         /** Send mode changes for an object.
68          * @param target The channel name or user to send mode changes for.
69          * @param The mode changes to send.
70          */
71         virtual void SendMode(const std::string &target, parameterlist &modedata) { }
72
73         /** Convenience function, string wrapper around the above.
74           */
75         virtual void SendModeStr(const std::string &target, const std::string &modeline)
76         {
77                 irc::spacesepstream x(modeline);
78                 parameterlist n;
79                 std::string v;
80                 while (x.GetToken(v))
81                         n.push_back(v);
82                 SendMode(target, n);
83         }
84
85         /** Send a notice to users with a given mode(s).
86          * @param modes The modes required for the message to be sent.
87          * @param text The message to send.
88          */
89         virtual void SendModeNotice(const std::string &modes, const std::string &text) { }
90
91         /** Send a notice to users with a given snomask.
92          * @param snomask The snomask required for the message to be sent.
93          * @param text The message to send.
94          */
95         virtual void SendSNONotice(const std::string &snomask, const std::string &text) { }
96
97         /** Send raw data to a remote client.
98          * @param target The user to push data to.
99          * @param rawline The raw IRC protocol line to deliver (":me NOTICE you :foo", whatever).
100          */
101         virtual void PushToClient(User* target, const std::string &rawline) { }
102
103         /** Send a message to a channel.
104          * @param target The channel to message.
105          * @param status The status character (e.g. %) required to recieve.
106          * @param text The message to send.
107          */
108         virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text) { }
109
110         /** Send a notice to a channel.
111          * @param target The channel to message.
112          * @param status The status character (e.g. %) required to recieve.
113          * @param text The message to send.
114          */
115         virtual void SendChannelNotice(Channel* target, char status, const std::string &text) { }
116
117         /** Send a message to a user.
118          * @param target The user to message.
119          * @param text The message to send.
120          */
121         virtual void SendUserPrivmsg(User* target, const std::string &text) { }
122
123         /** Send a notice to a user.
124          * @param target The user to message.
125          * @param text The message to send.
126          */
127         virtual void SendUserNotice(User* target, const std::string &text) { }
128
129         /** Fill a list of servers and information about them.
130          * @param sl The list of servers to fill.
131          * XXX: document me properly, this is shit.
132          */
133         virtual void GetServerList(ProtoServerList &sl) { }
134
135         /** Send information about a user connection to linked servers.
136          * @param u The user to send information about.
137          */
138         virtual void Introduce(User* u) { }
139 };
140
141 #endif
142