From 0e758a2ac23dc4a001e8e126cec14588da9a9769 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 28 Jul 2016 21:29:35 -0400 Subject: Allow serializable fields to use storage in the respective objects. Split service management code nito a proper servicemanager. Make service references managed instead of lazy lookup. Also made events and serializable use service manager instead of their respective systems for management --- modules/nickserv/ajoin.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'modules/nickserv/ajoin.cpp') diff --git a/modules/nickserv/ajoin.cpp b/modules/nickserv/ajoin.cpp index 0b074a84a..fc5e9b198 100644 --- a/modules/nickserv/ajoin.cpp +++ b/modules/nickserv/ajoin.cpp @@ -14,6 +14,11 @@ class AutoJoinImpl : public AutoJoin { + friend class AutoJoinType; + + NickServ::Account *account = nullptr; + Anope::string channel, key; + public: AutoJoinImpl(Serialize::TypeBase *type) : AutoJoin(type) { } AutoJoinImpl(Serialize::TypeBase *type, Serialize::ID id) : AutoJoin(type, id) { } @@ -34,10 +39,10 @@ class AutoJoinType : public Serialize::Type Serialize::ObjectField owner; Serialize::Field channel, key; - AutoJoinType(Module *me) : Serialize::Type(me, "AutoJoin") - , owner(this, "owner", true) - , channel(this, "channel") - , key(this, "key") + AutoJoinType(Module *me) : Serialize::Type(me) + , owner(this, "owner", &AutoJoinImpl::account, true) + , channel(this, "channel", &AutoJoinImpl::channel) + , key(this, "key", &AutoJoinImpl::key) { } }; @@ -76,7 +81,7 @@ class CommandNSAJoin : public Command { void DoList(CommandSource &source, NickServ::Account *nc) { - std::vector channels = nc->GetRefs(autojoin); + std::vector channels = nc->GetRefs(); if (channels.empty()) { @@ -107,7 +112,7 @@ class CommandNSAJoin : public Command void DoAdd(CommandSource &source, NickServ::Account *nc, const Anope::string &chans, const Anope::string &keys) { - std::vector channels = nc->GetRefs(autojoin); + std::vector channels = nc->GetRefs(); Anope::string addedchans; Anope::string alreadyadded; @@ -123,9 +128,9 @@ class CommandNSAJoin : public Command if (channels[i]->GetChannel().equals_ci(chan)) break; - if (channels.size() >= Config->GetModule(this->owner)->Get("ajoinmax")) + if (channels.size() >= Config->GetModule(this->GetOwner())->Get("ajoinmax")) { - source.Reply(_("Sorry, the maximum of \002{0}\002 auto join entries has been reached."), Config->GetModule(this->owner)->Get("ajoinmax")); + source.Reply(_("Sorry, the maximum of \002{0}\002 auto join entries has been reached."), Config->GetModule(this->GetOwner())->Get("ajoinmax")); return; } @@ -143,7 +148,7 @@ class CommandNSAJoin : public Command continue; } - AutoJoin *entry = autojoin.Create(); + AutoJoin *entry = Serialize::New(); entry->SetOwner(nc); entry->SetChannel(chan); entry->SetKey(key); @@ -174,7 +179,7 @@ class CommandNSAJoin : public Command void DoDel(CommandSource &source, NickServ::Account *nc, const Anope::string &chans) { - std::vector channels = nc->GetRefs(autojoin); + std::vector channels = nc->GetRefs(); Anope::string delchans; Anope::string notfoundchans; commasepstream sep(chans); @@ -282,6 +287,7 @@ class NSAJoin : public Module public: NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook(this) , commandnsajoin(this) , ajtype(this) { @@ -297,7 +303,7 @@ class NSAJoin : public Module if (!NickServ) return; - std::vector channels = u->Account()->GetRefs(autojoin); + std::vector channels = u->Account()->GetRefs(); if (channels.empty()) return; -- cgit