X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmode.cpp;h=758c02c20faa03c03c7cede7fd59c983e5447e28;hb=d555db40f4b39f10ad06c2449b42711c1e74105f;hp=1f6cc08b9c5bb28e47665dfa56da72f07a4ee62b;hpb=b57c7f4e466f72fdd2ac3deca42caa1ea7748338;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/mode.cpp b/src/mode.cpp index 1f6cc08b9..758c02c20 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -11,6 +11,11 @@ * --------------------------------------------------- */ +/* $Core: libIRCDmode */ +/* $ExtraDeps: $(RELCPPFILES) */ +/* $ExtraObjects: modes/modeclasses.a */ +/* $ExtraBuild: ${MAKE} -C "modes" DIRNAME="src/modes" CC="$(CC)" $(MAKEARGS) CPPFILES="$(CPPFILES)" */ + #include "inspircd.h" #include "inspstring.h" @@ -104,12 +109,12 @@ char ModeHandler::GetModeChar() return mode; } -ModeAction ModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) +ModeAction ModeHandler::OnModeChange(User*, User*, Channel*, std::string&, bool) { return MODEACTION_DENY; } -ModePair ModeHandler::ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) +ModePair ModeHandler::ModeSet(User*, User* dest, Channel* channel, const std::string&) { if (dest) { @@ -121,15 +126,15 @@ ModePair ModeHandler::ModeSet(User* source, User* dest, Channel* channel, const } } -void ModeHandler::DisplayList(User* user, Channel* channel) +void ModeHandler::DisplayList(User*, Channel*) { } -void ModeHandler::DisplayEmptyList(User* user, Channel* channel) +void ModeHandler::DisplayEmptyList(User*, Channel*) { } -bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel) +bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&, const std::string&, Channel*) { return (ours < theirs); } @@ -152,16 +157,16 @@ ModeType ModeWatcher::GetModeType() return m_type; } -bool ModeWatcher::BeforeMode(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, ModeType type) +bool ModeWatcher::BeforeMode(User*, User*, Channel*, std::string&, bool, ModeType) { return true; } -void ModeWatcher::AfterMode(User* source, User* dest, Channel* channel, const std::string ¶meter, bool adding, ModeType type) +void ModeWatcher::AfterMode(User*, User*, Channel*, const std::string&, bool, ModeType) { } -User* ModeParser::SanityChecks(User *user,const char *dest,Channel *chan,int status) +User* ModeParser::SanityChecks(User *user, const char *dest, Channel *chan, int) { User *d; if ((!user) || (!dest) || (!chan) || (!*dest)) @@ -301,6 +306,11 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser { unsigned char mletter = *mode; + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnRawMode, OnRawMode(user, targetchannel, *mode, "", true, 0)); + if (MOD_RESULT == ACR_DENY) + continue; + if (*mode == '+') { mode++; @@ -390,7 +400,8 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser * NOT a uline and NOT a servermode, * OR, NOT halfop or above. */ - user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, targetchannel->name); + user->WriteServ("482 %s %s :You're not a channel %soperator",user->nick, targetchannel->name, + ServerInstance->Config->AllowHalfop ? "(half)" : ""); return; } } @@ -495,6 +506,11 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser continue; } + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnRawMode, OnRawMode(user, targetchannel, modechar, parameter, adding, 1)); + if (MOD_RESULT == ACR_DENY) + return; + bool had_parameter = !parameter.empty(); for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) @@ -517,6 +533,11 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser } else { + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnRawMode, OnRawMode(user, targetchannel, modechar, "", adding, 0)); + if (MOD_RESULT == ACR_DENY) + return; + /* Fix by brain: mode watchers not being called for parameterless modes */ for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) { @@ -687,7 +708,7 @@ void ModeParser::CleanMask(std::string &mask) } } -bool ModeParser::AddMode(ModeHandler* mh, unsigned const char modeletter) +bool ModeParser::AddMode(ModeHandler* mh) { unsigned char mask = 0; unsigned char pos = 0; @@ -733,7 +754,7 @@ bool ModeParser::DelMode(ModeHandler* mh) switch (mh->GetModeType()) { case MODETYPE_USER: - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) { mh->RemoveMode(i->second); } @@ -1025,31 +1046,26 @@ void ModeHandler::RemoveMode(Channel* channel) ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) { - struct Initializer + ModeHandler* modes[] = { - char modechar; - ModeHandler* handler; - }; - - Initializer modes[] = { - { 's', new ModeChannelSecret(Instance) }, - { 'p', new ModeChannelPrivate(Instance) }, - { 'm', new ModeChannelModerated(Instance) }, - { 't', new ModeChannelTopicOps(Instance) }, - { 'n', new ModeChannelNoExternal(Instance) }, - { 'i', new ModeChannelInviteOnly(Instance) }, - { 'k', new ModeChannelKey(Instance) }, - { 'l', new ModeChannelLimit(Instance) }, - { 'b', new ModeChannelBan(Instance) }, - { 'o', new ModeChannelOp(Instance) }, - { 'h', new ModeChannelHalfOp(Instance) }, - { 'v', new ModeChannelVoice(Instance) }, - { 's', new ModeUserServerNotice(Instance) }, - { 'w', new ModeUserWallops(Instance) }, - { 'i', new ModeUserInvisible(Instance) }, - { 'o', new ModeUserOperator(Instance) }, - { 'n', new ModeUserServerNoticeMask(Instance) }, - { 0, NULL } + new ModeChannelSecret(Instance), + new ModeChannelPrivate(Instance), + new ModeChannelModerated(Instance), + new ModeChannelTopicOps(Instance), + new ModeChannelNoExternal(Instance), + new ModeChannelInviteOnly(Instance), + new ModeChannelKey(Instance), + new ModeChannelLimit(Instance), + new ModeChannelBan(Instance), + new ModeChannelOp(Instance), + new ModeChannelHalfOp(Instance), + new ModeChannelVoice(Instance), + new ModeUserServerNotice(Instance), + new ModeUserWallops(Instance), + new ModeUserInvisible(Instance), + new ModeUserOperator(Instance), + new ModeUserServerNoticeMask(Instance), + NULL }; /* Clear mode list */ @@ -1060,6 +1076,6 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) LastParse.clear(); /* Initialise the RFC mode letters */ - for (int index = 0; modes[index].modechar; index++) - this->AddMode(modes[index].handler, modes[index].modechar); + for (int index = 0; modes[index]; index++) + this->AddMode(modes[index]); }