X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodes%2Fcmode_h.cpp;h=9bd061cd26684d9d19b0fb81dd5a146893d747ff;hb=a7cbd51d457a5e3b435396092bc7e2fcf79168e1;hp=2c96b42248b14078c8ea743d1faf9c92566525cc;hpb=2d4621658d8daae931b7e44a9c3ecc6a04dcaf4f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 2c96b4224..9bd061cd2 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -1,28 +1,73 @@ -#include -#include -#include "inspircd_config.h" +/* +------------------------------------+ + * | 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. + * + * --------------------------------------------------- + */ + #include "configreader.h" -#include "hash_map.h" #include "inspircd.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_h.h" -extern InspIRCd* ServerInstance; -extern ServerConfig* Config; -extern std::vector modules; -extern std::vector factory; -extern int MODCOUNT; -extern time_t TIME; +ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false, '%') +{ +} + +unsigned int ModeChannelHalfOp::GetPrefixRank() +{ + return HALFOP_VALUE; +} + +ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) +{ + userrec* x = ServerInstance->FindNick(parameter); + if (x) + { + if (channel->GetStatusFlags(x) & UCMODE_HOP) + { + return std::make_pair(true, x->nick); + } + else + { + return std::make_pair(false, parameter); + } + } + return std::make_pair(false, parameter); +} + +void ModeChannelHalfOp::RemoveMode(chanrec* channel) +{ + CUList* list = channel->GetHalfoppedUsers(); + CUList copy; + char moderemove[MAXBUF]; + userrec* n = new userrec(ServerInstance); + n->SetFd(FD_MAGIC_NUMBER); -ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('h', 1, 1, true, MODETYPE_CHANNEL, false) + for (CUList::iterator i = list->begin(); i != list->end(); i++) + { + userrec* n = i->second; + copy.insert(std::make_pair(n,n)); + } + for (CUList::iterator i = copy.begin(); i != copy.end(); i++) + { + sprintf(moderemove,"-%c",this->GetModeChar()); + const char* parameters[] = { channel->name, moderemove, i->second->nick }; + ServerInstance->SendMode(parameters, 3, n); + } + delete n; +} + +void ModeChannelHalfOp::RemoveMode(userrec* user) { } @@ -31,13 +76,13 @@ ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanr /* If halfops are not enabled in the conf, we don't execute * anything in this class at all. */ - if (!Config->AllowHalfop) + if (!ServerInstance->Config->AllowHalfop) { parameter = ""; return MODEACTION_DENY; } - int status = cstatus(source, channel); + int status = channel->GetStatus(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) @@ -53,12 +98,15 @@ ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanr * 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 ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec *chan,int status) { - userrec *d = ModeParser::SanityChecks(user,dest,chan,status); + userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { @@ -71,22 +119,22 @@ std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec return ""; if (MOD_RESULT == ACR_DEFAULT) { - if ((status < STATUS_OP) && (!is_uline(user->server))) + if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) { - WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name); return ""; } } } - return ModeParser::Grant(d,chan,UCMODE_HOP); + return ServerInstance->Modes->Grant(d,chan,UCMODE_HOP); } return ""; } std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status) { - userrec *d = ModeParser::SanityChecks(user,dest,chan,status); + userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { @@ -99,15 +147,16 @@ std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec return ""; if (MOD_RESULT == ACR_DEFAULT) { - if ((user != d) && ((status < STATUS_OP) && (!is_uline(user->server)))) + if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))) { - WriteServ(user->fd,"482 %s %s :You are not a channel operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name); return ""; } } } - return ModeParser::Revoke(d,chan,UCMODE_HOP); + return ServerInstance->Modes->Revoke(d,chan,UCMODE_HOP); } return ""; } +