]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
fe5683246fb9ba3faada84fb69327475e6d128e3
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
6  *   Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
7  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
8  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
9  *
10  * This file is part of InspIRCd.  InspIRCd is free software: you can
11  * redistribute it and/or modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation, version 2.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23
24 #pragma once
25
26 #include "inspircd.h"
27 #include <stdarg.h>
28
29 /** If you make a change which breaks the protocol, increment this.
30  * If you  completely change the protocol, completely change the number.
31  *
32  * IMPORTANT: If you make changes, document your changes here, without fail:
33  * http://wiki.inspircd.org/List_of_protocol_changes_between_versions
34  *
35  * Failure to document your protocol changes will result in a painfully
36  * painful death by pain. You have been warned.
37  */
38 const long ProtocolVersion = 1202;
39 const long MinCompatProtocol = 1202;
40
41 /** Forward declarations
42  */
43 class SpanningTreeCommands;
44 class SpanningTreeUtilities;
45 class CacheRefreshTimer;
46 class TreeServer;
47 class Link;
48 class Autoconnect;
49
50 /** This is the main class for the spanningtree module
51  */
52 class ModuleSpanningTree : public Module
53 {
54         SpanningTreeCommands* commands;
55         void LocalMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list, const char* message_type);
56
57  public:
58         SpanningTreeUtilities* Utils;
59
60         CacheRefreshTimer *RefreshTimer;
61         /** Set to true if inside a spanningtree call, to prevent sending
62          * xlines and other things back to their source
63          */
64         bool loopCall;
65
66         /** Constructor
67          */
68         ModuleSpanningTree();
69         void init();
70
71         /** Shows /LINKS
72          */
73         void ShowLinks(TreeServer* Current, User* user, int hops);
74
75         /** Counts local and remote servers
76          */
77         int CountServs();
78
79         /** Handle LINKS command
80          */
81         void HandleLinks(const std::vector<std::string>& parameters, User* user);
82
83         /** Show MAP output to a user (recursive)
84          */
85         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
86
87         /** Handle MAP command
88          */
89         bool HandleMap(const std::vector<std::string>& parameters, User* user);
90
91         /** Handle SQUIT
92          */
93         ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
94
95         /** Handle remote WHOIS
96          */
97         ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
98
99         /** Ping all local servers
100          */
101         void DoPingChecks(time_t curtime);
102
103         /** Connect a server locally
104          */
105         void ConnectServer(Link* x, Autoconnect* y = NULL);
106
107         /** Connect the next autoconnect server
108          */
109         void ConnectServer(Autoconnect* y, bool on_timer);
110
111         /** Check if any servers are due to be autoconnected
112          */
113         void AutoConnectServers(time_t curtime);
114
115         /** Check if any connecting servers should timeout
116          */
117         void DoConnectTimeout(time_t curtime);
118
119         /** Handle remote VERSON
120          */
121         ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
122
123         /** Handle CONNECT
124          */
125         ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
126
127         /** Attempt to send a message to a user
128          */
129         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
130
131         /** Returns oper-specific MAP information
132          */
133         const std::string MapOperInfo(TreeServer* Current);
134
135         /** Display a time as a human readable string
136          */
137         std::string TimeToStr(time_t secs);
138
139         /**
140          ** *** MODULE EVENTS ***
141          **/
142
143         ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line);
144         void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *user, CmdResult result, const std::string &original_line);
145         void OnGetServerDescription(const std::string &servername,std::string &description);
146         void OnUserConnect(LocalUser* source);
147         void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
148         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
149         void OnWallops(User* user, const std::string &text);
150         void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
151         void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
152         void OnBackgroundTimer(time_t curtime);
153         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
154         void OnChangeHost(User* user, const std::string &newhost);
155         void OnChangeName(User* user, const std::string &gecos);
156         void OnChangeIdent(User* user, const std::string &ident);
157         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
158         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
159         void OnUserPostNick(User* user, const std::string &oldnick);
160         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
161         void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
162         void OnPreRehash(User* user, const std::string &parameter);
163         void OnRehash(User* user);
164         void OnOper(User* user, const std::string &opertype);
165         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
166         void OnAddLine(User *u, XLine *x);
167         void OnDelLine(User *u, XLine *x);
168         void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
169         ModResult OnStats(char statschar, User* user, string_list &results);
170         ModResult OnSetAway(User* user, const std::string &awaymsg);
171         void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
172         void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
173         void OnLoadModule(Module* mod);
174         void OnUnloadModule(Module* mod);
175         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
176         CullResult cull();
177         ~ModuleSpanningTree();
178         Version GetVersion();
179         void Prioritize();
180 };