X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodes%2Fcmode_h.cpp;h=9bd061cd26684d9d19b0fb81dd5a146893d747ff;hb=a7cbd51d457a5e3b435396092bc7e2fcf79168e1;hp=e9a74fc3e1bd4561dd84586ba0b2e117ede8961a;hpb=a1f073f66f4b985bf776b9be2015136209c0c311;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index e9a74fc3e..9bd061cd2 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -1,60 +1,88 @@ -#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, '%') +{ +} -ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('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 = Find(parameter); + userrec* x = ServerInstance->FindNick(parameter); if (x) { - if (cstatus(x, channel) == STATUS_HOP) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } + 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); + + 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) +{ +} + ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { /* 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) @@ -70,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) { @@ -88,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) { @@ -116,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 ""; } +