]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Add an event provider class for the event/messagetag event.
[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 "event.h"
28 #include "modules/dns.h"
29 #include "modules/ssl.h"
30 #include "modules/stats.h"
31 #include "modules/ctctags.h"
32 #include "modules/server.h"
33 #include "servercommand.h"
34 #include "commands.h"
35 #include "protocolinterface.h"
36 #include "tags.h"
37
38 /** An enumeration of all known protocol versions.
39  *
40  * If you introduce new protocol versions please document them here:
41  * https://docs.inspircd.org/spanningtree/changes
42  */
43 enum ProtocolVersion
44 {
45         /** The linking protocol version introduced in InspIRCd v2.0. */
46         PROTO_INSPIRCD_20 = 1202,
47
48         /** The linking protocol version introduced in InspIRCd v2.1 alpha 0. */
49         PROTO_INSPIRCD_21_A0 = 1203,
50
51         /** The linking protocol version introduced in InspIRCd v2.1 beta 2. */
52         PROTO_INSPIRCD_21_B2 = 1204,
53
54         /** The linking protocol version introduced in InspIRCd v3.0. */
55         PROTO_INSPIRCD_30 = 1205,
56
57         /** The oldest version of the protocol that we support. */
58         PROTO_OLDEST = PROTO_INSPIRCD_20,
59
60         /** The newest version of the protocol that we support. */
61         PROTO_NEWEST = PROTO_INSPIRCD_30
62 };
63
64 /** Forward declarations
65  */
66 class SpanningTreeUtilities;
67 class CacheRefreshTimer;
68 class TreeServer;
69 class Link;
70 class Autoconnect;
71
72 /** This is the main class for the spanningtree module
73  */
74 class ModuleSpanningTree
75         : public Module
76         , public Away::EventListener
77         , public Stats::EventListener
78         , public CTCTags::EventListener
79 {
80         /** Client to server commands, registered in the core
81          */
82         CommandRConnect rconnect;
83         CommandRSQuit rsquit;
84         CommandMap map;
85
86         /** Server to server only commands, not registered in the core
87          */
88         SpanningTreeCommands commands;
89
90         /** Next membership id assigned when a local user joins a channel
91          */
92         Membership::Id currmembid;
93
94         /** The specialized ProtocolInterface that is assigned to ServerInstance->PI on load
95          */
96         SpanningTreeProtocolInterface protocolinterface;
97
98         /** Event provider for our broadcast events. */
99         Events::ModuleEventProvider broadcasteventprov;
100
101         /** Event provider for our link events. */
102         Events::ModuleEventProvider linkeventprov;
103
104         /** Event provider for our message events. */
105         Events::ModuleEventProvider messageeventprov;
106
107         /** Event provider for our sync events. */
108         Events::ModuleEventProvider synceventprov;
109
110         /** API for accessing user SSL certificates. */
111         UserCertificateAPI sslapi;
112
113         /** Tag for marking services pseudoclients. */
114         ServiceTag servicetag;
115
116  public:
117         dynamic_reference<DNS::Manager> DNS;
118
119         /** Event provider for message tags. */
120         ClientProtocol::MessageTagEvent tagevprov;
121
122         ServerCommandManager CmdManager;
123
124         /** Set to true if inside a spanningtree call, to prevent sending
125          * xlines and other things back to their source
126          */
127         bool loopCall;
128
129         /** Constructor
130          */
131         ModuleSpanningTree();
132         void init() CXX11_OVERRIDE;
133
134         /** Shows /LINKS
135          */
136         void ShowLinks(TreeServer* Current, User* user, int hops);
137
138         /** Handle LINKS command
139          */
140         void HandleLinks(const CommandBase::Params& parameters, User* user);
141
142         /** Handle SQUIT
143          */
144         ModResult HandleSquit(const CommandBase::Params& parameters, User* user);
145
146         /** Handle remote WHOIS
147          */
148         ModResult HandleRemoteWhois(const CommandBase::Params& parameters, User* user);
149
150         /** Connect a server locally
151          */
152         void ConnectServer(Link* x, Autoconnect* y = NULL);
153
154         /** Connect the next autoconnect server
155          */
156         void ConnectServer(Autoconnect* y, bool on_timer);
157
158         /** Check if any servers are due to be autoconnected
159          */
160         void AutoConnectServers(time_t curtime);
161
162         /** Check if any connecting servers should timeout
163          */
164         void DoConnectTimeout(time_t curtime);
165
166         /** Handle remote VERSON
167          */
168         ModResult HandleVersion(const CommandBase::Params& parameters, User* user);
169
170         /** Handle CONNECT
171          */
172         ModResult HandleConnect(const CommandBase::Params& parameters, User* user);
173
174         /** Retrieves the event provider for broadcast events. */
175         const Events::ModuleEventProvider& GetBroadcastEventProvider() const { return broadcasteventprov; }
176
177         /** Retrieves the event provider for link events. */
178         const Events::ModuleEventProvider& GetLinkEventProvider() const { return linkeventprov; }
179
180         /** Retrieves the event provider for message events. */
181         const Events::ModuleEventProvider& GetMessageEventProvider() const { return messageeventprov; }
182
183         /** Retrieves the event provider for sync events. */
184         const Events::ModuleEventProvider& GetSyncEventProvider() const { return synceventprov; }
185
186         /**
187          ** *** MODULE EVENTS ***
188          **/
189
190         ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE;
191         void OnPostCommand(Command*, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, bool loop) CXX11_OVERRIDE;
192         void OnUserConnect(LocalUser* source) CXX11_OVERRIDE;
193         void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE;
194         ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE;
195         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE;
196         void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE;
197         void OnUserPostTagMessage(User* user, const MessageTarget& target, const CTCTags::TagMessageDetails& details) CXX11_OVERRIDE;
198         void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE;
199         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE;
200         void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE;
201         void OnChangeRealName(User* user, const std::string& real) CXX11_OVERRIDE;
202         void OnChangeIdent(User* user, const std::string &ident) CXX11_OVERRIDE;
203         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts) CXX11_OVERRIDE;
204         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE;
205         void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE;
206         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE;
207         void OnPreRehash(User* user, const std::string &parameter) CXX11_OVERRIDE;
208         void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE;
209         void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE;
210         void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE;
211         void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE;
212         ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE;
213         void OnUserAway(User* user) CXX11_OVERRIDE;
214         void OnUserBack(User* user) CXX11_OVERRIDE;
215         void OnLoadModule(Module* mod) CXX11_OVERRIDE;
216         void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
217         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
218         void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags) CXX11_OVERRIDE;
219         void OnShutdown(const std::string& reason) CXX11_OVERRIDE;
220         CullResult cull() CXX11_OVERRIDE;
221         ~ModuleSpanningTree();
222         Version GetVersion() CXX11_OVERRIDE;
223         void Prioritize() CXX11_OVERRIDE;
224 };