]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Add ProtocolInterface::Introduce() to prevent confusion over event ordering, and...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 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         int line;
45         int NumServers;
46         unsigned int max_local;
47         unsigned int max_global;
48         cmd_rconnect* command_rconnect;
49         cmd_rsquit* command_rsquit;
50         SpanningTreeUtilities* Utils;
51
52  public:
53         CacheRefreshTimer *RefreshTimer;
54
55         /** Constructor
56          */
57         ModuleSpanningTree(InspIRCd* Me);
58
59         /** Shows /LINKS
60          */
61         void ShowLinks(TreeServer* Current, User* user, int hops);
62
63         /** Counts local servers
64          */
65         int CountLocalServs();
66
67         /** Counts local and remote servers
68          */
69         int CountServs();
70
71         /** Handle LINKS command
72          */
73         void HandleLinks(const std::vector<std::string>& parameters, User* user);
74
75         /** Handle LUSERS command
76          */
77         void HandleLusers(const std::vector<std::string>& parameters, User* user);
78
79         /** Show MAP output to a user (recursive)
80          */
81         void ShowMap(TreeServer* Current, User* user, int depth, char matrix[128][128], float &totusers, float &totservers);
82
83         /** Handle remote MOTD
84          */
85         int HandleMotd(const std::vector<std::string>& parameters, User* user);
86
87         /** Handle remote ADMIN
88          */
89         int HandleAdmin(const std::vector<std::string>& parameters, User* user);
90
91         /** Handle remote STATS
92          */
93         int HandleStats(const std::vector<std::string>& parameters, User* user);
94
95         /** Handle MAP command
96          */
97         int HandleMap(const std::vector<std::string>& parameters, User* user);
98
99         /** Handle SQUIT
100          */
101         int HandleSquit(const std::vector<std::string>& parameters, User* user);
102
103         /** Handle TIME
104          */
105         int HandleTime(const std::vector<std::string>& parameters, User* user);
106
107         /** Handle remote WHOIS
108          */
109         int HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
110
111         /** Handle remote MODULES
112          */
113         int HandleModules(const std::vector<std::string>& parameters, User* user);
114
115         /** Ping all local servers
116          */
117         void DoPingChecks(time_t curtime);
118
119         /** Connect a server locally
120          */
121         void ConnectServer(Link* x);
122
123         /** Check if any servers are due to be autoconnected
124          */
125         void AutoConnectServers(time_t curtime);
126
127         /** Handle remote VERSON
128          */
129         int HandleVersion(const std::vector<std::string>& parameters, User* user);
130
131         /** Handle CONNECT
132          */
133         int HandleConnect(const std::vector<std::string>& parameters, User* user);
134
135         /** Attempt to send a message to a user
136          */
137         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
138
139         /** Returns oper-specific MAP information
140          */
141         const std::string MapOperInfo(TreeServer* Current);
142
143         /** Display a time as a human readable string
144          */
145         std::string TimeToStr(time_t secs);
146
147         /**
148          ** *** MODULE EVENTS ***
149          **/
150
151         virtual int OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
152         virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
153         virtual void OnGetServerDescription(const std::string &servername,std::string &description);
154         virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
155         virtual void OnPostLocalTopicChange(User* user, Channel* chan, const std::string &topic);
156         virtual void OnWallops(User* user, const std::string &text);
157         virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
158         virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
159         virtual void OnBackgroundTimer(time_t curtime);
160         virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
161         virtual void OnChangeHost(User* user, const std::string &newhost);
162         virtual void OnChangeName(User* user, const std::string &gecos);
163         virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent);
164         virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
165         virtual void OnUserPostNick(User* user, const std::string &oldnick);
166         virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent);
167         virtual void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
168         virtual void OnRehash(User* user, const std::string &parameter);
169         virtual void OnOper(User* user, const std::string &opertype);
170         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
171         virtual void OnAddLine(User *u, XLine *x);
172         virtual void OnDelLine(User *u, XLine *x);
173         virtual void OnMode(User* user, void* dest, int target_type, const std::string &text);
174         virtual int OnStats(char statschar, User* user, string_list &results);
175         virtual int OnSetAway(User* user, const std::string &awaymsg);
176         virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);
177         virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);
178         virtual void OnEvent(Event* event);
179         virtual ~ModuleSpanningTree();
180         virtual Version GetVersion();
181         void Prioritize();
182 };
183
184 #endif