diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-02-12 16:35:02 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-02-12 16:35:02 +0100 |
commit | ae6967b8b30ebc956e3158127ecba5d01dc09204 (patch) | |
tree | b0940ea9cbd75acfdaa655b3a9975f67e3f8ae48 /include/modules/cap.h | |
parent | a7aa76f17ac22897e08558f0f78d891d3d4f7de6 (diff) | |
parent | 7918febc630d7d6f94fda1a918fe7b98c2d0e742 (diff) |
Merge branch 'master+crossmodevents'
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; } }; |