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