The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ModeWatcher Class Reference

The ModeWatcher class can be used to alter the behaviour of a mode implemented by the core or by another module. More...

#include <mode.h>

Inheritance diagram for ModeWatcher:

Inheritance graph
[legend]
Collaboration diagram for ModeWatcher:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModeWatcher (InspIRCd *Instance, char modeletter, ModeType type)
 The constructor initializes the mode and the mode type.
virtual ~ModeWatcher ()
 The default destructor does nothing.
char GetModeChar ()
 Get the mode character being watched.
ModeType GetModeType ()
 Get the mode type being watched.
virtual bool BeforeMode (User *source, User *dest, Channel *channel, std::string &parameter, bool adding, ModeType type, bool servermode=false)
 Before the mode character is processed by its handler, this method will be called.
virtual void AfterMode (User *source, User *dest, Channel *channel, const std::string &parameter, bool adding, ModeType type, bool servermode=false)
 After the mode character has been processed by the ModeHandler, this method will be called.

Protected Attributes

InspIRCdServerInstance
 Creator/owner pointer.
char mode
 The mode letter this class is watching.
ModeType m_type
 The mode type being watched (user or channel).

Detailed Description

The ModeWatcher class can be used to alter the behaviour of a mode implemented by the core or by another module.

To use ModeWatcher, derive a class from it, and attach it to the mode using Server::AddModeWatcher and Server::DelModeWatcher. A ModeWatcher will be called both before and after the mode change.

Definition at line 340 of file mode.h.


Constructor & Destructor Documentation

ModeWatcher::ModeWatcher InspIRCd Instance,
char  modeletter,
ModeType  type
 

The constructor initializes the mode and the mode type.

Definition at line 220 of file mode.cpp.

ModeWatcher::~ModeWatcher  )  [virtual]
 

The default destructor does nothing.

Definition at line 224 of file mode.cpp.


Member Function Documentation

void ModeWatcher::AfterMode User source,
User dest,
Channel channel,
const std::string parameter,
bool  adding,
ModeType  type,
bool  servermode = false
[virtual]
 

After the mode character has been processed by the ModeHandler, this method will be called.

Parameters:
source The sender of the mode
dest The target user for the mode, if you are watching a user mode
channel The target channel for the mode, if you are watching a channel mode
parameter The parameter of the mode, if the mode is supposed to have a parameter. You cannot alter the parameter here, as the mode handler has already processed it.
adding True if the mode is being added and false if it is being removed The mode type, either MODETYPE_USER or MODETYPE_CHANNEL

Definition at line 243 of file mode.cpp.

bool ModeWatcher::BeforeMode User source,
User dest,
Channel channel,
std::string parameter,
bool  adding,
ModeType  type,
bool  servermode = false
[virtual]
 

Before the mode character is processed by its handler, this method will be called.

Parameters:
source The sender of the mode
dest The target user for the mode, if you are watching a user mode
channel The target channel for the mode, if you are watching a channel mode
parameter The parameter of the mode, if the mode is supposed to have a parameter. If you alter the parameter you are given, the mode handler will see your atered version when it handles the mode.
adding True if the mode is being added and false if it is being removed The mode type, either MODETYPE_USER or MODETYPE_CHANNEL
Returns:
True to allow the mode change to go ahead, false to abort it. If you abort the change, the mode handler (and ModeWatcher::AfterMode()) will never see the mode change.

Reimplemented in BanRedirect, and InvisibleDeOper.

Definition at line 238 of file mode.cpp.

char ModeWatcher::GetModeChar  ) 
 

Get the mode character being watched.

Returns:
The mode character being watched

Definition at line 228 of file mode.cpp.

References mode.

Referenced by ModeParser::AddModeWatcher(), and ModeParser::DelModeWatcher().

ModeType ModeWatcher::GetModeType  ) 
 

Get the mode type being watched.

Returns:
The mode type being watched (user or channel)

Definition at line 233 of file mode.cpp.

References m_type.

Referenced by ModeParser::AddModeWatcher(), and ModeParser::DelModeWatcher().


Member Data Documentation

ModeType ModeWatcher::m_type [protected]
 

The mode type being watched (user or channel).

Definition at line 354 of file mode.h.

Referenced by GetModeType().

char ModeWatcher::mode [protected]
 

The mode letter this class is watching.

Definition at line 350 of file mode.h.

Referenced by GetModeChar().

InspIRCd* ModeWatcher::ServerInstance [protected]
 

Creator/owner pointer.

Definition at line 346 of file mode.h.

Referenced by InvisibleDeOper::BeforeMode(), and BanRedirect::BeforeMode().


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