]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Remove special-case handling of SVSNICK, SVSJOIN, SVSPART; enables intelligent routing
[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 CommandSVSJoin;
37 class CommandSVSPart;
38 class CommandSVSNick;
39 class SpanningTreeUtilities;
40 class CacheRefreshTimer;
41 class TreeServer;
42 class Link;
43 class Autoconnect;
44
45 /** This is the main class for the spanningtree module
46  */
47 class ModuleSpanningTree : public Module
48 {
49         unsigned int max_local;
50         unsigned int max_global;
51         CommandRConnect* command_rconnect;
52         CommandRSQuit* command_rsquit;
53         CommandSVSJoin* command_svsjoin;
54         CommandSVSPart* command_svspart;
55         CommandSVSNick* command_svsnick;
56         SpanningTreeUtilities* Utils;
57
58         void RedoConfig(Module* mod);
59
60  public:
61         CacheRefreshTimer *RefreshTimer;
62         /** Set to true if inside a spanningtree call, to prevent sending
63          * xlines and other things back to their source
64          */
65         bool loopCall;
66
67         /** Constructor
68          */
69         ModuleSpanningTree();
70
71         /** Shows /LINKS
72          */
73         void ShowLinks(TreeServer* Current, User* user, int hops);
74
75         /** Counts local servers
76          */
77         int CountLocalServs();
78
79         /** Counts local and remote servers
80          */
81         int CountServs();
82
83         /** Handle LINKS command
84          */
85         void HandleLinks(const std::vector<std::string>& parameters, User* user);
86
87         /** Handle LUSERS command
88          */
89         void HandleLusers(const std::vector<std::string>& parameters, User* user);
90
91         /** Show MAP output to a user (recursive)
92          */
93         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
94
95         /** Handle remote MOTD
96          */
97         ModResult HandleMotd(const std::vector<std::string>& parameters, User* user);
98
99         /** Handle remote ADMIN
100          */
101         ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user);
102
103         /** Handle remote STATS
104          */
105         ModResult HandleStats(const std::vector<std::string>& parameters, User* user);
106
107         /** Handle MAP command
108          */
109         bool HandleMap(const std::vector<std::string>& parameters, User* user);
110
111         /** Handle SQUIT
112          */
113         ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
114
115         /** Handle TIME
116          */
117         ModResult HandleTime(const std::vector<std::string>& parameters, User* user);
118
119         /** Handle remote WHOIS
120          */
121         ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
122
123         /** Ping all local servers
124          */
125         void DoPingChecks(time_t curtime);
126
127         /** Connect a server locally
128          */
129         void ConnectServer(Link* x, Autoconnect* y = NULL);
130
131         /** Connect the next autoconnect server
132          */
133         void ConnectServer(Autoconnect* y, bool on_timer);
134
135         /** Check if any servers are due to be autoconnected
136          */
137         void AutoConnectServers(time_t curtime);
138
139         /** Check if any connecting servers should timeout
140          */
141         void DoConnectTimeout(time_t curtime);
142
143         /** Handle remote VERSON
144          */
145         ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
146
147         /** Handle CONNECT
148          */
149         ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
150
151         /** Attempt to send a message to a user
152          */
153         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
154
155         /** Returns oper-specific MAP information
156          */
157         const std::string MapOperInfo(TreeServer* Current);
158
159         /** Display a time as a human readable string
160          */
161         std::string TimeToStr(time_t secs);
162
163         /**
164          ** *** MODULE EVENTS ***
165          **/
166
167         ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
168         void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
169         void OnGetServerDescription(const std::string &servername,std::string &description);
170         void OnUserConnect(LocalUser* source);
171         void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
172         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
173         void OnWallops(User* user, const std::string &text);
174         void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
175         void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
176         void OnBackgroundTimer(time_t curtime);
177         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
178         void OnChangeHost(User* user, const std::string &newhost);
179         void OnChangeName(User* user, const std::string &gecos);
180         void OnChangeIdent(User* user, const std::string &ident);
181         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
182         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
183         void OnUserPostNick(User* user, const std::string &oldnick);
184         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
185         void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
186         void OnPreRehash(User* user, const std::string &parameter);
187         void OnRehash(User* user);
188         void OnOper(User* user, const std::string &opertype);
189         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
190         void OnAddLine(User *u, XLine *x);
191         void OnDelLine(User *u, XLine *x);
192         void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
193         ModResult OnStats(char statschar, User* user, string_list &results);
194         ModResult OnSetAway(User* user, const std::string &awaymsg);
195         void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
196         void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
197         void OnLoadModule(Module* mod);
198         void OnUnloadModule(Module* mod);
199         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
200         CullResult cull();
201         ~ModuleSpanningTree();
202         Version GetVersion();
203         void Prioritize();
204 };
205
206 #endif