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

Redirect Class Reference

Handle channel mode +L. More...

Inheritance diagram for Redirect:

Inheritance graph
[legend]
Collaboration diagram for Redirect:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Redirect (InspIRCd *Instance)
ModePair ModeSet (userrec *source, userrec *dest, chanrec *channel, const std::string &parameter)
 When a remote server needs to bounce a set of modes, it will call this method for every mode in the mode string to determine if the mode is set or not.
bool CheckTimeStamp (time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec *channel)
 If your mode needs special action during a server sync to determine which side wins when comparing timestamps, override this function and use it to return true or false.
ModeAction OnModeChange (userrec *source, userrec *dest, chanrec *channel, std::string &parameter, bool adding)
 Called when a mode change for your mode occurs.

Detailed Description

Handle channel mode +L.

Definition at line 23 of file m_redirect.cpp.


Constructor & Destructor Documentation

Redirect::Redirect InspIRCd Instance  )  [inline]
 

Definition at line 26 of file m_redirect.cpp.

00026 : ModeHandler(Instance, 'L', 1, 0, false, MODETYPE_CHANNEL, false) { }


Member Function Documentation

bool Redirect::CheckTimeStamp time_t  theirs,
time_t  ours,
const std::string their_param,
const std::string our_param,
chanrec channel
[inline, virtual]
 

If your mode needs special action during a server sync to determine which side wins when comparing timestamps, override this function and use it to return true or false.

The default implementation just returns true if theirs < ours. This will only be called for non-listmodes with parameters, when adding the mode and where theirs == ours (therefore the default implementation will always return false).

Parameters:
theirs The timestamp of the remote side
ours The timestamp of the local side
their_param Their parameter if the mode has a parameter
our_param Our parameter if the mode has a parameter
channel The channel we are checking against
Returns:
True if the other side wins the merge, false if we win the merge for this mode.

Reimplemented from ModeHandler.

Definition at line 36 of file m_redirect.cpp.

00037         {
00038                 /* When TS is equal, the alphabetically later one wins */
00039                 return (their_param < our_param);
00040         }

ModePair Redirect::ModeSet userrec source,
userrec dest,
chanrec channel,
const std::string parameter
[inline, virtual]
 

When a remote server needs to bounce a set of modes, it will call this method for every mode in the mode string to determine if the mode is set or not.

Parameters:
source of the mode change, this will be NULL for a server mode
dest Target user of the mode change, if this is a user mode
channel Target channel of the mode change, if this is a channel mode
parameter The parameter given for the mode change, or an empty string
Returns:
The first value of the pair should be true if the mode is set with the given parameter. In the case of permissions modes such as channelmode +o, this should return true if the user given as the parameter has the given privilage on the given channel. The string value of the pair will hold the current setting for this mode set locally, when the bool is true, or, the parameter given. This allows the local server to enforce our locally set parameters back to a remote server.

Reimplemented from ModeHandler.

Definition at line 28 of file m_redirect.cpp.

References chanrec::GetModeParameter(), and chanrec::IsModeSet().

00029         {
00030                 if (channel->IsModeSet('L'))
00031                         return std::make_pair(true, channel->GetModeParameter('L'));
00032                 else
00033                         return std::make_pair(false, parameter);
00034         }

ModeAction Redirect::OnModeChange userrec source,
userrec dest,
chanrec channel,
std::string parameter,
bool  adding
[inline, virtual]
 

Called when a mode change for your mode occurs.

Parameters:
source Contains the user setting the mode.
dest For usermodes, contains the destination user the mode is being set on. For channelmodes, this is an undefined value.
channel For channel modes, contains the destination channel the modes are being set on. For usermodes, this is an undefined value.
parameter The parameter for your mode, if you indicated that your mode requires a parameter when being set or unset. Note that if you alter this value, the new value becomes the one displayed and send out to the network, also, if you set this to an empty string but you specified your mode REQUIRES a parameter, this is equivalent to returning MODEACTION_DENY and will prevent the mode from being displayed.
adding This value is true when the mode is being set, or false when it is being unset.
Returns:
MODEACTION_ALLOW to allow the mode, or MODEACTION_DENY to prevent the mode, also see the description of 'parameter'.

Reimplemented from ModeHandler.

Definition at line 42 of file m_redirect.cpp.

References InspIRCd::chanlist, InspIRCd::FindChan(), IS_LOCAL, InspIRCd::IsChannel(), chanrec::IsModeSet(), MODEACTION_ALLOW, MODEACTION_DENY, chanrec::name, userrec::nick, ModeHandler::ServerInstance, chanrec::SetMode(), chanrec::SetModeParam(), and userrec::WriteServ().

00043         {
00044                 if (adding)
00045                 {
00046                         chanrec* c = NULL;
00047 
00048                         if (!ServerInstance->IsChannel(parameter.c_str()))
00049                         {
00050                                 source->WriteServ("403 %s %s :Invalid channel name",source->nick, parameter.c_str());
00051                                 parameter.clear();
00052                                 return MODEACTION_DENY;
00053                         }
00054 
00055                         c = ServerInstance->FindChan(parameter);
00056                         if (c)
00057                         {
00058                                 /* Fix by brain: Dont let a channel be linked to *itself* either */
00059                                 if (IS_LOCAL(source))
00060                                 {
00061                                         if ((c == channel) || (c->IsModeSet('L')))
00062                                         {
00063                                                 source->WriteServ("690 %s :Circular or chained +L to %s not allowed (Channel already has +L). Pack of wild dogs has been unleashed.",source->nick,parameter.c_str());
00064                                                 parameter.clear();
00065                                                 return MODEACTION_DENY;
00066                                         }
00067                                         else
00068                                         {
00069                                                 for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
00070                                                 {
00071                                                         if ((i->second != channel) && (i->second->IsModeSet('L')) && (irc::string(i->second->GetModeParameter('L').c_str()) == irc::string(channel->name)))
00072                                                         {
00073                                                                 source->WriteServ("690 %s :Circular or chained +L to %s not allowed (Already forwarded here from %s). Angry monkeys dispatched.",source->nick,parameter.c_str(),i->second->name);
00074                                                                 return MODEACTION_DENY;
00075                                                         }
00076                                                 }
00077                                         }
00078                                 }
00079                         }
00080 
00081                         channel->SetMode('L', true);
00082                         channel->SetModeParam('L', parameter.c_str(), true);
00083                         return MODEACTION_ALLOW;
00084                 }
00085                 else
00086                 {
00087                         if (channel->IsModeSet('L'))
00088                         {
00089                                 channel->SetMode('L', false);
00090                                 return MODEACTION_ALLOW;
00091                         }
00092                 }
00093 
00094                 return MODEACTION_DENY;
00095                 
00096         }


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