]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Make classbase and refcountbase uncopyable; expand comments on their indended uses
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __ST_MAIN__
15 #define __ST_MAIN__
16
17 #include "inspircd.h"
18 #include <stdarg.h>
19
20 /** If you make a change which breaks the protocol, increment this.
21  * If you  completely change the protocol, completely change the number.
22  *
23  * IMPORTANT: If you make changes, document your changes here, without fail:
24  * http://wiki.inspircd.org/List_of_protocol_changes_between_versions
25  *
26  * Failure to document your protocol changes will result in a painfully
27  * painful death by pain. You have been warned.
28  */
29 const long ProtocolVersion = 1202;
30 const long MinCompatProtocol = 1201;
31
32 /** Forward declarations
33  */
34 class CommandRConnect;
35 class CommandRSQuit;
36 class SpanningTreeUtilities;
37 class CacheRefreshTimer;
38 class TreeServer;
39 class Link;
40 class Autoconnect;
41
42 /** This is the main class for the spanningtree module
43  */
44 class ModuleSpanningTree : public Module
45 {
46         unsigned int max_local;
47         unsigned int max_global;
48         CommandRConnect* command_rconnect;
49         CommandRSQuit* command_rsquit;
50         SpanningTreeUtilities* Utils;
51
52         void RedoConfig(Module* mod);
53
54  public:
55         CacheRefreshTimer *RefreshTimer;
56         /** Set to true if inside a spanningtree call, to prevent sending
57          * xlines and other things back to their source
58          */
59         bool loopCall;
60
61         /** Constructor
62          */
63         ModuleSpanningTree();
64
65         /** Shows /LINKS
66          */
67         void ShowLinks(TreeServer* Current, User* user, int hops);
68
69         /** Counts local servers
70          */
71         int CountLocalServs();
72
73         /** Counts local and remote servers
74          */
75         int CountServs();
76
77         /** Handle LINKS command
78          */
79         void HandleLinks(const std::vector<std::string>& parameters, User* user);
80
81         /** Handle LUSERS command
82          */
83         void HandleLusers(const std::vector<std::string>& parameters, User* user);
84
85         /** Show MAP output to a user (recursive)
86          */
87         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
88
89         /** Handle remote MOTD
90          */
91         ModResult HandleMotd(const std::vector<std::string>& parameters, User* user);
92
93         /** Handle remote ADMIN
94          */
95         ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user);
96
97         /** Handle remote STATS
98          */
99         ModResult HandleStats(const std::vector<std::string>& parameters, User* user);
100
101         /** Handle MAP command
102          */
103         bool HandleMap(const std::vector<std::string>& parameters, User* user);
104
105         /** Handle SQUIT
106          */
107         ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
108
109         /** Handle TIME
110          */
111         ModResult HandleTime(const std::vector<std::string>& parameters, User* user);
112
113         /** Handle remote WHOIS
114          */
115         ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
116
117         /** Ping all local servers
118          */
119         void DoPingChecks(time_t curtime);
120
121         /** Connect a server locally
122          */
123         void ConnectServer(Link* x, Autoconnect* y = NULL);
124
125         /** Connect the next autoconnect server
126          */
127         void ConnectServer(Autoconnect* y, bool on_timer);
128
129         /** Check if any servers are due to be autoconnected
130          */
131         void AutoConnectServers(time_t curtime);
132
133         /** Check if any connecting servers should timeout
134          */
135         void DoConnectTimeout(time_t curtime);
136
137         /** Handle remote VERSON
138          */
139         ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
140
141         /** Handle CONNECT
142          */
143         ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
144
145         /** Attempt to send a message to a user
146          */
147         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
148
149         /** Returns oper-specific MAP information
150          */
151         const std::string MapOperInfo(TreeServer* Current);
152
153         /** Display a time as a human readable string
154          */
155         std::string TimeToStr(time_t secs);
156
157         /**
158          ** *** MODULE EVENTS ***
159          **/
160
161         ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
162         void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
163         void OnGetServerDescription(const std::string &servername,std::string &description);
164         void OnUserConnect(User* source);
165         void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
166         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
167         void OnWallops(User* user, const std::string &text);
168         void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
169         void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
170         void OnBackgroundTimer(time_t curtime);
171         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
172         ModResult OnChangeLocalUserHost(User* user, const std::string &newhost);
173         void OnChangeName(User* user, const std::string &gecos);
174         void OnChangeIdent(User* user, const std::string &ident);
175         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
176         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
177         void OnUserPostNick(User* user, const std::string &oldnick);
178         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
179         void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
180         void OnPreRehash(User* user, const std::string &parameter);
181         void OnRehash(User* user);
182         void OnOper(User* user, const std::string &opertype);
183         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
184         void OnAddLine(User *u, XLine *x);
185         void OnDelLine(User *u, XLine *x);
186         void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
187         ModResult OnStats(char statschar, User* user, string_list &results);
188         ModResult OnSetAway(User* user, const std::string &awaymsg);
189         void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
190         void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
191         void OnLoadModule(Module* mod);
192         void OnUnloadModule(Module* mod);
193         CullResult cull();
194         ~ModuleSpanningTree();
195         Version GetVersion();
196         void Prioritize();
197 };
198
199 #endif