|
|||
|
|||
|
#include <mode.h>
Inheritance diagram for ModeParser:


Public Member Functions | |
| ModeParser (InspIRCd *Instance) | |
| The constructor initializes all the RFC basic modes by using ModeParserAddMode(). | |
| User * | SanityChecks (User *user, const char *dest, Channel *chan, int status) |
| Used to check if user 'd' should be allowed to do operation 'MASK' on channel 'chan'. | |
| const char * | Grant (User *d, Channel *chan, int MASK) |
| Grant a built in privilage (e.g. | |
| const char * | Revoke (User *d, Channel *chan, int MASK) |
| Revoke a built in privilage (e.g. | |
| const std::string & | GetLastParse () |
| Get the last string to be processed, as it was sent to the user or channel. | |
| bool | AddMode (ModeHandler *mh) |
| Add a mode to the mode parser. | |
| bool | DelMode (ModeHandler *mh) |
| Delete a mode from the mode parser. | |
| bool | AddModeWatcher (ModeWatcher *mw) |
| Add a mode watcher. | |
| bool | DelModeWatcher (ModeWatcher *mw) |
| Delete a mode watcher. | |
| void | Process (const std::vector< std::string > ¶meters, User *user, bool servermode) |
| Process a set of mode changes from a server or user. | |
| ModeHandler * | FindMode (unsigned const char modeletter, ModeType mt) |
| Find the mode handler for a given mode and type. | |
| ModeHandler * | FindPrefix (unsigned const char pfxletter) |
| Find a mode handler by its prefix. | |
| std::string | UserModeList () |
| Returns a list of mode characters which are usermodes. | |
| std::string | ChannelModeList () |
| Returns a list of channel mode characters which are listmodes. | |
| std::string | ParaModeList () |
| Returns a list of channel mode characters which take parameters. | |
| std::string | GiveModeList (ModeMasks m) |
| Generates a list of modes, comma seperated by type: 1; Listmodes EXCEPT those with a prefix 2; Modes that take a param when adding or removing 3; Modes that only take a param when adding 4; Modes that dont take a param. | |
| std::string | BuildPrefixes () |
| This returns the PREFIX=(ohv)%+ section of the 005 numeric. | |
| std::string | ModeString (User *user, Channel *channel, bool nick_suffix=true) |
| This returns the privilages of a user upon a channel, in the format of a mode change. | |
Static Public Member Functions | |
| static void | CleanMask (std::string &mask) |
| Tidy a banmask. | |
| static bool | PrefixComparison (prefixtype one, prefixtype two) |
| Used by this class internally during std::sort and 005 generation. | |
Private Member Functions | |
| void | DisplayCurrentModes (User *user, User *targetuser, Channel *targetchannel, const char *text) |
| Displays the current modes of a channel or user. | |
Private Attributes | |
| InspIRCd * | ServerInstance |
| Creator/owner pointer. | |
| ModeHandler * | modehandlers [256] |
| Mode handlers for each mode, to access a handler subtract 65 from the ascii value of the mode letter. | |
| std::vector< ModeWatcher * > | modewatchers [256] |
| Mode watcher classes arranged in the same way as the mode handlers, except for instead of having 256 of them we have 256 lists of them. | |
| std::string | LastParse |
| The string representing the last set of modes to be parsed. | |
| unsigned int | sent [256] |
| unsigned int | seq |
It marshalls, controls and maintains both ModeWatcher and ModeHandler classes, parses client to server MODE strings for user and channel modes, and performs processing for the 004 mode list numeric, amongst other things.
Definition at line 411 of file mode.h.
|
|
The constructor initializes all the RFC basic modes by using ModeParserAddMode().
Definition at line 1193 of file mode.cpp. References AddMode(), LastParse, modehandlers, sent, and seq. |
|
|
|
Add a mode watcher. A mode watcher is triggered before and after a mode handler is triggered. See the documentation of class ModeWatcher for more information.
Definition at line 1101 of file mode.cpp. References ModeWatcher::GetModeChar(), ModeWatcher::GetModeType(), MASK_CHANNEL, MASK_USER, MODETYPE_USER, and modewatchers. Referenced by ModuleBanRedirect::ModuleBanRedirect(), and ModuleInvisible::ModuleInvisible(). |
|
|
This returns the PREFIX=(ohv)%+ section of the 005 numeric.
Definition at line 1069 of file mode.cpp. References ServerConfig::AllowHalfop, InspIRCd::Config, ModeHandler::GetPrefix(), MASK_CHANNEL, modehandlers, PrefixComparison(), and ServerInstance. Referenced by InspIRCd::BuildISupport(), TreeSocket::Capab(), and TreeSocket::SendCapabilities(). |
|
|
Returns a list of channel mode characters which are listmodes. This is used in the 004 numeric when users connect. Definition at line 927 of file mode.cpp. References ServerConfig::AllowHalfop, InspIRCd::Config, MASK_CHANNEL, modehandlers, and ServerInstance. Referenced by User::FullConnect(). |
|
|
Tidy a banmask. This makes a banmask 'acceptable' if fields are left out. E.g. nick -> nick!*@* nick!ident -> nick!ident@* host.name -> *!*.name ident@host.name -> *!ident.name This method can be used on both IPV4 and IPV6 user masks. Definition at line 794 of file mode.cpp. Referenced by ModeChannelBan::AddBan(), ModeChannelBan::DelBan(), CommandSilence::Handle(), and ListModeBase::OnModeChange(). |
|
|
|
Delete a mode watcher. A mode watcher is triggered before and after a mode handler is triggered. See the documentation of class ModeWatcher for more information.
Definition at line 1120 of file mode.cpp. References ModeWatcher::GetModeChar(), ModeWatcher::GetModeType(), MASK_CHANNEL, MASK_USER, MODETYPE_USER, and modewatchers. Referenced by ModuleBanRedirect::~ModuleBanRedirect(), and ModuleInvisible::~ModuleInvisible(). |
|
||||||||||||||||||||
|
Displays the current modes of a channel or user. Used by ModeParser::Process. Definition at line 323 of file mode.cpp. References classbase::age, Channel::ChanModes(), ERR_NOSUCHNICK, ERR_USERSDONTMATCH, User::FormatModes(), User::FormatNoticeMasks(), User::HasPrivPermission(), Channel::HasUser(), IS_OPER, Channel::name, User::nick, RPL_CHANNELCREATED, RPL_CHANNELMODEIS, RPL_SNOMASKIS, RPL_UMODEIS, User::Visibility, VisData::VisibleTo(), and User::WriteNumeric(). Referenced by Process(). |
|
||||||||||||
|
Find the mode handler for a given mode and type.
Definition at line 897 of file mode.cpp. References MASK_CHANNEL, MASK_USER, modehandlers, and MODETYPE_USER. Referenced by User::DecrementModes(), TreeSocket::ForceJoin(), User::FormatModes(), UserManager::ModeCount(), ModulePermanentChannels::OnRehash(), TreeSocket::ParseUID(), Process(), Channel::SetDefaultModes(), and User::UnOper(). |
|
|
Find a mode handler by its prefix. If there is no mode handler with the given prefix, NULL will be returned.
Definition at line 965 of file mode.cpp. References MASK_CHANNEL, and modehandlers. Referenced by SpanningTreeUtilities::DoOneToAllButSenderRaw(), Channel::ForceChan(), ModuleChanProtect::LoadSettings(), Process(), and TreeSocket::ServerMessage(). |
|
|
Get the last string to be processed, as it was sent to the user or channel. Use this to display a string you just sent to be parsed, as the actual output may be different to what you sent after it has been 'cleaned up' by the parser.
Definition at line 789 of file mode.cpp. References LastParse. Referenced by CommandSamode::Handle(), ModuleTimedBans::OnBackgroundTimer(), and ModuleOverride::OnPostCommand(). |
|
|
Generates a list of modes, comma seperated by type: 1; Listmodes EXCEPT those with a prefix 2; Modes that take a param when adding or removing 3; Modes that only take a param when adding 4; Modes that dont take a param.
Definition at line 1013 of file mode.cpp. References ServerConfig::AllowHalfop, InspIRCd::Config, ModeHandler::GetModeChar(), modehandlers, and ServerInstance. Referenced by InspIRCd::BuildISupport(), TreeSocket::Capab(), and TreeSocket::SendCapabilities(). |
|
||||||||||||||||
|
Grant a built in privilage (e.g. ops, halfops, voice) to a user on a channel Definition at line 263 of file mode.cpp. References User::chans, User::nick, UCMODE_HOP, UCMODE_OP, and UCMODE_VOICE. Referenced by ModeChannelHalfOp::AddHalfOp(), ModeChannelOp::AddOp(), and ModeChannelVoice::AddVoice(). |
|
||||||||||||||||
|
This returns the privilages of a user upon a channel, in the format of a mode change. For example, if a user has privilages +avh, this will return the string "avh nick nick nick". This is used by the core when cycling a user to refresh their hostname. You may use it for similar purposes.
Definition at line 979 of file mode.cpp. References ModeHandler::GetModeChar(), ModeHandler::GetNumParams(), MASK_CHANNEL, modehandlers, ModeHandler::ModeSet(), and User::nick. Referenced by User::ChangeDisplayedHost(), User::ChangeIdent(), Channel::ForceChan(), InvisibleMode::OnModeChange(), ModuleServProtectMode::OnRawMode(), ModuleDelayJoin::OnText(), ModuleSpanningTree::OnUserJoin(), and TreeSocket::SendFJoins(). |
|
|
Returns a list of channel mode characters which take parameters. This is used in the 004 numeric when users connect. Definition at line 946 of file mode.cpp. References ServerConfig::AllowHalfop, InspIRCd::Config, MASK_CHANNEL, modehandlers, and ServerInstance. Referenced by User::FullConnect(). |
|
||||||||||||
|
Used by this class internally during std::sort and 005 generation.
Definition at line 1064 of file mode.cpp. Referenced by BuildPrefixes(), and Channel::SetPrefix(). |
|
||||||||||||||||
|
Process a set of mode changes from a server or user.
Definition at line 360 of file mode.cpp. References AC_GENERAL_MODE, ACR_ALLOW, ACR_DENY, ModeHandler::ChangeCount(), InspIRCd::Config, ServerConfig::DisabledCModes, ServerConfig::DisabledUModes, DisplayCurrentModes(), ModeHandler::DisplayEmptyList(), ModeHandler::DisplayList(), ERR_CHANOPRIVSNEEDED, ERR_NOPRIVILEGES, ERR_NOSUCHNICK, ERR_USERSDONTMATCH, InspIRCd::FindChan(), FindMode(), InspIRCd::FindNick(), FindPrefix(), FOREACH_MOD, FOREACH_RESULT, Channel::GetAllPrefixChars(), ModeHandler::GetModeChar(), ModeHandler::GetNeededPrefix(), ModeHandler::GetPrefixRank(), Channel::GetStatus(), User::HasModePermission(), User::HasPrivPermission(), ServerConfig::HideModeLists, I_OnAccessCheck, I_OnMode, I_OnRawMode, IS_LOCAL, IS_OPER, ModeHandler::IsListMode(), LastParse, ServerConfig::Limits, MASK_CHANNEL, MASK_USER, ServerLimits::MaxModes, MODEACTION_ALLOW, modehandlers, MODETYPE_CHANNEL, MODETYPE_USER, modewatchers, Channel::name, User::nick, ModeHandler::OnModeChange(), ModeHandler::OnParameterMissing(), User::oper, sent, seq, User::server, ServerInstance, ServerConfig::ServerName, Channel::SetPrefix(), STATUS_HOP, TYPE_CHANNEL, TYPE_USER, InspIRCd::ULine(), Channel::WriteChannel(), Channel::WriteChannelWithServ(), User::WriteNumeric(), User::WriteServ(), and User::WriteTo(). Referenced by InvisibleDeOper::BeforeMode(), ModeHandler::RemoveMode(), and InspIRCd::SendMode(). |
|
||||||||||||||||
|
Revoke a built in privilage (e.g. ops, halfops, voice) to a user on a channel Definition at line 293 of file mode.cpp. References User::chans, User::nick, UCMODE_HOP, UCMODE_OP, and UCMODE_VOICE. Referenced by ModeChannelHalfOp::DelHalfOp(), ModeChannelOp::DelOp(), and ModeChannelVoice::DelVoice(). |
|
||||||||||||||||||||
|
Used to check if user 'd' should be allowed to do operation 'MASK' on channel 'chan'. for example, should 'user A' be able to 'op' on 'channel B'. Definition at line 247 of file mode.cpp. References ERR_NOSUCHNICK, InspIRCd::FindNick(), User::nick, ServerInstance, and User::WriteNumeric(). Referenced by ModeChannelHalfOp::AddHalfOp(), ModeChannelOp::AddOp(), ModeChannelVoice::AddVoice(), ModeChannelHalfOp::DelHalfOp(), ModeChannelOp::DelOp(), and ModeChannelVoice::DelVoice(). |
|
|
Returns a list of mode characters which are usermodes. This is used in the 004 numeric when users connect. Definition at line 911 of file mode.cpp. References MASK_USER, and modehandlers. Referenced by User::FullConnect(). |
|
|
The string representing the last set of modes to be parsed. Use GetLastParse() to get this value, to be used for display purposes. Definition at line 437 of file mode.h. Referenced by GetLastParse(), ModeParser(), and Process(). |
|
|
Mode handlers for each mode, to access a handler subtract 65 from the ascii value of the mode letter. The upper bit of the value indicates if its a usermode or a channel mode, so we have 256 of them not 64. Definition at line 423 of file mode.h. Referenced by AddMode(), BuildPrefixes(), ChannelModeList(), DelMode(), FindMode(), FindPrefix(), GiveModeList(), ModeParser(), ModeString(), ParaModeList(), Process(), and UserModeList(). |
|
|
Mode watcher classes arranged in the same way as the mode handlers, except for instead of having 256 of them we have 256 lists of them.
Definition at line 428 of file mode.h. Referenced by AddModeWatcher(), DelModeWatcher(), and Process(). |
|
|
Definition at line 439 of file mode.h. Referenced by ModeParser(), and Process(). |
|
|
Definition at line 441 of file mode.h. Referenced by ModeParser(), and Process(). |
|
|
Creator/owner pointer.
Definition at line 417 of file mode.h. Referenced by BuildPrefixes(), ChannelModeList(), DelMode(), GiveModeList(), ParaModeList(), Process(), and SanityChecks(). |