diff options
| author | 2022-12-27 17:57:54 +0000 | |
|---|---|---|
| committer | 2022-12-27 18:19:10 +0000 | |
| commit | 75de6e0d5c28d0a4f798a02be024e45f148bc52c (patch) | |
| tree | 1e4b18a50051b3950716f79c0818a0cf5e7a5bcb /src/modules | |
| parent | Merge branch 'insp3' into master. (diff) | |
Add the ListExtItem extension type.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_account.cpp | 45 | ||||
| -rw-r--r-- | src/modules/m_cloaking.cpp | 19 | ||||
| -rw-r--r-- | src/modules/m_dnsbl.cpp | 8 |
3 files changed, 8 insertions, 64 deletions
diff --git a/src/modules/m_account.cpp b/src/modules/m_account.cpp index 33ca64929..3e1795ed5 100644 --- a/src/modules/m_account.cpp +++ b/src/modules/m_account.cpp @@ -83,54 +83,13 @@ public: } }; - -class AccountNicksExtItem final - : public SimpleExtItem<Account::NickList> -{ -public: - AccountNicksExtItem(Module* mod) - : SimpleExtItem<Account::NickList>(mod, "accountnicks", ExtensionType::USER, true) - { - } - - void FromInternal(Extensible* container, const std::string& value) noexcept override - { - if (container->extype != this->extype) - return; - - auto list = new Account::NickList(); - irc::spacesepstream nickstream(value); - for (std::string nick; nickstream.GetToken(nick); ) - list->insert(nick); - - if (list->empty()) - { - // The remote sent an empty list of nicknames for some reason. - delete list; - Unset(container); - } - else - { - // The remote sent a non-zero list of nicks; set it. - Set(container, list); - } - } - - std::string ToInternal(const Extensible* container, void* item) const noexcept override - { - auto list = static_cast<Account::NickList*>(item); - return stdalgo::string::join(*list); - } -}; - - class AccountAPIImpl final : public Account::APIBase { private: AccountExtItemImpl accountext; StringExtItem accountidext; - AccountNicksExtItem accountnicksext; + ListExtItem<Account::NickList> accountnicksext; UserModeReference identifiedmode; public: @@ -138,7 +97,7 @@ public: : Account::APIBase(mod) , accountext(mod) , accountidext(mod, "accountid", ExtensionType::USER, true) - , accountnicksext(mod) + , accountnicksext(mod, "accountnicks", ExtensionType::USER, true) , identifiedmode(mod, "u_registered") { } diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 0cb209ea7..d70979972 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -84,34 +84,19 @@ struct CloakInfo final typedef std::vector<std::string> CloakList; -class CloakExtItem final - : public SimpleExtItem<CloakList> -{ -public: - CloakExtItem(Module* Creator) - : SimpleExtItem(Creator, "cloaks", ExtensionType::USER) - { - } - - std::string ToHuman(const Extensible* container, void* item) const noexcept override - { - return stdalgo::string::join(*static_cast<CloakList*>(item), ' '); - } -}; - class CloakUser final : public ModeHandler { public: bool active = false; - CloakExtItem ext; + ListExtItem<CloakList> ext; std::string debounce_uid; time_t debounce_ts = 0; int debounce_count = 0; CloakUser(Module* source) : ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER) - , ext(source) + , ext(source, "cloaks", ExtensionType::USER) { } diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 3dafbb486..bfa72d39b 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -163,7 +163,7 @@ public: } }; -typedef SimpleExtItem<std::vector<std::string> > MarkExtItem; +typedef ListExtItem<std::vector<std::string>> MarkExtItem; class DNSBLResolver final : public DNS::Request @@ -296,10 +296,10 @@ public: them->ChangeDisplayedHost(ConfEntry->markhost); } - std::vector<std::string>* marks = nameExt.Get(them); + MarkExtItem::List* marks = nameExt.Get(them); if (!marks) { - marks = new std::vector<std::string>(); + marks = new MarkExtItem::List(); nameExt.Set(them, marks); } marks->push_back(ConfEntry->name); @@ -475,7 +475,7 @@ public: if (!myclass->config->readString("dnsbl", dnsbl)) return MOD_RES_PASSTHRU; - std::vector<std::string>* match = nameExt.Get(user); + MarkExtItem::List* match = nameExt.Get(user); if (!match) { ServerInstance->Logs.Debug("CONNECTCLASS", "The %s connect class is not suitable as it requires a DNSBL mark", |
