]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/commands.h
m_spanningtree Rewrite /map
[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  public:
46         CommandMap(Module* Creator);
47         CmdResult Handle(const std::vector<std::string>& parameters, User* user);
48         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
49 };
50
51 class CommandSVSJoin : public ServerCommand
52 {
53  public:
54         CommandSVSJoin(Module* Creator) : ServerCommand(Creator, "SVSJOIN", 2) { }
55         CmdResult Handle(User* user, std::vector<std::string>& params);
56         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
57 };
58
59 class CommandSVSPart : public ServerCommand
60 {
61  public:
62         CommandSVSPart(Module* Creator) : ServerCommand(Creator, "SVSPART", 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 CommandSVSNick : public ServerCommand
68 {
69  public:
70         CommandSVSNick(Module* Creator) : ServerCommand(Creator, "SVSNICK", 3) { }
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 CommandMetadata : public ServerCommand
76 {
77  public:
78         CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
79         CmdResult Handle(User* user, std::vector<std::string>& params);
80
81         class Builder : public CmdBuilder
82         {
83          public:
84                 Builder(User* user, const std::string& key, const std::string& val);
85                 Builder(Channel* chan, const std::string& key, const std::string& val);
86                 Builder(const std::string& key, const std::string& val);
87         };
88 };
89
90 class CommandUID : public ServerOnlyServerCommand<CommandUID>
91 {
92  public:
93         CommandUID(Module* Creator) : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10) { }
94         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& params);
95
96         class Builder : public CmdBuilder
97         {
98          public:
99                 Builder(User* user);
100         };
101 };
102
103 class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
104 {
105  public:
106         CommandOpertype(Module* Creator) : UserOnlyServerCommand<CommandOpertype>(Creator, "OPERTYPE", 1) { }
107         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
108
109         class Builder : public CmdBuilder
110         {
111          public:
112                 Builder(User* user);
113         };
114 };
115
116 class TreeSocket;
117 class CommandFJoin : public ServerCommand
118 {
119         /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
120          * This does not update the timestamp of the target channel, this must be done seperately.
121          */
122         static void RemoveStatus(Channel* c);
123         static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack);
124
125         /**
126          * Lowers the TS on the given channel: removes all modes, unsets all extensions,
127          * clears the topic and removes all pending invites.
128          * @param chan The target channel whose TS to lower
129          * @param TS The new TS to set
130          * @param newname The new name of the channel; must be the same or a case change of the current name
131          */
132         static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
133         bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
134  public:
135         CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
136         CmdResult Handle(User* user, std::vector<std::string>& params);
137 };
138
139 class CommandFMode : public ServerCommand
140 {
141  public:
142         CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
143         CmdResult Handle(User* user, std::vector<std::string>& params);
144 };
145
146 class CommandFTopic : public ServerCommand
147 {
148  public:
149         CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
150         CmdResult Handle(User* user, std::vector<std::string>& params);
151
152         class Builder : public CmdBuilder
153         {
154          public:
155                 Builder(Channel* chan);
156                 Builder(User* user, Channel* chan);
157         };
158 };
159
160 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
161 {
162  public:
163         CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
164         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
165 };
166
167 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
168 {
169  public:
170         CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
171         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
172 };
173
174 class CommandFName : public UserOnlyServerCommand<CommandFName>
175 {
176  public:
177         CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
178         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
179 };
180
181 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
182 {
183  public:
184         CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
185         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
186 };
187
188 class CommandResync : public ServerOnlyServerCommand<CommandResync>
189 {
190  public:
191         CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
192         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
193 };
194
195 class CommandAway : public UserOnlyServerCommand<CommandAway>
196 {
197  public:
198         CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
199         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
200
201         class Builder : public CmdBuilder
202         {
203          public:
204                 Builder(User* user);
205                 Builder(User* user, const std::string& msg);
206         };
207 };
208
209 class XLine;
210 class CommandAddLine : public ServerCommand
211 {
212  public:
213         CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
214         CmdResult Handle(User* user, std::vector<std::string>& parameters);
215
216         class Builder : public CmdBuilder
217         {
218          public:
219                 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
220         };
221 };
222
223 class CommandDelLine : public ServerCommand
224 {
225  public:
226         CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
227         CmdResult Handle(User* user, std::vector<std::string>& parameters);
228 };
229
230 class CommandEncap : public ServerCommand
231 {
232  public:
233         CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
234         CmdResult Handle(User* user, std::vector<std::string>& parameters);
235         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
236 };
237
238 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
239 {
240  public:
241         CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
242         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
243         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
244 };
245
246 class CommandNick : public UserOnlyServerCommand<CommandNick>
247 {
248  public:
249         CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
250         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
251 };
252
253 class CommandPing : public ServerCommand
254 {
255  public:
256         CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
257         CmdResult Handle(User* user, std::vector<std::string>& parameters);
258         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
259 };
260
261 class CommandPong : public ServerOnlyServerCommand<CommandPong>
262 {
263  public:
264         CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
265         CmdResult HandleServer(TreeServer* server, 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 CommandPush : public ServerCommand
270 {
271  public:
272         CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
273         CmdResult Handle(User* user, 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 CommandSave : public ServerCommand
278 {
279  public:
280         CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
281         CmdResult Handle(User* user, std::vector<std::string>& parameters);
282 };
283
284 class CommandServer : public ServerOnlyServerCommand<CommandServer>
285 {
286  public:
287         CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
288         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
289
290         class Builder : public CmdBuilder
291         {
292          public:
293                 Builder(TreeServer* server);
294         };
295 };
296
297 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
298 {
299  public:
300         CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
301         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
302 };
303
304 class CommandSNONotice : public ServerCommand
305 {
306  public:
307         CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
308         CmdResult Handle(User* user, std::vector<std::string>& parameters);
309 };
310
311 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
312 {
313  public:
314         CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
315         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
316 };
317
318 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
319 {
320  public:
321         CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
322         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
323 };
324
325 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
326 {
327  public:
328         CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
329         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
330 };
331
332 class SpanningTreeCommands
333 {
334  public:
335         CommandSVSJoin svsjoin;
336         CommandSVSPart svspart;
337         CommandSVSNick svsnick;
338         CommandMetadata metadata;
339         CommandUID uid;
340         CommandOpertype opertype;
341         CommandFJoin fjoin;
342         CommandIJoin ijoin;
343         CommandResync resync;
344         CommandFMode fmode;
345         CommandFTopic ftopic;
346         CommandFHost fhost;
347         CommandFIdent fident;
348         CommandFName fname;
349         CommandAway away;
350         CommandAddLine addline;
351         CommandDelLine delline;
352         CommandEncap encap;
353         CommandIdle idle;
354         CommandNick nick;
355         CommandPing ping;
356         CommandPong pong;
357         CommandPush push;
358         CommandSave save;
359         CommandServer server;
360         CommandSQuit squit;
361         CommandSNONotice snonotice;
362         CommandVersion version;
363         CommandBurst burst;
364         CommandEndBurst endburst;
365         SpanningTreeCommands(ModuleSpanningTree* module);
366 };