summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules/cap.h16
-rw-r--r--src/modules/m_cap.cpp9
-rw-r--r--src/modules/m_ircv3.cpp7
-rw-r--r--src/modules/m_namesx.cpp5
-rw-r--r--src/modules/m_sasl.cpp5
-rw-r--r--src/modules/m_starttls.cpp5
-rw-r--r--src/modules/m_uhnames.cpp5
7 files changed, 14 insertions, 38 deletions
diff --git a/include/modules/cap.h b/include/modules/cap.h
index fae7fff15..7aa60cd21 100644
--- a/include/modules/cap.h
+++ b/include/modules/cap.h
@@ -20,7 +20,9 @@
#pragma once
-class CapEvent : public Event
+#include "event.h"
+
+class CapEvent
{
public:
enum CapEventType
@@ -35,10 +37,10 @@ class CapEvent : public Event
std::vector<std::string> wanted;
std::vector<std::string> ack;
User* user;
- CapEvent(Module* sender, User* u, CapEventType capevtype) : Event(sender, "cap_request"), type(capevtype), user(u) {}
+ CapEvent(Module* sender, User* u, CapEventType capevtype) : type(capevtype), user(u) {}
};
-class GenericCap
+class GenericCap : public Events::ModuleEventListener
{
bool active;
@@ -46,17 +48,15 @@ class GenericCap
LocalIntExt ext;
const std::string cap;
GenericCap(Module* parent, const std::string& Cap)
- : active(true)
+ : Events::ModuleEventListener(parent, "event/cap")
+ , active(true)
, ext("cap_" + Cap, ExtensionItem::EXT_USER, parent)
, cap(Cap)
{
}
- void HandleEvent(Event& ev)
+ void OnCapEvent(CapEvent& ev) CXX11_OVERRIDE
{
- if (ev.id != "cap_request")
- return;
-
if (!active)
return;
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index db5d85f0f..2c2178a18 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -39,9 +39,12 @@ CAP END
*/
class CommandCAP : public Command
{
+ Events::ModuleEventProvider capevprov;
+
public:
LocalIntExt reghold;
CommandCAP (Module* mod) : Command(mod, "CAP", 1),
+ capevprov(mod, "event/cap"),
reghold("CAP_REGHOLD", ExtensionItem::EXT_USER, mod)
{
works_before_reg = true;
@@ -70,7 +73,7 @@ class CommandCAP : public Command
}
reghold.set(user, 1);
- Data.Send();
+ FOREACH_MOD_CUSTOM(capevprov, GenericCap, OnCapEvent, (Data));
if (Data.ack.size() > 0)
{
@@ -93,7 +96,7 @@ class CommandCAP : public Command
CapEvent Data(creator, user, subcommand == "LS" ? CapEvent::CAPEVENT_LS : CapEvent::CAPEVENT_LIST);
reghold.set(user, 1);
- Data.Send();
+ FOREACH_MOD_CUSTOM(capevprov, GenericCap, OnCapEvent, (Data));
std::string Result = irc::stringjoiner(Data.wanted);
user->WriteCommand("CAP", subcommand + " :" + Result);
@@ -103,7 +106,7 @@ class CommandCAP : public Command
CapEvent Data(creator, user, CapEvent::CAPEVENT_CLEAR);
reghold.set(user, 1);
- Data.Send();
+ FOREACH_MOD_CUSTOM(capevprov, GenericCap, OnCapEvent, (Data));
std::string Result = irc::stringjoiner(Data.ack);
user->WriteCommand("CAP", "ACK :" + Result);
diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp
index 861ccec14..caee0d329 100644
--- a/src/modules/m_ircv3.cpp
+++ b/src/modules/m_ircv3.cpp
@@ -65,13 +65,6 @@ class ModuleIRCv3 : public Module, public AccountEventListener
cap_extendedjoin.SetActive(conf->getBool("extendedjoin", true));
}
- void OnEvent(Event& ev) CXX11_OVERRIDE
- {
- cap_awaynotify.HandleEvent(ev);
- cap_extendedjoin.HandleEvent(ev);
- cap_accountnotify.HandleEvent(ev);
- }
-
void OnAccountChange(User* user, const std::string& newaccount) CXX11_OVERRIDE
{
// :nick!user@host ACCOUNT account
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp
index f211b01d8..c701f16bf 100644
--- a/src/modules/m_namesx.cpp
+++ b/src/modules/m_namesx.cpp
@@ -94,11 +94,6 @@ class ModuleNamesX : public Module
line.erase(pos, 1);
line.insert(pos, prefixes);
}
-
- void OnEvent(Event& ev) CXX11_OVERRIDE
- {
- cap.HandleEvent(ev);
- }
};
MODULE_INIT(ModuleNamesX)
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 0a2c840bd..ade998b4e 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -283,11 +283,6 @@ class ModuleSASL : public Module
{
return Version("Provides support for IRC Authentication Layer (aka: atheme SASL) via AUTHENTICATE.",VF_VENDOR);
}
-
- void OnEvent(Event &ev) CXX11_OVERRIDE
- {
- cap.HandleEvent(ev);
- }
};
MODULE_INIT(ModuleSASL)
diff --git a/src/modules/m_starttls.cpp b/src/modules/m_starttls.cpp
index d591eed55..b05302fa9 100644
--- a/src/modules/m_starttls.cpp
+++ b/src/modules/m_starttls.cpp
@@ -102,11 +102,6 @@ class ModuleStartTLS : public Module
ssl.SetProvider("ssl/" + newprovider);
}
- void OnEvent(Event& ev) CXX11_OVERRIDE
- {
- tls.HandleEvent(ev);
- }
-
void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
{
tokens["STARTTLS"];
diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp
index 0a171c4dc..90bac54f5 100644
--- a/src/modules/m_uhnames.cpp
+++ b/src/modules/m_uhnames.cpp
@@ -66,11 +66,6 @@ class ModuleUHNames : public Module
return MOD_RES_PASSTHRU;
}
-
- void OnEvent(Event& ev) CXX11_OVERRIDE
- {
- cap.HandleEvent(ev);
- }
};
MODULE_INIT(ModuleUHNames)