#include "users.h"
#include "modules.h"
#include "inspstring.h"
-#include "helperfuncs.h"
+
#include "commands.h"
#include "mode.h"
/* +n (notice mask - our implementation of snomasks) */
#include "modes/umode_n.h"
-extern InspIRCd* ServerInstance;
-
-extern time_t TIME;
-
-ModeHandler::ModeHandler(char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly)
- : mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), oper(operonly)
+ModeHandler::ModeHandler(InspIRCd* Instance, char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly)
+ : ServerInstance(Instance), mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), oper(operonly)
{
}
return (ours < theirs);
}
-ModeWatcher::ModeWatcher(char modeletter, ModeType type) : mode(modeletter), m_type(type)
+ModeWatcher::ModeWatcher(InspIRCd* Instance, char modeletter, ModeType type) : ServerInstance(Instance), mode(modeletter), m_type(type)
{
}
n->channel->AddVoicedUser(d);
break;
}
- log(DEBUG,"grant: %s %s",n->channel->name,d->nick);
+ ServerInstance->Log(DEBUG,"grant: %s %s",n->channel->name,d->nick);
return d->nick;
}
}
n->channel->DelVoicedUser(d);
break;
}
- log(DEBUG,"revoke: %s %s",n->channel->name,d->nick);
+ ServerInstance->Log(DEBUG,"revoke: %s %s",n->channel->name,d->nick);
return d->nick;
}
}
chanrec* targetchannel = ServerInstance->FindChan(parameters[0]);
userrec* targetuser = ServerInstance->FindNick(parameters[0]);
- log(DEBUG,"ModeParser::Process start");
+ ServerInstance->Log(DEBUG,"ModeParser::Process start");
/* Special case for displaying the list for listmodes,
* e.g. MODE #chan b, or MODE #chan +b without a parameter
if ((IS_LOCAL(user)) && (targetchannel->GetStatus(user) < STATUS_HOP))
{
/* We don't have halfop */
- log(DEBUG,"The user is not a halfop or above, checking other reasons for being able to set the modes");
+ ServerInstance->Log(DEBUG,"The user is not a halfop or above, checking other reasons for being able to set the modes");
/* Are we a uline or is it a servermode? */
- if ((!is_uline(user->server)) && (!servermode))
+ if ((!ServerInstance->ULine(user->server)) && (!servermode))
{
/* Not enough permission:
* NOT a uline and NOT a servermode,
if (parameter_counter < pcnt)
{
parameter = parameters[parameter_counter++];
+
+ /* Yerk, invalid! */
+ if ((parameter.rfind(':') || (parameter.rfind(' '))))
+ parameter = "";
}
else
{
{
if (type == MODETYPE_CHANNEL)
{
- log(DEBUG,"Write output sequence and parameters to channel: %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
+ ServerInstance->Log(DEBUG,"Write output sequence and parameters to channel: %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
targetchannel->WriteChannel(user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str()));
}
if (!user)
return;
- ServerInstance->ModeGrok->Process(parameters, pcnt, user, false);
+ ServerInstance->Modes->Process(parameters, pcnt, user, false);
return;
}
return false;
modehandlers[pos] = mh;
- log(DEBUG,"ModeParser::AddMode: added mode %c",mh->GetModeChar());
+ ServerInstance->Log(DEBUG,"ModeParser::AddMode: added mode %c",mh->GetModeChar());
return true;
}
pos = (mw->GetModeChar()-65) | mask;
modewatchers[pos].push_back(mw);
- log(DEBUG,"ModeParser::AddModeWatcher: watching mode %c",mw->GetModeChar());
+ ServerInstance->Log(DEBUG,"ModeParser::AddModeWatcher: watching mode %c",mw->GetModeChar());
return true;
}
return false;
modewatchers[pos].erase(a);
- log(DEBUG,"ModeParser::DelModeWatcher: stopped watching mode %c",mw->GetModeChar());
+ ServerInstance->Log(DEBUG,"ModeParser::DelModeWatcher: stopped watching mode %c",mw->GetModeChar());
return true;
}
-ModeParser::ModeParser()
+ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
{
/* Clear mode list */
memset(modehandlers, 0, sizeof(modehandlers));
/* Initialise the RFC mode letters */
/* Start with channel simple modes, no params */
- this->AddMode(new ModeChannelSecret, 's');
- this->AddMode(new ModeChannelPrivate, 'p');
- this->AddMode(new ModeChannelModerated, 'm');
- this->AddMode(new ModeChannelTopicOps, 't');
- this->AddMode(new ModeChannelNoExternal, 'n');
- this->AddMode(new ModeChannelInviteOnly, 'i');
+ this->AddMode(new ModeChannelSecret(Instance), 's');
+ this->AddMode(new ModeChannelPrivate(Instance), 'p');
+ this->AddMode(new ModeChannelModerated(Instance), 'm');
+ this->AddMode(new ModeChannelTopicOps(Instance), 't');
+ this->AddMode(new ModeChannelNoExternal(Instance), 'n');
+ this->AddMode(new ModeChannelInviteOnly(Instance), 'i');
/* Cannel modes with params */
- this->AddMode(new ModeChannelKey, 'k');
- this->AddMode(new ModeChannelLimit, 'l');
+ this->AddMode(new ModeChannelKey(Instance), 'k');
+ this->AddMode(new ModeChannelLimit(Instance), 'l');
/* Channel listmodes */
- this->AddMode(new ModeChannelBan, 'b');
- this->AddMode(new ModeChannelOp, 'o');
- this->AddMode(new ModeChannelHalfOp, 'h');
- this->AddMode(new ModeChannelVoice, 'v');
+ this->AddMode(new ModeChannelBan(Instance), 'b');
+ this->AddMode(new ModeChannelOp(Instance), 'o');
+ this->AddMode(new ModeChannelHalfOp(Instance), 'h');
+ this->AddMode(new ModeChannelVoice(Instance), 'v');
/* Now for usermodes */
- this->AddMode(new ModeUserServerNotice, 's');
- this->AddMode(new ModeUserWallops, 'w');
- this->AddMode(new ModeUserInvisible, 'i');
- this->AddMode(new ModeUserOperator, 'o');
- this->AddMode(new ModeUserServerNoticeMask, 'n');
+ this->AddMode(new ModeUserServerNotice(Instance), 's');
+ this->AddMode(new ModeUserWallops(Instance), 'w');
+ this->AddMode(new ModeUserInvisible(Instance), 'i');
+ this->AddMode(new ModeUserOperator(Instance), 'o');
+ this->AddMode(new ModeUserServerNoticeMask(Instance), 'n');
}
bool ModeParser::InsertMode(std::string &output, const char* mode, unsigned short section)
if(section > 4 || section == 0)
{
- log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section);
+ ServerInstance->Log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section);
return false;
}