]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/snomasks.h
Remove SpanningTreeProtocolInterface::SendOperNotice - it was translated to a SendSNO...
[user/henk/code/inspircd.git] / include / snomasks.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __SNOMASKS_H__
15 #define __SNOMASKS_H__
16
17 class Snomask : public Extensible
18 {
19  private:
20         InspIRCd *ServerInstance;
21
22  public:
23         char MySnomask;
24         std::string Description;
25         std::string LastMessage;
26         unsigned int Count;
27         bool LocalOnly; // whether or not messages are netwide
28
29         /** Create a new Snomask
30          */
31         Snomask(InspIRCd* Instance, char snomask, const std::string &description, bool local) : ServerInstance(Instance), MySnomask(snomask), Description(description), LastMessage(""), Count(0), LocalOnly(local)
32         {
33         }
34
35         /** Sends a message to all opers with this snomask.
36          */
37         void SendMessage(const std::string &message);
38
39         /** Sends out a pending message
40          */
41         void Flush();
42 };
43
44 /** A list of snomasks which are valid, and their descriptive texts
45  */
46 typedef std::map<char, Snomask *> SnoList;
47
48 /** Snomask manager handles routing of SNOMASK (usermode +n) messages to opers.
49  * Modules and the core can enable and disable snomask characters. If they do,
50  * then sending snomasks using these characters becomes possible.
51  */
52 class CoreExport SnomaskManager : public Extensible
53 {
54  private:
55         /** Creator/owner
56          */
57         InspIRCd* ServerInstance;
58
59         /** Currently active snomask list
60          */
61         SnoList SnoMasks;
62
63         /** Set up the default (core available) snomask chars
64          */
65         void SetupDefaults();
66  public:
67         /** Create a new SnomaskManager
68          */
69         SnomaskManager(InspIRCd* Instance);
70
71         /** Delete SnomaskManager
72          */
73         ~SnomaskManager();
74
75         /** Enable a snomask.
76          * @param letter The snomask letter to enable. Once enabled,
77          * server notices may be routed to users with this letter in
78          * their list, and users may add this letter to their list.
79          * @param description The descriptive text sent along with any
80          * server notices, at the start of the notice, e.g. "GLOBOPS".
81          * @param local Whether or not messages should be locally broadcast only (default off)
82          * @return True if the snomask was enabled, false if it already
83          * exists.
84          */
85         bool EnableSnomask(char letter, const std::string &description, bool local = false);
86
87         /** Disable a snomask.
88          * @param letter The snomask letter to disable.
89          * @return True if the snomask was disabled, false if it didn't
90          * exist.
91          */
92         bool DisableSnomask(char letter);
93
94         /** Write to all users with a given snomask.
95          * @param letter The snomask letter to write to
96          * @param text The text to send to the users
97          */
98         void WriteToSnoMask(char letter, const std::string &text);
99
100         /** Write to all users with a given snomask.
101          * @param letter The snomask letter to write to
102          * @param text A format string containing text to send
103          * @param ... Format arguments
104          */
105         void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
106
107         /** Called once per 5 seconds from the mainloop, this flushes any cached
108          * snotices. The way the caching works is as follows:
109          * Calls to WriteToSnoMask write to a cache, if the call is the same as it was
110          * for the previous call, then a count is incremented. If it is different,
111          * the previous message it just sent normally via NOTICE (with count if > 1)
112          * and the new message is cached. This acts as a sender in case the number of notices
113          * is not particularly significant, in order to keep notices going out.
114          */
115         void FlushSnotices();
116
117         /** Check if a snomask is enabled.
118          * @param letter The snomask letter to check.
119          * @return True if the snomask has been enabled.
120          */
121         bool IsEnabled(char letter);
122 };
123
124 #endif