]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Bump ABI version and protocol version. Note that this really means 1.1 and 1.2 are...
[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 "modules.h"
19 #include <stdarg.h>
20
21 /** If you make a change which breaks the protocol, increment this.
22  * If you  completely change the protocol, completely change the number.
23  *
24  * IMPORTANT: If you make changes, document your changes here, without fail:
25  * http://www.inspircd.org/wiki/List_of_protocol_changes_between_versions
26  *
27  * Failure to document your protocol changes will result in a painfully
28  * painful death by pain. You have been warned.
29  */
30 const long ProtocolVersion = 1200;
31
32 /** Forward declarations
33  */
34 class cmd_rconnect;
35 class cmd_rsquit;
36 class SpanningTreeUtilities;
37 class TimeSyncTimer;
38 class CacheRefreshTimer;
39 class TreeServer;
40 class Link;
41
42 /** This is the main class for the spanningtree module
43  */
44 class ModuleSpanningTree : public Module
45 {
46         int line;
47         int NumServers;
48         unsigned int max_local;
49         unsigned int max_global;
50         cmd_rconnect* command_rconnect;
51         cmd_rsquit* command_rsquit;
52         SpanningTreeUtilities* Utils;
53
54  public:
55         /** Timer for clock syncs
56          */
57         TimeSyncTimer *SyncTimer;
58
59         CacheRefreshTimer *RefreshTimer;
60
61         /** Constructor
62          */
63         ModuleSpanningTree(InspIRCd* Me);
64
65         /** Shows /LINKS
66          */
67         void ShowLinks(TreeServer* Current, userrec* user, int hops);
68
69         /** Counts local servers
70          */
71         int CountLocalServs();
72
73         /** Counts local and remote servers
74          */
75         int CountServs();
76
77         /** Handle LINKS command
78          */
79         void HandleLinks(const char** parameters, int pcnt, userrec* user);
80
81         /** Handle LUSERS command
82          */
83         void HandleLusers(const char** parameters, int pcnt, userrec* user);
84
85         /** Show MAP output to a user (recursive)
86          */
87         void ShowMap(TreeServer* Current, userrec* user, int depth, char matrix[128][128], float &totusers, float &totservers);
88
89         /** Handle remote MOTD
90          */
91         int HandleMotd(const char** parameters, int pcnt, userrec* user);
92
93         /** Handle remote ADMIN
94          */
95         int HandleAdmin(const char** parameters, int pcnt, userrec* user);
96
97         /** Handle remote STATS
98          */
99         int HandleStats(const char** parameters, int pcnt, userrec* user);
100
101         /** Handle MAP command
102          */
103         void HandleMap(const char** parameters, int pcnt, userrec* user);
104
105         /** Handle SQUIT
106          */
107         int HandleSquit(const char** parameters, int pcnt, userrec* user);
108
109         /** Handle TIME
110          */
111         int HandleTime(const char** parameters, int pcnt, userrec* user);
112
113         /** Handle remote WHOIS
114          */
115         int HandleRemoteWhois(const char** parameters, int pcnt, userrec* user);
116
117         /** Handle remote MODULES
118          */
119         int HandleModules(const char** parameters, int pcnt, userrec* user);
120
121         /** Ping all local servers
122          */
123         void DoPingChecks(time_t curtime);
124
125         /** Connect a server locally
126          */
127         void ConnectServer(Link* x);
128
129         /** Check if any servers are due to be autoconnected
130          */
131         void AutoConnectServers(time_t curtime);
132
133         /** Handle remote VERSON
134          */
135         int HandleVersion(const char** parameters, int pcnt, userrec* user);
136
137         /** Handle CONNECT
138          */
139         int HandleConnect(const char** parameters, int pcnt, userrec* user);
140
141         /** Send out time sync to all servers
142          */
143         void BroadcastTimeSync();
144
145         /** Attempt to send a message to a user
146          */
147         void RemoteMessage(userrec* user, const char* format, ...);
148
149         /** Returns oper-specific MAP information
150          */
151         const std::string MapOperInfo(TreeServer* Current);
152
153         /** Display a time as a human readable string
154          */
155         std::string TimeToStr(time_t secs);
156
157         /**
158          ** *** MODULE EVENTS ***
159          **/
160
161         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line);
162         virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line);
163         virtual void OnGetServerDescription(const std::string &servername,std::string &description);
164         virtual void OnUserInvite(userrec* source,userrec* dest,chanrec* channel);
165         virtual void OnPostLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic);
166         virtual void OnWallops(userrec* user, const std::string &text);
167         virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
168         virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
169         virtual void OnBackgroundTimer(time_t curtime);
170         virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent);
171         virtual void OnChangeHost(userrec* user, const std::string &newhost);
172         virtual void OnChangeName(userrec* user, const std::string &gecos);
173         virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent);
174         virtual void OnUserConnect(userrec* user);
175         virtual void OnUserQuit(userrec* user, const std::string &reason, const std::string &oper_message);
176         virtual void OnUserPostNick(userrec* user, const std::string &oldnick);
177         virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason, bool &silent);
178         virtual void OnRemoteKill(userrec* source, userrec* dest, const std::string &reason, const std::string &operreason);
179         virtual void OnRehash(userrec* user, const std::string &parameter);
180         virtual void OnOper(userrec* user, const std::string &opertype);
181         void OnLine(userrec* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
182         virtual void OnAddGLine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);
183         virtual void OnAddZLine(long duration, userrec* source, const std::string &reason, const std::string &ipmask);
184         virtual void OnAddQLine(long duration, userrec* source, const std::string &reason, const std::string &nickmask);
185         virtual void OnAddELine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);
186         virtual void OnDelGLine(userrec* source, const std::string &hostmask);
187         virtual void OnDelZLine(userrec* source, const std::string &ipmask);
188         virtual void OnDelQLine(userrec* source, const std::string &nickmask);
189         virtual void OnDelELine(userrec* source, const std::string &hostmask);
190         virtual void OnMode(userrec* user, void* dest, int target_type, const std::string &text);
191         virtual int OnStats(char statschar, userrec* user, string_list &results);
192         virtual void OnSetAway(userrec* user);
193         virtual void OnCancelAway(userrec* user);
194         virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);
195         virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);
196         virtual void OnEvent(Event* event);
197         virtual ~ModuleSpanningTree();
198         virtual Version GetVersion();
199         void Implements(char* List);
200         Priority Prioritize();
201 };
202
203 #endif