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