2 * InspIRCd -- Internet Relay Chat Daemon
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>
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.
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
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/>.
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
38 virtual void SendMetaData(const std::string& key, const std::string& data) = 0;
41 class CoreExport ProtocolInterface
44 typedef ProtocolServer Server;
49 std::string servername;
50 std::string parentname;
51 std::string description;
52 unsigned int usercount;
53 unsigned int opercount;
54 unsigned int latencyms;
57 typedef std::vector<ServerInfo> ServerList;
59 virtual ~ProtocolInterface() { }
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.
71 virtual bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source = NULL) { return false; }
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
81 virtual void BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source = NULL, User* omit = NULL) { }
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
88 virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
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
95 virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
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
101 virtual void SendMetaData(const std::string& key, const std::string& data) { }
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.
107 virtual void SendSNONotice(char snomask, const std::string& text) { }
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)
115 virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { }
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)
122 virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
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.
129 DEPRECATED_METHOD(void SendChannelNotice(Channel* target, char status, const std::string& text))
131 SendMessage(target, status, text, MSG_NOTICE);
134 /** Send a notice to a user.
135 * @param target The user to message.
136 * @param text The message to send.
138 DEPRECATED_METHOD(void SendUserNotice(User* target, const std::string& text))
140 SendMessage(target, text, MSG_NOTICE);
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.
147 virtual void GetServerList(ServerList& sl) { }