2012-04-19 20:58:29 +02:00
|
|
|
/*
|
|
|
|
* InspIRCd -- Internet Relay Chat Daemon
|
2009-10-09 21:33:50 +00:00
|
|
|
*
|
2020-01-11 22:02:47 +00:00
|
|
|
* Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
|
|
|
|
* Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
|
|
|
|
* Copyright (C) 2012 Robby <robby@chatbelgie.be>
|
|
|
|
* Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
|
2012-04-19 20:58:29 +02:00
|
|
|
* Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
|
2009-10-09 21:33:50 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
2009-10-09 21:33:50 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-10-09 21:33:50 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-19 20:58:29 +02:00
|
|
|
|
2013-04-02 20:12:15 +01:00
|
|
|
#pragma once
|
2009-10-09 21:33:50 +00:00
|
|
|
|
2019-07-15 12:43:05 +01:00
|
|
|
namespace ServerProtocol
|
|
|
|
{
|
|
|
|
class BroadcastEventListener;
|
|
|
|
class LinkEventListener;
|
2019-07-19 14:12:13 +01:00
|
|
|
class MessageEventListener;
|
2019-07-15 12:43:05 +01:00
|
|
|
class SyncEventListener;
|
|
|
|
}
|
|
|
|
|
2022-06-26 15:20:06 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
// From ircu.
|
|
|
|
RPL_MAP = 15,
|
|
|
|
RPL_ENDMAP = 17,
|
|
|
|
|
|
|
|
// InspIRCd-specific.
|
|
|
|
RPL_MAPUSERS = 18,
|
|
|
|
};
|
|
|
|
|
2019-07-15 12:43:05 +01:00
|
|
|
class ServerProtocol::BroadcastEventListener
|
|
|
|
: public Events::ModuleEventListener
|
2009-10-09 21:33:50 +00:00
|
|
|
{
|
2022-01-25 13:59:42 +00:00
|
|
|
public:
|
2019-07-15 12:43:05 +01:00
|
|
|
BroadcastEventListener(Module* mod)
|
|
|
|
: ModuleEventListener(mod, "event/server-broadcast")
|
2009-10-09 21:33:50 +00:00
|
|
|
{
|
|
|
|
}
|
2015-02-11 17:23:08 +01:00
|
|
|
|
2018-09-29 16:19:26 +01:00
|
|
|
/** Fired when a channel message is being broadcast across the network.
|
|
|
|
* @param channel The channel which is having a message sent to it.
|
|
|
|
* @param server The server which might have a message broadcast to it.
|
|
|
|
* @return Either MOD_RES_ALLOW to always send the message to the server, MOD_RES_DENY to never
|
|
|
|
* send the message to the server or MOD_RES_PASSTHRU if no module handled the event.
|
|
|
|
*/
|
|
|
|
virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; }
|
2019-07-15 12:43:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class ServerProtocol::LinkEventListener
|
|
|
|
: public Events::ModuleEventListener
|
|
|
|
{
|
2022-01-25 13:59:42 +00:00
|
|
|
public:
|
2019-07-15 12:43:05 +01:00
|
|
|
LinkEventListener(Module* mod)
|
|
|
|
: ModuleEventListener(mod, "event/server-link")
|
|
|
|
{
|
|
|
|
}
|
2018-09-29 16:19:26 +01:00
|
|
|
|
2019-09-23 12:44:42 +01:00
|
|
|
/** Fired when a server has linked to the network.
|
|
|
|
* @param server Server that recently linked.
|
2015-02-11 17:23:08 +01:00
|
|
|
*/
|
2015-02-12 16:54:34 +01:00
|
|
|
virtual void OnServerLink(const Server* server) { }
|
2015-02-11 17:23:08 +01:00
|
|
|
|
2019-09-23 12:44:42 +01:00
|
|
|
/** Fired when a server has finished bursting.
|
|
|
|
* @param server Server that recently finished bursting.
|
|
|
|
*/
|
|
|
|
virtual void OnServerBurst(const Server* server) { }
|
|
|
|
|
2019-09-23 11:51:09 +01:00
|
|
|
/** Fired when a server splits
|
|
|
|
* @param server Server that split
|
|
|
|
* @param error Whether the server split because of an error.
|
|
|
|
*/
|
2019-11-13 15:24:45 +00:00
|
|
|
virtual void OnServerSplit(const Server* server, bool error) { }
|
2019-07-15 12:43:05 +01:00
|
|
|
};
|
|
|
|
|
2019-07-19 14:12:13 +01:00
|
|
|
class ServerProtocol::MessageEventListener
|
|
|
|
: public Events::ModuleEventListener
|
|
|
|
{
|
2022-01-25 13:59:42 +00:00
|
|
|
public:
|
2019-07-19 14:12:13 +01:00
|
|
|
MessageEventListener(Module* mod)
|
|
|
|
: ModuleEventListener(mod, "event/server-message")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Fired when a server message is being sent by a user.
|
|
|
|
* @param source The user who sent the message.
|
|
|
|
* @param name The name of the command which was sent.
|
|
|
|
* @param tags The tags which will be sent with the message.
|
|
|
|
*/
|
2020-11-10 23:14:21 +00:00
|
|
|
virtual void OnBuildUserMessage(User* source, const char* name, ClientProtocol::TagMap& tags) { }
|
2019-07-19 14:12:13 +01:00
|
|
|
|
|
|
|
/** Fired when a server message is being sent by a server.
|
|
|
|
* @param source The server who sent the message.
|
|
|
|
* @param name The name of the command which was sent.
|
|
|
|
* @param tags The tags which will be sent with the message.
|
|
|
|
*/
|
2020-11-10 23:14:21 +00:00
|
|
|
virtual void OnBuildServerMessage(Server* source, const char* name, ClientProtocol::TagMap& tags) { }
|
2019-07-19 14:12:13 +01:00
|
|
|
};
|
|
|
|
|
2019-07-15 12:43:05 +01:00
|
|
|
class ServerProtocol::SyncEventListener
|
|
|
|
: public Events::ModuleEventListener
|
|
|
|
{
|
2022-01-25 13:59:42 +00:00
|
|
|
public:
|
2019-07-15 12:43:05 +01:00
|
|
|
SyncEventListener(Module* mod)
|
|
|
|
: ModuleEventListener(mod, "event/server-sync")
|
|
|
|
{
|
|
|
|
}
|
2017-11-22 12:37:20 +00:00
|
|
|
|
|
|
|
/** Allows modules to synchronize user metadata during a netburst. This will
|
|
|
|
* be called for every user visible on your side of the burst.
|
|
|
|
* @param user The user being synchronized.
|
|
|
|
* @param server The target of the burst.
|
|
|
|
*/
|
|
|
|
virtual void OnSyncUser(User* user, ProtocolServer& server) { }
|
|
|
|
|
|
|
|
/** Allows modules to synchronize channel metadata during a netburst. This will
|
|
|
|
* be called for every channel visible on your side of the burst.
|
|
|
|
* @param chan The channel being synchronized.
|
|
|
|
* @param server The target of the burst.
|
|
|
|
*/
|
|
|
|
virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { }
|
|
|
|
|
|
|
|
/** Allows modules to synchronize network metadata during a netburst.
|
|
|
|
* @param server The target of the burst.
|
|
|
|
*/
|
|
|
|
virtual void OnSyncNetwork(ProtocolServer& server) { }
|
2009-10-09 21:33:50 +00:00
|
|
|
};
|