]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/protocol.h
Introduce ModeProcessFlags, can be passed to ModeParser::Process() to indicate local...
[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 #pragma once
22
23 #include "hashcomp.h"
24
25 class User;
26
27 typedef std::vector<std::string> parameterlist;
28
29 class ProtoServer
30 {
31  public:
32         std::string servername;
33         std::string parentname;
34         std::string gecos;
35         unsigned int usercount;
36         unsigned int opercount;
37         unsigned int latencyms;
38 };
39
40 typedef std::list<ProtoServer> ProtoServerList;
41
42 class ProtocolInterface
43 {
44  public:
45         ProtocolInterface() { }
46         virtual ~ProtocolInterface() { }
47
48         /** Send an ENCAP message to one or more linked servers.
49          * See the protocol documentation for the purpose of ENCAP.
50          * @param encap This is a list of string parameters, the first of which must be a server ID or glob matching servernames.
51          * The second must be a subcommand. All subsequent parameters are dependant on the subcommand.
52          * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
53          * @return True if the message was sent out (target exists)
54          */
55         virtual bool SendEncapsulatedData(const parameterlist &encap) { return false; }
56
57         /** Send metadata for an object to other linked servers.
58          * @param target The object to send metadata for.
59          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
60          * @param data The string representation of the data
61          */
62         virtual void SendMetaData(Extensible* target, const std::string &key, const std::string &data) { }
63
64         /** Send a topic change for a channel
65          * @param channel The channel to change the topic for.
66          * @param topic The new topic to use for the channel.
67          */
68         virtual void SendTopic(Channel* channel, std::string &topic) { }
69
70         /** Send mode changes for an object.
71          * @param source The source of the mode change
72          * @param usertarget The target user, NULL if the target is a channel
73          * @param chantarget The target channel, NULL if the target is a user
74          * @param modedata The mode changes to send.
75          * @param translate A list of translation types
76          */
77         virtual void SendMode(User* source, User* usertarget, Channel* chantarget, const parameterlist& modedata, const std::vector<TranslateType>& translate) { }
78
79         /** Send a notice to users with a given snomask.
80          * @param snomask The snomask required for the message to be sent.
81          * @param text The message to send.
82          */
83         virtual void SendSNONotice(const std::string &snomask, const std::string &text) { }
84
85         /** Send raw data to a remote client.
86          * @param target The user to push data to.
87          * @param rawline The raw IRC protocol line to deliver (":me NOTICE you :foo", whatever).
88          */
89         virtual void PushToClient(User* target, const std::string &rawline) { }
90
91         /** Send a message to a channel.
92          * @param target The channel to message.
93          * @param status The status character (e.g. %) required to recieve.
94          * @param text The message to send.
95          */
96         virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text) { }
97
98         /** Send a notice to a channel.
99          * @param target The channel to message.
100          * @param status The status character (e.g. %) required to recieve.
101          * @param text The message to send.
102          */
103         virtual void SendChannelNotice(Channel* target, char status, const std::string &text) { }
104
105         /** Send a message to a user.
106          * @param target The user to message.
107          * @param text The message to send.
108          */
109         virtual void SendUserPrivmsg(User* target, const std::string &text) { }
110
111         /** Send a notice to a user.
112          * @param target The user to message.
113          * @param text The message to send.
114          */
115         virtual void SendUserNotice(User* target, const std::string &text) { }
116
117         /** Fill a list of servers and information about them.
118          * @param sl The list of servers to fill.
119          * XXX: document me properly, this is shit.
120          */
121         virtual void GetServerList(ProtoServerList &sl) { }
122 };