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