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