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

SnomaskManager Class Reference

Snomask manager handles routing of SNOMASK (usermode +n) messages to opers. More...

#include <snomasks.h>

Inheritance diagram for SnomaskManager:

Inheritance graph
[legend]
Collaboration diagram for SnomaskManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SnomaskManager (InspIRCd *Instance)
 Create a new SnomaskManager.
 ~SnomaskManager ()
 Delete SnomaskManager.
bool EnableSnomask (char letter, const std::string &description)
 Enable a snomask.
bool DisableSnomask (char letter)
 Disable a snomask.
void WriteToSnoMask (char letter, const std::string &text)
 Write to all users with a given snomask.
void WriteToSnoMask (char letter, const char *text,...)
 Write to all users with a given snomask.
bool IsEnabled (char letter)
 Check if a snomask is enabled.

Private Member Functions

void SetupDefaults ()
 Set up the default (core available) snomask chars.

Private Attributes

InspIRCdServerInstance
 Creator/owner.
SnoList SnoMasks
 Currently active snomask list.

Detailed Description

Snomask manager handles routing of SNOMASK (usermode +n) messages to opers.

Modules and the core can enable and disable snomask characters. If they do, then sending snomasks using these characters becomes possible.

Definition at line 31 of file snomasks.h.


Constructor & Destructor Documentation

SnomaskManager::SnomaskManager InspIRCd Instance  ) 
 

Create a new SnomaskManager.

Definition at line 20 of file snomasks.cpp.

References SetupDefaults(), and SnoMasks.

00020                                                  : ServerInstance(Instance)
00021 {
00022         SnoMasks.clear();
00023         this->SetupDefaults();
00024 }

SnomaskManager::~SnomaskManager  ) 
 

Delete SnomaskManager.

Definition at line 26 of file snomasks.cpp.

00027 {
00028 }


Member Function Documentation

bool SnomaskManager::DisableSnomask char  letter  ) 
 

Disable a snomask.

Parameters:
letter The snomask letter to disable.
Returns:
True if the snomask was disabled, false if it didn't exist.

Definition at line 40 of file snomasks.cpp.

References SnoMasks.

Referenced by ModuleChanCreate::~ModuleChanCreate(), ModuleGlobops::~ModuleGlobops(), ModuleOverride::~ModuleOverride(), and ModuleSeeNicks::~ModuleSeeNicks().

00041 {
00042         SnoList::iterator n = SnoMasks.find(letter);
00043         if (n != SnoMasks.end())
00044         {
00045                 SnoMasks.erase(n);
00046                 return true;
00047         }
00048         return false;
00049 }

bool SnomaskManager::EnableSnomask char  letter,
const std::string description
 

Enable a snomask.

Parameters:
letter The snomask letter to enable. Once enabled, server notices may be routed to users with this letter in their list, and users may add this letter to their list.
description The descriptive text sent along with any server notices, at the start of the notice, e.g. "GLOBOPS".
Returns:
True if the snomask was enabled, false if it already exists.

Definition at line 30 of file snomasks.cpp.

References SnoMasks.

Referenced by ModuleChanCreate::ModuleChanCreate(), ModuleGlobops::ModuleGlobops(), ModuleOverride::ModuleOverride(), ModuleSeeNicks::ModuleSeeNicks(), and SetupDefaults().

00031 {
00032         if (SnoMasks.find(letter) == SnoMasks.end())
00033         {
00034                 SnoMasks[letter] = type;
00035                 return true;
00036         }
00037         return false;
00038 }

bool SnomaskManager::IsEnabled char  letter  ) 
 

Check if a snomask is enabled.

Parameters:
letter The snomask letter to check.
Returns:
True if the snomask has been enabled.

Definition at line 82 of file snomasks.cpp.

References SnoMasks.

Referenced by userrec::ProcessNoticeMasks().

00083 {
00084         return (SnoMasks.find(letter) != SnoMasks.end());
00085 }

void SnomaskManager::SetupDefaults  )  [private]
 

Set up the default (core available) snomask chars.

Definition at line 87 of file snomasks.cpp.

References EnableSnomask().

Referenced by SnomaskManager().

00088 {
00089         this->EnableSnomask('c',"CONNECT");                     /* Local connect notices */
00090         this->EnableSnomask('C',"REMOTECONNECT");       /* Remote connect notices */
00091         this->EnableSnomask('q',"QUIT");                        /* Local quit notices */
00092         this->EnableSnomask('Q',"REMOTEQUIT");          /* Remote quit notices */
00093         this->EnableSnomask('k',"KILL");                        /* Kill notices */
00094         this->EnableSnomask('K',"REMOTEKILL");          /* Remote kill notices */
00095         this->EnableSnomask('l',"LINK");                        /* Link notices */
00096         this->EnableSnomask('o',"OPER");                        /* Oper up/down notices */
00097         this->EnableSnomask('d',"DEBUG");                       /* Debug notices */
00098         this->EnableSnomask('x',"XLINE");                       /* Xline notice (g/z/q/k/e) */
00099         this->EnableSnomask('t',"STATS");                       /* Local or remote stats request */
00100         this->EnableSnomask('f',"FLOOD");                       /* Flooding notices */
00101 }

void SnomaskManager::WriteToSnoMask char  letter,
const char *  text,
  ...
 

Write to all users with a given snomask.

Parameters:
letter The snomask letter to write to
text A format string containing text to send
... Format arguments

Definition at line 70 of file snomasks.cpp.

References MAXBUF, and WriteToSnoMask().

00071 {
00072         char textbuffer[MAXBUF];
00073         va_list argsPtr;
00074 
00075         va_start(argsPtr, text);
00076         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
00077         va_end(argsPtr);
00078 
00079         this->WriteToSnoMask(letter, std::string(textbuffer));
00080 }

void SnomaskManager::WriteToSnoMask char  letter,
const std::string text
 

Write to all users with a given snomask.

Parameters:
letter The snomask letter to write to
text The text to send to the users

Definition at line 51 of file snomasks.cpp.

References InspIRCd::all_opers, IS_LOCAL, userrec::IsModeSet(), userrec::IsNoticeMaskSet(), userrec::nick, ServerInstance, SnoMasks, and userrec::WriteServ().

Referenced by TreeSocket::AddLine(), CullList::Apply(), ModuleSpanningTree::AutoConnectServers(), TreeSocket::DoBurst(), ModuleSpanningTree::DoPingChecks(), DoStats(), TreeSocket::Error(), XLineManager::expire_lines(), InspIRCd::FloodQuitUser(), TreeSocket::ForceJoin(), TreeSocket::ForceMode(), userrec::FullConnect(), cmd_rsquit::Handle(), cmd_rconnect::Handle(), cmd_globops::Handle(), cmd_zline::Handle(), cmd_qline::Handle(), cmd_oper::Handle(), cmd_nick::Handle(), cmd_kline::Handle(), cmd_kill::Handle(), cmd_gline::Handle(), cmd_eline::Handle(), ModuleSpanningTree::HandleSquit(), TreeSocket::Inbound_Server(), TreeSocket::IntroduceClient(), TreeSocket::OnIncomingConnection(), ModuleOverride::OnPostCommand(), ModuleOperSSLCert::OnPreCommand(), ModuleSpanningTree::OnStats(), ModuleChanCreate::OnUserJoin(), ModuleSeeNicks::OnUserPostNick(), ModuleOverride::OnUserPreJoin(), ModuleOverride::OnUserPreKick(), TreeSocket::OperType(), ModuleSQLOper::OperUser(), TreeSocket::Outbound_Reply_Server(), TreeSocket::ProcessLine(), ModuleSpanningTree::RemoteMessage(), TreeSocket::RemoteRehash(), TreeSocket::RemoteServer(), TreeSocket::Squit(), and WriteToSnoMask().

00052 {
00053         /* Only send to snomask chars which are enabled */
00054         SnoList::iterator n = SnoMasks.find(letter);
00055         if (n != SnoMasks.end())
00056         {
00057                 /* Only opers can receive snotices, so we iterate the oper list */
00058                 for (std::list<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
00059                 {
00060                         userrec* a = *i;
00061                         if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(n->first))
00062                         {
00063                                 /* send server notices to all with +ns */
00064                                 a->WriteServ("NOTICE %s :*** %s: %s",a->nick, n->second.c_str(), text.c_str());
00065                         }
00066                 }
00067         }
00068 }


Member Data Documentation

InspIRCd* SnomaskManager::ServerInstance [private]
 

Creator/owner.

Definition at line 36 of file snomasks.h.

Referenced by WriteToSnoMask().

SnoList SnomaskManager::SnoMasks [private]
 

Currently active snomask list.

Definition at line 39 of file snomasks.h.

Referenced by DisableSnomask(), EnableSnomask(), IsEnabled(), SnomaskManager(), and WriteToSnoMask().


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