]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/protocol.h
Change type of snomask parameter to char in ProtocolInterface::SendSNONotice()
[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 ProtocolServer
30 {
31  public:
32         /** Send metadata related to this server to the target server
33          * @param key The 'key' of the data
34          * @param data The string representation of the data
35          */
36         virtual void SendMetaData(const std::string& key, const std::string& data) = 0;
37 };
38
39 class CoreExport ProtocolInterface
40 {
41  public:
42         typedef ProtocolServer Server;
43
44         class ServerInfo
45         {
46          public:
47                 std::string servername;
48                 std::string parentname;
49                 std::string gecos;
50                 unsigned int usercount;
51                 unsigned int opercount;
52                 unsigned int latencyms;
53         };
54
55         typedef std::vector<ServerInfo> ServerList;
56
57         virtual ~ProtocolInterface() { }
58
59         /** Send an ENCAP message to one or more linked servers.
60          * See the protocol documentation for the purpose of ENCAP.
61          * @param encap This is a list of string parameters, the first of which must be a server ID or glob matching servernames.
62          * The second must be a subcommand. All subsequent parameters are dependant on the subcommand.
63          * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
64          * @return True if the message was sent out (target exists)
65          */
66         virtual bool SendEncapsulatedData(const parameterlist &encap) { return false; }
67
68         /** Send metadata for a channel to other linked servers.
69          * @param chan The channel to send metadata for
70          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
71          * @param data The string representation of the data
72          */
73         virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
74
75         /** Send metadata for a user to other linked servers.
76          * @param user The user to send metadata for
77          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
78          * @param data The string representation of the data
79          */
80         virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
81
82         /** Send metadata related to the server to other linked servers.
83          * @param key The 'key' of the data
84          * @param data The string representation of the data
85          */
86         virtual void SendMetaData(const std::string& key, const std::string& data) { }
87
88         /** Send a topic change for a channel
89          * @param channel The channel to change the topic for.
90          * @param topic The new topic to use for the channel.
91          */
92         virtual void SendTopic(Channel* channel, std::string &topic) { }
93
94         /** Send mode changes for an object.
95          * @param source The source of the mode change
96          * @param usertarget The target user, NULL if the target is a channel
97          * @param chantarget The target channel, NULL if the target is a user
98          * @param modedata The mode changes to send.
99          * @param translate A list of translation types
100          */
101         virtual void SendMode(User* source, User* usertarget, Channel* chantarget, const parameterlist& modedata, const std::vector<TranslateType>& translate) { }
102
103         /** Send a notice to users with a given snomask.
104          * @param snomask The snomask required for the message to be sent.
105          * @param text The message to send.
106          */
107         virtual void SendSNONotice(char snomask, const std::string& text) { }
108
109         /** Send raw data to a remote client.
110          * @param target The user to push data to.
111          * @param rawline The raw IRC protocol line to deliver (":me NOTICE you :foo", whatever).
112          */
113         virtual void PushToClient(User* target, const std::string &rawline) { }
114
115         /** Send a message to a channel.
116          * @param target The channel to message.
117          * @param status The status character (e.g. %) required to recieve.
118          * @param text The message to send.
119          * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
120          */
121         virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { }
122
123         /** Send a message to a user.
124          * @param target The user to message.
125          * @param text The message to send.
126          * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
127          */
128         virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
129
130         /** Send a notice to a channel.
131          * @param target The channel to message.
132          * @param status The status character (e.g. %) required to recieve.
133          * @param text The message to send.
134          */
135         void SendChannelNotice(Channel* target, char status, const std::string &text)
136         {
137                 SendMessage(target, status, text, MSG_NOTICE);
138         }
139
140         /** Send a notice to a user.
141          * @param target The user to message.
142          * @param text The message to send.
143          */
144         void SendUserNotice(User* target, const std::string &text)
145         {
146                 SendMessage(target, text, MSG_NOTICE);
147         }
148
149         /** Fill a list of servers and information about them.
150          * @param sl The list of servers to fill.
151          * XXX: document me properly, this is shit.
152          */
153         virtual void GetServerList(ServerList& sl) { }
154 };