X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fu_listmode.h;h=f98faefd5d97799ff6f303ef4db8932f8addae8d;hb=50fb079808cf6ff76fb8213c3469e435774ae42f;hp=31f07148f3ce38035c07b01e03ac901516b8eee9;hpb=5db1d322be106c8462dc691072f9415dc0766ed4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/u_listmode.h b/include/u_listmode.h index 31f07148f..f98faefd5 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -14,8 +14,6 @@ #ifndef INSPIRCD_LISTMODE_PROVIDER #define INSPIRCD_LISTMODE_PROVIDER -#include "wildcard.h" - /** Get the time as a string */ inline std::string stringtime() @@ -31,7 +29,7 @@ class ListItem : public classbase { public: std::string nick; - irc::string mask; + std::string mask; std::string time; }; @@ -87,10 +85,10 @@ class ListModeBase : public ModeHandler std::string infokey; /** Numeric to use when outputting the list */ - std::string listnumeric; + unsigned int listnumeric; /** Numeric to indicate end of list */ - std::string endoflistnumeric; + unsigned int endoflistnumeric; /** String to send for end of list */ std::string endofliststring; @@ -115,7 +113,7 @@ class ListModeBase : public ModeHandler * @param autotidy Automatically tidy list entries on add * @param ctag Configuration tag to get limits from */ - ListModeBase(InspIRCd* Instance, char modechar, const std::string &eolstr, const std::string &lnum, const std::string &eolnum, bool autotidy, const std::string &ctag = "banlist") + ListModeBase(InspIRCd* Instance, char modechar, const std::string &eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy, const std::string &ctag = "banlist") : ModeHandler(Instance, modechar, 1, 1, true, MODETYPE_CHANNEL, false), listnumeric(lnum), endoflistnumeric(eolnum), endofliststring(eolstr), tidy(autotidy), configtag(ctag) { this->DoRehash(); @@ -153,52 +151,58 @@ class ListModeBase : public ModeHandler { for (modelist::reverse_iterator it = el->rbegin(); it != el->rend(); ++it) { - 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->WriteNumeric(listnumeric, "%s %s %s %s %s", user->nick.c_str(), channel->name.c_str(), 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->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick.c_str(), channel->name.c_str(), endofliststring.c_str()); } virtual void DisplayEmptyList(User* user, Channel* channel) { - user->WriteServ("%s %s %s :%s", endoflistnumeric.c_str(), user->nick, channel->name, endofliststring.c_str()); + user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick.c_str(), channel->name.c_str(), endofliststring.c_str()); } /** Remove all instances of the mode from a channel. * See mode.h * @param channel The channel to remove all instances of the mode from */ - virtual void RemoveMode(Channel* channel) + virtual void RemoveMode(Channel* channel, irc::modestacker* stack) { modelist* el; channel->GetExt(infokey, el); if (el) { - irc::modestacker modestack(false); + irc::modestacker modestack(ServerInstance, false); std::deque stackresult; - const char* mode_junk[MAXMODES+2]; - mode_junk[0] = channel->name; + std::vector mode_junk; + mode_junk.push_back(channel->name); for (modelist::iterator it = el->begin(); it != el->end(); it++) { - modestack.Push(this->GetModeChar(), assign(it->mask)); + if (stack) + stack->Push(this->GetModeChar(), it->mask); + else + modestack.Push(this->GetModeChar(), it->mask); } + if (stack) + return; + while (modestack.GetStackedLine(stackresult)) { for (size_t j = 0; j < stackresult.size(); j++) { - mode_junk[j+1] = stackresult[j].c_str(); + mode_junk.push_back(stackresult[j]); } - ServerInstance->SendMode(mode_junk, stackresult.size() + 1, ServerInstance->FakeClient); + ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient); } } } /** See mode.h */ - virtual void RemoveMode(User*) + virtual void RemoveMode(User*, irc::modestacker* stack) { /* Listmodes dont get set on users */ } @@ -241,7 +245,7 @@ class ListModeBase : public ModeHandler /** Handle the list mode. * See mode.h */ - virtual ModeAction OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) + virtual ModeAction OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding, bool servermode) { // Try and grab the list modelist* el; @@ -278,11 +282,11 @@ class ListModeBase : public ModeHandler for (limitlist::iterator it = chanlimits.begin(); it != chanlimits.end(); it++) { - if (match(channel->name, it->mask.c_str())) + if (InspIRCd::Match(channel->name, it->mask)) { // We have a pattern matching the channel... maxsize = el->size(); - if (maxsize < it->limit) + if (IS_LOCAL(source) || (maxsize < it->limit)) { /* Ok, it *could* be allowed, now give someone subclassing us * a chance to validate the parameter. @@ -298,8 +302,8 @@ class ListModeBase : public ModeHandler { // And now add the mask onto the list... ListItem e; - e.mask = assign(parameter); - e.nick = source->nick; + e.mask = parameter; + e.nick = servermode ? ServerInstance->Config->ServerName : source->nick; e.time = stringtime(); el->push_back(e); @@ -317,7 +321,7 @@ class ListModeBase : public ModeHandler /* List is full, give subclass a chance to send a custom message */ if (!TellListTooLong(source, channel, parameter)) { - source->WriteServ("478 %s %s %s :Channel ban/ignore list is full", source->nick, channel->name, parameter.c_str()); + source->WriteNumeric(478, "%s %s %s :Channel ban/ignore list is full", source->nick.c_str(), channel->name.c_str(), parameter.c_str()); } parameter = ""; @@ -390,13 +394,13 @@ class ListModeBase : public ModeHandler { modelist* mlist; chan->GetExt(infokey, mlist); - irc::modestacker modestack(true); + irc::modestacker modestack(ServerInstance, true); std::deque stackresult; if (mlist) { for (modelist::iterator it = mlist->begin(); it != mlist->end(); it++) { - modestack.Push(std::string(1, mode)[0], assign(it->mask)); + modestack.Push(std::string(1, mode)[0], it->mask); } } while (modestack.GetStackedLine(stackresult))