X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fcommands.h;h=1f7456426e3d6a9df87aa35a2ba956468e234470;hb=6c5ac89f35d49833d7075c1449b2d82ddf7926dc;hp=a895c569b2510aa6933631de0d98f76f968bdd86;hpb=b14ebbccf08ec34a73e1ba271e67da80d9fe805c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index a895c569b..1f7456426 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -19,24 +19,33 @@ #pragma once -#include "main.h" +#include "servercommand.h" +#include "commandbuilder.h" /** Handle /RCONNECT */ class CommandRConnect : public Command { public: - CommandRConnect(Module* Creator); - CmdResult Handle (const std::vector& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector& parameters); + CommandRConnect(Module* Creator); + CmdResult Handle(const std::vector& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector& parameters); }; class CommandRSQuit : public Command { public: - CommandRSQuit(Module* Creator); - CmdResult Handle (const std::vector& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector& parameters); + CommandRSQuit(Module* Creator); + CmdResult Handle(const std::vector& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector& parameters); +}; + +class CommandMap : public Command +{ + public: + CommandMap(Module* Creator); + CmdResult Handle(const std::vector& parameters, User* user); + RouteDescriptor GetRouting(User* user, const std::vector& parameters); }; class CommandSVSJoin : public ServerCommand @@ -68,34 +77,93 @@ class CommandMetadata : public ServerCommand public: CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { } CmdResult Handle(User* user, std::vector& params); + + class Builder : public CmdBuilder + { + public: + Builder(User* user, const std::string& key, const std::string& val); + Builder(Channel* chan, const std::string& key, const std::string& val); + Builder(const std::string& key, const std::string& val); + }; }; -class CommandUID : public ServerCommand +class CommandUID : public ServerOnlyServerCommand { public: - CommandUID(Module* Creator) : ServerCommand(Creator, "UID", 10) { } - CmdResult Handle(User* user, std::vector& params); + CommandUID(Module* Creator) : ServerOnlyServerCommand(Creator, "UID", 10) { } + CmdResult HandleServer(TreeServer* server, std::vector& params); + + class Builder : public CmdBuilder + { + public: + Builder(User* user); + }; }; -class CommandOpertype : public ServerCommand +class CommandOpertype : public UserOnlyServerCommand { public: - CommandOpertype(Module* Creator) : ServerCommand(Creator, "OPERTYPE", 1) { } - CmdResult Handle(User* user, std::vector& params); + CommandOpertype(Module* Creator) : UserOnlyServerCommand(Creator, "OPERTYPE", 1) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& params); + + class Builder : public CmdBuilder + { + public: + Builder(User* user); + }; }; class TreeSocket; +class FwdFJoinBuilder; class CommandFJoin : public ServerCommand { /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes. * This does not update the timestamp of the target channel, this must be done seperately. */ static void RemoveStatus(Channel* c); - static void ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& stack); - bool ProcessModeUUIDPair(const std::string& item, TreeSocket* src_socket, Channel* chan, irc::modestacker* modestack); + + /** + * Lowers the TS on the given channel: removes all modes, unsets all extensions, + * clears the topic and removes all pending invites. + * @param chan The target channel whose TS to lower + * @param TS The new TS to set + * @param newname The new name of the channel; must be the same or a case change of the current name + */ + static void LowerTS(Channel* chan, time_t TS, const std::string& newname); + void ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, Modes::ChangeList* modechangelist, FwdFJoinBuilder& fwdfjoin); public: CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { } CmdResult Handle(User* user, std::vector& params); + RouteDescriptor GetRouting(User* user, const std::vector& parameters) { return ROUTE_LOCALONLY; } + + class Builder : public CmdBuilder + { + /** Maximum possible Membership::Id length in decimal digits, used for determining whether a user will fit into + * a message or not + */ + static const size_t membid_max_digits = 20; + static const size_t maxline = 510; + std::string::size_type pos; + + protected: + void add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend); + bool has_room(std::string::size_type nummodes) const; + + public: + Builder(Channel* chan, TreeServer* source = Utils->TreeRoot); + void add(Membership* memb) + { + add(memb, memb->modes.begin(), memb->modes.end()); + } + + bool has_room(Membership* memb) const + { + return has_room(memb->modes.size()); + } + + void clear(); + const std::string& finalize(); + }; }; class CommandFMode : public ServerCommand @@ -108,57 +176,79 @@ class CommandFMode : public ServerCommand class CommandFTopic : public ServerCommand { public: - CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 5) { } + CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { } CmdResult Handle(User* user, std::vector& params); + + class Builder : public CmdBuilder + { + public: + Builder(Channel* chan); + Builder(User* user, Channel* chan); + }; }; -class CommandFHost : public ServerCommand +class CommandFHost : public UserOnlyServerCommand { public: - CommandFHost(Module* Creator) : ServerCommand(Creator, "FHOST", 1) { } - CmdResult Handle(User* user, std::vector& params); + CommandFHost(Module* Creator) : UserOnlyServerCommand(Creator, "FHOST", 1) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& params); }; -class CommandFIdent : public ServerCommand +class CommandFIdent : public UserOnlyServerCommand { public: - CommandFIdent(Module* Creator) : ServerCommand(Creator, "FIDENT", 1) { } - CmdResult Handle(User* user, std::vector& params); + CommandFIdent(Module* Creator) : UserOnlyServerCommand(Creator, "FIDENT", 1) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& params); }; -class CommandFName : public ServerCommand +class CommandFName : public UserOnlyServerCommand { public: - CommandFName(Module* Creator) : ServerCommand(Creator, "FNAME", 1) { } - CmdResult Handle(User* user, std::vector& params); + CommandFName(Module* Creator) : UserOnlyServerCommand(Creator, "FNAME", 1) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& params); }; -class CommandIJoin : public ServerCommand +class CommandIJoin : public UserOnlyServerCommand { public: - CommandIJoin(Module* Creator) : ServerCommand(Creator, "IJOIN", 1) { } - CmdResult Handle(User* user, std::vector& params); + CommandIJoin(Module* Creator) : UserOnlyServerCommand(Creator, "IJOIN", 2) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& params); }; -class CommandResync : public ServerCommand +class CommandResync : public ServerOnlyServerCommand { public: - CommandResync(Module* Creator) : ServerCommand(Creator, "RESYNC", 1) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandResync(Module* Creator) : ServerOnlyServerCommand(Creator, "RESYNC", 1) { } + CmdResult HandleServer(TreeServer* server, std::vector& parameters); + RouteDescriptor GetRouting(User* user, const std::vector& parameters) { return ROUTE_LOCALONLY; } }; -class CommandAway : public ServerCommand +class CommandAway : public UserOnlyServerCommand { public: - CommandAway(Module* Creator) : ServerCommand(Creator, "AWAY", 0, 2) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandAway(Module* Creator) : UserOnlyServerCommand(Creator, "AWAY", 0, 2) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& parameters); + + class Builder : public CmdBuilder + { + public: + Builder(User* user); + Builder(User* user, const std::string& msg); + }; }; +class XLine; class CommandAddLine : public ServerCommand { public: CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { } CmdResult Handle(User* user, std::vector& parameters); + + class Builder : public CmdBuilder + { + public: + Builder(XLine* xline, User* user = ServerInstance->FakeClient); + }; }; class CommandDelLine : public ServerCommand @@ -176,19 +266,19 @@ class CommandEncap : public ServerCommand RouteDescriptor GetRouting(User* user, const std::vector& parameters); }; -class CommandIdle : public ServerCommand +class CommandIdle : public UserOnlyServerCommand { public: - CommandIdle(Module* Creator) : ServerCommand(Creator, "IDLE", 1) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandIdle(Module* Creator) : UserOnlyServerCommand(Creator, "IDLE", 1) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& parameters); RouteDescriptor GetRouting(User* user, const std::vector& parameters) { return ROUTE_UNICAST(parameters[0]); } }; -class CommandNick : public ServerCommand +class CommandNick : public UserOnlyServerCommand { public: - CommandNick(Module* Creator) : ServerCommand(Creator, "NICK", 2) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandNick(Module* Creator) : UserOnlyServerCommand(Creator, "NICK", 2) { } + CmdResult HandleRemote(RemoteUser* user, std::vector& parameters); }; class CommandPing : public ServerCommand @@ -199,11 +289,11 @@ class CommandPing : public ServerCommand RouteDescriptor GetRouting(User* user, const std::vector& parameters) { return ROUTE_UNICAST(parameters[0]); } }; -class CommandPong : public ServerCommand +class CommandPong : public ServerOnlyServerCommand { public: - CommandPong(Module* Creator) : ServerCommand(Creator, "PONG", 1) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandPong(Module* Creator) : ServerOnlyServerCommand(Creator, "PONG", 1) { } + CmdResult HandleServer(TreeServer* server, std::vector& parameters); RouteDescriptor GetRouting(User* user, const std::vector& parameters) { return ROUTE_UNICAST(parameters[0]); } }; @@ -218,22 +308,38 @@ class CommandPush : public ServerCommand class CommandSave : public ServerCommand { public: + /** Timestamp of the uuid nick of all users who collided and got their nick changed to uuid + */ + static const time_t SavedTimestamp = 100; + CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { } CmdResult Handle(User* user, std::vector& parameters); }; -class CommandServer : public ServerCommand +class CommandServer : public ServerOnlyServerCommand { + static void HandleExtra(TreeServer* newserver, const std::vector& params); + public: - CommandServer(Module* Creator) : ServerCommand(Creator, "SERVER", 5) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandServer(Module* Creator) : ServerOnlyServerCommand(Creator, "SERVER", 3) { } + CmdResult HandleServer(TreeServer* server, std::vector& parameters); + + class Builder : public CmdBuilder + { + void push_property(const char* key, const std::string& val) + { + push(key).push_raw('=').push_raw(val); + } + public: + Builder(TreeServer* server); + }; }; -class CommandSQuit : public ServerCommand +class CommandSQuit : public ServerOnlyServerCommand { public: - CommandSQuit(Module* Creator) : ServerCommand(Creator, "SQUIT", 2) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandSQuit(Module* Creator) : ServerOnlyServerCommand(Creator, "SQUIT", 2) { } + CmdResult HandleServer(TreeServer* server, std::vector& parameters); }; class CommandSNONotice : public ServerCommand @@ -243,32 +349,29 @@ class CommandSNONotice : public ServerCommand CmdResult Handle(User* user, std::vector& parameters); }; -class CommandVersion : public ServerCommand +class CommandEndBurst : public ServerOnlyServerCommand { public: - CommandVersion(Module* Creator) : ServerCommand(Creator, "VERSION", 1) { } - CmdResult Handle(User* user, std::vector& parameters); + CommandEndBurst(Module* Creator) : ServerOnlyServerCommand(Creator, "ENDBURST") { } + CmdResult HandleServer(TreeServer* server, std::vector& parameters); }; -class CommandBurst : public ServerCommand +class CommandSInfo : public ServerOnlyServerCommand { public: - CommandBurst(Module* Creator) : ServerCommand(Creator, "BURST") { } - CmdResult Handle(User* user, std::vector& parameters); -}; + CommandSInfo(Module* Creator) : ServerOnlyServerCommand(Creator, "SINFO", 2) { } + CmdResult HandleServer(TreeServer* server, std::vector& parameters); -class CommandEndBurst : public ServerCommand -{ - public: - CommandEndBurst(Module* Creator) : ServerCommand(Creator, "ENDBURST") { } - CmdResult Handle(User* user, std::vector& parameters); + class Builder : public CmdBuilder + { + public: + Builder(TreeServer* server, const char* type, const std::string& value); + }; }; class SpanningTreeCommands { public: - CommandRConnect rconnect; - CommandRSQuit rsquit; CommandSVSJoin svsjoin; CommandSVSPart svspart; CommandSVSNick svsnick; @@ -296,8 +399,7 @@ class SpanningTreeCommands CommandServer server; CommandSQuit squit; CommandSNONotice snonotice; - CommandVersion version; - CommandBurst burst; CommandEndBurst endburst; + CommandSInfo sinfo; SpanningTreeCommands(ModuleSpanningTree* module); };