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