mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-12 12:09:03 -04:00
Implement missing modechange constructors
This commit is contained in:
parent
2438705ac8
commit
146acdea12
@ -18,6 +18,27 @@
|
||||
|
||||
#define MODE_ID_MAX 128
|
||||
|
||||
/**
|
||||
* Holds the values for different type of modes
|
||||
* that can exist, USER or CHANNEL type.
|
||||
*/
|
||||
enum ModeType
|
||||
{
|
||||
/** User mode */
|
||||
MODETYPE_USER = 0,
|
||||
/** Channel mode */
|
||||
MODETYPE_CHANNEL = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* Holds mode actions - modes can be allowed or denied.
|
||||
*/
|
||||
enum ModeAction
|
||||
{
|
||||
MODEACTION_DENY = 0, /* Drop the mode change, AND a parameter if its a parameterized mode */
|
||||
MODEACTION_ALLOW = 1 /* Allow the mode */
|
||||
};
|
||||
|
||||
/** Mode identifier for quick lookup of modes that do not have a letter */
|
||||
class ModeID
|
||||
{
|
||||
@ -52,7 +73,7 @@ namespace irc
|
||||
modechange(ModeID id, const std::string& param = "", bool add = true)
|
||||
: adding(add), mode(id), value(param) {}
|
||||
modechange(const std::string& name, const std::string& param = "", bool add = true);
|
||||
modechange(char modechar, const std::string& param = "", bool add = true);
|
||||
modechange(char modechar, ModeType type, const std::string& param = "", bool add = true);
|
||||
};
|
||||
|
||||
/** irc::modestacker stacks mode sequences into a list.
|
||||
@ -75,38 +96,6 @@ namespace irc
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the values for different type of modes
|
||||
* that can exist, USER or CHANNEL type.
|
||||
*/
|
||||
enum ModeType
|
||||
{
|
||||
/** User mode */
|
||||
MODETYPE_USER = 0,
|
||||
/** Channel mode */
|
||||
MODETYPE_CHANNEL = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* Holds mode actions - modes can be allowed or denied.
|
||||
*/
|
||||
enum ModeAction
|
||||
{
|
||||
MODEACTION_DENY = 0, /* Drop the mode change, AND a parameter if its a parameterized mode */
|
||||
MODEACTION_ALLOW = 1 /* Allow the mode */
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to mask off the mode types in the mode handler
|
||||
* array. Used in a simple two instruction hashing function
|
||||
* "(modeletter - 65) OR mask"
|
||||
*/
|
||||
enum ModeMasks
|
||||
{
|
||||
MASK_USER = 128, /* A user mode */
|
||||
MASK_CHANNEL = 0 /* A channel mode */
|
||||
};
|
||||
|
||||
/**
|
||||
* These fixed values can be used to proportionally compare module-defined prefixes to known values.
|
||||
* For example, if your module queries a Channel, and is told that user 'joebloggs' has the prefix
|
||||
@ -590,7 +579,7 @@ class CoreExport ModeParser
|
||||
* 3; Modes that only take a param when adding
|
||||
* 4; Modes that dont take a param
|
||||
*/
|
||||
std::string GiveModeList(ModeMasks m);
|
||||
std::string GiveModeList(ModeType m);
|
||||
|
||||
static bool PrefixComparison(ModeHandler* one, ModeHandler* two);
|
||||
|
||||
|
@ -81,7 +81,11 @@ class CoreExport ListModeBase : public ModeHandler
|
||||
configtag(ctag), extItem(name + "_mode_list", Creator)
|
||||
{
|
||||
list = true;
|
||||
this->DoRehash();
|
||||
}
|
||||
|
||||
inline void init()
|
||||
{
|
||||
DoRehash();
|
||||
ServerInstance->Extensions.Register(&extItem);
|
||||
}
|
||||
|
||||
|
23
src/mode.cpp
23
src/mode.cpp
@ -213,6 +213,21 @@ void ModeWatcher::AfterMode(User*, User*, Channel*, const std::string&, bool, Mo
|
||||
{
|
||||
}
|
||||
|
||||
irc::modechange::modechange(const std::string& name, const std::string& param, bool add)
|
||||
: adding(add), value(param)
|
||||
{
|
||||
ModeHandler* mh = ServerInstance->Modes->FindMode(name);
|
||||
if (mh)
|
||||
mode = mh->id;
|
||||
}
|
||||
|
||||
irc::modechange::modechange(char modechar, ModeType type, const std::string& param, bool add)
|
||||
{
|
||||
ModeHandler* mh = ServerInstance->Modes->FindMode(modechar, type);
|
||||
if (mh)
|
||||
mode = mh->id;
|
||||
}
|
||||
|
||||
std::string irc::modestacker::popModeLine(bool use_uid)
|
||||
{
|
||||
char pm_now = '\0';
|
||||
@ -672,6 +687,9 @@ bool ModeParser::AddMode(ModeHandler* mh)
|
||||
if (FindMode(mh->GetModeChar(), mh->GetModeType()))
|
||||
return false;
|
||||
|
||||
if (FindMode(mh->name))
|
||||
return false;
|
||||
|
||||
for(int id = 1; id < MODE_ID_MAX; id++)
|
||||
{
|
||||
if (handlers[id])
|
||||
@ -788,7 +806,7 @@ ModeHandler* ModeParser::FindPrefix(unsigned const char pfxletter)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string ModeParser::GiveModeList(ModeMasks m)
|
||||
std::string ModeParser::GiveModeList(ModeType m)
|
||||
{
|
||||
std::string type1; /* Listmodes EXCEPT those with a prefix */
|
||||
std::string type2; /* Modes that take a param when adding or removing */
|
||||
@ -798,7 +816,7 @@ std::string ModeParser::GiveModeList(ModeMasks m)
|
||||
for(ModeIDIter id; id; id++)
|
||||
{
|
||||
ModeHandler* mh = FindMode(id);
|
||||
if (mh)
|
||||
if (mh && mh->GetModeType() == m)
|
||||
{
|
||||
if (mh->GetNumParams(true))
|
||||
{
|
||||
@ -1149,6 +1167,7 @@ struct builtin_modes
|
||||
|
||||
void init(ModeParser* modes)
|
||||
{
|
||||
b.init();
|
||||
modes->AddMode(&s);
|
||||
modes->AddMode(&p);
|
||||
modes->AddMode(&m);
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
|
||||
void init()
|
||||
{
|
||||
mh.init();
|
||||
ServerInstance->Modules->AddService(mh);
|
||||
|
||||
Implementation list[] = { I_OnUserPreJoin, I_OnRehash };
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
void init()
|
||||
{
|
||||
be.init();
|
||||
ServerInstance->Modules->AddService(be);
|
||||
|
||||
Implementation list[] = { I_OnRehash, I_On005Numeric, I_OnExtBanCheck, I_OnCheckChannelBan };
|
||||
|
@ -237,12 +237,12 @@ class ModuleBanRedirect : public Module
|
||||
|
||||
for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)
|
||||
{
|
||||
modestack.push(irc::modechange('b', i->targetchan.insert(0, i->banmask), false));
|
||||
modestack.push(irc::modechange("ban", i->targetchan.insert(0, i->banmask), false));
|
||||
}
|
||||
|
||||
for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)
|
||||
{
|
||||
modestack.push(irc::modechange('b', i->banmask, true));
|
||||
modestack.push(irc::modechange("ban", i->banmask, true));
|
||||
}
|
||||
|
||||
ServerInstance->SendMode(ServerInstance->FakeClient, chan, modestack, false);
|
||||
|
@ -67,6 +67,7 @@ class ModuleChanFilter : public Module
|
||||
|
||||
void init()
|
||||
{
|
||||
cf.init();
|
||||
ServerInstance->Modules->AddService(cf);
|
||||
|
||||
Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice, I_OnSyncChannel };
|
||||
|
@ -65,6 +65,7 @@ class ModuleExemptChanOps : public Module
|
||||
|
||||
void init()
|
||||
{
|
||||
ec.init();
|
||||
ServerInstance->Modules->AddService(ec);
|
||||
Implementation eventlist[] = { I_OnChannelDelete, I_OnChannelRestrictionApply, I_OnRehash, I_OnSyncChannel };
|
||||
ServerInstance->Modules->Attach(eventlist, this, 4);
|
||||
|
@ -89,7 +89,7 @@ class InvisibleDeOper : public ModeWatcher
|
||||
/* Users who are opers and have +Q get their +Q removed when they deoper */
|
||||
if ((!adding) && (dest->IsModeSet('Q')))
|
||||
{
|
||||
irc::modechange mc('Q', "", false);
|
||||
irc::modechange mc('Q', MODETYPE_CHANNEL, "", false);
|
||||
irc::modestacker ms;
|
||||
ms.push(mc);
|
||||
ServerInstance->SendMode(source, dest, ms, false);
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
|
||||
void init()
|
||||
{
|
||||
ie.init();
|
||||
ServerInstance->Modules->AddService(ie);
|
||||
|
||||
Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite, I_OnRehash };
|
||||
|
@ -150,8 +150,8 @@ void TreeSocket::SendCapabilities(int phase)
|
||||
" IP6SUPPORT=1"+
|
||||
" PROTOCOL="+ConvToStr(ProtocolVersion)+extra+
|
||||
" PREFIX="+ServerInstance->Modes->BuildPrefixes()+
|
||||
" CHANMODES="+ServerInstance->Modes->GiveModeList(MASK_CHANNEL)+
|
||||
" USERMODES="+ServerInstance->Modes->GiveModeList(MASK_USER)+
|
||||
" CHANMODES="+ServerInstance->Modes->GiveModeList(MODETYPE_CHANNEL)+
|
||||
" USERMODES="+ServerInstance->Modes->GiveModeList(MODETYPE_USER)+
|
||||
" SVSPART=1");
|
||||
|
||||
this->WriteLine("CAPAB END");
|
||||
@ -281,7 +281,7 @@ bool TreeSocket::Capab(const parameterlist ¶ms)
|
||||
}
|
||||
else if (this->capab->CapKeys.find("CHANMODES") != this->capab->CapKeys.end())
|
||||
{
|
||||
if (this->capab->CapKeys.find("CHANMODES")->second != ServerInstance->Modes->GiveModeList(MASK_CHANNEL))
|
||||
if (this->capab->CapKeys.find("CHANMODES")->second != ServerInstance->Modes->GiveModeList(MODETYPE_CHANNEL))
|
||||
reason = "One or more of the channel modes on the remote server are invalid on this server.";
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ bool TreeSocket::Capab(const parameterlist ¶ms)
|
||||
}
|
||||
else if (this->capab->CapKeys.find("USERMODES") != this->capab->CapKeys.end())
|
||||
{
|
||||
if (this->capab->CapKeys.find("USERMODES")->second != ServerInstance->Modes->GiveModeList(MASK_USER))
|
||||
if (this->capab->CapKeys.find("USERMODES")->second != ServerInstance->Modes->GiveModeList(MODETYPE_USER))
|
||||
reason = "One or more of the user modes on the remote server are invalid on this server.";
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
|
||||
|
||||
/* Add any modes this user had to the mode stack */
|
||||
for (std::string::iterator x = modes.begin(); x != modes.end(); ++x)
|
||||
modestack.push(irc::modechange(*x, who->nick, true));
|
||||
modestack.push(irc::modechange(*x, MODETYPE_CHANNEL, who->nick, true));
|
||||
|
||||
Channel::JoinUser(who, channel.c_str(), true, "", route_back_again->bursting, TS);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void InspIRCd::BuildISupport()
|
||||
std::stringstream v;
|
||||
v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes - 1 << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax - 1;
|
||||
v << " CASEMAPPING=rfc1459 STATUSMSG=" << Modes->BuildPrefixes(false) << " CHARSET=ascii TOPICLEN=" << Config->Limits.MaxTopic - 1 << " KICKLEN=" << Config->Limits.MaxKick - 1 << " MAXTARGETS=" << Config->MaxTargets - 1;
|
||||
v << " AWAYLEN=" << Config->Limits.MaxAway - 1 << " CHANMODES=" << this->Modes->GiveModeList(MASK_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU";
|
||||
v << " AWAYLEN=" << Config->Limits.MaxAway - 1 << " CHANMODES=" << this->Modes->GiveModeList(MODETYPE_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU";
|
||||
Config->data005 = v.str();
|
||||
FOREACH_MOD(I_On005Numeric,On005Numeric(Config->data005));
|
||||
Config->Update005();
|
||||
|
Loading…
x
Reference in New Issue
Block a user