]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
In the grand tradition of huge fucking commits:
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/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://www.inspircd.org/wiki/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 = 1200;
30
31 /** Forward declarations
32  */
33 class cmd_rconnect;
34 class cmd_rsquit;
35 class SpanningTreeUtilities;
36 class TimeSyncTimer;
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         int line;
46         int NumServers;
47         unsigned int max_local;
48         unsigned int max_global;
49         cmd_rconnect* command_rconnect;
50         cmd_rsquit* command_rsquit;
51         SpanningTreeUtilities* Utils;
52
53  public:
54         /** Timer for clock syncs
55          */
56         TimeSyncTimer *SyncTimer;
57
58         CacheRefreshTimer *RefreshTimer;
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 char** parameters, int pcnt, User* user);
79
80         /** Handle LUSERS command
81          */
82         void HandleLusers(const char** parameters, int pcnt, User* user);
83
84         /** Show MAP output to a user (recursive)
85          */
86         void ShowMap(TreeServer* Current, User* user, int depth, char matrix[128][128], float &totusers, float &totservers);
87
88         /** Handle remote MOTD
89          */
90         int HandleMotd(const char** parameters, int pcnt, User* user);
91
92         /** Handle remote ADMIN
93          */
94         int HandleAdmin(const char** parameters, int pcnt, User* user);
95
96         /** Handle remote STATS
97          */
98         int HandleStats(const char** parameters, int pcnt, User* user);
99
100         /** Handle MAP command
101          */
102         void HandleMap(const char** parameters, int pcnt, User* user);
103
104         /** Handle SQUIT
105          */
106         int HandleSquit(const char** parameters, int pcnt, User* user);
107
108         /** Handle TIME
109          */
110         int HandleTime(const char** parameters, int pcnt, User* user);
111
112         /** Handle remote WHOIS
113          */
114         int HandleRemoteWhois(const char** parameters, int pcnt, User* user);
115
116         /** Handle remote MODULES
117          */
118         int HandleModules(const char** parameters, int pcnt, 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         /** Handle remote VERSON
133          */
134         int HandleVersion(const char** parameters, int pcnt, User* user);
135
136         /** Handle CONNECT
137          */
138         int HandleConnect(const char** parameters, int pcnt, User* user);
139
140         /** Send out time sync to all servers
141          */
142         void BroadcastTimeSync();
143
144         /** Attempt to send a message to a user
145          */
146         void RemoteMessage(User* user, const char* format, ...);
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         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, User *user, bool validated, const std::string &original_line);
161         virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, User *user, CmdResult result, const std::string &original_line);
162         virtual void OnGetServerDescription(const std::string &servername,std::string &description);
163         virtual void OnUserInvite(User* source,User* dest,Channel* channel);
164         virtual void OnPostLocalTopicChange(User* user, Channel* chan, const std::string &topic);
165         virtual void OnWallops(User* user, const std::string &text);
166         virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
167         virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
168         virtual void OnBackgroundTimer(time_t curtime);
169         virtual void OnUserJoin(User* user, Channel* channel, bool &silent);
170         virtual void OnChangeHost(User* user, const std::string &newhost);
171         virtual void OnChangeName(User* user, const std::string &gecos);
172         virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent);
173         virtual void OnUserConnect(User* user);
174         virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
175         virtual void OnUserPostNick(User* user, const std::string &oldnick);
176         virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent);
177         virtual void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
178         virtual void OnRehash(User* user, const std::string &parameter);
179         virtual void OnOper(User* user, const std::string &opertype);
180         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
181         virtual void OnAddGLine(long duration, User* source, const std::string &reason, const std::string &hostmask);
182         virtual void OnAddZLine(long duration, User* source, const std::string &reason, const std::string &ipmask);
183         virtual void OnAddQLine(long duration, User* source, const std::string &reason, const std::string &nickmask);
184         virtual void OnAddELine(long duration, User* source, const std::string &reason, const std::string &hostmask);
185         virtual void OnDelGLine(User* source, const std::string &hostmask);
186         virtual void OnDelZLine(User* source, const std::string &ipmask);
187         virtual void OnDelQLine(User* source, const std::string &nickmask);
188         virtual void OnDelELine(User* source, const std::string &hostmask);
189         virtual void OnMode(User* user, void* dest, int target_type, const std::string &text);
190         virtual int OnStats(char statschar, User* user, string_list &results);
191         virtual void OnSetAway(User* user);
192         virtual void OnCancelAway(User* user);
193         virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);
194         virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);
195         virtual void OnEvent(Event* event);
196         virtual ~ModuleSpanningTree();
197         virtual Version GetVersion();
198         void Implements(char* List);
199         Priority Prioritize();
200 };
201
202 #endif