]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/fjoin.cpp
Configurable prefixes for chanmodes +qa: prefixes can be turned on or off individuall...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / fjoin.cpp
index eacd9ee04effd3ad2ccde1388d0f0ad8c510f607..0f33d65bdeebb753be2c70a0222a7fbbd572031f 100644 (file)
  */
 
 #include "inspircd.h"
-#include "commands/cmd_whois.h"
-#include "commands/cmd_stats.h"
-#include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
-#include "transport.h"
-#include "m_hash.h"
-#include "socketengine.h"
 
-#include "m_spanningtree/main.h"
-#include "m_spanningtree/utils.h"
-#include "m_spanningtree/treeserver.h"
-#include "m_spanningtree/link.h"
 #include "m_spanningtree/treesocket.h"
-#include "m_spanningtree/resolvers.h"
-#include "m_spanningtree/handshaketimer.h"
+#include "m_spanningtree/treeserver.h"
+#include "m_spanningtree/utils.h"
+
+/* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
 
-/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h */
 
 /** FJOIN, similar to TS6 SJOIN, but not quite. */
 bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &params)
@@ -78,7 +68,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        irc::tokenstream users((params.size() > 2) ? params[2] : "");   /* users from the user list */
        bool apply_other_sides_modes = true;                            /* True if we are accepting the other side's modes */
        Channel* chan = this->Instance->FindChan(channel);              /* The channel we're sending joins to */
-       time_t ourTS = chan ? chan->age : Instance->Time(true)+600;     /* The TS of our side of the link */
+       time_t ourTS = chan ? chan->age : Instance->Time()+600; /* The TS of our side of the link */
        bool created = !chan;                                           /* True if the channel doesnt exist here yet */
        std::string item;                                               /* One item in the list of nicks */
 
@@ -89,7 +79,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
 
        if (!TS)
        {
-               Instance->Log(DEFAULT,"*** BUG? *** TS of 0 sent to FJOIN. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
+               Instance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG? *** TS of 0 sent to FJOIN. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
                Instance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", source.c_str());
                return true;
        }
@@ -122,22 +112,26 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                const char* usr = item.c_str();
                if (usr && *usr)
                {
-                       const char* permissions = usr;
-                       /* Iterate through all the prefix values, convert them from prefixes to mode letters */
+                       const char* unparsedmodes = usr;
                        std::string modes;
-                       while ((*permissions) && (*permissions != ','))
+
+
+                       /* Iterate through all modes for this user and check they are valid. */
+                       while ((*unparsedmodes) && (*unparsedmodes != ','))
                        {
-                               ModeHandler* mh = Instance->Modes->FindPrefix(*permissions);
+                               ModeHandler *mh = Instance->Modes->FindMode(*unparsedmodes, MODETYPE_CHANNEL);
                                if (mh)
-                                       modes = modes + mh->GetModeChar();
+                                       modes += *unparsedmodes;
                                else
                                {
-                                       this->SendError(std::string("Invalid prefix '")+(*permissions)+"' in FJOIN");
+                                       this->SendError(std::string("Invalid prefix '")+(*unparsedmodes)+"' in FJOIN");
                                        return false;
                                }
+
                                usr++;
-                               permissions++;
+                               unparsedmodes++;
                        }
+
                        /* Advance past the comma, to the nick */
                        usr++;
                        
@@ -150,7 +144,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                                if ((!route_back_again) || (route_back_again->GetSocket() != this))
                                        continue;
 
-                               /* Add any permissions this user had to the mode stack */
+                               /* Add any modes this user had to the mode stack */
                                for (std::string::iterator x = modes.begin(); x != modes.end(); ++x)
                                        modestack.Push(*x, who->nick);
 
@@ -158,7 +152,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                        }
                        else
                        {
-                               Instance->Log(SPARSE,"Warning! Invalid user %s in FJOIN to channel %s IGNORED", usr, channel.c_str());
+                               Instance->Logs->Log("m_spanningtree",SPARSE,"Warning! Invalid user %s in FJOIN to channel %s IGNORED", usr, channel.c_str());
                                continue;
                        }
                }
@@ -184,3 +178,24 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        return true;
 }
 
+/** TODO: This creates a total mess of output and needs to really use irc::modestacker.
+ */
+bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string> &params)
+{
+       if (params.size() < 1)
+               return true;
+
+       Channel* c = Instance->FindChan(params[0]);
+
+       if (c)
+       {
+               for (char modeletter = 'A'; modeletter <= 'z'; modeletter++)
+               {
+                       ModeHandler* mh = Instance->Modes->FindMode(modeletter, MODETYPE_CHANNEL);
+                       if (mh)
+                               mh->RemoveMode(c);
+               }
+       }
+       return true;
+}