]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/u_listmode.h
Documentation change to indicate errno is valid on return from the constructor -...
[user/henk/code/inspircd.git] / include / u_listmode.h
index 79f2af92424d6f9589499e62e90b2ac5231969cf..28c364698fb07010b34d3fb0dbcfab88c5ccfaf9 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #ifndef INSPIRCD_LISTMODE_PROVIDER
 #define INSPIRCD_LISTMODE_PROVIDER
 
@@ -49,6 +62,21 @@ public:
 typedef std::vector<ListItem> modelist;
 typedef std::vector<ListLimit> limitlist;
 
+class ListModeRequest : public Request
+{
+ public:
+       userrec* user;
+       chanrec* chan;
+
+       ListModeRequest(Module* sender, Module* target, userrec* u, chanrec* c) : Request(sender, target, "LM_CHECKLIST"), user(u), chan(c)
+       {
+       }
+
+       ~ListModeRequest()
+       {
+       }
+};
+
 /** The base class for listmodes defined by u_listmode.h
  */
 class ListModeBase : public ModeHandler
@@ -67,7 +95,7 @@ class ListModeBase : public ModeHandler
        : ModeHandler(Instance, modechar, 1, 1, true, MODETYPE_CHANNEL, false), listnumeric(lnum), endoflistnumeric(eolnum), endofliststring(eolstr), tidy(autotidy), configtag(ctag)
        {
                this->DoRehash();
-               infokey = "exceptionbase_mode_" + std::string(1, mode) + "_list";
+               infokey = "listbase_mode_" + std::string(1, mode) + "_list";
        }
 
        std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
@@ -98,7 +126,7 @@ class ListModeBase : public ModeHandler
                                user->WriteServ("%s %s %s %s %s %s", listnumeric.c_str(), user->nick, channel->name, it->mask.c_str(), it->nick.c_str(), it->time.c_str());
                        }
                }
-               user->WriteServ("%s %s %s %s", endoflistnumeric.c_str(), user->nick, channel->name, endofliststring.c_str());
+               user->WriteServ("%s %s %s :%s", endoflistnumeric.c_str(), user->nick, channel->name, endofliststring.c_str());
        }
 
        virtual void RemoveMode(chanrec* channel)
@@ -109,22 +137,25 @@ class ListModeBase : public ModeHandler
                if (el)
                {
                        ServerInstance->Log(DEBUG,"Channel is extended with a list");
-                       char moderemove[MAXBUF];
+                       irc::modestacker modestack(false);
+                       std::deque<std::string> stackresult;
+                       const char* mode_junk[MAXMODES+1];
+                       mode_junk[0] = channel->name;
                        userrec* n = new userrec(ServerInstance);
                        n->SetFd(FD_MAGIC_NUMBER);
-                       modelist copy;
-                       /* Make a copy of it, because we cant change the list whilst iterating over it */
                        for(modelist::iterator it = el->begin(); it != el->end(); it++)
                        {
-                               copy.push_back(*it);
+                               modestack.Push(this->GetModeChar(), it->mask);
                        }
-                       for(modelist::iterator it = copy.begin(); it != copy.end(); it++)
+                       while (modestack.GetStackedLine(stackresult))
                        {
-                               ServerInstance->Log(DEBUG,"Remove item %s",it->mask.c_str());
-                               sprintf(moderemove,"-%c",this->GetModeChar());
-                               const char* parameters[] = { channel->name, moderemove, it->mask.c_str() };
-                               ServerInstance->SendMode(parameters, 3, n);
+                               for (size_t j = 0; j < stackresult.size(); j++)
+                               {
+                                       mode_junk[j+1] = stackresult[j].c_str();
+                               }
+                               ServerInstance->SendMode(mode_junk, stackresult.size() + 1, n);         
                        }
+
                        delete n;
                }
        }