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/>.
27 typedef std::vector<std::string> parameterlist;
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
36 virtual void SendMetaData(const std::string& key, const std::string& data) = 0;
39 class CoreExport ProtocolInterface
42 typedef ProtocolServer Server;
47 std::string servername;
48 std::string parentname;
50 unsigned int usercount;
51 unsigned int opercount;
52 unsigned int latencyms;
55 typedef std::vector<ServerInfo> ServerList;
57 virtual ~ProtocolInterface() { }
59 /** Send an ENCAP message to all servers matching a wildcard string.
60 * See the protocol documentation for the purpose of ENCAP.
61 * @param targetmask The target server mask (can contain wildcards)
62 * @param cmd The ENCAP subcommand
63 * @param params List of string parameters which are dependant on the subcommand
64 * @param source The source of the message (prefix), must be a local user or NULL which means use local server
65 * @return Always true if the target mask contains wildcards; otherwise true if the server name was found,
66 * and the message was sent, false if it was not found.
67 * ENCAP (should) be used instead of creating new protocol messages for easier third party application support.
69 virtual bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const parameterlist& params, User* source = NULL) { return false; }
71 /** Send metadata for a channel to other linked servers.
72 * @param chan The channel to send metadata for
73 * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
74 * @param data The string representation of the data
76 virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
78 /** Send metadata for a user to other linked servers.
79 * @param user The user to send metadata for
80 * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
81 * @param data The string representation of the data
83 virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
85 /** Send metadata related to the server to other linked servers.
86 * @param key The 'key' of the data
87 * @param data The string representation of the data
89 virtual void SendMetaData(const std::string& key, const std::string& data) { }
91 /** Send a topic change for a channel
92 * @param channel The channel to change the topic for.
93 * @param topic The new topic to use for the channel.
95 virtual void SendTopic(Channel* channel, std::string &topic) { }
97 /** Send mode changes for an object.
98 * @param source The source of the mode change
99 * @param usertarget The target user, NULL if the target is a channel
100 * @param chantarget The target channel, NULL if the target is a user
101 * @param modedata The mode changes to send.
102 * @param translate A list of translation types
104 virtual void SendMode(User* source, User* usertarget, Channel* chantarget, const parameterlist& modedata, const std::vector<TranslateType>& translate) { }
106 /** Send a notice to users with a given snomask.
107 * @param snomask The snomask required for the message to be sent.
108 * @param text The message to send.
110 virtual void SendSNONotice(char snomask, const std::string& text) { }
112 /** Send raw data to a remote client.
113 * @param target The user to push data to.
114 * @param rawline The raw IRC protocol line to deliver (":me NOTICE you :foo", whatever).
116 virtual void PushToClient(User* target, const std::string &rawline) { }
118 /** Send a message to a channel.
119 * @param target The channel to message.
120 * @param status The status character (e.g. %) required to recieve.
121 * @param text The message to send.
122 * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
124 virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { }
126 /** Send a message to a user.
127 * @param target The user to message.
128 * @param text The message to send.
129 * @param type The message type (MSG_PRIVMSG or MSG_NOTICE)
131 virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
133 /** Send a notice to a channel.
134 * @param target The channel to message.
135 * @param status The status character (e.g. %) required to recieve.
136 * @param text The message to send.
138 void SendChannelNotice(Channel* target, char status, const std::string &text)
140 SendMessage(target, status, text, MSG_NOTICE);
143 /** Send a notice to a user.
144 * @param target The user to message.
145 * @param text The message to send.
147 void SendUserNotice(User* target, const std::string &text)
149 SendMessage(target, text, MSG_NOTICE);
152 /** Fill a list of servers and information about them.
153 * @param sl The list of servers to fill.
154 * XXX: document me properly, this is shit.
156 virtual void GetServerList(ServerList& sl) { }