]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/protocol.h
Fixes by misspell-fixer
[user/henk/code/inspircd.git] / include / protocol.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Matt Schatz <genius3000@g3k.solutions>
5  *   Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
6  *   Copyright (C) 2013, 2018-2019 Sadie Powell <sadie@witchery.services>
7  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
8  *   Copyright (C) 2008, 2010 Craig Edwards <brain@inspircd.org>
9  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
10  *
11  * This file is part of InspIRCd.  InspIRCd is free software: you can
12  * redistribute it and/or modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation, version 2.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24
25 #pragma once
26
27 #include "hashcomp.h"
28
29 class User;
30
31 class ProtocolServer
32 {
33  public:
34         /** Send metadata related to this server to the target server
35          * @param key The 'key' of the data
36          * @param data The string representation of the data
37          */
38         virtual void SendMetaData(const std::string& key, const std::string& data) = 0;
39 };
40
41 class CoreExport ProtocolInterface
42 {
43  public:
44         typedef ProtocolServer Server;
45
46         class ServerInfo
47         {
48          public:
49                 std::string servername;
50                 std::string parentname;
51                 std::string description;
52                 unsigned int usercount;
53                 unsigned int opercount;
54                 unsigned int latencyms;
55         };
56
57         typedef std::vector<ServerInfo> ServerList;
58
59         virtual ~ProtocolInterface() { }
60
61         /** Send an ENCAP message to all servers matching a wildcard string.
62          * See the protocol documentation for the purpose of ENCAP.
63          * @param targetmask The target server mask (can contain wildcards)
64          * @param cmd The ENCAP subcommand
65          * @param params List of string parameters which are dependent on the subcommand
66          * @param source The source of the message (prefix), must be a local user or NULL which means use local server
67          * @return Always true if the target mask contains wildcards; otherwise true if the server name was found,
68          * and the message was sent, false if it was not found.
69          * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
70          */
71         virtual bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source = NULL) { return false; }
72
73         /** Send an ENCAP message to all servers.
74          * See the protocol documentation for the purpose of ENCAP.
75          * @param cmd The ENCAP subcommand
76          * @param params List of string parameters which are dependent on the subcommand
77          * @param source The source of the message (prefix), must be a local user or a user behind 'omit'
78          * or NULL which is equivalent to the local server
79          * @param omit If non-NULL the message won't be sent in the direction of this server, useful for forwarding messages
80          */
81         virtual void BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source = NULL, User* omit = NULL) { }
82
83         /** Send metadata for a channel to other linked servers.
84          * @param chan The channel to send metadata for
85          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
86          * @param data The string representation of the data
87          */
88         virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
89
90         /** Send metadata for a user to other linked servers.
91          * @param user The user to send metadata for
92          * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
93          * @param data The string representation of the data
94          */
95         virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
96
97         /** Send metadata related to the server to other linked servers.
98          * @param key The 'key' of the data
99          * @param data The string representation of the data
100          */
101         virtual void SendMetaData(const std::string& key, const std::string& data) { }
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 a message to a channel.
110          * @param target The channel to message.
111          * @param status The status character (e.g. %) required to receive.
112          * @param text The message to send.
113          * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
114          */
115         virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { }
116
117         /** Send a message to a user.
118          * @param target The user to message.
119          * @param text The message to send.
120          * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
121          */
122         virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
123
124         /** Send a notice to a channel.
125          * @param target The channel to message.
126          * @param status The status character (e.g. %) required to receive.
127          * @param text The message to send.
128          */
129         DEPRECATED_METHOD(void SendChannelNotice(Channel* target, char status, const std::string& text))
130         {
131                 SendMessage(target, status, text, MSG_NOTICE);
132         }
133
134         /** Send a notice to a user.
135          * @param target The user to message.
136          * @param text The message to send.
137          */
138         DEPRECATED_METHOD(void SendUserNotice(User* target, const std::string& text))
139         {
140                 SendMessage(target, text, MSG_NOTICE);
141         }
142
143         /** Fill a list of servers and information about them.
144          * @param sl The list of servers to fill.
145          * XXX: document me properly, this is shit.
146          */
147         virtual void GetServerList(ServerList& sl) { }
148 };