]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/commands.h
m_spanningtree Remove duplicate code for sending channel messages from RouteCommand()
[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
24 /** Handle /RCONNECT
25  */
26 class CommandRConnect : public Command
27 {
28  public:
29         CommandRConnect(Module* Creator);
30         CmdResult Handle (const std::vector<std::string>& parameters, User *user);
31                 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
32 };
33
34 class CommandRSQuit : public Command
35 {
36  public:
37         CommandRSQuit(Module* Creator);
38         CmdResult Handle (const std::vector<std::string>& parameters, User *user);
39                 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
40 };
41
42 class CommandMap : public Command
43 {
44         /** Show MAP output to a user (recursive)
45          */
46         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
47
48         /** Returns oper-specific MAP information
49          */
50         std::string MapOperInfo(TreeServer* Current);
51
52  public:
53         CommandMap(Module* Creator);
54         CmdResult Handle(const std::vector<std::string>& parameters, User* user);
55         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
56 };
57
58 class CommandSVSJoin : public ServerCommand
59 {
60  public:
61         CommandSVSJoin(Module* Creator) : ServerCommand(Creator, "SVSJOIN", 2) { }
62         CmdResult Handle(User* user, std::vector<std::string>& params);
63         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
64 };
65
66 class CommandSVSPart : public ServerCommand
67 {
68  public:
69         CommandSVSPart(Module* Creator) : ServerCommand(Creator, "SVSPART", 2) { }
70         CmdResult Handle(User* user, std::vector<std::string>& params);
71         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
72 };
73
74 class CommandSVSNick : public ServerCommand
75 {
76  public:
77         CommandSVSNick(Module* Creator) : ServerCommand(Creator, "SVSNICK", 3) { }
78         CmdResult Handle(User* user, std::vector<std::string>& params);
79         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
80 };
81
82 class CommandMetadata : public ServerCommand
83 {
84  public:
85         CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
86         CmdResult Handle(User* user, std::vector<std::string>& params);
87 };
88
89 class CommandUID : public ServerCommand
90 {
91  public:
92         CommandUID(Module* Creator) : ServerCommand(Creator, "UID", 10) { }
93         CmdResult Handle(User* user, std::vector<std::string>& params);
94 };
95
96 class CommandOpertype : public ServerCommand
97 {
98  public:
99         CommandOpertype(Module* Creator) : ServerCommand(Creator, "OPERTYPE", 1) { }
100         CmdResult Handle(User* user, std::vector<std::string>& params);
101 };
102
103 class TreeSocket;
104 class CommandFJoin : public ServerCommand
105 {
106         /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
107          * This does not update the timestamp of the target channel, this must be done seperately.
108          */
109         static void RemoveStatus(Channel* c);
110         static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack);
111         bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack);
112  public:
113         CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
114         CmdResult Handle(User* user, std::vector<std::string>& params);
115 };
116
117 class CommandFMode : public ServerCommand
118 {
119  public:
120         CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
121         CmdResult Handle(User* user, std::vector<std::string>& params);
122 };
123
124 class CommandFTopic : public ServerCommand
125 {
126  public:
127         CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 5) { }
128         CmdResult Handle(User* user, std::vector<std::string>& params);
129 };
130
131 class CommandFHost : public ServerCommand
132 {
133  public:
134         CommandFHost(Module* Creator) : ServerCommand(Creator, "FHOST", 1) { }
135         CmdResult Handle(User* user, std::vector<std::string>& params);
136 };
137
138 class CommandFIdent : public ServerCommand
139 {
140  public:
141         CommandFIdent(Module* Creator) : ServerCommand(Creator, "FIDENT", 1) { }
142         CmdResult Handle(User* user, std::vector<std::string>& params);
143 };
144
145 class CommandFName : public ServerCommand
146 {
147  public:
148         CommandFName(Module* Creator) : ServerCommand(Creator, "FNAME", 1) { }
149         CmdResult Handle(User* user, std::vector<std::string>& params);
150 };
151
152 class CommandIJoin : public ServerCommand
153 {
154  public:
155         CommandIJoin(Module* Creator) : ServerCommand(Creator, "IJOIN", 1) { }
156         CmdResult Handle(User* user, std::vector<std::string>& params);
157 };
158
159 class CommandResync : public ServerCommand
160 {
161  public:
162         CommandResync(Module* Creator) : ServerCommand(Creator, "RESYNC", 1) { }
163         CmdResult Handle(User* user, std::vector<std::string>& parameters);
164 };
165
166 class CommandAway : public ServerCommand
167 {
168  public:
169         CommandAway(Module* Creator) : ServerCommand(Creator, "AWAY", 0, 2) { }
170         CmdResult Handle(User* user, std::vector<std::string>& parameters);
171 };
172
173 class CommandAddLine : public ServerCommand
174 {
175  public:
176         CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
177         CmdResult Handle(User* user, std::vector<std::string>& parameters);
178 };
179
180 class CommandDelLine : public ServerCommand
181 {
182  public:
183         CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
184         CmdResult Handle(User* user, std::vector<std::string>& parameters);
185 };
186
187 class CommandEncap : public ServerCommand
188 {
189  public:
190         CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
191         CmdResult Handle(User* user, std::vector<std::string>& parameters);
192         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
193 };
194
195 class CommandIdle : public ServerCommand
196 {
197  public:
198         CommandIdle(Module* Creator) : ServerCommand(Creator, "IDLE", 1) { }
199         CmdResult Handle(User* user, std::vector<std::string>& parameters);
200         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
201 };
202
203 class CommandNick : public ServerCommand
204 {
205  public:
206         CommandNick(Module* Creator) : ServerCommand(Creator, "NICK", 2) { }
207         CmdResult Handle(User* user, std::vector<std::string>& parameters);
208 };
209
210 class CommandPing : public ServerCommand
211 {
212  public:
213         CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
214         CmdResult Handle(User* user, std::vector<std::string>& parameters);
215         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
216 };
217
218 class CommandPong : public ServerCommand
219 {
220  public:
221         CommandPong(Module* Creator) : ServerCommand(Creator, "PONG", 1) { }
222         CmdResult Handle(User* user, std::vector<std::string>& parameters);
223         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
224 };
225
226 class CommandPush : public ServerCommand
227 {
228  public:
229         CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
230         CmdResult Handle(User* user, std::vector<std::string>& parameters);
231         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
232 };
233
234 class CommandSave : public ServerCommand
235 {
236  public:
237         CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
238         CmdResult Handle(User* user, std::vector<std::string>& parameters);
239 };
240
241 class CommandServer : public ServerCommand
242 {
243  public:
244         CommandServer(Module* Creator) : ServerCommand(Creator, "SERVER", 5) { }
245         CmdResult Handle(User* user, std::vector<std::string>& parameters);
246 };
247
248 class CommandSQuit : public ServerCommand
249 {
250  public:
251         CommandSQuit(Module* Creator) : ServerCommand(Creator, "SQUIT", 2) { }
252         CmdResult Handle(User* user, std::vector<std::string>& parameters);
253 };
254
255 class CommandSNONotice : public ServerCommand
256 {
257  public:
258         CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
259         CmdResult Handle(User* user, std::vector<std::string>& parameters);
260 };
261
262 class CommandVersion : public ServerCommand
263 {
264  public:
265         CommandVersion(Module* Creator) : ServerCommand(Creator, "VERSION", 1) { }
266         CmdResult Handle(User* user, std::vector<std::string>& parameters);
267 };
268
269 class CommandBurst : public ServerCommand
270 {
271  public:
272         CommandBurst(Module* Creator) : ServerCommand(Creator, "BURST") { }
273         CmdResult Handle(User* user, std::vector<std::string>& parameters);
274 };
275
276 class CommandEndBurst : public ServerCommand
277 {
278  public:
279         CommandEndBurst(Module* Creator) : ServerCommand(Creator, "ENDBURST") { }
280         CmdResult Handle(User* user, std::vector<std::string>& parameters);
281 };
282
283 class SpanningTreeCommands
284 {
285  public:
286         CommandRConnect rconnect;
287         CommandRSQuit rsquit;
288         CommandMap map;
289         CommandSVSJoin svsjoin;
290         CommandSVSPart svspart;
291         CommandSVSNick svsnick;
292         CommandMetadata metadata;
293         CommandUID uid;
294         CommandOpertype opertype;
295         CommandFJoin fjoin;
296         CommandIJoin ijoin;
297         CommandResync resync;
298         CommandFMode fmode;
299         CommandFTopic ftopic;
300         CommandFHost fhost;
301         CommandFIdent fident;
302         CommandFName fname;
303         CommandAway away;
304         CommandAddLine addline;
305         CommandDelLine delline;
306         CommandEncap encap;
307         CommandIdle idle;
308         CommandNick nick;
309         CommandPing ping;
310         CommandPong pong;
311         CommandPush push;
312         CommandSave save;
313         CommandServer server;
314         CommandSQuit squit;
315         CommandSNONotice snonotice;
316         CommandVersion version;
317         CommandBurst burst;
318         CommandEndBurst endburst;
319         SpanningTreeCommands(ModuleSpanningTree* module);
320 };