diff options
| author | 2021-03-17 17:26:55 +0000 | |
|---|---|---|
| committer | 2021-03-17 21:14:07 +0000 | |
| commit | c1aa1d5a2b34b6a3339a157af3031b553fb8dd05 (patch) | |
| tree | 5b4090c8603f734ae8c6f230351afcd94190bb9d /src/modules/m_topiclock.cpp | |
| parent | Implement support for automatically syncing extension items. (diff) | |
Add a subclass of ExtensionItem exclusively for booleans.
Diffstat (limited to 'src/modules/m_topiclock.cpp')
| -rw-r--r-- | src/modules/m_topiclock.cpp | 56 |
1 files changed, 2 insertions, 54 deletions
diff --git a/src/modules/m_topiclock.cpp b/src/modules/m_topiclock.cpp index 01060d22c..07f121faa 100644 --- a/src/modules/m_topiclock.cpp +++ b/src/modules/m_topiclock.cpp @@ -74,69 +74,17 @@ class CommandSVSTOPIC : public Command } }; -// TODO: add a BoolExtItem to replace this. -class FlagExtItem : public ExtensionItem -{ - public: - FlagExtItem(const std::string& key, Module* owner) - : ExtensionItem(owner, key, ExtensionItem::EXT_CHANNEL) - { - } - - bool Get(const Extensible* container) const - { - return (GetRaw(container) != NULL); - } - - std::string ToHuman(const Extensible* container, void* item) const noexcept override - { - // Make the human version more readable. - return "true"; - } - - std::string ToNetwork(const Extensible* container, void* item) const noexcept override - { - return "1"; - } - - void FromNetwork(Extensible* container, const std::string& value) noexcept override - { - if (value == "1") - SetRaw(container, this); - else - UnsetRaw(container); - } - - void set(Extensible* container, bool value) - { - if (value) - SetRaw(container, this); - else - UnsetRaw(container); - } - - void Unset(Extensible* container) - { - UnsetRaw(container); - } - - void Delete(Extensible* container, void* item) override - { - // nothing to free - } -}; - class ModuleTopicLock : public Module { private: CommandSVSTOPIC cmd; - FlagExtItem topiclock; + BoolExtItem topiclock; public: ModuleTopicLock() : Module(VF_VENDOR | VF_COMMON, "Allows services to lock the channel topic so that it can not be changed.") , cmd(this) - , topiclock("topiclock", this) + , topiclock(this, "topiclock", ExtensionItem::EXT_CHANNEL) { } |
