]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/modules/server.h
Update my name and email address.
[user/henk/code/inspircd.git] / include / modules / server.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *
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.
9  *
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
13  * details.
14  *
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/>.
17  */
18
19
20 #pragma once
21
22 #ifdef __GNUC__
23 # pragma GCC diagnostic push
24 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
25 #endif
26
27 #include "event.h"
28
29 namespace ServerProtocol
30 {
31         class BroadcastEventListener;
32         class LinkEventListener;
33         class MessageEventListener;
34         class SyncEventListener;
35 }
36
37 class ServerProtocol::BroadcastEventListener
38         : public Events::ModuleEventListener
39 {
40  public:
41         BroadcastEventListener(Module* mod)
42                 : ModuleEventListener(mod, "event/server-broadcast")
43         {
44         }
45
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.
51          */
52         virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
53 };
54
55 class ServerProtocol::LinkEventListener
56         : public Events::ModuleEventListener
57 {
58  public:
59         LinkEventListener(Module* mod)
60                 : ModuleEventListener(mod, "event/server-link")
61         {
62         }
63
64         /** Fired when a server has linked to the network.
65          * @param server Server that recently linked.
66          */
67         virtual void OnServerLink(const Server* server) { }
68
69         /** Fired when a server has finished bursting.
70          * @param server Server that recently finished bursting.
71          */
72         virtual void OnServerBurst(const Server* server) { }
73
74         /** Fired when a server splits
75          * @param server Server that split
76          * @param error Whether the server split because of an error.
77          */
78         virtual void OnServerSplit(const Server* server, bool error) { OnServerSplit(server); }
79
80         /** Fired when a server splits
81          * @param server Server that split
82          */
83         DEPRECATED_METHOD(virtual void OnServerSplit(const Server* server)) { }
84 };
85
86 class ServerProtocol::MessageEventListener
87         : public Events::ModuleEventListener
88 {
89  public:
90         MessageEventListener(Module* mod)
91                 : ModuleEventListener(mod, "event/server-message")
92         {
93         }
94
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.
99          */
100         virtual void OnBuildMessage(User* source, const char* name, ClientProtocol::TagMap& tags) { }
101
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.
106          */
107         virtual void OnBuildMessage(Server* source, const char* name, ClientProtocol::TagMap& tags) { }
108 };
109
110 class ServerProtocol::SyncEventListener
111         : public Events::ModuleEventListener
112 {
113  public:
114         SyncEventListener(Module* mod)
115                 : ModuleEventListener(mod, "event/server-sync")
116         {
117         }
118
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.
123          */
124         virtual void OnSyncUser(User* user, ProtocolServer& server) { }
125
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.
130          */
131         virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
132
133         /** Allows modules to synchronize network metadata during a netburst.
134          * @param server The target of the burst.
135          */
136         virtual void OnSyncNetwork(ProtocolServer& server) { }
137 };
138
139 /** Compatibility struct for <3.3.0 modules. */
140 class ServerEventListener
141         : public ServerProtocol::BroadcastEventListener
142         , public ServerProtocol::LinkEventListener
143         , public ServerProtocol::SyncEventListener
144 {
145  public:
146         ServerEventListener(Module* mod)
147                 : ServerProtocol::BroadcastEventListener(mod)
148                 , ServerProtocol::LinkEventListener(mod)
149                 , ServerProtocol::SyncEventListener(mod)
150         {
151         }
152 };
153
154 #ifdef __GNUC__
155 # pragma GCC diagnostic pop
156 #endif
157