summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-15 12:43:05 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-15 12:55:48 +0100
commit06e2961a86705d794fd5904000e44a7ae08004d9 (patch)
tree389d7deffa90b80f5cc468de1b70fda2145877c4 /src/modules
parent0b0443687d072bb1d4a4274828a72bbc9a171ede (diff)
Split ServerEventListener into {Broadcast,Link,Sync}EventListener.
There is no reason to have these events in one big handler and it causes unnecessary event hooks to be created by having them like this. The ServerEventListener class still exists for compatibility
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_chanhistory.cpp4
-rw-r--r--src/modules/m_filter.cpp7
-rw-r--r--src/modules/m_sasl.cpp5
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/modules/m_spanningtree/main.h20
-rw-r--r--src/modules/m_spanningtree/netburst.cpp6
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.cpp2
8 files changed, 36 insertions, 18 deletions
diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp
index dffda8e72..227fda3c2 100644
--- a/src/modules/m_chanhistory.cpp
+++ b/src/modules/m_chanhistory.cpp
@@ -112,7 +112,7 @@ class HistoryMode : public ParamMode<HistoryMode, SimpleExtItem<HistoryList> >
class ModuleChanHistory
: public Module
- , public ServerEventListener
+ , public ServerProtocol::BroadcastEventListener
{
HistoryMode m;
bool sendnotice;
@@ -125,7 +125,7 @@ class ModuleChanHistory
public:
ModuleChanHistory()
- : ServerEventListener(this)
+ : ServerProtocol::BroadcastEventListener(this)
, m(this)
, botmode(this, "bot")
, batchcap(this)
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index e7aab2eeb..6c2206993 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -173,7 +173,10 @@ class CommandFilter : public Command
}
};
-class ModuleFilter : public Module, public ServerEventListener, public Stats::EventListener
+class ModuleFilter
+ : public Module
+ , public ServerProtocol::SyncEventListener
+ , public Stats::EventListener
{
typedef insp::flat_set<std::string, irc::insensitive_swo> ExemptTargetSet;
@@ -332,7 +335,7 @@ bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags)
}
ModuleFilter::ModuleFilter()
- : ServerEventListener(this)
+ : ServerProtocol::SyncEventListener(this)
, Stats::EventListener(this)
, initing(true)
, filtcommand(this)
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 54bb8a44a..2647b63e1 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -37,7 +37,8 @@ enum
static std::string sasl_target;
-class ServerTracker : public ServerEventListener
+class ServerTracker
+ : public ServerProtocol::LinkEventListener
{
bool online;
@@ -65,7 +66,7 @@ class ServerTracker : public ServerEventListener
public:
ServerTracker(Module* mod)
- : ServerEventListener(mod)
+ : ServerProtocol::LinkEventListener(mod)
{
Reset();
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 1a51955d1..f8531cb01 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -45,7 +45,9 @@ ModuleSpanningTree::ModuleSpanningTree()
, map(this)
, commands(this)
, currmembid(0)
- , eventprov(this, "event/server")
+ , broadcasteventprov(this, "event/server-broadcast")
+ , linkeventprov(this, "event/server-link")
+ , synceventprov(this, "event/server-sync")
, sslapi(this)
, DNS(this, "DNS")
, tagevprov(this, "event/messagetag")
@@ -687,7 +689,7 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod)
{
TreeServer* server = i->second;
if (!server->IsRoot())
- FOREACH_MOD_CUSTOM(GetEventProvider(), ServerEventListener, OnServerSplit, (server));
+ FOREACH_MOD_CUSTOM(GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (server));
}
return;
}
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 9a9d4733d..1aeffbc72 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -93,9 +93,14 @@ class ModuleSpanningTree
*/
SpanningTreeProtocolInterface protocolinterface;
- /** Event provider for our events
- */
- Events::ModuleEventProvider eventprov;
+ /** Event provider for our broadcast events. */
+ Events::ModuleEventProvider broadcasteventprov;
+
+ /** Event provider for our link events. */
+ Events::ModuleEventProvider linkeventprov;
+
+ /** Event provider for our sync events. */
+ Events::ModuleEventProvider synceventprov;
/** API for accessing user SSL certificates. */
UserCertificateAPI sslapi;
@@ -158,7 +163,14 @@ class ModuleSpanningTree
*/
ModResult HandleConnect(const CommandBase::Params& parameters, User* user);
- const Events::ModuleEventProvider& GetEventProvider() const { return eventprov; }
+ /** Retrieves the event provider for broadcast events. */
+ const Events::ModuleEventProvider& GetBroadcastEventProvider() const { return broadcasteventprov; }
+
+ /** Retrieves the event provider for link events. */
+ const Events::ModuleEventProvider& GetLinkEventProvider() const { return linkeventprov; }
+
+ /** Retrieves the event provider for sync events. */
+ const Events::ModuleEventProvider& GetSyncEventProvider() const { return synceventprov; }
/**
** *** MODULE EVENTS ***
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index ed15591e9..ca4d1a472 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -123,7 +123,7 @@ void TreeSocket::DoBurst(TreeServer* s)
// Send all xlines
this->SendXLines();
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncNetwork, (bs.server));
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetSyncEventProvider(), ServerProtocol::SyncEventListener, OnSyncNetwork, (bs.server));
this->WriteLine(CmdBuilder("ENDBURST"));
ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \002"+ s->GetName()+"\002.");
@@ -265,7 +265,7 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs)
this->WriteLine(CommandMetadata::Builder(chan, item->name, value));
}
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncChannel, (chan, bs.server));
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetSyncEventProvider(), ServerProtocol::SyncEventListener, OnSyncChannel, (chan, bs.server));
}
void TreeSocket::SyncChannel(Channel* chan)
@@ -301,6 +301,6 @@ void TreeSocket::SendUsers(BurstState& bs)
this->WriteLine(CommandMetadata::Builder(user, item->name, value));
}
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncUser, (user, bs.server));
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetSyncEventProvider(), ServerProtocol::SyncEventListener, OnSyncUser, (user, bs.server));
}
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index bbe66ff83..ec1fb079d 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -117,7 +117,7 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s
this->AddHashEntry();
Parent->Children.push_back(this);
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnServerLink, (this));
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerLink, (this));
}
void TreeServer::BeginBurst(uint64_t startms)
@@ -207,7 +207,7 @@ void TreeServer::SQuitInternal(unsigned int& num_lost_servers)
RemoveHash();
if (!Utils->Creator->dying)
- FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnServerSplit, (this));
+ FOREACH_MOD_CUSTOM(Utils->Creator->GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (this));
}
unsigned int TreeServer::QuitUsers(const std::string& reason)
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index a18ec854d..5fbd16da0 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -171,7 +171,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet
for (TreeServer::ChildServers::const_iterator i = children.begin(); i != children.end(); ++i)
{
ModResult result;
- FIRST_MOD_RESULT_CUSTOM(Creator->GetEventProvider(), ServerEventListener, OnBroadcastMessage, result, (c, *i));
+ FIRST_MOD_RESULT_CUSTOM(Creator->GetBroadcastEventProvider(), ServerProtocol::BroadcastEventListener, OnBroadcastMessage, result, (c, *i));
if (result == MOD_RES_ALLOW)
list.insert((*i)->GetSocket());
}