InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | Static Public Member Functions | List of all members
ModeParser Class Reference

#include <mode.h>

Public Member Functions

 ModeParser ()
 
UserSanityChecks (User *user, const char *dest, Channel *chan, int status)
 
const std::string & GetLastParse ()
 
const std::vector< std::string > & GetLastParseParams ()
 
const std::vector
< TranslateType > & 
GetLastParseTranslate ()
 
bool AddMode (ModeHandler *mh)
 
bool DelMode (ModeHandler *mh)
 
bool AddModeWatcher (ModeWatcher *mw)
 
bool DelModeWatcher (ModeWatcher *mw)
 
void Process (const std::vector< std::string > &parameters, User *user, bool merge=false)
 
ModeHandlerFindMode (unsigned const char modeletter, ModeType mt)
 
ModeHandlerFindPrefix (unsigned const char pfxletter)
 
std::string UserModeList ()
 
std::string ChannelModeList ()
 
std::string ParaModeList ()
 
std::string GiveModeList (ModeMasks m)
 
std::string BuildPrefixes (bool lettersAndModes=true)
 

Static Public Member Functions

static void CleanMask (std::string &mask)
 
static bool PrefixComparison (ModeHandler *one, ModeHandler *two)
 

Detailed Description

The mode parser handles routing of modes and handling of mode strings. 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.

Constructor & Destructor Documentation

ModeParser::ModeParser ( )

The constructor initializes all the RFC basic modes by using ModeParserAddMode().

Member Function Documentation

bool ModeParser::AddMode ( ModeHandler mh)

Add a mode to the mode parser.

Returns
True if the mode was successfully added.
bool ModeParser::AddModeWatcher ( ModeWatcher mw)

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.

Parameters
mwThe ModeWatcher you want to add
Returns
True if the ModeWatcher was added correctly
std::string ModeParser::BuildPrefixes ( bool  lettersAndModes = true)

This returns the PREFIX=(ohv)%+ section of the 005 numeric, or just the "@%+" part if the parameter false

std::string ModeParser::ChannelModeList ( )

Returns a list of channel mode characters which are listmodes. This is used in the 004 numeric when users connect.

void ModeParser::CleanMask ( std::string &  mask)
static

Tidy a banmask. This makes a banmask 'acceptable' if fields are left out. E.g.

nick -> nick!*@*

nick!ident -> nick!ident@*

host.name -> *!*@host.name

ident.nosp@m.@hos.nosp@m.t.nam.nosp@m.e -> *!ident@host.name

This method can be used on both IPV4 and IPV6 user masks.

bool ModeParser::DelMode ( ModeHandler mh)

Delete a mode from the mode parser. When a mode is deleted, the mode handler will be called for every user (if it is a user mode) or for every channel (if it is a channel mode) to unset the mode on all objects. This prevents modes staying in the system which no longer exist.

Parameters
mhThe mode handler to remove
Returns
True if the mode was successfully removed.
bool ModeParser::DelModeWatcher ( ModeWatcher mw)

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.

Parameters
mwThe ModeWatcher you want to delete
Returns
True if the ModeWatcher was deleted correctly
ModeHandler * ModeParser::FindMode ( unsigned const char  modeletter,
ModeType  mt 
)

Find the mode handler for a given mode and type.

Parameters
modelettermode letter to search for
mttype of mode to search for, user or channel
Returns
a pointer to a ModeHandler class, or NULL of there isnt a handler for the given mode
ModeHandler * ModeParser::FindPrefix ( unsigned const char  pfxletter)

Find a mode handler by its prefix. If there is no mode handler with the given prefix, NULL will be returned.

Parameters
pfxletterThe prefix to find, e.g. '@'
Returns
The mode handler which handles this prefix, or NULL if there is none.
const std::string & ModeParser::GetLastParse ( )

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.

Returns
Last parsed string, as seen by users.
std::string ModeParser::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 ModeParser::ParaModeList ( )

Returns a list of channel mode characters which take parameters. This is used in the 004 numeric when users connect.

void ModeParser::Process ( const std::vector< std::string > &  parameters,
User user,
bool  merge = false 
)

Process a set of mode changes from a server or user.

Parameters
parametersThe parameters of the mode change, in the format they would be from a MODE command.
userThe user setting or removing the modes. When the modes are set by a server, an 'uninitialized' User is used, where *user::nick == NULL and *user->server == NULL.
mergeShould the mode parameters be merged?
User * ModeParser::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'. for example, should 'user A' be able to 'op' on 'channel B'.

std::string ModeParser::UserModeList ( )

Returns a list of mode characters which are usermodes. This is used in the 004 numeric when users connect.


The documentation for this class was generated from the following files: