]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/commands.h
Merge pull request #1337 from SaberUK/master+merge
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / commands.h
index 89bd2bfee3d7839dbc8a942ec1b926ddbfc1540d..8eea0291551d9acc005ede266c96b8ed08c3b4cb 100644 (file)
 
 #include "servercommand.h"
 #include "commandbuilder.h"
+#include "remoteuser.h"
+
+namespace SpanningTree
+{
+       class CommandAway;
+       class CommandNick;
+       class CommandPing;
+       class CommandPong;
+       class CommandServer;
+}
+
+using SpanningTree::CommandAway;
+using SpanningTree::CommandNick;
+using SpanningTree::CommandPing;
+using SpanningTree::CommandPong;
+using SpanningTree::CommandServer;
 
 /** Handle /RCONNECT
  */
@@ -114,6 +130,7 @@ class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
 };
 
 class TreeSocket;
+class FwdFJoinBuilder;
 class CommandFJoin : public ServerCommand
 {
        /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
@@ -129,10 +146,11 @@ class CommandFJoin : public ServerCommand
         * @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);
+       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<std::string>& params);
+       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_LOCALONLY; }
 
        class Builder : public CmdBuilder
        {
@@ -140,13 +158,25 @@ class CommandFJoin : public ServerCommand
                 * a message or not
                 */
                static const size_t membid_max_digits = 20;
-               static const size_t maxline = 480;
+               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);
-               void add(Membership* memb);
-               bool has_room(Membership* memb) const;
+               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();
        };
@@ -209,11 +239,11 @@ class CommandResync : public ServerOnlyServerCommand<CommandResync>
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_LOCALONLY; }
 };
 
-class CommandAway : public UserOnlyServerCommand<CommandAway>
+class SpanningTree::CommandAway : public UserOnlyServerCommand<SpanningTree::CommandAway>
 {
  public:
-       CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
-       CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
+       CommandAway(Module* Creator) : UserOnlyServerCommand<SpanningTree::CommandAway>(Creator, "AWAY", 0, 2) { }
+       CmdResult HandleRemote(::RemoteUser* user, std::vector<std::string>& parameters);
 
        class Builder : public CmdBuilder
        {
@@ -260,14 +290,14 @@ class CommandIdle : public UserOnlyServerCommand<CommandIdle>
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
 };
 
-class CommandNick : public UserOnlyServerCommand<CommandNick>
+class SpanningTree::CommandNick : public UserOnlyServerCommand<SpanningTree::CommandNick>
 {
  public:
-       CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
-       CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
+       CommandNick(Module* Creator) : UserOnlyServerCommand<SpanningTree::CommandNick>(Creator, "NICK", 2) { }
+       CmdResult HandleRemote(::RemoteUser* user, std::vector<std::string>& parameters);
 };
 
-class CommandPing : public ServerCommand
+class SpanningTree::CommandPing : public ServerCommand
 {
  public:
        CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
@@ -275,22 +305,14 @@ class CommandPing : public ServerCommand
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
 };
 
-class CommandPong : public ServerOnlyServerCommand<CommandPong>
+class SpanningTree::CommandPong : public ServerOnlyServerCommand<SpanningTree::CommandPong>
 {
  public:
-       CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
+       CommandPong(Module* Creator) : ServerOnlyServerCommand<SpanningTree::CommandPong>(Creator, "PONG", 1) { }
        CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
 };
 
-class CommandPush : public ServerCommand
-{
- public:
-       CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
-       CmdResult Handle(User* user, std::vector<std::string>& parameters);
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
-};
-
 class CommandSave : public ServerCommand
 {
  public:
@@ -302,12 +324,12 @@ class CommandSave : public ServerCommand
        CmdResult Handle(User* user, std::vector<std::string>& parameters);
 };
 
-class CommandServer : public ServerOnlyServerCommand<CommandServer>
+class SpanningTree::CommandServer : public ServerOnlyServerCommand<SpanningTree::CommandServer>
 {
        static void HandleExtra(TreeServer* newserver, const std::vector<std::string>& params);
 
  public:
-       CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 3) { }
+       CommandServer(Module* Creator) : ServerOnlyServerCommand<SpanningTree::CommandServer>(Creator, "SERVER", 3) { }
        CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
 
        class Builder : public CmdBuilder
@@ -355,6 +377,20 @@ class CommandSInfo : public ServerOnlyServerCommand<CommandSInfo>
        };
 };
 
+class CommandNum : public ServerOnlyServerCommand<CommandNum>
+{
+ public:
+       CommandNum(Module* Creator) : ServerOnlyServerCommand<CommandNum>(Creator, "NUM", 3) { }
+       CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
+       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+
+       class Builder : public CmdBuilder
+       {
+        public:
+               Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric);
+       };
+};
+
 class SpanningTreeCommands
 {
  public:
@@ -372,20 +408,20 @@ class SpanningTreeCommands
        CommandFHost fhost;
        CommandFIdent fident;
        CommandFName fname;
-       CommandAway away;
+       SpanningTree::CommandAway away;
        CommandAddLine addline;
        CommandDelLine delline;
        CommandEncap encap;
        CommandIdle idle;
-       CommandNick nick;
-       CommandPing ping;
-       CommandPong pong;
-       CommandPush push;
+       SpanningTree::CommandNick nick;
+       SpanningTree::CommandPing ping;
+       SpanningTree::CommandPong pong;
        CommandSave save;
-       CommandServer server;
+       SpanningTree::CommandServer server;
        CommandSQuit squit;
        CommandSNONotice snonotice;
        CommandEndBurst endburst;
        CommandSInfo sinfo;
+       CommandNum num;
        SpanningTreeCommands(ModuleSpanningTree* module);
 };