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/>.
23 # pragma GCC diagnostic push
24 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
29 namespace ServerProtocol
31 class BroadcastEventListener;
32 class LinkEventListener;
33 class MessageEventListener;
34 class SyncEventListener;
37 class ServerProtocol::BroadcastEventListener
38 : public Events::ModuleEventListener
41 BroadcastEventListener(Module* mod)
42 : ModuleEventListener(mod, "event/server-broadcast")
46 /** Fired when a channel message is being broadcast across the network.
47 * @param channel The channel which is having a message sent to it.
48 * @param server The server which might have a message broadcast to it.
49 * @return Either MOD_RES_ALLOW to always send the message to the server, MOD_RES_DENY to never
50 * send the message to the server or MOD_RES_PASSTHRU if no module handled the event.
52 virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
55 class ServerProtocol::LinkEventListener
56 : public Events::ModuleEventListener
59 LinkEventListener(Module* mod)
60 : ModuleEventListener(mod, "event/server-link")
64 /** Fired when a server has linked to the network.
65 * @param server Server that recently linked.
67 virtual void OnServerLink(const Server* server) { }
69 /** Fired when a server has finished bursting.
70 * @param server Server that recently finished bursting.
72 virtual void OnServerBurst(const Server* server) { }
74 /** Fired when a server splits
75 * @param server Server that split
76 * @param error Whether the server split because of an error.
78 virtual void OnServerSplit(const Server* server, bool error) { OnServerSplit(server); }
80 /** Fired when a server splits
81 * @param server Server that split
83 DEPRECATED_METHOD(virtual void OnServerSplit(const Server* server)) { }
86 class ServerProtocol::MessageEventListener
87 : public Events::ModuleEventListener
90 MessageEventListener(Module* mod)
91 : ModuleEventListener(mod, "event/server-message")
95 /** Fired when a server message is being sent by a user.
96 * @param source The user who sent the message.
97 * @param name The name of the command which was sent.
98 * @param tags The tags which will be sent with the message.
100 virtual void OnBuildMessage(User* source, const char* name, ClientProtocol::TagMap& tags) { }
102 /** Fired when a server message is being sent by a server.
103 * @param source The server who sent the message.
104 * @param name The name of the command which was sent.
105 * @param tags The tags which will be sent with the message.
107 virtual void OnBuildMessage(Server* source, const char* name, ClientProtocol::TagMap& tags) { }
110 class ServerProtocol::SyncEventListener
111 : public Events::ModuleEventListener
114 SyncEventListener(Module* mod)
115 : ModuleEventListener(mod, "event/server-sync")
119 /** Allows modules to synchronize user metadata during a netburst. This will
120 * be called for every user visible on your side of the burst.
121 * @param user The user being synchronized.
122 * @param server The target of the burst.
124 virtual void OnSyncUser(User* user, ProtocolServer& server) { }
126 /** Allows modules to synchronize channel metadata during a netburst. This will
127 * be called for every channel visible on your side of the burst.
128 * @param chan The channel being synchronized.
129 * @param server The target of the burst.
131 virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
133 /** Allows modules to synchronize network metadata during a netburst.
134 * @param server The target of the burst.
136 virtual void OnSyncNetwork(ProtocolServer& server) { }
139 /** Compatibility struct for <3.3.0 modules. */
140 class ServerEventListener
141 : public ServerProtocol::BroadcastEventListener
142 , public ServerProtocol::LinkEventListener
143 , public ServerProtocol::SyncEventListener
146 ServerEventListener(Module* mod)
147 : ServerProtocol::BroadcastEventListener(mod)
148 , ServerProtocol::LinkEventListener(mod)
149 , ServerProtocol::SyncEventListener(mod)
155 # pragma GCC diagnostic pop