]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/commands.h
Automatically register and unregister mode watchers
[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
133         /**
134          * Lowers the TS on the given channel: removes all modes, unsets all extensions,
135          * clears the topic and removes all pending invites.
136          * @param chan The target channel whose TS to lower
137          * @param TS The new TS to set
138          * @param newname The new name of the channel; must be the same or a case change of the current name
139          */
140         static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
141         bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
142  public:
143         CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
144         CmdResult Handle(User* user, std::vector<std::string>& params);
145 };
146
147 class CommandFMode : public ServerCommand
148 {
149  public:
150         CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
151         CmdResult Handle(User* user, std::vector<std::string>& params);
152 };
153
154 class CommandFTopic : public ServerCommand
155 {
156  public:
157         CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
158         CmdResult Handle(User* user, std::vector<std::string>& params);
159
160         class Builder : public CmdBuilder
161         {
162          public:
163                 Builder(Channel* chan);
164                 Builder(User* user, Channel* chan);
165         };
166 };
167
168 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
169 {
170  public:
171         CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
172         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
173 };
174
175 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
176 {
177  public:
178         CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
179         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
180 };
181
182 class CommandFName : public UserOnlyServerCommand<CommandFName>
183 {
184  public:
185         CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
186         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
187 };
188
189 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
190 {
191  public:
192         CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
193         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
194 };
195
196 class CommandResync : public ServerOnlyServerCommand<CommandResync>
197 {
198  public:
199         CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
200         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
201 };
202
203 class CommandAway : public UserOnlyServerCommand<CommandAway>
204 {
205  public:
206         CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
207         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
208
209         class Builder : public CmdBuilder
210         {
211          public:
212                 Builder(User* user);
213                 Builder(User* user, const std::string& msg);
214         };
215 };
216
217 class XLine;
218 class CommandAddLine : public ServerCommand
219 {
220  public:
221         CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
222         CmdResult Handle(User* user, std::vector<std::string>& parameters);
223
224         class Builder : public CmdBuilder
225         {
226          public:
227                 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
228         };
229 };
230
231 class CommandDelLine : public ServerCommand
232 {
233  public:
234         CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
235         CmdResult Handle(User* user, std::vector<std::string>& parameters);
236 };
237
238 class CommandEncap : public ServerCommand
239 {
240  public:
241         CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
242         CmdResult Handle(User* user, std::vector<std::string>& parameters);
243         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
244 };
245
246 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
247 {
248  public:
249         CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
250         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
251         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
252 };
253
254 class CommandNick : public UserOnlyServerCommand<CommandNick>
255 {
256  public:
257         CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
258         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
259 };
260
261 class CommandPing : public ServerCommand
262 {
263  public:
264         CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
265         CmdResult Handle(User* user, std::vector<std::string>& parameters);
266         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
267 };
268
269 class CommandPong : public ServerOnlyServerCommand<CommandPong>
270 {
271  public:
272         CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
273         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
274         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
275 };
276
277 class CommandPush : public ServerCommand
278 {
279  public:
280         CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
281         CmdResult Handle(User* user, std::vector<std::string>& parameters);
282         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
283 };
284
285 class CommandSave : public ServerCommand
286 {
287  public:
288         CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
289         CmdResult Handle(User* user, std::vector<std::string>& parameters);
290 };
291
292 class CommandServer : public ServerOnlyServerCommand<CommandServer>
293 {
294  public:
295         CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
296         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
297
298         class Builder : public CmdBuilder
299         {
300          public:
301                 Builder(TreeServer* server);
302         };
303 };
304
305 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
306 {
307  public:
308         CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
309         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
310 };
311
312 class CommandSNONotice : public ServerCommand
313 {
314  public:
315         CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
316         CmdResult Handle(User* user, std::vector<std::string>& parameters);
317 };
318
319 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
320 {
321  public:
322         CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
323         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
324 };
325
326 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
327 {
328  public:
329         CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
330         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
331 };
332
333 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
334 {
335  public:
336         CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
337         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
338 };
339
340 class SpanningTreeCommands
341 {
342  public:
343         CommandSVSJoin svsjoin;
344         CommandSVSPart svspart;
345         CommandSVSNick svsnick;
346         CommandMetadata metadata;
347         CommandUID uid;
348         CommandOpertype opertype;
349         CommandFJoin fjoin;
350         CommandIJoin ijoin;
351         CommandResync resync;
352         CommandFMode fmode;
353         CommandFTopic ftopic;
354         CommandFHost fhost;
355         CommandFIdent fident;
356         CommandFName fname;
357         CommandAway away;
358         CommandAddLine addline;
359         CommandDelLine delline;
360         CommandEncap encap;
361         CommandIdle idle;
362         CommandNick nick;
363         CommandPing ping;
364         CommandPong pong;
365         CommandPush push;
366         CommandSave save;
367         CommandServer server;
368         CommandSQuit squit;
369         CommandSNONotice snonotice;
370         CommandVersion version;
371         CommandBurst burst;
372         CommandEndBurst endburst;
373         SpanningTreeCommands(ModuleSpanningTree* module);
374 };