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