chanrec* targetchannel = ServerInstance->FindChan(parameters[0]);
userrec* targetuser = ServerInstance->FindNick(parameters[0]);
- ServerInstance->Log(DEBUG,"ModeParser::Process start");
+ ServerInstance->Log(DEBUG,"ModeParser::Process start: pcnt=%d",pcnt);
+ for (int j = 0; j < pcnt; j++)
+ ServerInstance->Log(DEBUG," parameters[%d] = '%s'", j, parameters[j]);
+
+ LastParse = "";
/* Special case for displaying the list for listmodes,
* e.g. MODE #chan b, or MODE #chan +b without a parameter
/* We don't have halfop */
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 ((!ServerInstance->ULine(user->server)) && (!servermode))
- {
- /* Not enough permission:
- * 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);
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user, NULL, targetchannel, AC_GENERAL_MODE));
+ if (MOD_RESULT == ACR_DENY)
return;
+
+ if (MOD_RESULT == ACR_DEFAULT)
+ {
+ /* Are we a uline or is it a servermode? */
+ if ((!ServerInstance->ULine(user->server)) && (!servermode))
+ {
+ /* Not enough permission:
+ * 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);
+ return;
+ }
}
}
}
bool adding = true, state_change = false;
unsigned char handler_id = 0;
int parameter_counter = 2; /* Index of first parameter */
+ int parameter_count = 0;
/* A mode sequence that doesnt start with + or -. Assume +. - Thanks for the suggestion spike (bug#132) */
if ((*mode_sequence.begin() != '+') && (*mode_sequence.begin() != '-'))
/* This mode expects a parameter, do we have any parameters left in our list to use? */
if (parameter_counter < pcnt)
{
+ ServerInstance->Log(DEBUG,"parameter_counter = %d, pcnt = %d", parameter_counter, pcnt);
parameter = parameters[parameter_counter++];
/* Yerk, invalid! */
if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter != ""))
{
parameter_list << " " << parameter;
+ parameter_count++;
/* Does this mode have a prefix? */
if (modehandlers[handler_id]->GetPrefix() && targetchannel)
{
/* Reset the state change flag */
state_change = false;
+
+ if ((output_sequence.length() + parameter_list.str().length() > 450) || (output_sequence.length() > 100)
+ || (parameter_count > MAXMODES))
+ {
+ /* We cant have a mode sequence this long */
+ letter = mode_sequence.end() - 1;
+ continue;
+ }
}
}
}
if (type == MODETYPE_CHANNEL)
{
targetchannel->WriteChannelWithServ(ServerInstance->Config->ServerName, "MODE %s %s%s", targetchannel->name, output_sequence.c_str(), parameter_list.str().c_str());
+ this->LastParse = targetchannel->name;
}
else
{
targetuser->WriteServ("MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
+ this->LastParse = targetuser->nick;
}
}
else
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()));
+ this->LastParse = targetchannel->name;
}
else
{
user->WriteTo(targetuser,"MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence));
+ this->LastParse = targetuser->nick;
}
}
+
+ LastParse.append(" ");
+ LastParse.append(output_sequence);
+ LastParse.append(parameter_list.str());
}
}
}
-
-void cmd_mode::Handle (const char** parameters, int pcnt, userrec *user)
+const std::string& ModeParser::GetLastParse()
{
- if (!user)
- return;
-
- ServerInstance->Modes->Process(parameters, pcnt, user, false);
-
- return;
+ return LastParse;
}
void ModeParser::CleanMask(std::string &mask)
std::string types;
std::string pars;
+ if (!channel || !user)
+ return "";
+
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
unsigned char pos = (mode-65) | MASK_CHANNEL;
{
ModePair ret;
ret = mh->ModeSet(NULL, user, channel, user->nick);
- if (ret.first)
+ if ((ret.first) && (ret.second == user->nick))
{
pars.append(" ");
pars.append(user->nick);
if (!mw)
return false;
- if ((mw->GetModeType() < 'A') || (mw->GetModeType() > 'z'))
+ if ((mw->GetModeChar() < 'A') || (mw->GetModeChar() > 'z'))
return false;
mw->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
ModeWatchIter a = find(modewatchers[pos].begin(),modewatchers[pos].end(),mw);
if (a == modewatchers[pos].end())
+ {
+ ServerInstance->Log(DEBUG, "ModeParser::DelModeWatcher: Couldn't find watcher for mode %c in list", mw->GetModeChar());
return false;
+ }
modewatchers[pos].erase(a);
ServerInstance->Log(DEBUG,"ModeParser::DelModeWatcher: stopped watching mode %c",mw->GetModeChar());
memset(modehandlers, 0, sizeof(modehandlers));
memset(modewatchers, 0, sizeof(modewatchers));
+ /* Last parse string */
+ LastParse = "";
+
/* Initialise the RFC mode letters */
/* Start with channel simple modes, no params */
this->AddMode(new ModeUserOperator(Instance), 'o');
this->AddMode(new ModeUserServerNoticeMask(Instance), 'n');
}
-