diff options
Diffstat (limited to 'include/modules/cap.h')
-rw-r--r-- | include/modules/cap.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/include/modules/cap.h b/include/modules/cap.h index cc1cb8d8c..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,23 +37,27 @@ 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; + public: LocalIntExt ext; const std::string cap; GenericCap(Module* parent, const std::string& Cap) - : ext("cap_" + Cap, ExtensionItem::EXT_USER, parent) + : 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") + if (!active) return; CapEvent *data = static_cast<CapEvent*>(&ev); @@ -87,4 +93,7 @@ class GenericCap ext.set(data->user, 0); } } + + void SetActive(bool newstate) { active = newstate; } + bool IsActive() const { return active; } }; |