]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/modules/server.h
Get rid of CommandBuilder::push_back.
[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 #include "event.h"
23
24 namespace ServerProtocol
25 {
26         class BroadcastEventListener;
27         class LinkEventListener;
28         class SyncEventListener;
29 }
30
31 class ServerProtocol::BroadcastEventListener
32         : public Events::ModuleEventListener
33 {
34  public:
35         BroadcastEventListener(Module* mod)
36                 : ModuleEventListener(mod, "event/server-broadcast")
37         {
38         }
39
40         /** Fired when a channel message is being broadcast across the network.
41          * @param channel The channel which is having a message sent to it.
42          * @param server The server which might have a message broadcast to it.
43          * @return Either MOD_RES_ALLOW to always send the message to the server, MOD_RES_DENY to never
44          *         send the message to the server or MOD_RES_PASSTHRU if no module handled the event.
45          */
46         virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
47 };
48
49 class ServerProtocol::LinkEventListener
50         : public Events::ModuleEventListener
51 {
52  public:
53         LinkEventListener(Module* mod)
54                 : ModuleEventListener(mod, "event/server-link")
55         {
56         }
57
58         /** Fired when a server finishes burst
59          * @param server Server that recently linked and finished burst
60          */
61         virtual void OnServerLink(const Server* server) { }
62
63          /** Fired when a server splits
64           * @param server Server that split
65           */
66         virtual void OnServerSplit(const Server* server) { }
67 };
68
69 class ServerProtocol::SyncEventListener
70         : public Events::ModuleEventListener
71 {
72  public:
73         SyncEventListener(Module* mod)
74                 : ModuleEventListener(mod, "event/server-sync")
75         {
76         }
77
78         /** Allows modules to synchronize user metadata during a netburst. This will
79          * be called for every user visible on your side of the burst.
80          * @param user The user being synchronized.
81          * @param server The target of the burst.
82          */
83         virtual void OnSyncUser(User* user, ProtocolServer& server) { }
84
85         /** Allows modules to synchronize channel metadata during a netburst. This will
86          * be called for every channel visible on your side of the burst.
87          * @param chan The channel being synchronized.
88          * @param server The target of the burst.
89          */
90         virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
91
92         /** Allows modules to synchronize network metadata during a netburst.
93          * @param server The target of the burst.
94          */
95         virtual void OnSyncNetwork(ProtocolServer& server) { }
96 };
97
98 /** Compatibility struct for <3.3.0 modules. */
99 class ServerEventListener
100         : public ServerProtocol::BroadcastEventListener
101         , public ServerProtocol::LinkEventListener
102         , public ServerProtocol::SyncEventListener
103 {
104  public:
105         ServerEventListener(Module* mod)
106                 : ServerProtocol::BroadcastEventListener(mod)
107                 , ServerProtocol::LinkEventListener(mod)
108                 , ServerProtocol::SyncEventListener(mod)
109         {
110         }
111 };