X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodes%2Fcmode_v.cpp;h=1a04393d9b72461d16d67dc519a8687ee7506e00;hb=392ff5ef8fdac46d5f0a28d3fd12f25a7c541ddf;hp=b71775885314288acebab76bddd3ad551056a736;hpb=dafc021be4f3ad34ca37953de6a0109a161dd165;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index b71775885..1a04393d9 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -1,37 +1,40 @@ -#include -#include -#include "inspircd_config.h" -#include "configreader.h" -#include "hash_map.h" + +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2008 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. + * + * --------------------------------------------------- + */ + #include "inspircd.h" +#include "configreader.h" #include "mode.h" #include "channels.h" #include "users.h" -#include "helperfuncs.h" -#include "message.h" -#include "commands.h" #include "modules.h" -#include "inspstring.h" -#include "hashcomp.h" #include "modes/cmode_v.h" -extern InspIRCd* ServerInstance; - -extern std::vector modules; -extern std::vector factory; -extern int MODCOUNT; -extern time_t TIME; +ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+') +{ +} -ModeChannelVoice::ModeChannelVoice() : ModeHandler('v', 1, 1, true, MODETYPE_CHANNEL, false) +unsigned int ModeChannelVoice::GetPrefixRank() { + return VOICE_VALUE; } -ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +ModePair ModeChannelVoice::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) { - userrec* x = ServerInstance->FindNick(parameter); + User* x = ServerInstance->FindNick(parameter); if (x) { - if (channel->GetStatus(x) == STATUS_VOICE) + if (channel->GetStatusFlags(x) & UCMODE_VOICE) { return std::make_pair(true, x->nick); } @@ -43,7 +46,34 @@ ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* chan return std::make_pair(false, parameter); } -ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) +void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack) +{ + CUList* clist = channel->GetVoicedUsers(); + CUList copy; + + for (CUList::iterator i = clist->begin(); i != clist->end(); i++) + { + User* n = i->first; + copy.insert(std::make_pair(n,n->nick)); + } + + for (CUList::iterator i = copy.begin(); i != copy.end(); i++) + { + if (stack) + stack->Push(this->GetModeChar(), i->first->nick); + else + { + std::vector parameters; parameters.push_back(channel->name); parameters.push_back("-v"); parameters.push_back(i->first->nick); + ServerInstance->SendMode(parameters, ServerInstance->FakeClient); + } + } +} + +void ModeChannelVoice::RemoveMode(User*, irc::modestacker* stack) +{ +} + +ModeAction ModeChannelVoice::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding, bool servermode) { int status = channel->GetStatus(source); @@ -61,12 +91,15 @@ ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanre * the return value and is always MODEACTION_DENY if the mode is supposed to have * a parameter. */ - return MODEACTION_ALLOW; + if (parameter.length()) + return MODEACTION_ALLOW; + else + return MODEACTION_DENY; } -std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *chan,int status) +std::string ModeChannelVoice::AddVoice(User *user,const char* dest,Channel *chan,int status) { - userrec *d = ModeParser::SanityChecks(user,dest,chan,status); + User *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { @@ -79,22 +112,22 @@ std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *c return ""; if (MOD_RESULT == ACR_DEFAULT) { - if ((status < STATUS_HOP) && (!is_uline(user->server))) + if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) { - user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick.c_str(), chan->name.c_str()); return ""; } } } - return ModeParser::Grant(d,chan,UCMODE_VOICE); + return ServerInstance->Modes->Grant(d,chan,UCMODE_VOICE); } return ""; } -std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *chan,int status) +std::string ModeChannelVoice::DelVoice(User *user,const char *dest,Channel *chan,int status) { - userrec *d = ModeParser::SanityChecks(user,dest,chan,status); + User *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { @@ -107,15 +140,15 @@ std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *c return ""; if (MOD_RESULT == ACR_DEFAULT) { - if ((status < STATUS_HOP) && (!is_uline(user->server))) + if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) { - user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick.c_str(), chan->name.c_str()); return ""; } } } - return ModeParser::Revoke(d,chan,UCMODE_VOICE); + return ServerInstance->Modes->Revoke(d,chan,UCMODE_VOICE); } return ""; }