2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 namespace ServerProtocol
26 class BroadcastEventListener;
27 class LinkEventListener;
28 class MessageEventListener;
29 class SyncEventListener;
32 class ServerProtocol::BroadcastEventListener
33 : public Events::ModuleEventListener
36 BroadcastEventListener(Module* mod)
37 : ModuleEventListener(mod, "event/server-broadcast")
41 /** Fired when a channel message is being broadcast across the network.
42 * @param channel The channel which is having a message sent to it.
43 * @param server The server which might have a message broadcast to it.
44 * @return Either MOD_RES_ALLOW to always send the message to the server, MOD_RES_DENY to never
45 * send the message to the server or MOD_RES_PASSTHRU if no module handled the event.
47 virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
50 class ServerProtocol::LinkEventListener
51 : public Events::ModuleEventListener
54 LinkEventListener(Module* mod)
55 : ModuleEventListener(mod, "event/server-link")
59 /** Fired when a server finishes burst
60 * @param server Server that recently linked and finished burst
62 virtual void OnServerLink(const Server* server) { }
64 /** Fired when a server splits
65 * @param server Server that split
67 virtual void OnServerSplit(const Server* server) { }
70 class ServerProtocol::MessageEventListener
71 : public Events::ModuleEventListener
74 MessageEventListener(Module* mod)
75 : ModuleEventListener(mod, "event/server-message")
79 /** Fired when a server message is being sent by a user.
80 * @param source The user who sent the message.
81 * @param name The name of the command which was sent.
82 * @param tags The tags which will be sent with the message.
84 virtual void OnBuildMessage(User* source, const char* name, ClientProtocol::TagMap& tags) { }
86 /** Fired when a server message is being sent by a server.
87 * @param source The server who sent the message.
88 * @param name The name of the command which was sent.
89 * @param tags The tags which will be sent with the message.
91 virtual void OnBuildMessage(Server* source, const char* name, ClientProtocol::TagMap& tags) { }
94 class ServerProtocol::SyncEventListener
95 : public Events::ModuleEventListener
98 SyncEventListener(Module* mod)
99 : ModuleEventListener(mod, "event/server-sync")
103 /** Allows modules to synchronize user metadata during a netburst. This will
104 * be called for every user visible on your side of the burst.
105 * @param user The user being synchronized.
106 * @param server The target of the burst.
108 virtual void OnSyncUser(User* user, ProtocolServer& server) { }
110 /** Allows modules to synchronize channel metadata during a netburst. This will
111 * be called for every channel visible on your side of the burst.
112 * @param chan The channel being synchronized.
113 * @param server The target of the burst.
115 virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
117 /** Allows modules to synchronize network metadata during a netburst.
118 * @param server The target of the burst.
120 virtual void OnSyncNetwork(ProtocolServer& server) { }
123 /** Compatibility struct for <3.3.0 modules. */
124 class ServerEventListener
125 : public ServerProtocol::BroadcastEventListener
126 , public ServerProtocol::LinkEventListener
127 , public ServerProtocol::SyncEventListener
130 ServerEventListener(Module* mod)
131 : ServerProtocol::BroadcastEventListener(mod)
132 , ServerProtocol::LinkEventListener(mod)
133 , ServerProtocol::SyncEventListener(mod)