]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/commands.h
Split ProtocolInterface::SendMetaData() into multiple functions
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / commands.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #pragma once
21
22 #include "servercommand.h"
23 #include "commandbuilder.h"
24
25 /** Handle /RCONNECT
26  */
27 class CommandRConnect : public Command
28 {
29  public:
30         CommandRConnect(Module* Creator);
31         CmdResult Handle(const std::vector<std::string>& parameters, User* user);
32         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
33 };
34
35 class CommandRSQuit : public Command
36 {
37  public:
38         CommandRSQuit(Module* Creator);
39         CmdResult Handle(const std::vector<std::string>& parameters, User* user);
40         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
41 };
42
43 class CommandMap : public Command
44 {
45         /** Show MAP output to a user (recursive)
46          */
47         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
48
49         /** Returns oper-specific MAP information
50          */
51         std::string MapOperInfo(TreeServer* Current);
52
53  public:
54         CommandMap(Module* Creator);
55         CmdResult Handle(const std::vector<std::string>& parameters, User* user);
56         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
57 };
58
59 class CommandSVSJoin : public ServerCommand
60 {
61  public:
62         CommandSVSJoin(Module* Creator) : ServerCommand(Creator, "SVSJOIN", 2) { }
63         CmdResult Handle(User* user, std::vector<std::string>& params);
64         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
65 };
66
67 class CommandSVSPart : public ServerCommand
68 {
69  public:
70         CommandSVSPart(Module* Creator) : ServerCommand(Creator, "SVSPART", 2) { }
71         CmdResult Handle(User* user, std::vector<std::string>& params);
72         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
73 };
74
75 class CommandSVSNick : public ServerCommand
76 {
77  public:
78         CommandSVSNick(Module* Creator) : ServerCommand(Creator, "SVSNICK", 3) { }
79         CmdResult Handle(User* user, std::vector<std::string>& params);
80         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
81 };
82
83 class CommandMetadata : public ServerCommand
84 {
85  public:
86         CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
87         CmdResult Handle(User* user, std::vector<std::string>& params);
88
89         class Builder : public CmdBuilder
90         {
91          public:
92                 Builder(User* user, const std::string& key, const std::string& val);
93                 Builder(Channel* chan, const std::string& key, const std::string& val);
94                 Builder(const std::string& key, const std::string& val);
95         };
96 };
97
98 class CommandUID : public ServerOnlyServerCommand<CommandUID>
99 {
100  public:
101         CommandUID(Module* Creator) : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10) { }
102         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& params);
103
104         class Builder : public CmdBuilder
105         {
106          public:
107                 Builder(User* user);
108         };
109 };
110
111 class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
112 {
113  public:
114         CommandOpertype(Module* Creator) : UserOnlyServerCommand<CommandOpertype>(Creator, "OPERTYPE", 1) { }
115         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
116
117         class Builder : public CmdBuilder
118         {
119          public:
120                 Builder(User* user);
121         };
122 };
123
124 class TreeSocket;
125 class CommandFJoin : public ServerCommand
126 {
127         /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
128          * This does not update the timestamp of the target channel, this must be done seperately.
129          */
130         static void RemoveStatus(Channel* c);
131         static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack);
132         bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
133  public:
134         CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
135         CmdResult Handle(User* user, std::vector<std::string>& params);
136 };
137
138 class CommandFMode : public ServerCommand
139 {
140  public:
141         CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
142         CmdResult Handle(User* user, std::vector<std::string>& params);
143 };
144
145 class CommandFTopic : public ServerCommand
146 {
147  public:
148         CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
149         CmdResult Handle(User* user, std::vector<std::string>& params);
150
151         class Builder : public CmdBuilder
152         {
153          public:
154                 Builder(Channel* chan);
155                 Builder(User* user, Channel* chan);
156         };
157 };
158
159 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
160 {
161  public:
162         CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
163         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
164 };
165
166 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
167 {
168  public:
169         CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
170         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
171 };
172
173 class CommandFName : public UserOnlyServerCommand<CommandFName>
174 {
175  public:
176         CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
177         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
178 };
179
180 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
181 {
182  public:
183         CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
184         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
185 };
186
187 class CommandResync : public ServerOnlyServerCommand<CommandResync>
188 {
189  public:
190         CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
191         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
192 };
193
194 class CommandAway : public UserOnlyServerCommand<CommandAway>
195 {
196  public:
197         CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
198         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
199
200         class Builder : public CmdBuilder
201         {
202          public:
203                 Builder(User* user);
204                 Builder(User* user, const std::string& msg);
205         };
206 };
207
208 class XLine;
209 class CommandAddLine : public ServerCommand
210 {
211  public:
212         CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
213         CmdResult Handle(User* user, std::vector<std::string>& parameters);
214
215         class Builder : public CmdBuilder
216         {
217          public:
218                 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
219         };
220 };
221
222 class CommandDelLine : public ServerCommand
223 {
224  public:
225         CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
226         CmdResult Handle(User* user, std::vector<std::string>& parameters);
227 };
228
229 class CommandEncap : public ServerCommand
230 {
231  public:
232         CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
233         CmdResult Handle(User* user, std::vector<std::string>& parameters);
234         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
235 };
236
237 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
238 {
239  public:
240         CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
241         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
242         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
243 };
244
245 class CommandNick : public UserOnlyServerCommand<CommandNick>
246 {
247  public:
248         CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
249         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
250 };
251
252 class CommandPing : public ServerCommand
253 {
254  public:
255         CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
256         CmdResult Handle(User* user, std::vector<std::string>& parameters);
257         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
258 };
259
260 class CommandPong : public ServerOnlyServerCommand<CommandPong>
261 {
262  public:
263         CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
264         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
265         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
266 };
267
268 class CommandPush : public ServerCommand
269 {
270  public:
271         CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
272         CmdResult Handle(User* user, std::vector<std::string>& parameters);
273         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
274 };
275
276 class CommandSave : public ServerCommand
277 {
278  public:
279         CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
280         CmdResult Handle(User* user, std::vector<std::string>& parameters);
281 };
282
283 class CommandServer : public ServerOnlyServerCommand<CommandServer>
284 {
285  public:
286         CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
287         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
288
289         class Builder : public CmdBuilder
290         {
291          public:
292                 Builder(TreeServer* server);
293         };
294 };
295
296 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
297 {
298  public:
299         CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
300         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
301 };
302
303 class CommandSNONotice : public ServerCommand
304 {
305  public:
306         CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
307         CmdResult Handle(User* user, std::vector<std::string>& parameters);
308 };
309
310 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
311 {
312  public:
313         CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
314         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
315 };
316
317 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
318 {
319  public:
320         CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
321         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
322 };
323
324 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
325 {
326  public:
327         CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
328         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
329 };
330
331 class SpanningTreeCommands
332 {
333  public:
334         CommandSVSJoin svsjoin;
335         CommandSVSPart svspart;
336         CommandSVSNick svsnick;
337         CommandMetadata metadata;
338         CommandUID uid;
339         CommandOpertype opertype;
340         CommandFJoin fjoin;
341         CommandIJoin ijoin;
342         CommandResync resync;
343         CommandFMode fmode;
344         CommandFTopic ftopic;
345         CommandFHost fhost;
346         CommandFIdent fident;
347         CommandFName fname;
348         CommandAway away;
349         CommandAddLine addline;
350         CommandDelLine delline;
351         CommandEncap encap;
352         CommandIdle idle;
353         CommandNick nick;
354         CommandPing ping;
355         CommandPong pong;
356         CommandPush push;
357         CommandSave save;
358         CommandServer server;
359         CommandSQuit squit;
360         CommandSNONotice snonotice;
361         CommandVersion version;
362         CommandBurst burst;
363         CommandEndBurst endburst;
364         SpanningTreeCommands(ModuleSpanningTree* module);
365 };