]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/protocol.h
Fix Doxygen syntax errors.
[user/henk/code/inspircd.git] / include / protocol.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
5  *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #ifndef PROTOCOL_H
22 #define PROTOCOL_H
23
24 #include "hashcomp.h"
25
26 class User;
27
28 typedef std::vector<std::string> parameterlist;
29
30 class ProtoServer
31 {
32  public:
33         std::string servername;
34         std::string parentname;
35         std::string gecos;
36         unsigned int usercount;
37         unsigned int opercount;
38         unsigned int latencyms;
39 };
40
41 typedef std::list<ProtoServer> ProtoServerList;
42
43 class ProtocolInterface
44 {
45  public:
46         ProtocolInterface() { }
47         virtual ~ProtocolInterface() { }
48
49         /** Send an ENCAP message to one or more linked servers.
50          * See the protocol documentation for the purpose of ENCAP.
51          * @param encap This is a list of string parameters, the first of which must be a server ID or glob matching servernames.
52          * The second must be a subcommand. All subsequent parameters are dependant on the subcommand.
53          * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
54          * @return True if the message was sent out (target exists)
55          */
56         virtual bool SendEncapsulatedData(const parameterlist &encap) { return false; }
57
58         /** Send metadata for an object to other linked servers.
59          * @param target The object to send metadata for.
60          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
61          * @param data The string representation of the data
62          */
63         virtual void SendMetaData(Extensible* target, const std::string &key, const std::string &data) { }
64
65         /** Send a topic change for a channel
66          * @param channel The channel to change the topic for.
67          * @param topic The new topic to use for the channel.
68          */
69         virtual void SendTopic(Channel* channel, std::string &topic) { }
70
71         /** Send mode changes for an object.
72          * @param target The channel name or user to send mode changes for.
73          * @param modedata The mode changes to send.
74          * @param translate A list of translation types
75          */
76         virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &translate) { }
77
78         /** Convenience function, string wrapper around the above.
79           */
80         virtual void SendModeStr(const std::string &target, const std::string &modeline)
81         {
82                 irc::spacesepstream x(modeline);
83                 parameterlist n;
84                 std::vector<TranslateType> types;
85                 std::string v;
86                 while (x.GetToken(v))
87                 {
88                         n.push_back(v);
89                         types.push_back(TR_TEXT);
90                 }
91                 SendMode(target, n, types);
92         }
93
94         /** Send a notice to users with a given snomask.
95          * @param snomask The snomask required for the message to be sent.
96          * @param text The message to send.
97          */
98         virtual void SendSNONotice(const std::string &snomask, const std::string &text) { }
99
100         /** Send raw data to a remote client.
101          * @param target The user to push data to.
102          * @param rawline The raw IRC protocol line to deliver (":me NOTICE you :foo", whatever).
103          */
104         virtual void PushToClient(User* target, const std::string &rawline) { }
105
106         /** Send a message to a channel.
107          * @param target The channel to message.
108          * @param status The status character (e.g. %) required to recieve.
109          * @param text The message to send.
110          */
111         virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text) { }
112
113         /** Send a notice to a channel.
114          * @param target The channel to message.
115          * @param status The status character (e.g. %) required to recieve.
116          * @param text The message to send.
117          */
118         virtual void SendChannelNotice(Channel* target, char status, const std::string &text) { }
119
120         /** Send a message to a user.
121          * @param target The user to message.
122          * @param text The message to send.
123          */
124         virtual void SendUserPrivmsg(User* target, const std::string &text) { }
125
126         /** Send a notice to a user.
127          * @param target The user to message.
128          * @param text The message to send.
129          */
130         virtual void SendUserNotice(User* target, const std::string &text) { }
131
132         /** Fill a list of servers and information about them.
133          * @param sl The list of servers to fill.
134          * XXX: document me properly, this is shit.
135          */
136         virtual void GetServerList(ProtoServerList &sl) { }
137 };
138
139 #endif
140