2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
5 * Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
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.
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
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/>.
30 /** Send metadata related to this server to the target server
31 * @param key The 'key' of the data
32 * @param data The string representation of the data
34 virtual void SendMetaData(const std::string& key, const std::string& data) = 0;
37 class CoreExport ProtocolInterface
40 typedef ProtocolServer Server;
45 std::string servername;
46 std::string parentname;
47 std::string description;
48 unsigned int usercount;
49 unsigned int opercount;
50 unsigned int latencyms;
53 typedef std::vector<ServerInfo> ServerList;
55 virtual ~ProtocolInterface() { }
57 /** Send an ENCAP message to all servers matching a wildcard string.
58 * See the protocol documentation for the purpose of ENCAP.
59 * @param targetmask The target server mask (can contain wildcards)
60 * @param cmd The ENCAP subcommand
61 * @param params List of string parameters which are dependant on the subcommand
62 * @param source The source of the message (prefix), must be a local user or NULL which means use local server
63 * @return Always true if the target mask contains wildcards; otherwise true if the server name was found,
64 * and the message was sent, false if it was not found.
65 * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
67 virtual bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source = NULL) { return false; }
69 /** Send an ENCAP message to all servers.
70 * See the protocol documentation for the purpose of ENCAP.
71 * @param cmd The ENCAP subcommand
72 * @param params List of string parameters which are dependant on the subcommand
73 * @param source The source of the message (prefix), must be a local user or a user behind 'omit'
74 * or NULL which is equivalent to the local server
75 * @param omit If non-NULL the message won't be sent in the direction of this server, useful for forwarding messages
77 virtual void BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source = NULL, User* omit = NULL) { }
79 /** Send metadata for a channel to other linked servers.
80 * @param chan The channel to send metadata for
81 * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
82 * @param data The string representation of the data
84 virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
86 /** Send metadata for a user to other linked servers.
87 * @param user The user to send metadata for
88 * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
89 * @param data The string representation of the data
91 virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
93 /** Send metadata related to the server to other linked servers.
94 * @param key The 'key' of the data
95 * @param data The string representation of the data
97 virtual void SendMetaData(const std::string& key, const std::string& data) { }
99 /** Send a notice to users with a given snomask.
100 * @param snomask The snomask required for the message to be sent.
101 * @param text The message to send.
103 virtual void SendSNONotice(char snomask, const std::string& text) { }
105 /** Send a message to a channel.
106 * @param target The channel to message.
107 * @param status The status character (e.g. %) required to recieve.
108 * @param text The message to send.
109 * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
111 virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { }
113 /** Send a message to a user.
114 * @param target The user to message.
115 * @param text The message to send.
116 * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
118 virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
120 /** Send a notice to a channel.
121 * @param target The channel to message.
122 * @param status The status character (e.g. %) required to recieve.
123 * @param text The message to send.
125 void SendChannelNotice(Channel* target, char status, const std::string &text)
127 SendMessage(target, status, text, MSG_NOTICE);
130 /** Send a notice to a user.
131 * @param target The user to message.
132 * @param text The message to send.
134 void SendUserNotice(User* target, const std::string &text)
136 SendMessage(target, text, MSG_NOTICE);
139 /** Fill a list of servers and information about them.
140 * @param sl The list of servers to fill.
141 * XXX: document me properly, this is shit.
143 virtual void GetServerList(ServerList& sl) { }