2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
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.
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
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/>.
22 #include "servercommand.h"
23 #include "commandbuilder.h"
27 class CommandRConnect : public Command
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);
35 class CommandRSQuit : public Command
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);
43 class CommandMap : public Command
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);
51 class CommandSVSJoin : public ServerCommand
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);
59 class CommandSVSPart : public ServerCommand
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);
67 class CommandSVSNick : public ServerCommand
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);
75 class CommandMetadata : public ServerCommand
78 CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
79 CmdResult Handle(User* user, std::vector<std::string>& params);
81 class Builder : public CmdBuilder
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);
90 class CommandUID : public ServerOnlyServerCommand<CommandUID>
93 CommandUID(Module* Creator) : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10) { }
94 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& params);
96 class Builder : public CmdBuilder
103 class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
106 CommandOpertype(Module* Creator) : UserOnlyServerCommand<CommandOpertype>(Creator, "OPERTYPE", 1) { }
107 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
109 class Builder : public CmdBuilder
117 class CommandFJoin : public ServerCommand
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.
122 static void RemoveStatus(Channel* c);
123 static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack);
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
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);
135 CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
136 CmdResult Handle(User* user, std::vector<std::string>& params);
138 class Builder : public CmdBuilder
140 /** Maximum possible Membership::Id length in decimal digits, used for determining whether a user will fit into
143 static const size_t membid_max_digits = 20;
144 static const size_t maxline = 480;
145 std::string::size_type pos;
148 Builder(Channel* chan);
149 void add(Membership* memb);
150 bool has_room(Membership* memb) const;
152 const std::string& finalize();
156 class CommandFMode : public ServerCommand
159 CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
160 CmdResult Handle(User* user, std::vector<std::string>& params);
163 class CommandFTopic : public ServerCommand
166 CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
167 CmdResult Handle(User* user, std::vector<std::string>& params);
169 class Builder : public CmdBuilder
172 Builder(Channel* chan);
173 Builder(User* user, Channel* chan);
177 class CommandFHost : public UserOnlyServerCommand<CommandFHost>
180 CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
181 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
184 class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
187 CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
188 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
191 class CommandFName : public UserOnlyServerCommand<CommandFName>
194 CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
195 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
198 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
201 CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 2) { }
202 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
205 class CommandResync : public ServerOnlyServerCommand<CommandResync>
208 CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
209 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
210 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_LOCALONLY; }
213 class CommandAway : public UserOnlyServerCommand<CommandAway>
216 CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
217 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
219 class Builder : public CmdBuilder
223 Builder(User* user, const std::string& msg);
228 class CommandAddLine : public ServerCommand
231 CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
232 CmdResult Handle(User* user, std::vector<std::string>& parameters);
234 class Builder : public CmdBuilder
237 Builder(XLine* xline, User* user = ServerInstance->FakeClient);
241 class CommandDelLine : public ServerCommand
244 CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
245 CmdResult Handle(User* user, std::vector<std::string>& parameters);
248 class CommandEncap : public ServerCommand
251 CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
252 CmdResult Handle(User* user, std::vector<std::string>& parameters);
253 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
256 class CommandIdle : public UserOnlyServerCommand<CommandIdle>
259 CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
260 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
261 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
264 class CommandNick : public UserOnlyServerCommand<CommandNick>
267 CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
268 CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
271 class CommandPing : public ServerCommand
274 CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
275 CmdResult Handle(User* user, std::vector<std::string>& parameters);
276 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
279 class CommandPong : public ServerOnlyServerCommand<CommandPong>
282 CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
283 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
284 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
287 class CommandPush : public ServerCommand
290 CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
291 CmdResult Handle(User* user, std::vector<std::string>& parameters);
292 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
295 class CommandSave : public ServerCommand
298 CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
299 CmdResult Handle(User* user, std::vector<std::string>& parameters);
302 class CommandServer : public ServerOnlyServerCommand<CommandServer>
305 CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 5) { }
306 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
308 class Builder : public CmdBuilder
311 Builder(TreeServer* server);
315 class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
318 CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
319 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
322 class CommandSNONotice : public ServerCommand
325 CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
326 CmdResult Handle(User* user, std::vector<std::string>& parameters);
329 class CommandVersion : public ServerOnlyServerCommand<CommandVersion>
332 CommandVersion(Module* Creator) : ServerOnlyServerCommand<CommandVersion>(Creator, "VERSION", 1) { }
333 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
336 class CommandBurst : public ServerOnlyServerCommand<CommandBurst>
339 CommandBurst(Module* Creator) : ServerOnlyServerCommand<CommandBurst>(Creator, "BURST") { }
340 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
343 class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
346 CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
347 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
350 class CommandSInfo : public ServerOnlyServerCommand<CommandSInfo>
353 CommandSInfo(Module* Creator) : ServerOnlyServerCommand<CommandSInfo>(Creator, "SINFO", 2) { }
354 CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
356 class Builder : public CmdBuilder
359 Builder(TreeServer* server, const char* type, const std::string& value);
363 class SpanningTreeCommands
366 CommandSVSJoin svsjoin;
367 CommandSVSPart svspart;
368 CommandSVSNick svsnick;
369 CommandMetadata metadata;
371 CommandOpertype opertype;
374 CommandResync resync;
376 CommandFTopic ftopic;
378 CommandFIdent fident;
381 CommandAddLine addline;
382 CommandDelLine delline;
390 CommandServer server;
392 CommandSNONotice snonotice;
393 CommandVersion version;
395 CommandEndBurst endburst;
397 SpanningTreeCommands(ModuleSpanningTree* module);