]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Fix ENCAP stripping, was incorrectly checking for " CHGHOST" and similar commands
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 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 SpanningTreeCommands;
35 class SpanningTreeUtilities;
36 class CacheRefreshTimer;
37 class TreeServer;
38 class Link;
39 class Autoconnect;
40
41 /** This is the main class for the spanningtree module
42  */
43 class ModuleSpanningTree : public Module
44 {
45         SpanningTreeCommands* commands;
46         void RedoConfig(Module* mod);
47
48  public:
49         SpanningTreeUtilities* Utils;
50
51         CacheRefreshTimer *RefreshTimer;
52         /** Set to true if inside a spanningtree call, to prevent sending
53          * xlines and other things back to their source
54          */
55         bool loopCall;
56
57         /** Constructor
58          */
59         ModuleSpanningTree();
60         void init();
61
62         /** Shows /LINKS
63          */
64         void ShowLinks(TreeServer* Current, User* user, int hops);
65
66         /** Counts local and remote servers
67          */
68         int CountServs();
69
70         /** Handle LINKS command
71          */
72         void HandleLinks(const std::vector<std::string>& parameters, User* user);
73
74         /** Show MAP output to a user (recursive)
75          */
76         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
77
78         /** Handle MAP command
79          */
80         bool HandleMap(const std::vector<std::string>& parameters, User* user);
81
82         /** Handle SQUIT
83          */
84         ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
85
86         /** Handle remote WHOIS
87          */
88         ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
89
90         /** Ping all local servers
91          */
92         void DoPingChecks(time_t curtime);
93
94         /** Connect a server locally
95          */
96         void ConnectServer(Link* x, Autoconnect* y = NULL);
97
98         /** Connect the next autoconnect server
99          */
100         void ConnectServer(Autoconnect* y, bool on_timer);
101
102         /** Check if any servers are due to be autoconnected
103          */
104         void AutoConnectServers(time_t curtime);
105
106         /** Check if any connecting servers should timeout
107          */
108         void DoConnectTimeout(time_t curtime);
109
110         /** Handle remote VERSON
111          */
112         ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
113
114         /** Handle CONNECT
115          */
116         ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
117
118         /** Attempt to send a message to a user
119          */
120         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
121
122         /** Returns oper-specific MAP information
123          */
124         const std::string MapOperInfo(TreeServer* Current);
125
126         /** Display a time as a human readable string
127          */
128         std::string TimeToStr(time_t secs);
129
130         /**
131          ** *** MODULE EVENTS ***
132          **/
133
134         ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line);
135         void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *user, CmdResult result, const std::string &original_line);
136         void OnGetServerDescription(const std::string &servername,std::string &description);
137         void OnUserConnect(LocalUser* source);
138         void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
139         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
140         void OnWallops(User* user, const std::string &text);
141         void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
142         void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
143         void OnBackgroundTimer(time_t curtime);
144         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
145         void OnChangeHost(User* user, const std::string &newhost);
146         void OnChangeName(User* user, const std::string &gecos);
147         void OnChangeIdent(User* user, const std::string &ident);
148         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
149         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
150         void OnUserPostNick(User* user, const std::string &oldnick);
151         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
152         void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
153         void OnPreRehash(User* user, const std::string &parameter);
154         void OnRehash(User* user);
155         void OnOper(User* user, const std::string &opertype);
156         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
157         void OnAddLine(User *u, XLine *x);
158         void OnDelLine(User *u, XLine *x);
159         void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
160         ModResult OnStats(char statschar, User* user, string_list &results);
161         ModResult OnSetAway(User* user, const std::string &awaymsg);
162         void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
163         void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
164         void OnLoadModule(Module* mod);
165         void OnUnloadModule(Module* mod);
166         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
167         CullResult cull();
168         ~ModuleSpanningTree();
169         Version GetVersion();
170         void Prioritize();
171 };
172
173 #endif