summaryrefslogtreecommitdiff
path: root/modules/nickserv
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-07-28 21:29:35 -0400
committerAdam <Adam@anope.org>2016-07-28 21:29:35 -0400
commit0e758a2ac23dc4a001e8e126cec14588da9a9769 (patch)
tree45df813323e023c5c89db7279426c4ad0943b4a9 /modules/nickserv
parenta3c8afae00c54d5b95c620248b51f90679d7d53f (diff)
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
Diffstat (limited to 'modules/nickserv')
-rw-r--r--modules/nickserv/access.cpp31
-rw-r--r--modules/nickserv/ajoin.cpp28
-rw-r--r--modules/nickserv/alist.cpp2
-rw-r--r--modules/nickserv/cert.cpp33
-rw-r--r--modules/nickserv/drop.cpp10
-rw-r--r--modules/nickserv/group.cpp44
-rw-r--r--modules/nickserv/identify.cpp6
-rw-r--r--modules/nickserv/info.cpp23
-rw-r--r--modules/nickserv/list.cpp7
-rw-r--r--modules/nickserv/logout.cpp3
-rw-r--r--modules/nickserv/main/account.cpp10
-rw-r--r--modules/nickserv/main/account.h4
-rw-r--r--modules/nickserv/main/accounttype.cpp13
-rw-r--r--modules/nickserv/main/identifyrequest.cpp11
-rw-r--r--modules/nickserv/main/identifyrequest.h1
-rw-r--r--modules/nickserv/main/mode.h5
-rw-r--r--modules/nickserv/main/modetype.h6
-rw-r--r--modules/nickserv/main/nick.cpp8
-rw-r--r--modules/nickserv/main/nick.h8
-rw-r--r--modules/nickserv/main/nickserv.cpp67
-rw-r--r--modules/nickserv/main/nicktype.cpp28
-rw-r--r--modules/nickserv/maxemail.cpp7
-rw-r--r--modules/nickserv/recover.cpp8
-rw-r--r--modules/nickserv/register.cpp45
-rw-r--r--modules/nickserv/resetpass.cpp3
-rw-r--r--modules/nickserv/set.cpp71
-rw-r--r--modules/nickserv/set_misc.cpp22
-rw-r--r--modules/nickserv/suspend.cpp57
-rw-r--r--modules/nickserv/update.cpp10
29 files changed, 309 insertions, 262 deletions
diff --git a/modules/nickserv/access.cpp b/modules/nickserv/access.cpp
index 0e405484c..f29b98904 100644
--- a/modules/nickserv/access.cpp
+++ b/modules/nickserv/access.cpp
@@ -15,6 +15,11 @@
class NickAccessImpl : public NickAccess
{
+ friend class NickAccessType;
+
+ NickServ::Account *account = nullptr;
+ Anope::string mask;
+
public:
NickAccessImpl(Serialize::TypeBase *type) : NickAccess(type) { }
NickAccessImpl(Serialize::TypeBase *type, Serialize::ID id) : NickAccess(type, id) { }
@@ -32,9 +37,9 @@ class NickAccessType : public Serialize::Type<NickAccessImpl>
Serialize::ObjectField<NickAccessImpl, NickServ::Account *> account;
Serialize::Field<NickAccessImpl, Anope::string> mask;
- NickAccessType(Module *creator) : Serialize::Type<NickAccessImpl>(creator, "NSAccess")
- , account(this, "account", true)
- , mask(this, "mask")
+ NickAccessType(Module *creator) : Serialize::Type<NickAccessImpl>(creator)
+ , account(this, "account", &NickAccessImpl::account, true)
+ , mask(this, "mask", &NickAccessImpl::mask)
{
}
};
@@ -76,11 +81,11 @@ class CommandNSAccess : public Command
return;
}
- std::vector<NickAccess *> access = nc->GetRefs<NickAccess *>(nsaccess);
+ std::vector<NickAccess *> access = nc->GetRefs<NickAccess *>();
- if (access.size() >= Config->GetModule(this->owner)->Get<unsigned>("accessmax", "32"))
+ if (access.size() >= Config->GetModule(this->GetOwner())->Get<unsigned>("accessmax", "32"))
{
- source.Reply(_("Sorry, the maximum of \002{0}\002 access entries has been reached."), Config->GetModule(this->owner)->Get<unsigned>("accessmax"));
+ source.Reply(_("Sorry, the maximum of \002{0}\002 access entries has been reached."), Config->GetModule(this->GetOwner())->Get<unsigned>("accessmax"));
return;
}
@@ -91,7 +96,7 @@ class CommandNSAccess : public Command
return;
}
- NickAccess *a = nsaccess.Create();
+ NickAccess *a = Serialize::New<NickAccess *>();
a->SetAccount(nc);
a->SetMask(mask);
@@ -113,7 +118,7 @@ class CommandNSAccess : public Command
return;
}
- for (NickAccess *a : nc->GetRefs<NickAccess *>(nsaccess))
+ for (NickAccess *a : nc->GetRefs<NickAccess *>())
if (a->GetMask().equals_ci(mask))
{
a->Delete();
@@ -128,7 +133,7 @@ class CommandNSAccess : public Command
void DoList(CommandSource &source, NickServ::Account *nc, const Anope::string &mask)
{
- std::vector<NickAccess *> access = nc->GetRefs<NickAccess *>(nsaccess);
+ std::vector<NickAccess *> access = nc->GetRefs<NickAccess *>();
if (access.empty())
{
source.Reply(_("The access list of \002{0}\002 is empty."), nc->GetDisplay());
@@ -236,6 +241,7 @@ class NSAccess : public Module
public:
NSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<NickServ::Event::NickRegister>(this)
, commandnsaccess(this)
, nick_type(this)
{
@@ -245,11 +251,12 @@ class NSAccess : public Module
{
if (u && Config->GetModule(this)->Get<bool>("addaccessonreg"))
{
- NickAccess *a = nsaccess.Create();
+ NickAccess *a = Serialize::New<NickAccess *>();
a->SetAccount(na->GetAccount());
a->SetMask(u->Mask());
- //XXX?
-// source.Reply(_("\002{0}\002 has been registered under your hostmask: \002{1}\002"), u_nick, na->GetAccount()->GetAccess(0));
+
+ u->SendMessage(Config->GetClient("NickServ"),
+ _("\002{0}\002 has been registered under your hostmask: \002{1}\002"), na->GetNick(), a->GetMask());
}
}
};
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<AutoJoinImpl>
Serialize::ObjectField<AutoJoinImpl, NickServ::Account *> owner;
Serialize::Field<AutoJoinImpl, Anope::string> channel, key;
- AutoJoinType(Module *me) : Serialize::Type<AutoJoinImpl>(me, "AutoJoin")
- , owner(this, "owner", true)
- , channel(this, "channel")
- , key(this, "key")
+ AutoJoinType(Module *me) : Serialize::Type<AutoJoinImpl>(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<AutoJoin *> channels = nc->GetRefs<AutoJoin *>(autojoin);
+ std::vector<AutoJoin *> channels = nc->GetRefs<AutoJoin *>();
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<AutoJoin *> channels = nc->GetRefs<AutoJoin *>(autojoin);
+ std::vector<AutoJoin *> channels = nc->GetRefs<AutoJoin *>();
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<unsigned>("ajoinmax"))
+ if (channels.size() >= Config->GetModule(this->GetOwner())->Get<unsigned>("ajoinmax"))
{
- source.Reply(_("Sorry, the maximum of \002{0}\002 auto join entries has been reached."), Config->GetModule(this->owner)->Get<unsigned>("ajoinmax"));
+ source.Reply(_("Sorry, the maximum of \002{0}\002 auto join entries has been reached."), Config->GetModule(this->GetOwner())->Get<unsigned>("ajoinmax"));
return;
}
@@ -143,7 +148,7 @@ class CommandNSAJoin : public Command
continue;
}
- AutoJoin *entry = autojoin.Create();
+ AutoJoin *entry = Serialize::New<AutoJoin *>();
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<AutoJoin *> channels = nc->GetRefs<AutoJoin *>(autojoin);
+ std::vector<AutoJoin *> channels = nc->GetRefs<AutoJoin *>();
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<Event::UserLogin>(this)
, commandnsajoin(this)
, ajtype(this)
{
@@ -297,7 +303,7 @@ class NSAJoin : public Module
if (!NickServ)
return;
- std::vector<AutoJoin *> channels = u->Account()->GetRefs<AutoJoin *>(autojoin);
+ std::vector<AutoJoin *> channels = u->Account()->GetRefs<AutoJoin *>();
if (channels.empty())
return;
diff --git a/modules/nickserv/alist.cpp b/modules/nickserv/alist.cpp
index e4aaff38b..f80af7cb1 100644
--- a/modules/nickserv/alist.cpp
+++ b/modules/nickserv/alist.cpp
@@ -47,7 +47,7 @@ class CommandNSAList : public Command
list.AddColumn(_("Number")).AddColumn(_("Channel")).AddColumn(_("Access")).AddColumn(_("Description"));
- std::vector<ChanServ::Channel *> chans = nc->GetRefs<ChanServ::Channel *>(ChanServ::channel);
+ std::vector<ChanServ::Channel *> chans = nc->GetRefs<ChanServ::Channel *>();
std::sort(chans.begin(), chans.end(), ChannelSort);
for (ChanServ::Channel *ci : chans)
{
diff --git a/modules/nickserv/cert.cpp b/modules/nickserv/cert.cpp
index 23487f305..6df85aacd 100644
--- a/modules/nickserv/cert.cpp
+++ b/modules/nickserv/cert.cpp
@@ -14,7 +14,6 @@
#include "modules/nickserv.h"
static Anope::hash_map<NickServ::Account *> certmap;
-static EventHandlers<Event::NickCertEvents> *events;
class CertServiceImpl : public CertService
{
@@ -31,7 +30,7 @@ class CertServiceImpl : public CertService
bool Matches(User *u, NickServ::Account *nc) override
{
- std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry);
+ std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>();
return !u->fingerprint.empty() && FindCert(cl, u->fingerprint);
}
@@ -46,6 +45,11 @@ class CertServiceImpl : public CertService
class NSCertEntryImpl : public NSCertEntry
{
+ friend class NSCertEntryType;
+
+ NickServ::Account *account = nullptr;
+ Anope::string cert;
+
public:
NSCertEntryImpl(Serialize::TypeBase *type) : NSCertEntry(type) { }
NSCertEntryImpl(Serialize::TypeBase *type, Serialize::ID id) : NSCertEntry(type, id) { }
@@ -95,9 +99,9 @@ class NSCertEntryType : public Serialize::Type<NSCertEntryImpl>
}
} mask;
- NSCertEntryType(Module *me) : Serialize::Type<NSCertEntryImpl>(me, "NSCertEntry")
- , nc(this, "nc", true)
- , mask(this, "mask")
+ NSCertEntryType(Module *me) : Serialize::Type<NSCertEntryImpl>(me)
+ , nc(this, "nc", &NSCertEntryImpl::account, true)
+ , mask(this, "mask", &NSCertEntryImpl::cert)
{
}
};
@@ -141,8 +145,8 @@ class CommandNSCert : public Command
void DoAdd(CommandSource &source, NickServ::Account *nc, Anope::string certfp)
{
- std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry);
- unsigned max = Config->GetModule(this->owner)->Get<unsigned>("max", "5");
+ std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>();
+ unsigned max = Config->GetModule(this->GetOwner())->Get<unsigned>("max", "5");
if (cl.size() >= max)
{
@@ -175,9 +179,11 @@ class CommandNSCert : public Command
return;
}
- NSCertEntry *e = certentry.Create();
+ NSCertEntry *e = Serialize::New<NSCertEntry *>();
e->SetAccount(nc);
e->SetCert(certfp);
+
+ // XXX fire events
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to ADD certificate fingerprint " << certfp << " to " << nc->GetDisplay();
source.Reply(_("\002{0}\002 added to the certificate list of \002{1}\002."), certfp, nc->GetDisplay());
@@ -185,7 +191,7 @@ class CommandNSCert : public Command
void DoDel(CommandSource &source, NickServ::Account *nc, Anope::string certfp)
{
- std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry);
+ std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>();
if (certfp.empty())
{
@@ -215,7 +221,7 @@ class CommandNSCert : public Command
void DoList(CommandSource &source, NickServ::Account *nc)
{
- std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry);
+ std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>();
if (cl.empty())
{
@@ -309,18 +315,15 @@ class NSCert : public Module
CommandNSCert commandnscert;
CertServiceImpl cs;
- EventHandlers<Event::NickCertEvents> onnickservevents;
-
public:
NSCert(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::Fingerprint>(this)
+ , EventHook<NickServ::Event::NickValidate>(this)
, commandnscert(this)
, cs(this)
- , onnickservevents(this)
{
if (!IRCD || !IRCD->CanCertFP)
throw ModuleException("Your IRCd does not support ssl client certificates");
-
- events = &onnickservevents;
}
void OnFingerprint(User *u) override
diff --git a/modules/nickserv/drop.cpp b/modules/nickserv/drop.cpp
index e1eba9a3c..e45f1e2ea 100644
--- a/modules/nickserv/drop.cpp
+++ b/modules/nickserv/drop.cpp
@@ -14,10 +14,8 @@
class CommandNSDrop : public Command
{
- EventHandlers<Event::NickDrop> &onnickdrop;
-
public:
- CommandNSDrop(Module *creator, EventHandlers<Event::NickDrop> &event) : Command(creator, "nickserv/drop", 1, 1), onnickdrop(event)
+ CommandNSDrop(Module *creator) : Command(creator, "nickserv/drop", 1, 1)
{
this->SetSyntax(_("\037nickname\037"));
this->SetDesc(_("Cancel the registration of a nickname"));
@@ -54,7 +52,7 @@ class CommandNSDrop : public Command
return;
}
- this->onnickdrop(&Event::NickDrop::OnNickDrop, source, na);
+ EventManager::Get()->Dispatch(&Event::NickDrop::OnNickDrop, source, na);
Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ") (email: " << (!na->GetAccount()->GetEmail().empty() ? na->GetAccount()->GetEmail() : "none") << ")";
na->Delete();
@@ -77,12 +75,10 @@ class CommandNSDrop : public Command
class NSDrop : public Module
{
CommandNSDrop commandnsdrop;
- EventHandlers<Event::NickDrop> onnickdrop;
public:
NSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
- , commandnsdrop(this, onnickdrop)
- , onnickdrop(this)
+ , commandnsdrop(this)
{
}
diff --git a/modules/nickserv/group.cpp b/modules/nickserv/group.cpp
index 3a50d0306..5c9fb326f 100644
--- a/modules/nickserv/group.cpp
+++ b/modules/nickserv/group.cpp
@@ -15,14 +15,13 @@
class NSGroupRequestListener : public NickServ::IdentifyRequestListener
{
- EventHandlers<Event::NickGroup> &onnickgroup;
CommandSource source;
Command *cmd;
Anope::string nick;
Reference<NickServ::Nick> target;
public:
- NSGroupRequestListener(EventHandlers<Event::NickGroup> &event, CommandSource &src, Command *c, const Anope::string &n, NickServ::Nick *targ) : onnickgroup(event), source(src), cmd(c), nick(n), target(targ) { }
+ NSGroupRequestListener(CommandSource &src, Command *c, const Anope::string &n, NickServ::Nick *targ) : source(src), cmd(c), nick(n), target(targ) { }
void OnSuccess(NickServ::IdentifyRequest *) override
{
@@ -34,11 +33,11 @@ class NSGroupRequestListener : public NickServ::IdentifyRequestListener
/* If the nick is already registered, drop it. */
if (na)
{
- Event::OnChangeCoreDisplay(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, na->GetAccount(), u->nick);
+ EventManager::Get()->Dispatch(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, na->GetAccount(), u->nick);
delete na;
}
- na = NickServ::nick.Create();
+ na = Serialize::New<NickServ::Nick *>();
na->SetNick(nick);
na->SetAccount(target->GetAccount());
na->SetLastUsermask(u->GetIdent() + "@" + u->GetDisplayedHost());
@@ -47,7 +46,7 @@ class NSGroupRequestListener : public NickServ::IdentifyRequestListener
na->SetTimeRegistered(Anope::CurTime);
u->Login(target->GetAccount());
- this->onnickgroup(&Event::NickGroup::OnNickGroup, u, target);
+ EventManager::Get()->Dispatch(&Event::NickGroup::OnNickGroup, u, target);
Log(LOG_COMMAND, source, cmd) << "to make " << nick << " join group of " << target->GetNick() << " (" << target->GetAccount()->GetDisplay() << ") (email: " << (!target->GetAccount()->GetEmail().empty() ? target->GetAccount()->GetEmail() : "none") << ")";
source.Reply(_("You are now in the group of \002{0}\002."), target->GetNick());
@@ -69,10 +68,10 @@ class NSGroupRequestListener : public NickServ::IdentifyRequestListener
class CommandNSGroup : public Command
{
- EventHandlers<Event::NickGroup> &onnickgroup;
-
+ ServiceReference<CertService> certservice;
+
public:
- CommandNSGroup(Module *creator, EventHandlers<Event::NickGroup> &event) : Command(creator, "nickserv/group", 0, 2), onnickgroup(event)
+ CommandNSGroup(Module *creator) : Command(creator, "nickserv/group", 0, 2)
{
this->SetDesc(_("Join a group"));
this->SetSyntax(_("\037[target]\037 \037[password]\037"));
@@ -115,7 +114,7 @@ class CommandNSGroup : public Command
}
if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks"))
- for (Oper *o : Serialize::GetObjects<Oper *>(operblock))
+ for (Oper *o : Serialize::GetObjects<Oper *>())
{
if (!u->HasMode("OPER") && u->nick.find_ci(o->GetName()) != Anope::string::npos)
{
@@ -127,7 +126,7 @@ class CommandNSGroup : public Command
NickServ::Nick *target, *na = NickServ::FindNick(u->nick);
const Anope::string &guestnick = Config->GetModule("nickserv")->Get<Anope::string>("guestnickprefix", "Guest");
time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay");
- unsigned maxaliases = Config->GetModule(this->owner)->Get<unsigned>("maxaliases");
+ unsigned maxaliases = Config->GetModule(this->GetOwner())->Get<unsigned>("maxaliases");
if (!(target = NickServ::FindNick(nick)))
{
source.Reply(_("\002{0}\002 isn't registered."), nick);
@@ -147,7 +146,7 @@ class CommandNSGroup : public Command
return;
}
- if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
+ if (na && Config->GetModule(this->GetOwner())->Get<bool>("nogroupchange"))
{
source.Reply(_("Your nick is already registered."));
return;
@@ -165,13 +164,13 @@ class CommandNSGroup : public Command
return;
}
- if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
+ if (na && Config->GetModule(this->GetOwner())->Get<bool>("nogroupchange"))
{
source.Reply(_("You are already registered."));
return;
}
- if (maxaliases && target->GetAccount()->GetRefs<NickServ::Nick *>(NickServ::nick).size() >= maxaliases && !target->GetAccount()->IsServicesOper())
+ if (maxaliases && target->GetAccount()->GetRefs<NickServ::Nick *>().size() >= maxaliases && !target->GetAccount()->IsServicesOper())
{
source.Reply(_("There are too many nicknames in your group."));
return;
@@ -194,13 +193,13 @@ class CommandNSGroup : public Command
if (ok == false && !pass.empty())
{
- NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSGroupRequestListener(onnickgroup, source, this, u->nick, target), owner, target->GetAccount()->GetDisplay(), pass);
- Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req);
+ NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSGroupRequestListener(source, this, u->nick, target), this->GetOwner(), target->GetAccount()->GetDisplay(), pass);
+ EventManager::Get()->Dispatch(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req);
req->Dispatch();
}
else
{
- NSGroupRequestListener req(onnickgroup, source, this, u->nick, target);
+ NSGroupRequestListener req(source, this, u->nick, target);
if (ok)
req.OnSuccess(nullptr);
@@ -238,7 +237,7 @@ class CommandNSUngroup : public Command
Anope::string nick = !params.empty() ? params[0] : "";
NickServ::Nick *na = NickServ::FindNick(!nick.empty() ? nick : u->nick);
- if (u->Account()->GetRefs<NickServ::Nick *>(NickServ::nick).size() == 1)
+ if (u->Account()->GetRefs<NickServ::Nick *>().size() == 1)
{
source.Reply(_("Your nickname is not grouped to anything, so you can't ungroup it."));
return;
@@ -260,9 +259,9 @@ class CommandNSUngroup : public Command
NickServ::Account *oldcore = na->GetAccount();
if (na->GetNick().equals_ci(oldcore->GetDisplay()))
- oldcore->SetDisplay(oldcore->GetRef<NickServ::Nick *>(NickServ::nick));
+ oldcore->SetDisplay(oldcore->GetRef<NickServ::Nick *>());
- NickServ::Account *nc = NickServ::account.Create();
+ NickServ::Account *nc = Serialize::New<NickServ::Account *>();
nc->SetDisplay(na->GetNick());
na->SetAccount(nc);
@@ -319,7 +318,7 @@ class CommandNSGList : public Command
list.AddColumn(_("Nick")).AddColumn(_("Expires"));
time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire", "21d"),
unconfirmed_expire = Config->GetModule("nickserv")->Get<time_t>("unconfirmedexpire", "1d");
- for (NickServ::Nick *na2 : nc->GetRefs<NickServ::Nick *>(NickServ::nick))
+ for (NickServ::Nick *na2 : nc->GetRefs<NickServ::Nick *>())
{
Anope::string expires;
if (na2->HasFieldS("NS_NO_EXPIRE"))
@@ -368,14 +367,11 @@ class NSGroup : public Module
CommandNSUngroup commandnsungroup;
CommandNSGList commandnsglist;
- EventHandlers<Event::NickGroup> onnickgroup;
-
public:
NSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
- , commandnsgroup(this, onnickgroup)
+ , commandnsgroup(this)
, commandnsungroup(this)
, commandnsglist(this)
- , onnickgroup(this)
{
if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership"))
throw ModuleException(modname + " can not be used with options:nonicknameownership enabled");
diff --git a/modules/nickserv/identify.cpp b/modules/nickserv/identify.cpp
index 122378d8a..a9b1f9284 100644
--- a/modules/nickserv/identify.cpp
+++ b/modules/nickserv/identify.cpp
@@ -89,15 +89,15 @@ class CommandNSIdentify : public Command
return;
}
- unsigned int maxlogins = Config->GetModule(this->owner)->Get<unsigned int>("maxlogins");
+ unsigned int maxlogins = Config->GetModule(this->GetOwner())->Get<unsigned int>("maxlogins");
if (na && maxlogins && na->GetAccount()->users.size() >= maxlogins)
{
source.Reply(_("Account \002{0}\002 has already reached the maximum number of simultaneous logins ({1})."), na->GetAccount()->GetDisplay(), maxlogins);
return;
}
- NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSIdentifyRequestListener(source, this), owner, na ? na->GetAccount()->GetDisplay() : nick, pass);
- Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, u, req);
+ NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSIdentifyRequestListener(source, this), this->GetOwner(), na ? na->GetAccount()->GetDisplay() : nick, pass);
+ EventManager::Get()->Dispatch(&Event::CheckAuthentication::OnCheckAuthentication, u, req);
req->Dispatch();
}
diff --git a/modules/nickserv/info.cpp b/modules/nickserv/info.cpp
index 0bc712ac9..02be72f2b 100644
--- a/modules/nickserv/info.cpp
+++ b/modules/nickserv/info.cpp
@@ -15,10 +15,8 @@
class CommandNSInfo : public Command
{
- EventHandlers<Event::NickInfo> &onnickinfo;
-
public:
- CommandNSInfo(Module *creator, EventHandlers<Event::NickInfo> &event) : Command(creator, "nickserv/info", 0, 2), onnickinfo(event)
+ CommandNSInfo(Module *creator) : Command(creator, "nickserv/info", 0, 2)
{
this->SetDesc(_("Displays information about a given nickname"));
this->SetSyntax(_("[\037nickname\037]"));
@@ -60,7 +58,7 @@ class CommandNSInfo : public Command
source.Reply(_("\002{0}\002 has not confirmed their account."), na->GetNick());
if (na->GetAccount()->IsServicesOper() && (show_hidden || !na->GetAccount()->HasFieldS("HIDE_STATUS")))
- source.Reply(_("\002{0}\002 is a Services Operator of type \002{0}\002."), na->GetNick(), na->GetAccount()->o->GetType()->GetName());
+ source.Reply(_("\002{0}\002 is a Services Operator of type \002{1}\002."), na->GetNick(), na->GetAccount()->o->GetType()->GetName());
InfoFormatter info(source.nc);
@@ -112,7 +110,7 @@ class CommandNSInfo : public Command
}
}
- this->onnickinfo(&Event::NickInfo::OnNickInfo, source, na, info, show_hidden);
+ EventManager::Get()->Dispatch(&Event::NickInfo::OnNickInfo, source, na, info, show_hidden);
std::vector<Anope::string> replies;
info.Process(replies);
@@ -161,7 +159,7 @@ class CommandNSSetHide : public Command
}
NickServ::Account *nc = na->GetAccount();
- EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param);
+ EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::SetNickOption::OnSetNickOption, source, this, nc, param);
if (MOD_RESULT == EVENT_STOP)
return;
@@ -259,20 +257,17 @@ class NSInfo : public Module
CommandNSSetHide commandnssethide;
CommandNSSASetHide commandnssasethide;
- EventHandlers<Event::NickInfo> onnickinfo;
-
Serialize::Field<NickServ::Account, bool> hide_email, hide_usermask, hide_status, hide_quit;
public:
NSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
- , commandnsinfo(this, onnickinfo)
+ , commandnsinfo(this)
, commandnssethide(this)
, commandnssasethide(this)
- , onnickinfo(this)
- , hide_email(this, NickServ::account, "HIDE_EMAIL")
- , hide_usermask(this, NickServ::account, "HIDE_MASK")
- , hide_status(this, NickServ::account, "HIDE_STATUS")
- , hide_quit(this, NickServ::account, "HIDE_QUIT")
+ , hide_email(this, "HIDE_EMAIL")
+ , hide_usermask(this, "HIDE_MASK")
+ , hide_status(this, "HIDE_STATUS")
+ , hide_quit(this, "HIDE_QUIT")
{
}
diff --git a/modules/nickserv/list.cpp b/modules/nickserv/list.cpp
index 53a3a9394..c6758d583 100644
--- a/modules/nickserv/list.cpp
+++ b/modules/nickserv/list.cpp
@@ -31,7 +31,7 @@ class CommandNSList : public Command
bool is_servadmin = source.HasCommand("nickserv/list");
int count = 0, from = 0, to = 0;
bool suspended, nsnoexpire, unconfirmed;
- unsigned listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax", "50");
+ unsigned listmax = Config->GetModule(this->GetOwner())->Get<unsigned>("listmax", "50");
suspended = nsnoexpire = unconfirmed = false;
@@ -200,7 +200,7 @@ class CommandNSSetPrivate : public Command
}
NickServ::Account *nc = na->GetAccount();
- EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param);
+ EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::SetNickOption::OnSetNickOption, source, this, nc, param);
if (MOD_RESULT == EVENT_STOP)
return;
@@ -270,10 +270,11 @@ class NSList : public Module
public:
NSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::NickInfo>(this)
, commandnslist(this)
, commandnssetprivate(this)
, commandnssasetprivate(this)
- , priv(this, NickServ::account, "NS_PRIVATE")
+ , priv(this, "NS_PRIVATE")
{
}
diff --git a/modules/nickserv/logout.cpp b/modules/nickserv/logout.cpp
index 9bcb543fc..2afc65124 100644
--- a/modules/nickserv/logout.cpp
+++ b/modules/nickserv/logout.cpp
@@ -46,6 +46,7 @@ class CommandNSLogout : public Command
return;
}
+#warning "revalidate"
#if 0
if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServ::service)
NickServ::service->Validate(u2);
@@ -64,7 +65,7 @@ class CommandNSLogout : public Command
u2->Logout();
/* Send out an event */
- Event::OnNickLogout(&Event::NickLogout::OnNickLogout, u2);
+ EventManager::Get()->Dispatch(&Event::NickLogout::OnNickLogout, u2);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/nickserv/main/account.cpp b/modules/nickserv/main/account.cpp
index d74154d97..bfde7f15b 100644
--- a/modules/nickserv/main/account.cpp
+++ b/modules/nickserv/main/account.cpp
@@ -22,7 +22,7 @@ AccountImpl::~AccountImpl()
void AccountImpl::Delete()
{
- Event::OnDelCore(&Event::DelCore::OnDelCore, this);
+ EventManager::Get()->Dispatch(&Event::DelCore::OnDelCore, this);
for (unsigned i = users.size(); i > 0; --i)
users[i - 1]->Logout();
@@ -72,7 +72,7 @@ void AccountImpl::SetLanguage(const Anope::string &lang)
MemoServ::MemoInfo *AccountImpl::GetMemos()
{
- return GetRef<MemoServ::MemoInfo *>(MemoServ::memoinfo);
+ return GetRef<MemoServ::MemoInfo *>();
}
void AccountImpl::SetDisplay(NickServ::Nick *na)
@@ -80,7 +80,7 @@ void AccountImpl::SetDisplay(NickServ::Nick *na)
if (na->GetAccount() != this || na-&