]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/commands.h
m_spanningtree Remove CommandFJoin::ApplyModeStack()
[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
124         /**
125          * Lowers the TS on the given channel: removes all modes, unsets all extensions,
126          * clears the topic and removes all pending invites.
127          * @param chan The target channel whose TS to lower
128          * @param TS The new TS to set
129          * @param newname The new name of the channel; must be the same or a case change of the current name
130          */
131         static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
132         void ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, Modes::ChangeList* modechangelist);
133  public:
134         CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
135         CmdResult Handle(User* user, std::vector<std::string>& params);
136
137         class Builder : public CmdBuilder
138         {
139                 /** Maximum possible Membership::Id length in decimal digits, used for determining whether a user will fit into
140                  * a message or not
141                  */
142                 static const size_t membid_max_digits = 20;
143                 static const size_t maxline = 480;
144                 std::string::size_type pos;
145
146          public:
147                 Builder(Channel* chan);
148                 void add(Membership* memb);
149                 bool has_room(Membership* memb) const;
150                 void clear();
151                 const std::string& finalize();
152         };
153 };
154
155 class CommandFMode : public ServerCommand
156 {
157  public:
158         CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
159         CmdResult Handle(User* user, std::vector<std::string>& params);
160 };
161
162 class CommandFTopic : public ServerCommand
163 {
164  public:
165         CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
166         CmdResult Handle(User* user, std::vector<std::string>& params);
167
168         class Builder : public CmdBuilder
169         {
170          public:
171                 Builder(Channel* chan);
172                 Builder(User* user, Channel* chan);
173         };
174 };
175
176 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
177 {
178  public:
179         CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
180         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
181 };
182
183 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
184 {
185  public:
186         CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
187         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
188 };
189
190 class CommandFName : public UserOnlyServerCommand<CommandFName>
191 {
192  public:
193         CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
194         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
195 };
196
197 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
198 {
199  public:
200         CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 2) { }
201         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
202 };
203
204 class CommandResync : public ServerOnlyServerCommand<CommandResync>
205 {
206  public:
207         CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
208         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
209         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_LOCALONLY; }
210 };
211
212 class CommandAway : public UserOnlyServerCommand<CommandAway>
213 {
214  public:
215         CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
216         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
217
218         class Builder : public CmdBuilder
219         {
220          public:
221                 Builder(User* user);
222                 Builder(User* user, const std::string& msg);
223         };
224 };
225
226 class XLine;
227 class CommandAddLine : public ServerCommand
228 {
229  public:
230         CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
231         CmdResult Handle(User* user, std::vector<std::string>& parameters);
232
233         class Builder : public CmdBuilder
234         {
235          public:
236                 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
237         };
238 };
239
240 class CommandDelLine : public ServerCommand
241 {
242  public:
243         CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
244         CmdResult Handle(User* user, std::vector<std::string>& parameters);
245 };
246
247 class CommandEncap : public ServerCommand
248 {
249  public:
250         CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
251         CmdResult Handle(User* user, std::vector<std::string>& parameters);
252         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
253 };
254
255 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
256 {
257  public:
258         CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
259         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
260         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
261 };
262
263 class CommandNick : public UserOnlyServerCommand<CommandNick>
264 {
265  public:
266         CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
267         CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
268 };
269
270 class CommandPing : public ServerCommand
271 {
272  public:
273         CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
274         CmdResult Handle(User* user, std::vector<std::string>& parameters);
275         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
276 };
277
278 class CommandPong : public ServerOnlyServerCommand<CommandPong>
279 {
280  public:
281         CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
282         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
283         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
284 };
285
286 class CommandPush : public ServerCommand
287 {
288  public:
289         CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
290         CmdResult Handle(User* user, std::vector<std::string>& parameters);
291         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
292 };
293
294 class CommandSave : public ServerCommand
295 {
296  public:
297         /** Timestamp of the uuid nick of all users who collided and got their nick changed to uuid
298          */
299         static const time_t SavedTimestamp = 100;
300
301         CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
302         CmdResult Handle(User* user, std::vector<std::string>& parameters);
303 };
304
305 class CommandServer : public ServerOnlyServerCommand<CommandServer>
306 {
307         static void HandleExtra(TreeServer* newserver, const std::vector<std::string>& params);
308
309  public:
310         CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 3) { }
311         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
312
313         class Builder : public CmdBuilder
314         {
315                 void push_property(const char* key, const std::string& val)
316                 {
317                         push(key).push_raw('=').push_raw(val);
318                 }
319          public:
320                 Builder(TreeServer* server);
321         };
322 };
323
324 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
325 {
326  public:
327         CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
328         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
329 };
330
331 class CommandSNONotice : public ServerCommand
332 {
333  public:
334         CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
335         CmdResult Handle(User* user, 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 CommandSInfo : public ServerOnlyServerCommand<CommandSInfo>
346 {
347  public:
348         CommandSInfo(Module* Creator) : ServerOnlyServerCommand<CommandSInfo>(Creator, "SINFO", 2) { }
349         CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
350
351         class Builder : public CmdBuilder
352         {
353          public:
354                 Builder(TreeServer* server, const char* type, const std::string& value);
355         };
356 };
357
358 class SpanningTreeCommands
359 {
360  public:
361         CommandSVSJoin svsjoin;
362         CommandSVSPart svspart;
363         CommandSVSNick svsnick;
364         CommandMetadata metadata;
365         CommandUID uid;
366         CommandOpertype opertype;
367         CommandFJoin fjoin;
368         CommandIJoin ijoin;
369         CommandResync resync;
370         CommandFMode fmode;
371         CommandFTopic ftopic;
372         CommandFHost fhost;
373         CommandFIdent fident;
374         CommandFName fname;
375         CommandAway away;
376         CommandAddLine addline;
377         CommandDelLine delline;
378         CommandEncap encap;
379         CommandIdle idle;
380         CommandNick nick;
381         CommandPing ping;
382         CommandPong pong;
383         CommandPush push;
384         CommandSave save;
385         CommandServer server;
386         CommandSQuit squit;
387         CommandSNONotice snonotice;
388         CommandEndBurst endburst;
389         CommandSInfo sinfo;
390         SpanningTreeCommands(ModuleSpanningTree* module);
391 };