diff options
| author | Adam <Adam@anope.org> | 2014-05-28 12:07:29 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-05-28 12:07:54 -0400 |
| commit | f29e1cf383529a1a29f02b0669d973f5ee0b7a66 (patch) | |
| tree | 3c33db276dc9328235bbd572641521ed44458176 /modules | |
| parent | 1253c70e0682fa1490c99c3d2869049a0e3fa2e0 (diff) | |
Move most of the core pseudoclient logic to modules
Diffstat (limited to 'modules')
183 files changed, 2991 insertions, 1212 deletions
diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp index e7543d646..e9a6e062b 100644 --- a/modules/bs_autoassign.cpp +++ b/modules/bs_autoassign.cpp @@ -14,11 +14,11 @@ class BSAutoAssign : public Module { public: BSAutoAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) - , EventHook<Event::ChanRegistered>("OnChanRegistered") + , EventHook<Event::ChanRegistered>("OnChanRegistered") { } - void OnChanRegistered(ChannelInfo *ci) override + void OnChanRegistered(ChanServ::Channel *ci) override { const Anope::string &bot = Config->GetModule(this)->Get<const Anope::string>("bot"); if (bot.empty()) diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 90fb7ed56..fe7938fc8 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -32,7 +32,7 @@ class CommandBSAssign : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -46,7 +46,7 @@ class CommandBSAssign : public Command return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (ci->HasExt("BS_NOBOT") || (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration"))) { source.Reply(ACCESS_DENIED); @@ -100,14 +100,14 @@ class CommandBSUnassign : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (!source.HasPriv("botserv/administration") && !access.HasPriv("ASSIGN")) { source.Reply(ACCESS_DENIED); @@ -157,7 +157,7 @@ class CommandBSSetNoBot : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string &value = params[1]; if (Anope::ReadOnly) @@ -174,7 +174,7 @@ class CommandBSSetNoBot : public Command if (value.equals_ci("ON")) { - Log(LOG_ADMIN, source, this, ci) << "to enable nobot"; + Log(LOG_ADMIN, source, this, ci) << "to enable nobot"; ci->Extend<bool>("BS_NOBOT"); if (ci->bi) @@ -183,7 +183,7 @@ class CommandBSSetNoBot : public Command } else if (value.equals_ci("OFF")) { - Log(LOG_ADMIN, source, this, ci) << "to disable nobot"; + Log(LOG_ADMIN, source, this, ci) << "to disable nobot"; ci->Shrink<bool>("BS_NOBOT"); source.Reply(_("No-bot mode is now \002off\002 on channel %s."), ci->name.c_str()); @@ -230,7 +230,7 @@ class BSAssign : public Module if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = dynamic_cast<BotInfo *>(targ))) return; - AccessGroup access = c->ci->AccessFor(source); + ChanServ::AccessGroup access = c->ci->AccessFor(source); if (nobot.HasExt(c->ci) || (!access.HasPriv("ASSIGN") && !source->HasPriv("botserv/administration"))) { targ->SendMessage(bi, ACCESS_DENIED); @@ -253,7 +253,7 @@ class BSAssign : public Module targ->SendMessage(bi, _("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), c->name.c_str()); } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChanServ::Channel *ci, InfoFormatter &info) override { if (nobot.HasExt(ci)) info.AddOption(_("No bot")); diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 082dae0bd..b410aced2 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -31,11 +31,11 @@ struct BadWordImpl : BadWord, Serializable struct BadWordsImpl : BadWords { - Serialize::Reference<ChannelInfo> ci; + Serialize::Reference<ChanServ::Channel> ci; typedef std::vector<BadWordImpl *> list; Serialize::Checker<list> badwords; - BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { } + BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChanServ::Channel *>(obj)), badwords("BadWord") { } ~BadWordsImpl(); @@ -72,7 +72,7 @@ struct BadWordsImpl : BadWords { if (this->badwords->empty() || index >= this->badwords->size()) return; - + (*bwevents)(&Event::BadWordEvents::OnBadWordDel, ci, (*this->badwords)[index]); delete this->badwords->at(index); @@ -103,7 +103,7 @@ BadWordsImpl::~BadWordsImpl() BadWordImpl::~BadWordImpl() { - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci) { BadWordsImpl *badwords = ci->GetExt<BadWordsImpl>("badwords"); @@ -123,13 +123,13 @@ Serializable* BadWordImpl::Unserialize(Serializable *obj, Serialize::Data &data) data["ci"] >> sci; data["word"] >> sword; - ChannelInfo *ci = ChannelInfo::Find(sci); + ChanServ::Channel *ci = ChanServ::Find(sci); if (!ci) return NULL; unsigned int n; data["type"] >> n; - + BadWordImpl *bw; if (obj) bw = anope_dynamic_static_cast<BadWordImpl *>(obj); @@ -141,20 +141,20 @@ Serializable* BadWordImpl::Unserialize(Serializable *obj, Serialize::Data &data) BadWordsImpl *bws = ci->Require<BadWordsImpl>("badwords"); bws->badwords->push_back(bw); - + return bw; } class BadwordsDelCallback : public NumberList { CommandSource &source; - ChannelInfo *ci; + ChanServ::Channel *ci; BadWords *bw; Command *c; unsigned deleted; bool override; public: - BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false) + BadwordsDelCallback(CommandSource &_source, ChanServ::Channel *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false) { if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) this->override = true; @@ -185,7 +185,7 @@ class BadwordsDelCallback : public NumberList class CommandBSBadwords : public Command { private: - void DoList(CommandSource &source, ChannelInfo *ci, const Anope::string &word) + void DoList(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; @@ -259,7 +259,7 @@ class CommandBSBadwords : public Command } } - void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &word) + void DoAdd(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { size_t pos = word.rfind(' '); BadWordType bwtype = BW_ANY; @@ -308,7 +308,7 @@ class CommandBSBadwords : public Command source.Reply(_("\002%s\002 added to %s bad words list."), realword.c_str(), ci->name.c_str()); } - void DoDelete(CommandSource &source, ChannelInfo *ci, const Anope::string &word) + void DoDelete(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { BadWords *badwords = ci->GetExt<BadWords>("badwords"); @@ -354,7 +354,7 @@ class CommandBSBadwords : public Command badwords->Check(); } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR"; @@ -387,7 +387,7 @@ class CommandBSBadwords : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 9aa572f00..977d4b72f 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -73,7 +73,7 @@ class CommandBSBot : public Command * if so. You need to drop the nick manually before you can use * it as a bot nick from now on -GD */ - if (NickAlias::Find(nick)) + if (NickServ::FindNick(nick)) { source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return; @@ -176,7 +176,7 @@ class CommandBSBot : public Command * if so. You need to drop the nick manually before you can use * it as a bot nick from now on -GD */ - if (NickAlias::Find(nick)) + if (NickServ::FindNick(nick)) { source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return; @@ -210,10 +210,10 @@ class CommandBSBot : public Command { IRCD->SendClientIntroduction(bi); unsigned minusers = Config->GetBlock("botserv")->Get<unsigned>("minusers"); - const std::set<ChannelInfo *> &channels = bi->GetChannels(); - for (std::set<ChannelInfo *>::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) + const std::set<ChanServ::Channel *> &channels = bi->GetChannels(); + for (std::set<ChanServ::Channel *>::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) { - const ChannelInfo *ci = *it; + const ChanServ::Channel *ci = *it; if (ci->c && ci->c->users.size() >= minusers) bi->Join(ci->c); diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 38745c191..0311a9df2 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -24,7 +24,7 @@ class CommandBSSay : public Command { const Anope::string &text = params[1]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -84,7 +84,7 @@ class CommandBSAct : public Command { Anope::string message = params[1]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 49775a053..88ac15a48 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -20,18 +20,13 @@ class CommandBSInfo : public Command void send_bot_channels(std::vector<Anope::string> &buffers, const BotInfo *bi) { Anope::string buf; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + for (ChanServ::Channel *ci : bi->GetChannels()) { - const ChannelInfo *ci = it->second; - - if (ci->bi == bi) + buf += " " + ci->name + " "; + if (buf.length() > 300) { - buf += " " + ci->name + " "; - if (buf.length() > 300) - { - buffers.push_back(buf); - buf.clear(); - } + buffers.push_back(buf); + buf.clear(); } } if (!buf.empty()) @@ -51,7 +46,7 @@ class CommandBSInfo : public Command const Anope::string &query = params[0]; BotInfo *bi = BotInfo::Find(query, true); - ChannelInfo *ci = ChannelInfo::Find(query); + ChanServ::Channel *ci = ChanServ::Find(query); InfoFormatter info(source.nc); if (bi) diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 3a4d78c93..7ffd9d353 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -28,15 +28,15 @@ struct KickerDataImpl : KickerData capsmin = capspercent = 0; floodlines = floodsecs = 0; repeattimes = 0; - + dontkickops = dontkickvoices = false; } - void Check(ChannelInfo *ci) override + void Check(ChanServ::Channel *ci) override { if (amsgs || badwords || bolds || caps || colors || flood || italics || repeat || reverses || underlines) return; - + ci->Shrink<KickerData>("kickerdata"); } @@ -46,10 +46,10 @@ struct KickerDataImpl : KickerData void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { - if (s->GetSerializableType()->GetName() != "ChannelInfo") + if (s->GetSerializableType()->GetName() != "ChanServ::Channel") return; - const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(e); + const ChanServ::Channel *ci = anope_dynamic_static_cast<const ChanServ::Channel *>(e); KickerData *kd = this->Get(ci); if (kd == NULL) return; @@ -76,10 +76,10 @@ struct KickerDataImpl : KickerData void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { - if (s->GetSerializableType()->GetName() != "ChannelInfo") + if (s->GetSerializableType()->GetName() != "ChanServ::Channel") return; - ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(e); + ChanServ::Channel *ci = anope_dynamic_static_cast<ChanServ::Channel *>(e); KickerData *kd = ci->Require<KickerData>("kickerdata"); data["kickerdata:amsgs"] >> kd->amsgs; @@ -173,12 +173,12 @@ class CommandBSKickBase : public Command virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0; protected: - bool CheckArguments(CommandSource &source, const std::vector<Anope::string> ¶ms, ChannelInfo* &ci) + bool CheckArguments(CommandSource &source, const std::vector<Anope::string> ¶ms, ChanServ::Channel* &ci) { const Anope::string &chan = params[0]; const Anope::string &option = params[1]; - ci = ChannelInfo::Find(chan); + ci = ChanServ::Find(chan); if (Anope::ReadOnly) source.Reply(_("Sorry, kicker configuration is temporarily disabled.")); @@ -198,7 +198,7 @@ class CommandBSKickBase : public Command return false; } - void Process(CommandSource &source, ChannelInfo *ci, const Anope::string ¶m, const Anope::string &ttb, size_t ttb_idx, const Anope::string &optname, KickerData *kd, bool &val) + void Process(CommandSource &source, ChanServ::Channel *ci, const Anope::string ¶m, const Anope::string &ttb, size_t ttb_idx, const Anope::string &optname, KickerData *kd, bool &val) { if (param.equals_ci("ON")) { @@ -257,7 +257,7 @@ class CommandBSKickAMSG : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); @@ -293,14 +293,14 @@ class CommandBSKickBadwords : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_BADWORDS, "badwords", kd, kd->badwords); kd->Check(ci); } - + } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -332,7 +332,7 @@ class CommandBSKickBolds : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); @@ -366,7 +366,7 @@ class CommandBSKickCaps : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (!CheckArguments(source, params, ci)) return; @@ -462,7 +462,7 @@ class CommandBSKickColors : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); @@ -496,7 +496,7 @@ class CommandBSKickFlood : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (!CheckArguments(source, params, ci)) return; @@ -594,7 +594,7 @@ class CommandBSKickItalics : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); @@ -628,7 +628,7 @@ class CommandBSKickRepeat : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (!CheckArguments(source, params, ci)) return; @@ -716,7 +716,7 @@ class CommandBSKickReverses : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); @@ -750,7 +750,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci; + ChanServ::Channel *ci; if (CheckArguments(source, params, ci)) { KickerData *kd = ci->Require<KickerData>("kickerdata"); @@ -784,14 +784,14 @@ class CommandBSSetDontKickOps : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); @@ -808,7 +808,7 @@ class CommandBSSetDontKickOps : public Command if (params[1].equals_ci("ON")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickops"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickops"; kd->dontkickops = true; source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str()); @@ -816,7 +816,7 @@ class CommandBSSetDontKickOps : public Command else if (params[1].equals_ci("OFF")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickops"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickops"; kd->dontkickops = false; source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str()); @@ -849,14 +849,14 @@ class CommandBSSetDontKickVoices : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); @@ -873,7 +873,7 @@ class CommandBSSetDontKickVoices : public Command if (params[1].equals_ci("ON")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickvoices"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickvoices"; kd->dontkickvoices = true; source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str()); @@ -881,7 +881,7 @@ class CommandBSSetDontKickVoices : public Command else if (params[1].equals_ci("OFF")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickvoices"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickvoices"; kd->dontkickvoices = false; source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str()); @@ -1041,7 +1041,7 @@ class BSKick : public Module return ud; } - void check_ban(ChannelInfo *ci, User *u, KickerData *kd, int ttbtype) + void check_ban(ChanServ::Channel *ci, User *u, KickerData *kd, int ttbtype) { /* Don't ban ulines or protected users */ if (u->IsProtected()) @@ -1065,7 +1065,7 @@ class BSKick : public Module } } - void bot_kick(ChannelInfo *ci, User *u, const char *message, ...) + void bot_kick(ChanServ::Channel *ci, User *u, const char *message, ...) { va_list args; char buf[1024]; @@ -1112,7 +1112,7 @@ class BSKick : public Module } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChanServ::Channel *ci, InfoFormatter &info) override { if (!ci) return; @@ -1237,7 +1237,7 @@ class BSKick : public Module * But FIRST we check whether the user is protected in any * way. */ - ChannelInfo *ci = c->ci; + ChanServ::Channel *ci = c->ci; if (ci == NULL) return; KickerData *kd = kickerdata.Get(ci); @@ -1370,7 +1370,7 @@ class BSKick : public Module else { Anope::string wordbuf = " " + bw->word + " "; - + if ((casesensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 68aaf8d47..9c92e462c 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -85,14 +85,14 @@ class CommandBSSetBanExpire : public Command const Anope::string &chan = params[0]; const Anope::string &arg = params[1]; - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); @@ -208,7 +208,7 @@ class BSSet : public Module { } - void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) override + void OnBotBan(User *u, ChanServ::Channel *ci, const Anope::string &mask) override { if (!ci->banexpire) return; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 3bfbde97d..83d00f6ae 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -10,29 +10,30 @@ */ #include "module.h" +#include "modules/chanserv.h" #include "modules/cs_access.h" static std::map<Anope::string, int16_t, ci::less> defaultLevels; -static inline void reset_levels(ChannelInfo *ci) +static inline void reset_levels(ChanServ::Channel *ci) { ci->ClearLevels(); for (std::map<Anope::string, int16_t, ci::less>::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it) ci->SetLevel(it->first, it->second); } -class AccessChanAccess : public ChanAccess +class AccessChanAccess : public ChanServ::ChanAccess { public: int level; - AccessChanAccess(AccessProvider *p) : ChanAccess(p), level(0) + AccessChanAccess(ChanServ::AccessProvider *p) : ChanAccess(p), level(0) { } bool HasPriv(const Anope::string &name) const override { - return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name); + return this->ci->GetLevel(name) != ChanServ::ACCESS_INVALID && this->level >= this->ci->GetLevel(name); } Anope::string AccessSerialize() const @@ -51,15 +52,15 @@ class AccessChanAccess : public ChanAccess } } - bool operator>(const ChanAccess &other) const override + bool operator>(const ChanServ::ChanAccess &other) const override { if (this->provider != other.provider) - return ChanAccess::operator>(other); + return ChanServ::ChanAccess::operator>(other); else return this->level > anope_dynamic_static_cast<const AccessChanAccess *>(&other)->level; } - bool operator<(const ChanAccess &other) const override + bool operator<(const ChanServ::ChanAccess &other) const override { if (this->provider != other.provider) return ChanAccess::operator<(other); @@ -68,17 +69,17 @@ class AccessChanAccess : public ChanAccess } }; -class AccessAccessProvider : public AccessProvider +class AccessAccessProvider : public ChanServ::AccessProvider { public: static AccessAccessProvider *me; - AccessAccessProvider(Module *o) : AccessProvider(o, "access/access") + AccessAccessProvider(Module *o) : ChanServ::AccessProvider(o, "access/access") { me = this; } - ChanAccess *Create() override + ChanServ::ChanAccess *Create() override { return new AccessChanAccess(this); } @@ -87,11 +88,11 @@ AccessAccessProvider* AccessAccessProvider::me; class CommandCSAccess : public Command { - void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoAdd(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params[2]; - Privilege *p = NULL; - int level = ACCESS_INVALID; + ChanServ::Privilege *p = NULL; + int level = ChanServ::ACCESS_INVALID; try { @@ -99,7 +100,7 @@ class CommandCSAccess : public Command } catch (const ConvertException &) { - p = PrivilegeManager::FindPrivilege(params[3]); + p = ChanServ::service ? ChanServ::service->FindPrivilege(params[3]) : nullptr; if (p != NULL && defaultLevels[p->name]) level = defaultLevels[p->name]; } @@ -109,14 +110,14 @@ class CommandCSAccess : public Command source.Reply(_("Access level must be non-zero.")); return; } - else if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) + else if (level <= ChanServ::ACCESS_INVALID || level >= ChanServ::ACCESS_FOUNDER) { - source.Reply(CHAN_ACCESS_LEVEL_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); + source.Reply(CHAN_ACCESS_LEVEL_RANGE, ChanServ::ACCESS_INVALID + 1, ChanServ::ACCESS_FOUNDER - 1); return; } - AccessGroup u_access = source.AccessFor(ci); - const ChanAccess *highest = u_access.Highest(); + ChanServ::AccessGroup u_access = source.AccessFor(ci); + const ChanServ::ChanAccess *highest = u_access.Highest(); AccessChanAccess tmp_access(AccessAccessProvider::me); tmp_access.ci = ci; @@ -143,7 +144,7 @@ class CommandCSAccess : public Command return; } - ChannelInfo *targ_ci = ChannelInfo::Find(mask); + ChanServ::Channel *targ_ci = ChanServ::Find(mask); if (targ_ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, mask.c_str()); @@ -159,7 +160,7 @@ class CommandCSAccess : public Command } else { - const NickAlias *na = NickAlias::Find(mask); + const NickServ::Nick *na = NickServ::FindNick(mask); if (!na && Config->GetModule("chanserv")->Get<bool>("disallow_hostmask_access")) { source.Reply(_("Masks and unregistered users may not be on access lists.")); @@ -180,7 +181,7 @@ class CommandCSAccess : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { - const ChanAccess *access = ci->GetAccess(i - 1); + const ChanServ::ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->mask)) { /* Don't allow lowering from a level >= u_level */ @@ -201,7 +202,7 @@ class CommandCSAccess : public Command return; } - ServiceReference<AccessProvider> provider("AccessProvider", "access/access"); + ServiceReference<ChanServ::AccessProvider> provider("AccessProvider", "access/access"); if (!provider) return; AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create()); @@ -222,11 +223,11 @@ class CommandCSAccess : public Command source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->mask.c_str(), ci->name.c_str(), level); } - void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params[2]; - if (!isdigit(mask[0]) && mask.find_first_of("#!*@") == Anope::string::npos && !NickAlias::Find(mask)) + if (!isdigit(mask[0]) && mask.find_first_of("#!*@") == Anope::string::npos && !NickServ::FindNick(mask)) { User *targ = User::Find(mask, true); if (targ != NULL) @@ -245,14 +246,14 @@ class CommandCSAccess : public Command class AccessDelCallback : public NumberList { CommandSource &source; - ChannelInfo *ci; + ChanServ::Channel *ci; Command *c; unsigned deleted; Anope::string Nicks; bool denied; bool override; public: - AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), denied(false), override(false) + AccessDelCallback(CommandSource &_source, ChanServ::Channel *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), denied(false), override(false) { if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify")) this->override = true; @@ -280,10 +281,10 @@ class CommandCSAccess : public Command if (!Number || Number > ci->GetAccessCount()) return; - ChanAccess *access = ci->GetAccess(Number - 1); + ChanServ::ChanAccess *access = ci->GetAccess(Number - 1); - AccessGroup ag = source.AccessFor(ci); - const ChanAccess *u_highest = ag.Highest(); + ChanServ::AccessGroup ag = source.AccessFor(ci); + const ChanServ::ChanAccess *u_highest = ag.Highest(); if ((!u_highest || *u_highest <= *access) && !ag.founder && !this->override && !access->mask.equals_ci(source.nc->display)) { @@ -308,12 +309,12 @@ class CommandCSAccess : public Command } else { - AccessGroup u_access = source.AccessFor(ci); - const ChanAccess *highest = u_access.Highest(); + ChanServ::AccessGroup u_access = source.AccessFor(ci); + const ChanServ::ChanAccess *highest = u_access.Highest(); for (unsigned i = ci->GetAccessCount(); i > 0; --i) { - ChanAccess *access = ci->GetAccess(i - 1); + ChanServ::ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->mask)) { if (!access->mask.equals_ci(source.nc->display) && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) @@ -338,7 +339,7 @@ class CommandCSAccess : public Command return; } - void ProcessList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms, ListFormatter &list) + void ProcessList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms, ListFormatter &list) { const Anope::string &nick = params.size() > 2 ? params[2] : ""; @@ -349,10 +350,10 @@ class CommandCSAccess : public Command class AccessListCallback : public NumberList { ListFormatter &list; - ChannelInfo *ci; + ChanServ::Channel *ci; public: - AccessListCallback(ListFormatter &_list, ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), list(_list), ci(_ci) + AccessListCallback(ListFormatter &_list, ChanServ::Channel *_ci, const Anope::string &numlist) : NumberList(numlist, false), list(_list), ci(_ci) { } @@ -361,13 +362,13 @@ class CommandCSAccess : public Command if (!number || number > ci->GetAccessCount()) return; - const ChanAccess *access = ci->GetAccess(number - 1); + const ChanServ::ChanAccess *access = ci->GetAccess(number - 1); Anope::string timebuf; if (ci->c) for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) { - ChanAccess::Path p; + ChanServ::ChanAccess::Path p; if (access->Matches(cit->second->user, cit->second->user->Account(), p)) timebuf = "Now"; } @@ -395,7 +396,7 @@ class CommandCSAccess : public Command { for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { - const ChanAccess *access = ci->GetAccess(i); + const ChanServ::ChanAccess *access = ci->GetAccess(i); if (!nick.empty() && !Anope::Match(access->mask, nick)) continue; @@ -404,7 +405,7 @@ class CommandCSAccess : public Command if (ci->c) for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) { - ChanAccess::Path p; + ChanServ::ChanAccess::Path p; if (access->Matches(cit->second->user, cit->second->user->Account(), p)) timebuf = "Now"; } @@ -434,7 +435,7 @@ class CommandCSAccess : public Command list.Process(replies); source.Reply(_("Access list for %s:"), ci->name.c_str()); - + for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); @@ -444,7 +445,7 @@ class CommandCSAccess : public Command return; } - void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { if (!ci->GetAccessCount()) { @@ -457,7 +458,7 @@ class CommandCSAccess : public Command this->ProcessList(source, ci, params, list); } - void DoView(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoView(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { if (!ci->GetAccessCount()) { @@ -470,7 +471,7 @@ class CommandCSAccess : public Command this->ProcessList(source, ci, params, list); } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); @@ -506,7 +507,7 @@ class CommandCSAccess : public Command const Anope::string &nick = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -526,7 +527,7 @@ class CommandCSAccess : public Command has_access = true; else if (is_del) { - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (na && na->nc == source.GetAccount()) has_access = true; } @@ -612,7 +613,7 @@ class CommandCSAccess : public Command class CommandCSLevels : public Command { - void DoSet(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoSet(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &what = params[2]; const Anope::string &lev = params[3]; @@ -620,7 +621,7 @@ class CommandCSLevels : public Command int level; if (lev.equals_ci("FOUNDER")) - level = ACCESS_FOUNDER; + level = ChanServ::ACCESS_FOUNDER; else { try @@ -634,11 +635,11 @@ class CommandCSLevels : public Command } } - if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER) - source.Reply(_("Level must be between %d and %d inclusive."), ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); + if (level <= ChanServ::ACCESS_INVALID || level > ChanServ::ACCESS_FOUNDER) + source.Reply(_("Level must be between %d and %d inclusive."), ChanServ::ACCESS_INVALID + 1, ChanServ::ACCESS_FOUNDER - 1); else { - Privilege *p = PrivilegeManager::FindPrivilege(what); + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(what) : nullptr; if (p == NULL) source.Reply(_("Setting \002%s\002 not known. Type \002%s%s HELP LEVELS\002 for a list of valid settings."), what.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); else @@ -649,7 +650,7 @@ class CommandCSLevels : public Command ci->SetLevel(p->name, level); this->onlevelchange(&Event::LevelChange::OnLevelChange, source, ci, p->name, level); - if (level == ACCESS_FOUNDER) + if (level == ChanServ::ACCESS_FOUNDER) source.Reply(_("Level for %s on channel %s changed to founder only."), p->name.c_str(), ci->name.c_str()); else source.Reply(_("Level for \002%s\002 on channel %s changed to \002%d\002."), p->name.c_str(), ci->name.c_str(), level); @@ -657,7 +658,7 @@ class CommandCSLevels : public Command } } - void DoDisable(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoDisable(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &what = params[2]; @@ -668,14 +669,14 @@ class CommandCSLevels : public Command return; } - Privilege *p = PrivilegeManager::FindPrivilege(what); + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(what) : nullptr; if (p != NULL) { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; - ci->SetLevel(p->name, ACCESS_INVALID); - this->onlevelchange(&Event::LevelChange::OnLevelChange, source, ci, p->name, ACCESS_INVALID); + ci->SetLevel(p->name, ChanServ::ACCESS_INVALID); + this->onlevelchange(&Event::LevelChange::OnLevelChange, source, ci, p->name, ChanServ::ACCESS_INVALID); source.Reply(_("\002%s\002 disabled on channel %s."), p->name.c_str(), ci->name.c_str()); return; @@ -684,26 +685,29 @@ class CommandCSLevels : public Command source.Reply(_("Setting \002%s\002 not known. Type \002%s%s HELP LEVELS\002 for a list of valid settings."), what.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); } - void DoList(CommandSource &source, ChannelInfo *ci) + void DoList(CommandSource &source, ChanServ::Channel *ci) { + if (!ChanServ::service) + return; + source.Reply(_("Access level settings for channel %s:"), ci->name.c_str()); ListFormatter list(source.GetAccount()); list.AddColumn(_("Name")).AddColumn(_("Level")); - const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); + const std::vector<ChanServ::Privilege> &privs = ChanServ::service->GetPrivileges(); for (unsigned i = 0; i < privs.size(); ++i) { - const Privilege &p = privs[i]; + const ChanServ::Privilege &p = privs[i]; int16_t j = ci->GetLevel(p.name); ListFormatter::ListEntry entry; entry["Name"] = p.name; - if (j == ACCESS_INVALID) + if (j == ChanServ::ACCESS_INVALID) entry["Level"] = Language::Translate(source.GetAccount(), _("(disabled)")); - else if (j == ACCESS_FOUNDER) + else if (j == ChanServ::ACCESS_FOUNDER) entry["Level"] = Language::Translate(source.GetAccount(), _("(founder only)")); else entry["Level"] = stringify(j); @@ -718,7 +722,7 @@ class CommandCSLevels : public Command source.Reply(replies[i]); } - void DoReset(CommandSource &source, ChannelInfo *ci) + void DoReset(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; @@ -747,7 +751,7 @@ class CommandCSLevels : public Command const Anope::string &what = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -786,14 +790,17 @@ class CommandCSLevels : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Name")).AddColumn(_("Description")); - const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); - for (unsigned i = 0; i < privs.size(); ++i) + if (ChanServ::service) { - const Privilege &p = privs[i]; - ListFormatter::ListEntry entry; - entry["Name"] = p.name; - entry["Description"] = Language::Translate(source.nc, p.desc.c_str()); - list.AddEntry(entry); + const std::vector<ChanServ::Privilege> &privs = ChanServ::service->GetPrivileges(); + for (unsigned i = 0; i < privs.size(); ++i) + { + const ChanServ::Privilege &p = privs[i]; + ListFormatter::ListEntry entry; + entry["Name"] = p.name; + entry["Description"] = Language::Translate(source.nc, p.desc.c_str()); + list.AddEntry(entry); + } } std::vector<Anope::string> replies; @@ -862,7 +869,7 @@ class CSAccess : public Module const Anope::string &pname = priv->Get<const Anope::string>("name"); - Privilege *p = PrivilegeManager::FindPrivilege(pname); + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(pname) : nullptr; if (p == NULL) continue; @@ -870,20 +877,20 @@ class CSAccess : public Module if (value.empty()) continue; else if (value.equals_ci("founder")) - defaultLevels[p->name] = ACCESS_FOUNDER; + defaultLevels[p->name] = ChanServ::ACCESS_FOUNDER; else if (value.equals_ci("disabled")) - defaultLevels[p->name] = ACCESS_INVALID; + defaultLevels[p->name] = ChanServ::ACCESS_INVALID; else defaultLevels[p->name] = priv->Get<int16_t>("level"); } } - void OnCreateChan(ChannelInfo *ci) override + void OnCreateChan(ChanServ::Channel *ci) override { reset_levels(ci); } - EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) override + EventReturn OnGroupCheckPriv(const ChanServ::AccessGroup *group, const Anope::string &priv) override { if (group->ci == NULL) return EVENT_CONTINUE; diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 61bc23181..b548d87a9 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -12,15 +12,89 @@ #include "module.h" #include "modules/cs_akick.h" +class AutoKickImpl : public AutoKick +{ + public: + ~AutoKickImpl() + { + if (this->ci) + { + std::vector<AutoKick *>::iterator it = std::find(this->ci->akick->begin(), this->ci->akick->end(), this); + if (it != this->ci->akick->end()) + this->ci->akick->erase(it); + + const NickServ::Nick *na = NickServ::FindNick(this->mask); + if (na != NULL) + na->nc->RemoveChannelReference(this->ci); + } + } + + void Serialize(Serialize::Data &data) const override + { + data["ci"] << this->ci->name; + if (this->nc) + data["nc"] << this->nc->display; + else + data["mask"] << this->mask; + data["reason"] << this->reason; + data["creator"] << this->creator; + data.SetType("addtime", Serialize::Data::DT_INT); data["addtime"] << this->addtime; + data.SetType("last_used", Serialize::Data::DT_INT); data["last_used"] << this->last_used; + } + + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) + { + Anope::string sci, snc; + + data["ci"] >> sci; + data["nc"] >> snc; + + ChanServ::Channel *ci = ChanServ::Find(sci); + if (!ci) + return NULL; + + AutoKick *ak; + NickServ::Account *nc = NickServ::FindAccount(snc); + if (obj) + { + ak = anope_dynamic_static_cast<AutoKick *>(obj); + data["creator"] >> ak->creator; + data["reason"] >> ak->reason; + ak->nc = NickServ::FindAccount(snc); + data["mask"] >> ak->mask; + data["addtime"] >> ak->addtime; + data["last_used"] >> ak->last_used; + } + else + { + time_t addtime, lastused; + data["addtime"] >> addtime; + data["last_used"] >> lastused; + + Anope::string screator, sreason, smask; + + data["creator"] >> screator; + data["reason"] >> sreason; + data["mask"] >> smask; + + if (nc) + ak = ci->AddAkick(screator, nc, sreason, addtime, lastused); + else + ak = ci->AddAkick(screator, smask, sreason, addtime, lastused); + } + + return ak; + } +}; + class CommandCSAKick : public Command { - void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoAdd(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params[2]; Anope::string reason = params.size() > 3 ? params[3] : ""; - const NickAlias *na = NickAlias::Find(mask); - NickCore *nc = NULL; - const AutoKick *akick; + const NickServ::Nick *na = NickServ::FindNick(mask); + NickServ::Account *nc = NULL; unsigned reasonmax = Config->GetModule("chanserv")->Get<unsigned>("reasonmax", "200"); if (reason.length() > reasonmax) @@ -59,7 +133,7 @@ class CommandCSAKick : public Command } Entry e("", mask); - + mask = (e.nick.empty() ? "*" : e.nick) + "!" + (e.user.empty() ? "*" : e.user) + "@" + (e.host.empty() ? "*" : e.host); @@ -94,7 +168,7 @@ class CommandCSAKick : public Command * or whether the mask matches a user with higher/equal access - Viper */ else if (ci->HasExt("PEACE") && nc) { - AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); + ChanServ::AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); if (nc == ci->GetFounder() || nc_access >= u_access) { source.Reply(ACCESS_DENIED); @@ -103,13 +177,14 @@ class CommandCSAKick : public Command } else if (ci->HasExt("PEACE")) { +#if 0 /* Match against all currently online users with equal or * higher access. - Viper */ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { User *u2 = it->second; - AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); + ChanServ::AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); Entry entry_mask("", mask); if ((ci->AccessFor(u2).HasPriv("FOUNDER") || nc_access >= u_access) && entry_mask.Matches(u2)) @@ -121,11 +196,11 @@ class CommandCSAKick : public Command /* Match against the lastusermask of all nickalias's with equal * or higher access. - Viper */ - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) + for (nickalias_map::const_iterator it = NickServ::NickList->begin(), it_end = NickServ::NickList->end(); it != it_end; ++it) { na = it->second; - AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci); + ChanServ::AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci); if (na->nc && (na->nc == ci->GetFounder() || nc_access >= u_access)) { Anope::string buf = na->nick + "!" + na->last_usermask; @@ -136,14 +211,15 @@ class CommandCSAKick : public Command } } } +#endif } for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j) { - akick = ci->GetAkick(j); - if (akick->nc ? akick->nc == nc : mask.equals_ci(akick->mask)) + AutoKick *ak = ci->GetAkick(j); + if (ak->nc ? ak->nc == nc : mask.equals_ci(ak->mask)) { - source.Reply(_("\002%s\002 already exists on %s autokick list."), akick->nc ? akick->nc->display.c_str() : akick->mask.c_str(), ci->name.c_str()); + source.Reply(_("\002%s\002 already exists on %s autokick list."), ak->nc ? ak->nc->display.c_str() : ak->mask.c_str(), ci->name.c_str()); return; } } @@ -154,21 +230,22 @@ class CommandCSAKick : public Command return; } + AutoKick *ak; if (nc) - akick = ci->AddAkick(source.GetNick(), nc, reason); + ak = ci->AddAkick(source.GetNick(), nc, reason); else - akick = ci->AddAkick(source.GetNick(), mask, reason); + ak = ci->AddAkick(source.GetNick(), mask, reason); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; - this->akickevents(&Event::Akick::OnAkickAdd, source, ci, akick); + this->akickevents(&Event::Akick::OnAkickAdd, source, ci, ak); source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str()); this->DoEnforce(source, ci); } - void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &mask = params[2]; unsigned i, end; @@ -185,12 +262,12 @@ class CommandCSAKick : public Command class AkickDelCallback : public NumberList { CommandSource &source; - ChannelInfo *ci; + ChanServ::Channel *ci; CommandCSAKick *c; unsigned deleted; - AccessGroup ag; + ChanServ::AccessGroup ag; public: - AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, CommandCSAKick *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), ag(source.AccessFor(ci)) + AkickDelCallback(CommandSource &_source, ChanServ::Channel *_ci, CommandCSAKick *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), ag(source.AccessFor(ci)) { } @@ -209,12 +286,12 @@ class CommandCSAKick : public Command if (!number || number > ci->GetAkickCount()) return; - const AutoKick *akick = ci->GetAkick(number - 1); + const AutoKick *ak = ci->GetAkick(number - 1); - c->akickevents(&Event::Akick::OnAkickDel, source, ci, akick); + c->akickevents(&Event::Akick::OnAkickDel, source, ci, ak); bool override = !ag.HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << (akick->nc ? akick->nc->display : akick->mask); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << (ak->nc ? ak->nc->display : ak->mask); ++deleted; ci->EraseAkick(number - 1); @@ -225,14 +302,14 @@ class CommandCSAKick : public Command } else { - const NickAlias *na = NickAlias::Find(mask); - const NickCore *nc = na ? *na->nc : NULL; + const NickServ::Nick *na = NickServ::FindNick(mask); + const NickServ::Account *nc = na ? *na->nc : NULL; for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { - const AutoKick *akick = ci->GetAkick(i); + const AutoKick *ak = ci->GetAkick(i); - if (akick->nc ? akick->nc == nc : mask.equals_ci(akick->mask)) + if (ak->nc ? ak->nc == nc : mask.equals_ci(ak->mask)) break; } @@ -253,7 +330,7 @@ class CommandCSAKick : public Command } } - void ProcessList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms, ListFormatter &list) + void ProcessList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms, ListFormatter &list) { const Anope::string &mask = params.size() > 2 ? params[2] : ""; @@ -262,10 +339,10 @@ class CommandCSAKick : public Command class AkickListCallback : public NumberList { ListFormatter &list; - ChannelInfo *ci; + ChanServ::Channel *ci; public: - AkickListCallback(ListFormatter &_list, ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), list(_list), ci(_ci) + AkickListCallback(ListFormatter &_list, ChanServ::Channel *_ci, const Anope::string &numlist) : NumberList(numlist, false), list(_list), ci(_ci) { } @@ -273,29 +350,29 @@ class CommandCSAKick : public Command { if (!number || number > ci->GetAkickCount()) return; - - const AutoKick *akick = ci->GetAkick(number - 1); + + const AutoKick *ak = ci->GetAkick(number - 1); Anope::string timebuf, lastused; - if (akick->addtime) - timebuf = Anope::strftime(akick->addtime, NULL, true); + if (ak->addtime) + timebuf = Anope::strftime(ak->addtime, NULL, true); else timebuf = UNKNOWN; - if (akick->last_used) - lastused = Anope::strftime(akick->last_used, NULL, true); + if (ak->last_used) + lastused = Anope::strftime(ak->last_used, NULL, true); else lastused = UNKNOWN; ListFormatter::ListEntry entry; entry["Number"] = stringify(number); - if (akick->nc) - entry["Mask"] = akick->nc->display; + if (ak->nc) + entry["Mask"] = ak->nc->display; else - entry["Mask"] = akick->mask; - entry["Creator"] = akick->creator; + entry["Mask"] = ak->mask; + entry["Creator"] = ak->creator; entry["Created"] = timebuf; entry["Last used"] = lastused; - entry["Reason"] = akick->reason; + entry["Reason"] = ak->reason; this->list.AddEntry(entry); } } @@ -306,36 +383,36 @@ class CommandCSAKick : public Command { for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i) { - const AutoKick *akick = ci->GetAkick(i); + const AutoKick *ak = ci->GetAkick(i); if (!mask.empty()) { - if (!akick->nc && !Anope::Match(akick->mask, mask)) + if (!ak->nc && !Anope::Match(ak->mask, mask)) continue; - if (akick->nc && !Anope::Match(akick->nc->display, mask)) + if (ak->nc && !Anope::Match(ak->nc->display, mask)) continue; } Anope::string timebuf, lastused; - if (akick->addtime) - timebuf = Anope::strftime(akick->addtime, NULL, true); + if (ak->addtime) + timebuf = Anope::strftime(ak->addtime, NULL, true); else timebuf = UNKNOWN; - if (akick->last_used) - lastused = Anope::strftime(akick->last_used, NULL, true); + if (ak->last_used) + lastused = Anope::strftime(ak->last_used, NULL, true); else lastused = UNKNOWN; ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); - if (akick->nc) - entry["Mask"] = akick->nc->display; + if (ak->nc) + entry["Mask"] = ak->nc->display; else - entry["Mask"] = akick->mask; - entry["Creator"] = akick->creator; + entry["Mask"] = ak->mask; + entry["Creator"] = ak->creator; entry["Created"] = timebuf; entry["Last used"] = lastused; - entry["Reason"] = akick->reason; + entry["Reason"] = ak->reason; list.AddEntry(entry); } } @@ -348,7 +425,7 @@ class CommandCSAKick : public Command list.Process(replies); source.Reply(_("Autokick list for %s:"), ci->name.c_str()); - + for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); @@ -356,7 +433,7 @@ class CommandCSAKick : public Command } } - void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { if (!ci->GetAkickCount()) { @@ -369,7 +446,7 @@ class CommandCSAKick : public Command this->ProcessList(source, ci, params, list); } - void DoView(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoView(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { if (!ci->GetAkickCount()) { @@ -382,7 +459,7 @@ class CommandCSAKick : public Command this->ProcessList(source, ci, params, list); } - void DoEnforce(CommandSource &source, ChannelInfo *ci) + void DoEnforce(CommandSource &source, ChanServ::Channel *ci) { Channel *c = ci->c; int count = 0; @@ -408,7 +485,7 @@ class CommandCSAKick : public Command source.Reply(_("AKICK ENFORCE for \002%s\002 complete; \002%d\002 users were affected."), ci->name.c_str(), count); } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the akick list"; @@ -437,7 +514,7 @@ class CommandCSAKick : public Command Anope::string cmd = params[1]; Anope::string mask = params.size() > 2 ? params[2] : ""; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -512,17 +589,26 @@ class CommandCSAKick : public Command }; class CSAKick : public Module + , public AutoKickService , public EventHook<Event::CheckKick> { CommandCSAKick commandcsakick; EventHandlers<Event::Akick> akickevents; + Serialize::Type akick_type; public: CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , AutoKickService(this) , EventHook<Event::CheckKick>("OnCheckKick") , commandcsakick(this, akickevents) , akickevents(this, "Akick") + , akick_type("AutoKick", AutoKickImpl::Unserialize) + { + } + + AutoKick* Create() override { + return new AutoKickImpl(); } EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index a6a1f4af6..e85afc4a0 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -44,7 +44,7 @@ class CommandCSBan : public Command { const Anope::string &chan = params[0]; - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -101,13 +101,13 @@ class CommandCSBan : public Command User *u = source.GetUser(); User *u2 = User::Find(target, true); - AccessGroup u_access = source.AccessFor(ci); + ChanServ::AccessGroup u_access = source.AccessFor(ci); if (!u_access.HasPriv("BAN") && !source.HasPriv("chanserv/kick")) source.Reply(ACCESS_DENIED); else if (u2) { - AccessGroup u2_access = ci->AccessFor(u2); + ChanServ::AccessGroup u2_access = ci->AccessFor(u2); if (u != u2 && ci->HasExt("PEACE") && u2_access >= u_access && !source.HasPriv("chanserv/kick")) source.Reply(ACCESS_DENIED); @@ -172,7 +172,7 @@ class CommandCSBan : public Command { ++matched; - AccessGroup u2_access = ci->AccessFor(uc->user); + ChanServ::AccessGroup u2_access = ci->AccessFor(uc->user); if (matched > 1 && !founder) continue; diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index e7102091a..bd7a6c990 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -11,6 +11,7 @@ #include "module.h" #include "modules/bs_badwords.h" +#include "modules/cs_akick.h" class CommandCSClone : public Command { @@ -34,7 +35,7 @@ public: } User *u = source.GetUser(); - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); bool override = false; if (ci == NULL) @@ -43,7 +44,7 @@ public: return; } - ChannelInfo *target_ci = ChannelInfo::Find(target); + ChanServ::Channel *target_ci = ChanServ::Find(target); if (!target_ci) { source.Reply(CHAN_X_NOT_REGISTERED, target.c_str()); @@ -73,9 +74,10 @@ public: if (what.empty()) { delete target_ci; - target_ci = new ChannelInfo(*ci); + target_ci = ChanServ::service->Create(*ci); target_ci->name = target; - (*RegisteredChannelList)[target_ci->name] = target_ci; + ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); + map[target_ci->name] = target_ci; target_ci->c = Channel::Find(target_ci->name); target_ci->bi = NULL; @@ -115,8 +117,8 @@ public: for (unsigned i = 0; i < ci->GetAccessCount(); ++i) { - const ChanAccess *taccess = ci->GetAccess(i); - AccessProvider *provider = taccess->provider; + const ChanServ::ChanAccess *taccess = ci->GetAccess(i); + ChanServ::AccessProvider *provider = taccess->provider; if (access_max && target_ci->GetDeepAccessCount() >= access_max) break; @@ -125,7 +127,7 @@ public: continue; masks.insert(taccess->mask); - ChanAccess *newaccess = provider->Create(); + ChanServ::ChanAccess *newaccess = provider->Create(); newaccess->ci = target_ci; newaccess->mask = taccess->mask; newaccess->creator = taccess->creator; @@ -145,11 +147,11 @@ public: target_ci->ClearAkick(); for (unsigned i = 0; i < ci->GetAkickCount(); ++i) { - const AutoKick *akick = ci->GetAkick(i); - if (akick->nc) - target_ci->AddAkick(akick->creator, akick->nc, akick->reason, akick->addtime, akick->last_used); + const AutoKick *ak = ci->GetAkick(i); + if (ak->nc) + target_ci->AddAkick(ak->creator, ak->nc, ak->reason, ak->addtime, ak->last_used); else - target_ci->AddAkick(akick->creator, akick->mask, akick->reason, akick->addtime, akick->last_used); + target_ci->AddAkick(ak->creator, ak->mask, ak->reason, ak->addtime, ak->last_used); } source.Reply(_("All akick entries from \002%s\002 have been cloned to \002%s\002."), channel.c_str(), target.c_str()); diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index 3b6c82ed0..55a28f294 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -33,7 +33,7 @@ class CommandCSDrop : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index aa710ef03..52b9093ca 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -16,7 +16,7 @@ class CommandCSEnforce : public Command { private: - void DoSecureOps(CommandSource &source, ChannelInfo *ci) + void DoSecureOps(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce secureops"; @@ -42,7 +42,7 @@ class CommandCSEnforce : public Command source.Reply(_("Secureops enforced on %s."), ci->name.c_str()); } - void DoRestricted(CommandSource &source, ChannelInfo *ci) + void DoRestricted(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce restricted"; @@ -61,7 +61,7 @@ class CommandCSEnforce : public Command } for (unsigned i = 0; i < users.size(); ++i) - { + { User *user = users[i]; Anope::string mask = ci->GetIdealBan(user); @@ -73,7 +73,7 @@ class CommandCSEnforce : public Command source.Reply(_("Restricted enforced on %s."), ci->name.c_str()); } - void DoRegOnly(CommandSource &source, ChannelInfo *ci) + void DoRegOnly(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce registered only"; @@ -105,7 +105,7 @@ class CommandCSEnforce : public Command source.Reply(_("Registered only enforced on %s."), ci->name.c_str()); } - void DoSSLOnly(CommandSource &source, ChannelInfo *ci) + void DoSSLOnly(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce SSL only"; @@ -137,7 +137,7 @@ class CommandCSEnforce : public Command source.Reply(_("SSL only enforced on %s."), ci->name.c_str()); } - void DoBans(CommandSource &source, ChannelInfo *ci) + void DoBans(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce bans"; @@ -158,7 +158,7 @@ class CommandCSEnforce : public Command for (unsigned i = 0; i < users.size(); ++i) { User *user = users[i]; - + Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick(); ci->c->Kick(NULL, user, "%s", reason.c_str()); } @@ -166,7 +166,7 @@ class CommandCSEnforce : public Command source.Reply(_("Bans enforced on %s."), ci->name.c_str()); } - void DoLimit(CommandSource &source, ChannelInfo *ci) + void DoLimit(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce limit"; @@ -213,7 +213,7 @@ class CommandCSEnforce : public Command for (unsigned i = 0; i < users.size(); ++i) { User *user = users[i]; - + Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick(); ci->c->Kick(NULL, user, "%s", reason.c_str()); } @@ -232,7 +232,7 @@ class CommandCSEnforce : public Command { const Anope::string &what = params.size() > 1 ? params[1] : ""; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (!ci) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 676d7b74a..8e196d18b 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -18,7 +18,7 @@ struct EntryMsgImpl : EntryMsg, Serializable { } - EntryMsgImpl(ChannelInfo *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime) : Serializable("EntryMsg") + EntryMsgImpl(ChanServ::Channel *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime) : Serializable("EntryMsg") { this->chan = c->name; this->creator = cname; @@ -51,7 +51,7 @@ struct EntryMessageListImpl : EntryMessageList EntryMsgImpl::~EntryMsgImpl() { - ChannelInfo *ci = ChannelInfo::Find(this->chan); + ChanServ::Channel *ci = ChanServ::Find(this->chan); if (!ci) return; @@ -74,7 +74,7 @@ Serializable* EntryMsgImpl::Unserialize(Serializable *obj, Serialize::Data &data data["creator"] >> screator; data["message"] >> smessage; - ChannelInfo *ci = ChannelInfo::Find(sci); + ChanServ::Channel *ci = ChanServ::Find(sci); if (!ci) return NULL; @@ -100,7 +100,7 @@ Serializable* EntryMsgImpl::Unserialize(Serializable *obj, Serialize::Data &data class CommandEntryMessage : public Command { private: - void DoList(CommandSource &source, ChannelInfo *ci) + void DoList(CommandSource &source, ChanServ::Channel *ci) { EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); @@ -133,8 +133,8 @@ class CommandEntryMessage : public Command source.Reply(_("End of entry message list.")); } - - void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message) + + void DoAdd(CommandSource &source, ChanServ::Channel *ci, const Anope::string &message) { EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); @@ -148,7 +148,7 @@ class CommandEntryMessage : public Command } } - void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message) + void DoDel(CommandSource &source, ChanServ::Channel *ci, const Anope::string &message) { EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); @@ -179,7 +179,7 @@ class CommandEntryMessage : public Command } } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { ci->Shrink<EntryMessageList>("entrymsg"); @@ -199,7 +199,7 @@ class CommandEntryMessage : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 1298f74c5..2c5cfa547 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -13,12 +13,12 @@ static std::map<Anope::string, char> defaultFlags; -class FlagsChanAccess : public ChanAccess +class FlagsChanAccess : public ChanServ::ChanAccess { public: std::set<char> flags; - FlagsChanAccess(AccessProvider *p) : ChanAccess(p) + FlagsChanAccess(ChanServ::AccessProvider *p) : ChanAccess(p) { } @@ -41,11 +41,11 @@ class FlagsChanAccess : public ChanAccess this->flags.insert(data[i - 1]); } - static Anope::string DetermineFlags(const ChanAccess *access) + static Anope::string DetermineFlags(const ChanServ::ChanAccess *access) { if (access->provider->name == "access/flags") return access->AccessSerialize(); - + std::set<char> buffer; for (std::map<Anope::string, char>::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it) @@ -59,17 +59,17 @@ class FlagsChanAccess : public ChanAccess } }; -class FlagsAccessProvider : public AccessProvider +class FlagsAccessProvider : public ChanServ::AccessProvider { public: static FlagsAccessProvider *ap; - FlagsAccessProvider(Module *o) : AccessProvider(o, "access/flags") + FlagsAccessProvider(Module *o) : ChanServ::AccessProvider(o, "access/flags") { ap = this; } - ChanAccess *Create() override + ChanServ::ChanAccess *Create() override { return new FlagsChanAccess(this); } @@ -78,7 +78,7 @@ FlagsAccessProvider* FlagsAccessProvider::ap; class CommandCSFlags : public Command { - void DoModify(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoModify(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params.size() > 2 ? params[2] : ""; Anope::string flags = params.size() > 3 ? params[3] : ""; @@ -89,8 +89,8 @@ class CommandCSFlags : public Command return; } - AccessGroup u_access = source.AccessFor(ci); - const ChanAccess *highest = u_access.Highest(); + ChanServ::AccessGroup u_access = source.AccessFor(ci); + const ChanServ::ChanAccess *highest = u_access.Highest(); if (IRCD->IsChannelValid(mask)) { @@ -100,7 +100,7 @@ class CommandCSFlags : public Command return; } - ChannelInfo *targ_ci = ChannelInfo::Find(mask); + ChanServ::Channel *targ_ci = ChanServ::Find(mask); if (targ_ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, mask.c_str()); @@ -116,7 +116,7 @@ class CommandCSFlags : public Command } else { - const NickAlias *na = NickAlias::Find(mask); + const NickServ::Nick *na = NickServ::FindNick(mask); if (!na && Config->GetModule("chanserv")->Get<bool>("disallow_hostmask_access")) { source.Reply(_("Masks and unregistered users may not be on access lists.")); @@ -135,13 +135,13 @@ class CommandCSFlags : public Command } } - ChanAccess *current = NULL; + ChanServ::ChanAccess *current = NULL; unsigned current_idx; std::set<char> current_flags; bool override = false; for (current_idx = ci->GetAccessCount(); current_idx > 0; --current_idx) { - ChanAccess *access = ci->GetAccess(current_idx - 1); + ChanServ::ChanAccess *access = ci->GetAccess(current_idx - 1); if (mask.equals_ci(access->mask)) { // Flags allows removing others that have the same access as you, @@ -174,7 +174,7 @@ class CommandCSFlags : public Command return; } - Privilege *p = NULL; + ChanServ::Privilege *p = NULL; bool add = true; for (size_t i = 0; i < flags.length(); ++i) { @@ -210,7 +210,7 @@ class CommandCSFlags : public Command } break; default: - p = PrivilegeManager::FindPrivilege(flags.substr(i)); + p = ChanServ::service ? ChanServ::service->FindPrivilege(flags.substr(i)) : nullptr; if (p != NULL && defaultFlags[p->name]) { f = defaultFlags[p->name]; @@ -256,7 +256,7 @@ class CommandCSFlags : public Command return; } - ServiceReference<AccessProvider> provider("AccessProvider", "access/flags"); + ServiceReference<ChanServ::AccessProvider> provider("AccessProvider", "access/flags"); if (!provider) return; FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); @@ -286,7 +286,7 @@ class CommandCSFlags : public Command source.Reply(_("Flags for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str()); } - void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &arg = params.size() > 2 ? params[2] : ""; @@ -303,7 +303,7 @@ class CommandCSFlags : public Command unsigned count = 0; for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { - const ChanAccess *access = ci->GetAccess(i); + const ChanServ::ChanAccess *access = ci->GetAccess(i); const Anope::string &flags = FlagsChanAccess::DetermineFlags(access); if (!arg.empty()) @@ -348,7 +348,7 @@ class CommandCSFlags : public Command } } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); @@ -381,7 +381,7 @@ class CommandCSFlags : public Command const Anope::string &chan = params[0]; const Anope::string &cmd = params.size() > 1 ? params[1] : ""; - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -441,7 +441,7 @@ class CommandCSFlags : public Command for (reverse_map::iterator it = reverse.begin(), it_end = reverse.end(); it != it_end; ++it) { - Privilege *p = PrivilegeManager::FindPrivilege(it->second); + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(it->second) : nullptr; if (p == NULL) continue; source.Reply(" %c - %s", it->first, Language::Translate(source.nc, p->desc.c_str())); @@ -475,7 +475,7 @@ class CSFlags : public Module const Anope::string &pname = priv->Get<const Anope::string>("name"); - Privilege *p = PrivilegeManager::FindPrivilege(pname); + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(pname) : nullptr; if (p == NULL) continue; diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index 6b714d093..122035acc 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -24,7 +24,7 @@ class CommandCSGetKey : public Command { const Anope::string &chan = params[0]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index d0ae17a7e..2b974ef1d 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -28,8 +28,8 @@ class CommandCSInfo : public Command { const Anope::string &chan = params[0]; - NickCore *nc = source.nc; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + NickServ::Account *nc = source.nc; + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index 6f19042cc..9e0168b53 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -33,7 +33,7 @@ class CommandCSInvite : public Command return; } - ChannelInfo *ci = c->ci; + ChanServ::Channel *ci = c->ci; if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index bfaec6a29..9828c79fa 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -28,7 +28,7 @@ class CommandCSKick : public Command Anope::string reason = params.size() > 2 ? params[2] : "Requested"; User *u = source.GetUser(); - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); Channel *c = Channel::Find(params[0]); User *u2 = User::Find(target, true); @@ -47,13 +47,13 @@ class CommandCSKick : public Command if (reason.length() > reasonmax) reason = reason.substr(0, reasonmax); - AccessGroup u_access = source.AccessFor(ci); + ChanServ::AccessGroup u_access = source.AccessFor(ci); if (!u_access.HasPriv("KICK") && !source.HasPriv("chanserv/kick")) source.Reply(ACCESS_DENIED); else if (u2) { - AccessGroup u2_access = ci->AccessFor(u2); + ChanServ::AccessGroup u2_access = ci->AccessFor(u2); if (u != u2 && ci->HasExt("PEACE") && u2_access >= u_access && !source.HasPriv("chanserv/kick")) source.Reply(ACCESS_DENIED); else if (u2->IsProtected()) @@ -85,7 +85,7 @@ class CommandCSKick : public Command { ++matched; - AccessGroup u2_access = ci->AccessFor(uc->user); + ChanServ::AccessGroup u2_access = ci->AccessFor(uc->user); if (u != uc->user && ci->HasExt("PEACE") && u2_access >= u_access) continue; else if (uc->user->IsProtected()) diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 68cca6d42..f97e6e065 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -75,13 +75,14 @@ class CommandCSList : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Name")).AddColumn(_("Description")); - Anope::map<ChannelInfo *> ordered_map; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) - ordered_map[it->first] = it->second; + Anope::map<ChanServ::Channel *> ordered_map; + if (ChanServ::service) + for (auto& it : ChanServ::service->GetChannels()) + ordered_map[it.first] = it.second; - for (Anope::map<ChannelInfo *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it) + for (Anope::map<ChanServ::Channel *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it) { - const ChannelInfo *ci = it->second; + const ChanServ::Channel *ci = it->second; if (!is_servadmin) { @@ -185,7 +186,7 @@ class CommandCSSetPrivate : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -225,7 +226,7 @@ class CommandCSSetPrivate : public Command this->SendSyntax(source); source.Reply(" "); source.Reply(_("Enables or disables the \002private\002 option for a channel.")); - + BotInfo *bi; Anope::string cmd; if (Command::FindCommandFromService("chanserv/list", bi, cmd)) @@ -252,7 +253,7 @@ class CSList : public Module { } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override { if (!show_all) return; diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index 678a2fd5f..39e6a31b5 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -21,7 +21,7 @@ struct LogSettingImpl : LogSetting, Serializable ~LogSettingImpl() { - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci) { LogSettings *ls = ci->GetExt<LogSettings>("logsettings"); @@ -51,10 +51,10 @@ struct LogSettingImpl : LogSetting, Serializable Anope::string sci; data["ci"] >> sci; - ChannelInfo *ci = ChannelInfo::Find(sci); + ChanServ::Channel *ci = ChanServ::Find(sci); if (ci == NULL) return NULL; - + LogSettingImpl *ls; if (obj) ls = anope_dynamic_static_cast<LogSettingImpl *>(obj); @@ -112,7 +112,7 @@ public: { const Anope::string &channel = params[0]; - ChannelInfo *ci = ChannelInfo::Find(channel); + ChanServ::Channel *ci = ChanServ::Find(channel); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/administration")) @@ -325,7 +325,7 @@ class CSLog : public Module } } - void OnChanRegistered(ChannelInfo *ci) override + void OnChanRegistered(ChanServ::Channel *ci) override { if (defaults.empty()) return; @@ -393,7 +393,7 @@ class CSLog : public Module else if (log->method.equals_ci("MESSAGE") && l->ci->c) { IRCD->SendPrivmsg(l->ci->WhoSends(), log->extra + l->ci->c->name, "%s", buffer.c_str()); - l->ci->WhoSends()->lastmsg = Anope::CurTime; + //l->ci->WhoSends()->lastmsg = Anope::CurTime; } else if (log->method.equals_ci("NOTICE") && l->ci->c) IRCD->SendNotice(l->ci->WhoSends(), log->extra + l->ci->c->name, "%s", buffer.c_str()); diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 2e858b382..9750cc031 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -23,7 +23,7 @@ struct ModeLockImpl : ModeLock, Serializable ~ModeLockImpl() { - ChannelInfo *chan = ChannelInfo::Find(ci); + ChanServ::Channel *chan = ChanServ::Find(ci); if (chan) { ModeLocks *ml = chan->GetExt<ModeLocks>("modelocks"); @@ -38,10 +38,10 @@ struct ModeLockImpl : ModeLock, Serializable struct ModeLocksImpl : ModeLocks { - Serialize::Reference<ChannelInfo> ci; + Serialize::Reference<ChanServ::Channel> ci; Serialize::Checker<ModeList> mlocks; - ModeLocksImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), mlocks("ModeLock") + ModeLocksImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChanServ::Channel *>(obj)), mlocks("ModeLock") { } @@ -224,13 +224,13 @@ void ModeLockImpl::Serialize(Serialize::Data &data) const Serializable* ModeLockImpl::Unserialize(Serializable *obj, Serialize::Data &data) { Anope::string sci; - + data["ci"] >> sci; - ChannelInfo *ci = ChannelInfo::Find(sci); + ChanServ::Channel *ci = ChanServ::Find(sci); if (!ci) return NULL; - + ModeLockImpl *ml; if (obj) ml = anope_dynamic_static_cast<ModeLockImpl *>(obj); @@ -254,7 +254,7 @@ Serializable* ModeLockImpl::Unserialize(Serializable *obj, Serialize::Data &data class CommandCSMode : public Command { - bool CanSet(CommandSource &source, ChannelInfo *ci, ChannelMode *cm, bool self) + bool CanSet(CommandSource &source, ChanServ::Channel *ci, ChannelMode *cm, bool self) { if (!ci || !cm || cm->type != MODE_STATUS) return false; @@ -262,7 +262,7 @@ class CommandCSMode : public Command return source.AccessFor(ci).HasPriv(cm->name + (self ? "ME" : "")); } - void DoLock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoLock(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); const Anope::string &subcommand = params[2]; @@ -332,7 +332,7 @@ class CommandCSMode : public Command source.Reply(_("List for mode %c is full."), cm->mchar); else { - modelocks->SetMLock(cm, adding, mode_param, source.GetNick()); + modelocks->SetMLock(cm, adding, mode_param, source.GetNick()); if (adding) { @@ -460,8 +460,8 @@ class CommandCSMode : public Command else this->OnSyntaxError(source, subcommand); } - - void DoSet(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + + void DoSet(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); @@ -536,7 +536,7 @@ class CommandCSMode : public Command if (!sep.GetToken(param)) param = source.GetNick(); - AccessGroup u_access = source.AccessFor(ci); + ChanServ::AccessGroup u_access = source.AccessFor(ci); if (param.find_first_of("*?") != Anope::string::npos) { @@ -551,7 +551,7 @@ class CommandCSMode : public Command ChanUserContainer *uc = it->second; ++it; - AccessGroup targ_access = ci->AccessFor(uc->user); + ChanServ::AccessGroup targ_access = ci->AccessFor(uc->user); if (uc->user->IsProtected() || (ci->HasExt("PEACE") && targ_access >= u_access && !can_override)) { @@ -585,7 +585,7 @@ class CommandCSMode : public Command if (source.GetUser() != target) { - AccessGroup targ_access = ci->AccessFor(target); + ChanServ::AccessGroup targ_access = ci->AccessFor(target); if (ci->HasExt("PEACE") && targ_access >= u_access && !can_override) { source.Reply(_("You do not have the access to change %s's modes."), target->nick.c_str()); @@ -632,7 +632,7 @@ class CommandCSMode : public Command } } - void DoClear(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoClear(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string ¶m = params.size() > 2 ? params[2] : ""; @@ -689,7 +689,7 @@ class CommandCSMode : public Command { const Anope::string &subcommand = params[1]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (!ci) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -760,7 +760,7 @@ class CommandCSModes : public Command { User *u = source.GetUser(), *targ = params.size() > 1 ? User::Find(params[1], true) : u; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (!targ) { @@ -780,7 +780,7 @@ class CommandCSModes : public Command return; } - AccessGroup u_access = source.AccessFor(ci), targ_access = ci->AccessFor(targ); + ChanServ::AccessGroup u_access = source.AccessFor(ci), targ_access = ci->AccessFor(targ); const std::pair<bool, Anope::string> &m = modes[source.command]; bool can_override = source.HasPriv("chanserv/administration"); @@ -791,7 +791,7 @@ class CommandCSModes : public Command source.Reply(ACCESS_DENIED); return; } - + if (u == targ ? !u_access.HasPriv(m.second + "ME") : !u_access.HasPriv(m.second)) { if (!can_override) @@ -898,7 +898,7 @@ class CSMode : public Module for (int i = 0; i < conf->CountBlock("command"); ++i) { Configuration::Block *block = conf->GetBlock("command", i); - + const Anope::string &cname = block->Get<const Anope::string>("name"), &cmd = block->Get<const Anope::string>("command"); @@ -907,7 +907,7 @@ class CSMode : public Module const Anope::string &set = block->Get<const Anope::string>("set"), &unset = block->Get<const Anope::string>("unset"); - + if (set.empty() && unset.empty()) continue; @@ -952,7 +952,7 @@ class CSMode : public Module if (c->HasMode(cm->name)) c->RemoveMode(NULL, cm, "", false); } - + } else if (cm->type == MODE_LIST || cm->type == MODE_STATUS) { @@ -964,7 +964,7 @@ class CSMode : public Module } } - void OnCreateChan(ChannelInfo *ci) override + void OnCreateChan(ChanServ::Channel *ci) override { ModeLocks *ml = modelocks.Require(ci); Anope::string mlock; @@ -990,7 +990,7 @@ class CSMode : public Module ml->Check(); } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_hidden) override { if (!show_hidden) return; diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index 7b2899939..4e584b51c 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -27,9 +27,9 @@ class CommandCSRegister : public Command unsigned maxregistered = Config->GetModule("chanserv")->Get<unsigned>("maxregistered"); User *u = source.GetUser(); - NickCore *nc = source.nc; + NickServ::Account *nc = source.nc; Channel *c = Channel::Find(params[0]); - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (Anope::ReadOnly) source.Reply(_("Sorry, channel registration is temporarily disabled.")); @@ -51,7 +51,9 @@ class CommandCSRegister : public Command source.Reply(nc->channelcount > maxregistered ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, maxregistered); else { - ci = new ChannelInfo(chan); + if (!ChanServ::service) + return; + ci = ChanServ::service->Create(chan); ci->SetFounder(nc); ci->desc = chdesc; diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 595b999c9..873457b3a 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -58,7 +58,7 @@ struct SeenInfo : Serializable static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { Anope::string snick; - + data["nick"] >> snick; SeenInfo *s; @@ -99,7 +99,7 @@ static SeenInfo *FindInfo(const Anope::string &nick) static bool ShouldHide(const Anope::string &channel, User *u) { Channel *targetchan = Channel::Find(channel); - const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : ChannelInfo::Find(channel); + const ChanServ::Channel *targetchan_ci = targetchan ? *targetchan->ci : ChanServ::Find(channel); if (targetchan && targetchan->HasMode("SECRET")) return true; @@ -202,7 +202,7 @@ class CommandSeen : public Command return; } - NickAlias *na = NickAlias::Find(params[0]); + NickServ::Nick *na = NickServ::FindNick(params[0]); if (!na) { source.Reply(_("I don't know who %s is."), params[0].c_str()); @@ -235,11 +235,11 @@ class CommandSeen : public Command } } - AccessGroup ag = source.c->ci->AccessFor(na->nc); + ChanServ::AccessGroup ag = source.c->ci->AccessFor(na->nc); time_t last = 0; for (unsigned i = 0; i < ag.size(); ++i) { - ChanAccess *a = ag[i]; + ChanServ::ChanAccess *a = ag[i]; if (*a->nc == na->nc && a->last_seen > last) last = a->last_seen; @@ -378,7 +378,7 @@ class CSSeen : public Module Serialize::Type seeninfo_type; CommandSeen commandseen; CommandOSSeen commandosseen; - + public: CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) , EventHook<Event::ExpireTick>("OnExpireTick") @@ -446,9 +446,10 @@ class CSSeen : public Module UpdateUser(u, PART, u->nick, "", channel, msg); } - void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) override + EventReturn OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) override { UpdateUser(cu->user, KICK, cu->user->nick, source.GetSource(), cu->chan->name, msg); + return EVENT_CONTINUE; } private: diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 4cef222a4..21969833d 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -83,7 +83,7 @@ class CommandCSSetAutoOp : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -145,7 +145,7 @@ class CommandCSSetBanType : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -212,7 +212,7 @@ class CommandCSSetDescription : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (ci == NULL) { @@ -274,7 +274,7 @@ class CommandCSSetFounder : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -292,14 +292,14 @@ class CommandCSSetFounder : public Command return; } - const NickAlias *na = NickAlias::Find(params[1]); + const NickServ::Nick *na = NickServ::FindNick(params[1]); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; unsigned max_reg = Config->GetModule("chanserv")->Get<unsigned>("maxregistered"); if (max_reg && nc->channelcount >= max_reg && !source.HasPriv("chanserv/no-register-limit")) { @@ -343,7 +343,7 @@ class CommandCSSetKeepModes : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -408,7 +408,7 @@ class CommandCSSetPeace : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -480,7 +480,7 @@ class CommandCSSetPersist : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -643,7 +643,7 @@ class CommandCSSetRestricted : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -705,7 +705,7 @@ class CommandCSSetSecure : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -769,7 +769,7 @@ class CommandCSSetSecureFounder : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -833,7 +833,7 @@ class CommandCSSetSecureOps : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -895,7 +895,7 @@ class CommandCSSetSignKick : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -972,7 +972,7 @@ class CommandCSSetSuccessor : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (ci == NULL) { @@ -991,11 +991,11 @@ class CommandCSSetSuccessor : public Command return; } - NickCore *nc; + NickServ::Account *nc; if (!param.empty()) { - const NickAlias *na = NickAlias::Find(param); + const NickServ::Nick *na = NickServ::FindNick(param); if (!na) { @@ -1058,7 +1058,7 @@ class CommandCSSetNoexpire : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -1124,10 +1124,10 @@ class CSSet : public Module { SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data); - if (s->GetSerializableType()->GetName() != "ChannelInfo") + if (s->GetSerializableType()->GetName() != "ChanServ::Channel") return; - const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(s); + const ChanServ::Channel *ci = anope_dynamic_static_cast<const ChanServ::Channel *>(s); Anope::string modes; for (Channel::ModeList::const_iterator it = ci->last_modes.begin(); it != ci->last_modes.end(); ++it) { @@ -1144,10 +1144,10 @@ class CSSet : public Module { SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data); - if (s->GetSerializableType()->GetName() != "ChannelInfo") + if (s->GetSerializableType()->GetName() != "ChanServ::Channel") return; - ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(s); + ChanServ::Channel *ci = anope_dynamic_static_cast<ChanServ::Channel *>(s); Anope::string modes; data["last_modes"] >> modes; for (spacesepstream sep(modes); sep.GetToken(modes);) @@ -1169,10 +1169,10 @@ class CSSet : public Module { SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data); - if (s->GetSerializableType()->GetName() != "ChannelInfo" || !this->HasExt(e)) + if (s->GetSerializableType()->GetName() != "ChanServ::Channel" || !this->HasExt(e)) return; - ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(s); + ChanServ::Channel *ci = anope_dynamic_static_cast<ChanServ::Channel *>(s); if (ci->c) return; @@ -1272,7 +1272,7 @@ class CSSet : public Module persist_lower_ts = conf->GetModule(this)->Get<bool>("persist_lower_ts"); } - void OnCreateChan(ChannelInfo *ci) override + void OnCreateChan(ChanServ::Channel *ci) override { ci->bantype = Config->GetModule(this)->Get<int>("defbantype", "2"); } @@ -1303,7 +1303,7 @@ class CSSet : public Module return EVENT_CONTINUE; } - void OnDelChan(ChannelInfo *ci) override + void OnDelChan(ChanServ::Channel *ci) override { if (ci->c && persist.HasExt(ci)) ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false); @@ -1357,11 +1357,11 @@ class CSSet : public Module } } - void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override + void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override { if (chan->ci) { - if (noautoop.HasExt(chan->ci)) + if (noautoop.HasExt(chan->ci)) give_modes = false; if (secureops.HasExt(chan->ci)) // This overrides what chanserv does because it is loaded after chanserv @@ -1369,13 +1369,13 @@ class CSSet : public Module } } - void OnPreChanExpire(ChannelInfo *ci, bool &expire) override + void OnPreChanExpire(ChanServ::Channel *ci, bool &expire) override { if (noexpire.HasExt(ci)) expire = false; } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override { if (!show_all) return; diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 3d8dbb0dd..783dae8d7 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -36,7 +36,7 @@ struct CSMiscData : MiscData, Serializable { CSMiscData(Extensible *obj) : Serializable("CSMiscData") { } - CSMiscData(ChannelInfo *c, const Anope::string &n, const Anope::string &d) : Serializable("CSMiscData") + CSMiscData(ChanServ::Channel *c, const Anope::string &n, const Anope::string &d) : Serializable("CSMiscData") { object = c->name; name = n; @@ -58,7 +58,7 @@ struct CSMiscData : MiscData, Serializable data["name"] >> sname; data["data"] >> sdata; - ChannelInfo *ci = ChannelInfo::Find(sci); + ChanServ::Channel *ci = ChanServ::Find(sci); if (ci == NULL) return NULL; @@ -105,7 +105,7 @@ class CommandCSSetMisc : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (ci == NULL) { @@ -206,7 +206,7 @@ class CSSetMisc : public Module } } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool) override { for (Anope::map<ExtensibleItem<CSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it) { diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index bd707d537..7b7415fdb 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/cs_akick.h" class CommandCSStatus : public Command { @@ -24,7 +25,7 @@ public: { const Anope::string &channel = params[0]; - ChannelInfo *ci = ChannelInfo::Find(channel); + ChanServ::Channel *ci = ChanServ::Find(channel); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/auspex")) @@ -35,14 +36,14 @@ public: if (params.size() > 1) nick = params[1]; - AccessGroup ag; + ChanServ::AccessGroup ag; User *u = User::Find(nick, true); - NickAlias *na = NULL; + NickServ::Nick *na = NULL; if (u != NULL) ag = ci->AccessFor(u); else { - na = NickAlias::Find(nick); + na = NickServ::FindNick(nick); if (na != NULL) ag = ci->AccessFor(na->nc); } @@ -59,7 +60,7 @@ public: for (unsigned i = 0; i < ag.size(); ++i) { - ChanAccess *acc = ag[i]; + ChanServ::ChanAccess *acc = ag[i]; source.Reply(_("\002%s\002 matches access entry %s, which has privilege %s."), nick.c_str(), acc->mask.c_str(), acc->AccessSerialize().c_str()); } diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 7b604b250..411b141e6 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -38,7 +38,7 @@ struct CSSuspendInfo : SuspendInfo, Serializable si = anope_dynamic_static_cast<CSSuspendInfo *>(obj); else { - ChannelInfo *ci = ChannelInfo::Find(schan); + ChanServ::Channel *ci = ChanServ::Find(schan); if (!ci) return NULL; si = ci->Extend<CSSuspendInfo>("CS_SUSPENDED"); @@ -58,7 +58,7 @@ class CommandCSSuspend : public Command EventHandlers<Event::ChanSuspend> &onchansuspend; public: CommandCSSuspend(Module *creator, EventHandlers<Event::ChanSuspend> &event) : Command(creator, "chanserv/suspend", 2, 3), onchansuspend(event) - { + { this->SetDesc(_("Prevent a channel from being used preserving channel data and settings")); this->SetSyntax(_("\037channel\037 [+\037expiry\037] [\037reason\037]")); } @@ -89,7 +89,7 @@ class CommandCSSuspend : public Command if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -164,7 +164,7 @@ class CommandCSUnSuspend : public Command if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -226,7 +226,7 @@ class CSSuspend : public Module { } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_hidden) override { CSSuspendInfo *si = suspend.Get(ci); if (si) @@ -243,7 +243,7 @@ class CSSuspend : public Module } } - void OnPreChanExpire(ChannelInfo *ci, bool &expire) override + void OnPreChanExpire(ChanServ::Channel *ci, bool &expire) override { CSSuspendInfo *si = suspend.Get(ci); if (!si) @@ -272,7 +272,7 @@ class CSSuspend : public Module return EVENT_STOP; } - EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) override + EventReturn OnChanDrop(CommandSource &source, ChanServ::Channel *ci) override { CSSuspendInfo *si = suspend.Get(ci); if (si && !source.HasCommand("chanserv/drop")) diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index d26ff6a7a..20154c70a 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -22,7 +22,7 @@ class CommandCSSync : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -55,7 +55,7 @@ class CommandCSSync : public Command class CSSync : public Module { CommandCSSync commandcssync; - + public: CSSync(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) , commandcssync(this) diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index 2fd1b0a81..0c0e56696 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -31,7 +31,7 @@ class CommandCSSetKeepTopic : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -82,7 +82,7 @@ class CommandCSTopic : public Command { ExtensibleRef<bool> topiclock; - void Lock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void Lock(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { if (Anope::ReadOnly) { @@ -99,7 +99,7 @@ class CommandCSTopic : public Command source.Reply(_("Topic lock option for %s is now \002on\002."), ci->name.c_str()); } - void Unlock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void Unlock(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { if (Anope::ReadOnly) { @@ -116,7 +116,7 @@ class CommandCSTopic : public Command source.Reply(_("Topic lock option for %s is now \002off\002."), ci->name.c_str()); } - void Set(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void Set(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &topic = params.size() > 2 ? params[2] : ""; @@ -125,12 +125,12 @@ class CommandCSTopic : public Command ci->c->ChangeTopic(source.GetNick(), topic, Anope::CurTime); if (has_topiclock) topiclock->Set(ci); - + bool override = !source.AccessFor(ci).HasPriv("TOPIC"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); } - void Append(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void Append(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &topic = params[2]; @@ -165,7 +165,7 @@ class CommandCSTopic : public Command { const Anope::string &subcmd = params[1]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); else if (!source.AccessFor(ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) @@ -256,7 +256,7 @@ class CSTopic : public Module } } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override { if (keeptopic.HasExt(ci)) info.AddOption(_("Topic retention")); diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index f5e2a6460..a658c65dd 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -27,13 +27,13 @@ class CommandCSUnban : public Command if (!source.GetUser()) return; - std::deque<ChannelInfo *> queue; + std::deque<ChanServ::Channel *> queue; source.GetAccount()->GetChannelReferences(queue); unsigned count = 0; for (unsigned i = 0; i < queue.size(); ++i) { - ChannelInfo *ci = queue[i]; + ChanServ::Channel *ci = queue[i]; if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; @@ -48,7 +48,7 @@ class CommandCSUnban : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 282eb1479..bf94b9c2d 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -22,7 +22,7 @@ class CommandCSUp : public Command bool giving = true; /* whether or not we have given a mode */ bool given = false; - AccessGroup u_access = c->ci->AccessFor(u); + ChanServ::AccessGroup u_access = c->ci->AccessFor(u); for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) { @@ -160,7 +160,7 @@ class CommandCSDown : public Command const Anope::string &nick = params.size() > 1 ? params[1] : source.GetNick(); Channel *c = Channel::Find(channel); - + if (c == NULL) { source.Reply(CHAN_X_NOT_IN_USE, channel.c_str()); diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 84a8fbfb7..b2c554d71 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -17,12 +17,12 @@ namespace std::map<Anope::string, std::vector<Anope::string> > permissions; } -class XOPChanAccess : public ChanAccess +class XOPChanAccess : public ChanServ::ChanAccess { public: Anope::string type; - XOPChanAccess(AccessProvider *p) : ChanAccess(p) + XOPChanAccess(ChanServ::AccessProvider *p) : ChanAccess(p) { } @@ -47,7 +47,7 @@ class XOPChanAccess : public ChanAccess this->type = data; } - static Anope::string DetermineLevel(const ChanAccess *access) + static Anope::string DetermineLevel(const ChanServ::ChanAccess *access) { if (access->provider->name == "access/xop") { @@ -81,14 +81,14 @@ class XOPChanAccess : public ChanAccess } }; -class XOPAccessProvider : public AccessProvider +class XOPAccessProvider : public ChanServ::AccessProvider { public: XOPAccessProvider(Module *o) : AccessProvider(o, "access/xop") { } - ChanAccess *Create() override + ChanServ::ChanAccess *Create() override { return new XOPChanAccess(this); } @@ -97,7 +97,7 @@ class XOPAccessProvider : public AccessProvider class CommandCSXOP : public Command { private: - void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoAdd(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params.size() > 2 ? params[2] : ""; @@ -117,8 +117,8 @@ class CommandCSXOP : public Command tmp_access.ci = ci; tmp_access.type = source.command.upper(); - AccessGroup access = source.AccessFor(ci); - const ChanAccess *highest = access.Highest(); + ChanServ::AccessGroup access = source.AccessFor(ci); + const ChanServ::ChanAccess *highest = access.Highest(); bool override = false; std::vector<Anope::string>::iterator cmd_it = std::find(order.begin(), order.end(), source.command.upper()), @@ -143,7 +143,7 @@ class CommandCSXOP : public Command return; } - ChannelInfo *targ_ci = ChannelInfo::Find(mask); + ChanServ::Channel *targ_ci = ChanServ::Find(mask); if (targ_ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, mask.c_str()); @@ -159,7 +159,7 @@ class CommandCSXOP : public Command } else { - const NickAlias *na = NickAlias::Find(mask); + const NickServ::Nick *na = NickServ::FindNick(mask); if (!na && Config->GetModule("chanserv")->Get<bool>("disallow_hostmask_access")) { source.Reply(_("Masks and unregistered users may not be on access lists.")); @@ -180,7 +180,7 @@ class CommandCSXOP : public Command for (unsigned i = 0; i < ci->GetAccessCount(); ++i) { - const ChanAccess *a = ci->GetAccess(i); + const ChanServ::ChanAccess *a = ci->GetAccess(i); if (a->mask.equals_ci(mask)) { @@ -202,7 +202,7 @@ class CommandCSXOP : public Command return; } - ServiceReference<AccessProvider> provider("AccessProvider", "access/xop"); + ServiceReference<ChanServ::AccessProvider> provider("AccessProvider", "access/xop"); if (!provider) return; XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create()); @@ -220,9 +220,9 @@ class CommandCSXOP : public Command source.Reply(_("\002%s\002 added to %s %s list."), acc->mask.c_str(), ci->name.c_str(), source.command.c_str()); } - void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { - NickCore *nc = source.nc; + NickServ::Account *nc = source.nc; Anope::string mask = params.size() > 2 ? params[2] : ""; if (mask.empty()) @@ -247,11 +247,11 @@ class CommandCSXOP : public Command tmp_access.ci = ci; tmp_access.type = source.command.upper(); - AccessGroup access = source.AccessFor(ci); - const ChanAccess *highest = access.Highest(); + ChanServ::AccessGroup access = source.AccessFor(ci); + const ChanServ::ChanAccess *highest = access.Highest(); bool override = false; - if (!isdigit(mask[0]) && mask.find_first_of("#!*@") == Anope::string::npos && !NickAlias::Find(mask)) + if (!isdigit(mask[0]) && mask.find_first_of("#!*@") == Anope::string::npos && !NickServ::FindNick(mask)) { User *targ = User::Find(mask, true); if (targ != NULL) @@ -283,13 +283,13 @@ class CommandCSXOP : public Command class XOPDelCallback : public NumberList { CommandSource &source; - ChannelInfo *ci; + ChanServ::Channel *ci; Command *c; unsigned deleted; Anope::string nicks; bool override; public: - XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), override(_override) + XOPDelCallback(CommandSource &_source, ChanServ::Channel *_ci, Command *_c, bool _override, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), override(_override) { } @@ -313,7 +313,7 @@ class CommandCSXOP : public Command if (!number || number > ci->GetAccessCount()) return; - ChanAccess *caccess = ci->GetAccess(number - 1); + ChanServ::ChanAccess *caccess = ci->GetAccess(number - 1); if (caccess->provider->name != "access/xop" || this->source.command.upper() != caccess->AccessSerialize()) return; @@ -336,7 +336,7 @@ class CommandCSXOP : public Command { for (unsigned i = 0; i < ci->GetAccessCount(); ++i) { - ChanAccess *a = ci->GetAccess(i); + ChanServ::ChanAccess *a = ci->GetAccess(i); if (a->provider->name != "access/xop" || source.command.upper() != a->AccessSerialize()) continue; @@ -354,17 +354,17 @@ class CommandCSXOP : public Command return; } } - + source.Reply(_("\002%s\002 not found on %s %s list."), mask.c_str(), ci->name.c_str(), source.command.c_str()); } } - void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) + void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &nick = params.size() > 2 ? params[2] : ""; - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (!access.HasPriv("ACCESS_LIST") && !source.HasCommand("chanserv/access/list")) { @@ -386,10 +386,10 @@ class CommandCSXOP : public Command class XOPListCallback : public NumberList { ListFormatter &list; - ChannelInfo *ci; + ChanServ::Channel *ci; CommandSource &source; public: - XOPListCallback(ListFormatter &_list, ChannelInfo *_ci, const Anope::string &numlist, CommandSource &src) : NumberList(numlist, false), list(_list), ci(_ci), source(src) + XOPListCallback(ListFormatter &_list, ChanServ::Channel *_ci, const Anope::string &numlist, CommandSource &src) : NumberList(numlist, false), list(_list), ci(_ci), source(src) { } @@ -398,7 +398,7 @@ class CommandCSXOP : public Command if (!Number || Number > ci->GetAccessCount()) return; - const ChanAccess *a = ci->GetAccess(Number - 1); + const ChanServ::ChanAccess *a = ci->GetAccess(Number - 1); if (a->provider->name != "access/xop" || this->source.command.upper() != a->AccessSerialize()) return; @@ -415,7 +415,7 @@ class CommandCSXOP : public Command { for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { - const ChanAccess *a = ci->GetAccess(i); + const ChanServ::ChanAccess *a = ci->GetAccess(i); if (a->provider->name != "access/xop" || source.command.upper() != a->AccessSerialize()) continue; @@ -442,7 +442,7 @@ class CommandCSXOP : public Command } } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { if (Anope::ReadOnly) { @@ -467,11 +467,11 @@ class CommandCSXOP : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { - const ChanAccess *access = ci->GetAccess(i - 1); + const ChanServ::ChanAccess *access = ci->GetAccess(i - 1); if (access->provider->name != "access/xop" || source.command.upper() != access->AccessSerialize()) continue; - + delete ci->EraseAccess(i - 1); } @@ -496,7 +496,7 @@ class CommandCSXOP : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -611,7 +611,7 @@ class CSXOP : public Module Configuration::Block *block = conf->GetBlock("privilege", i); const Anope::string &pname = block->Get<const Anope::string>("name"); - Privilege *p = PrivilegeManager::FindPrivilege(pname); + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(pname) : nullptr; if (p == NULL) continue; diff --git a/modules/commands/greet.cpp b/modules/commands/greet.cpp index cacda2d3c..e35ba5b19 100644 --- a/modules/commands/greet.cpp +++ b/modules/commands/greet.cpp @@ -25,7 +25,7 @@ class CommandBSSetGreet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string &value = params[1]; if (ci == NULL) @@ -49,7 +49,7 @@ class CommandBSSetGreet : public Command if (value.equals_ci("ON")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets"; ci->Extend<bool>("BS_GREET"); source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str()); @@ -57,7 +57,7 @@ class CommandBSSetGreet : public Command else if (value.equals_ci("OFF")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable greets"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable greets"; ci->Shrink<bool>("BS_GREET"); source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str()); @@ -95,13 +95,13 @@ class CommandNSSetGreet : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) @@ -208,14 +208,14 @@ class Greet : public Module } } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { Anope::string *greet = ns_greet.Get(na->nc); if (greet != NULL) info[_("Greet")] = *greet; } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChanServ::Channel *ci, InfoFormatter &info) override { if (bs_greet.HasExt(ci)) info.AddOption(_("Greet")); diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index c23454c25..ba743f661 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -42,7 +42,7 @@ class CommandHelp : public Command EventReturn MOD_RESULT = this->onhelp(&Event::Help::OnPreHelp, source, params); if (MOD_RESULT == EVENT_STOP) return; - + Anope::string source_command = source.command; const BotInfo *bi = source.service; const CommandInfo::map &map = source.c ? Config->Fantasy : bi->commands; @@ -151,7 +151,7 @@ class CommandHelp : public Command if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission)) continue; - + // Allow unregistered users to see help for commands that they explicitly request help for const Anope::string &subcommand = params.size() > max ? params[max] : ""; @@ -185,7 +185,7 @@ class CommandHelp : public Command if (helped == false) source.Reply(_("No help available for \002%s\002."), params[0].c_str()); } - + this->onhelp(&Event::Help::OnPostHelp, source, params); } }; diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index ae0e2e6c2..d527c772b 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -32,7 +32,7 @@ class CommandHSDel : public Command } const Anope::string &nick = params[0]; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (na) { Log(LOG_ADMIN, source, this) << "for user " << na->nick; @@ -74,11 +74,11 @@ class CommandHSDelAll : public Command } const Anope::string &nick = params[0]; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (na) { this->ondeletevhost(&Event::DeleteVhost::OnDeleteVhost, na); - const NickCore *nc = na->nc; + const NickServ::Account *nc = na->nc; for (unsigned i = 0; i < nc->aliases->size(); ++i) { na = nc->aliases->at(i); diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index eb1c6d299..47e4c03de 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -17,7 +17,7 @@ class CommandHSGroup : public Command bool setting; public: - void Sync(const NickAlias *na) + void Sync(const NickServ::Nick *na) { if (setting) return; @@ -25,10 +25,10 @@ class CommandHSGroup : public Command if (!na || !na->HasVhost()) return; - setting = true; + setting = true; for (unsigned i = 0; i < na->nc->aliases->size(); ++i) { - NickAlias *nick = na->nc->aliases->at(i); + NickServ::Nick *nick = na->nc->aliases->at(i); if (nick) { nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); @@ -51,7 +51,7 @@ class CommandHSGroup : public Command return; } - NickAlias *na = NickAlias::Find(source.GetNick()); + NickServ::Nick *na = NickServ::FindNick(source.GetNick()); if (na && source.GetAccount() == na->nc && na->HasVhost()) { this->Sync(na); @@ -93,7 +93,7 @@ class HSGroup : public Module { } - void OnSetVhost(NickAlias *na) override + void OnSetVhost(NickServ::Nick *na) override { if (!synconset) return; @@ -101,7 +101,7 @@ class HSGroup : public Module commandhsgroup.Sync(na); } - void OnNickGroup(User *u, NickAlias *na) override + void OnNickGroup(User *u, NickServ::Nick *na) override { if (!syncongroup) return; diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index b5b8aa76a..f662ebbf1 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -57,9 +57,9 @@ class CommandHSList : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Number")).AddColumn(_("Nick")).AddColumn(_("Vhost")).AddColumn(_("Creator")).AddColumn(_("Created")); - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetNickList()) { - const NickAlias *na = it->second; + const NickServ::Nick *na = it.second; if (!na->HasVhost()) continue; diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index c0d51f884..4923d390d 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -23,7 +23,7 @@ class CommandHSOff : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); - const NickAlias *na = NickAlias::Find(u->nick); + const NickServ::Nick *na = NickServ::FindNick(u->nick); if (!na || !na->HasVhost()) source.Reply(HOST_NOT_ASSIGNED); diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index 4b92bf0be..7331dd355 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -26,7 +26,7 @@ class CommandHSOn : public Command return; // HostServ wouldn't even be loaded at this point User *u = source.GetUser(); - const NickAlias *na = NickAlias::Find(u->nick); + const NickServ::Nick *na = NickServ::FindNick(u->nick); if (na && u->Account() == na->nc && na->HasVhost()) { if (!na->GetVhostIdent().empty()) diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 1e5c98e31..119cc5a6d 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -42,7 +42,7 @@ struct HostRequest : Serializable Anope::string snick; data["nick"] >> snick; - NickAlias *na = NickAlias::Find(snick); + NickServ::Nick *na = NickServ::FindNick(snick); if (na == NULL) return NULL; @@ -88,7 +88,7 @@ class CommandHSRequest : public Command } User *u = source.GetUser(); - NickAlias *na = NickAlias::Find(source.GetNick()); + NickServ::Nick *na = NickServ::FindNick(source.GetNick()); if (!na || na->nc != source.GetAccount()) { source.Reply(ACCESS_DENIED); @@ -96,7 +96,7 @@ class CommandHSRequest : public Command } Anope::string rawhostmask = params[0]; - + Anope::string user, host; size_t a = rawhostmask.find('@'); @@ -196,7 +196,7 @@ class CommandHSActivate : public Command const Anope::string &nick = params[0]; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL; if (req) { @@ -246,7 +246,7 @@ class CommandHSReject : public Command const Anope::string &nick = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL; if (req) { @@ -298,9 +298,9 @@ class CommandHSWaiting : public Command list.AddColumn(_("Number")).AddColumn(_("Nick")).AddColumn(_("Vhost")).AddColumn(_("Created")); - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetNickList()) { - const NickAlias *na = it->second; + const NickServ::Nick *na = it.second; HostRequest *hr = na->GetExt<HostRequest>("hostrequest"); if (!hr) continue; @@ -311,7 +311,7 @@ class CommandHSWaiting : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(display_counter); - entry["Nick"] = it->first; + entry["Nick"] = na->nick; if (!hr->ident.empty()) entry["Vhost"] = hr->ident + "@" + hr->host; else @@ -379,8 +379,8 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin for (unsigned i = 0; i < Oper::opers.size(); ++i) { Oper *o = Oper::opers[i]; - - const NickAlias *na = NickAlias::Find(o->name); + + const NickServ::Nick *na = NickServ::FindNick(o->name); if (!na) continue; diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 69281b6ec..614bfc2e9 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -30,7 +30,7 @@ class CommandHSSet : public Command const Anope::string &nick = params[0]; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -106,14 +106,14 @@ class CommandHSSet : public Command class CommandHSSetAll : public Command { - void Sync(const NickAlias *na) + void Sync(const NickServ::Nick *na) { if (!na || !na->HasVhost()) return; - + for (unsigned i = 0; i < na->nc->aliases->size(); ++i) { - NickAlias *nick = na->nc->aliases->at(i); + NickServ::Nick *nick = na->nc->aliases->at(i); if (nick) nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); } @@ -136,7 +136,7 @@ class CommandHSSetAll : public Command Anope::string nick = params[0]; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index 09746d0f2..0de3ae0ea 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -23,7 +23,7 @@ class CommandMSCancel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - if (Anope::ReadOnly) + if (Anope::ReadOnly || !MemoServ::service) { source.Reply(READ_ONLY_MODE); return; @@ -31,32 +31,32 @@ class CommandMSCancel : public Command const Anope::string &nname = params[0]; - bool ischan; - MemoInfo *mi = MemoInfo::GetMemoInfo(nname, ischan); + bool ischan, isregistered; + MemoServ::MemoInfo *mi = MemoServ::service->GetMemoInfo(name, ischan, isregistered, false); - if (mi == NULL) + if (!isregistered) source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), nname.c_str()); else { - ChannelInfo *ci = NULL; - NickAlias *na = NULL; + ChanServ::Channel *ci = NULL; + NickServ::Nick *na = NULL; if (ischan) - ci = ChannelInfo::Find(nname); + ci = ChanServ::Find(nname); else - na = NickAlias::Find(nname); - for (int i = mi->memos->size() - 1; i >= 0; --i) - if (mi->GetMemo(i)->unread && source.nc->display.equals_ci(mi->GetMemo(i)->sender)) - { - if (MemoServ::Event::OnMemoDel) - MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ischan ? ci->name : na->nc->display, mi, mi->GetMemo(i)); - mi->Del(i); - source.Reply(_("Last memo to \002%s\002 has been cancelled."), nname.c_str()); - return; - } + na = NickServ::FindNick(nname); + if (mi) + for (int i = mi->memos->size() - 1; i >= 0; --i) + if (mi->GetMemo(i)->unread && source.nc->display.equals_ci(mi->GetMemo(i)->sender)) + { + if (MemoServ::Event::OnMemoDel) + MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ischan ? ci->name : na->nc->display, mi, mi->GetMemo(i)); + mi->Del(i); + source.Reply(_("Last memo to \002%s\002 has been cancelled."), nname.c_str()); + return; + } source.Reply(_("No memo was cancelable.")); } - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index a534aaca3..f20724a45 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -27,34 +27,35 @@ class CommandMSCheck : public Command bool found = false; - const NickAlias *na = NickAlias::Find(recipient); + const NickServ::Nick *na = NickServ::FindNick(recipient); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, recipient.c_str()); return; } - MemoInfo *mi = &na->nc->memos; + MemoServ::MemoInfo *mi = na->nc->memos; /* Okay, I know this looks strange but we wanna get the LAST memo, so we have to loop backwards */ - for (unsigned i = mi->memos->size(); i > 0; --i) - { - Memo *m = mi->GetMemo(i - 1); - NickAlias *na2 = NickAlias::Find(m->sender); - - if (na2 != NULL && na2->nc == source.GetAccount()) + if (mi) + for (unsigned i = mi->memos->size(); i > 0; --i) { - found = true; /* Yes, we've found the memo */ - - if (m->unread) - source.Reply(_("The last memo you sent to %s (sent on %s) has not yet been read."), na->nick.c_str(), Anope::strftime(m->time, source.GetAccount()).c_str()); - else - source.Reply(_("The last memo you sent to %s (sent on %s) has been read."), na->nick.c_str(), Anope::strftime(m->time, source.GetAccount()).c_str()); - break; + MemoServ::Memo *m = mi->GetMemo(i - 1); + NickServ::Nick *na2 = NickServ::FindNick(m->sender); + + if (na2 != NULL && na2->nc == source.GetAccount()) + { + found = true; /* Yes, we've found the memo */ + + if (m->unread) + source.Reply(_("The last memo you sent to %s (sent on %s) has not yet been read."), na->nick.c_str(), Anope::strftime(m->time, source.GetAccount()).c_str()); + else + source.Reply(_("The last memo you sent to %s (sent on %s) has been read."), na->nick.c_str(), Anope::strftime(m->time, source.GetAccount()).c_str()); + break; + } } - } if (!found) source.Reply(_("Nick %s doesn't have a memo from you."), na->nick.c_str()); diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index e1d329921..9089dd6a1 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -15,10 +15,10 @@ class MemoDelCallback : public NumberList { CommandSource &source; - ChannelInfo *ci; - MemoInfo *mi; + ChanServ::Channel *ci; + MemoServ::MemoInfo *mi; public: - MemoDelCallback(CommandSource &_source, ChannelInfo *_ci, MemoInfo *_mi, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), mi(_mi) + MemoDelCallback(CommandSource &_source, ChanServ::Channel *_ci, MemoServ::MemoInfo *_mi, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), mi(_mi) { } @@ -52,8 +52,8 @@ class CommandMSDel : public Command return; } - MemoInfo *mi; - ChannelInfo *ci = NULL; + MemoServ::MemoInfo *mi; + ChanServ::Channel *ci = NULL; Anope::string numstr = !params.empty() ? params[0] : "", chan; if (!numstr.empty() && numstr[0] == '#') @@ -61,7 +61,7 @@ class CommandMSDel : public Command chan = numstr; numstr = params.size() > 1 ? params[1] : ""; - ci = ChannelInfo::Find(chan); + ci = ChanServ::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -72,13 +72,13 @@ class CommandMSDel : public Command source.Reply(ACCESS_DENIED); return; } - mi = &ci->memos; + mi = ci->memos; } else - mi = &source.nc->memos; + mi = source.nc->memos; if (numstr.empty() || (!isdigit(numstr[0]) && !numstr.equals_ci("ALL") && !numstr.equals_ci("LAST"))) this->OnSyntaxError(source, numstr); - else if (mi->memos->empty()) + else if (!mi || mi->memos->empty()) { if (!chan.empty()) source.Reply(MEMO_X_HAS_NO_MEMOS, chan.c_str()); diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index f73a27930..98b4a2f9e 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -29,6 +29,8 @@ class CommandMSIgnore : public Command source.Reply(READ_ONLY_MODE); return; } + if (!MemoServ::service) + return; Anope::string channel = params[0]; Anope::string command = (params.size() > 1 ? params[1] : ""); @@ -41,10 +43,10 @@ class CommandMSIgnore : public Command channel = source.GetNick(); } - bool ischan; - MemoInfo *mi = MemoInfo::GetMemoInfo(channel, ischan); - ChannelInfo *ci = ChannelInfo::Find(channel); - if (!mi) + bool ischan, isregistered; + MemoServ::MemoInfo *mi = MemoServ::service->GetMemoInfo(channel, ischan, isregistered, true); + ChanServ::Channel *ci = ChanServ::Find(channel); + if (!isregistered) source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), channel.c_str()); else if (ischan && !source.AccessFor(ci).HasPriv("MEMO")) source.Reply(ACCESS_DENIED); diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index 0e7506765..9544be3c7 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -22,27 +22,27 @@ class CommandMSInfo : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - NickCore *nc = source.nc; - const MemoInfo *mi; - const NickAlias *na = NULL; - ChannelInfo *ci = NULL; + NickServ::Account *nc = source.nc; + const MemoServ::MemoInfo *mi; + const NickServ::Nick *na = NULL; + ChanServ::Channel *ci = NULL; const Anope::string &nname = !params.empty() ? params[0] : ""; bool hardmax; if (!nname.empty() && nname[0] != '#' && source.HasPriv("memoserv/info")) { - na = NickAlias::Find(nname); + na = NickServ::FindNick(nname); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nname.c_str()); return; } - mi = &na->nc->memos; + mi = na->nc->memos; hardmax = na->nc->HasExt("MEMO_HARDMAX"); } else if (!nname.empty() && nname[0] == '#') { - ci = ChannelInfo::Find(nname); + ci = ChanServ::Find(nname); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, nname.c_str()); @@ -53,7 +53,7 @@ class CommandMSInfo : public Command source.Reply(ACCESS_DENIED); return; } - mi = &ci->memos; + mi = ci->memos; hardmax = ci->HasExt("MEMO_HARDMAX"); } else if (!nname.empty()) /* It's not a chan and we aren't services admin */ @@ -63,9 +63,11 @@ class CommandMSInfo : public Command } else { - mi = &nc->memos; + mi = nc->memos; hardmax = nc->HasExt("MEMO_HARDMAX"); } + if (!mi) + return; if (!nname.empty() && (ci || na->nc != nc)) { diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index e5ca96770..758bb08be 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -24,15 +24,15 @@ class CommandMSList : public Command { Anope::string param = !params.empty() ? params[0] : "", chan; - ChannelInfo *ci = NULL; - const MemoInfo *mi; + ChanServ::Channel *ci = NULL; + const MemoServ::MemoInfo *mi; if (!param.empty() && param[0] == '#') { chan = param; param = params.size() > 1 ? params[1] : ""; - ci = ChannelInfo::Find(chan); + ci = ChanServ::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -43,10 +43,10 @@ class CommandMSList : public Command source.Reply(ACCESS_DENIED); return; } - mi = &ci->memos; + mi = ci->memos; } else - mi = &source.nc->memos; + mi = source.nc->memos; if (!param.empty() && !isdigit(param[0]) && !param.equals_ci("NEW")) this->OnSyntaxError(source, param); @@ -69,9 +69,9 @@ class CommandMSList : public Command { ListFormatter &list; CommandSource &source; - const MemoInfo *mi; + const MemoServ::MemoInfo *mi; public: - MemoListCallback(ListFormatter &_list, CommandSource &_source, const MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), list(_list), source(_source), mi(_mi) + MemoListCallback(ListFormatter &_list, CommandSource &_source, const MemoServ::MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), list(_list), source(_source), mi(_mi) { } @@ -80,7 +80,7 @@ class CommandMSList : public Command if (!number || number > mi->memos->size()) return; - const Memo *m = mi->GetMemo(number - 1); + const MemoServ::Memo *m = mi->GetMemo(number - 1); ListFormatter::ListEntry entry; entry["Number"] = (m->unread ? "* " : " ") + stringify(number); @@ -115,7 +115,7 @@ class CommandMSList : public Command if (!param.empty() && !mi->GetMemo(i)->unread) continue; - const Memo *m = mi->GetMemo(i); + const MemoServ::Memo *m = mi->GetMemo(i); ListFormatter::ListEntry entry; entry["Number"] = (m->unread ? "* " : " ") + stringify(i + 1); diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index ba5eda863..32852a29f 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -12,19 +12,19 @@ #include "module.h" #include "modules/memoserv.h" -static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ) +static void rsend_notify(CommandSource &source, MemoServ::MemoInfo *mi, MemoServ::Memo *m, const Anope::string &targ) { /* Only send receipt if memos are allowed */ if (MemoServ::service && !Anope::ReadOnly) { /* Get nick alias for sender */ - const NickAlias *na = NickAlias::Find(m->sender); + const NickServ::Nick *na = NickServ::FindNick(m->sender); if (!na) return; /* Get nick core for sender */ - const NickCore *nc = na->nc; + const NickServ::Account *nc = na->nc; if (!nc) return; @@ -49,10 +49,10 @@ static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Ano class MemoListCallback : public NumberList { CommandSource &source; - MemoInfo *mi; - const ChannelInfo *ci; + MemoServ::MemoInfo *mi; + const ChanServ::Channel *ci; public: - MemoListCallback(CommandSource &_source, MemoInfo *_mi, const ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), source(_source), mi(_mi), ci(_ci) + MemoListCallback(CommandSource &_source, MemoServ::MemoInfo *_mi, const ChanServ::Channel *_ci, const Anope::string &numlist) : NumberList(numlist, false), source(_source), mi(_mi), ci(_ci) { } @@ -64,12 +64,12 @@ class MemoListCallback : public NumberList MemoListCallback::DoRead(source, mi, ci, number - 1); } - static void DoRead(CommandSource &source, MemoInfo *mi, const ChannelInfo *ci, unsigned index) + static void DoRead(CommandSource &source, MemoServ::MemoInfo *mi, const ChanServ::Channel *ci, unsigned index) { - Memo *m = mi->GetMemo(index); + MemoServ::Memo *m = mi->GetMemo(index); if (!m) return; - + if (ci) source.Reply(_("Memo %d from %s (%s)."), index + 1, m->sender.c_str(), Anope::strftime(m->time, source.GetAccount()).c_str()); else @@ -106,8 +106,8 @@ class CommandMSRead : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - MemoInfo *mi; - ChannelInfo *ci = NULL; + MemoServ::MemoInfo *mi; + ChanServ::Channel *ci = NULL; Anope::string numstr = params[0], chan; if (!numstr.empty() && numstr[0] == '#') @@ -115,7 +115,7 @@ class CommandMSRead : public Command chan = numstr; numstr = params.size() > 1 ? params[1] : ""; - ci = ChannelInfo::Find(chan); + ci = ChanServ::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -126,10 +126,10 @@ class CommandMSRead : public Command source.Reply(ACCESS_DENIED); return; } - mi = &ci->memos; + mi = ci->memos; } else - mi = &source.nc->memos; + mi = source.nc->memos; if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.is_number_only())) this->OnSyntaxError(source, numstr); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index 4cdeb132b..98315845c 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -34,10 +34,10 @@ class CommandMSRSend : public Command const Anope::string &nick = params[0]; const Anope::string &text = params[1]; - const NickAlias *na = NULL; + const NickServ::Nick *na = NULL; /* prevent user from rsend to themselves */ - if ((na = NickAlias::Find(nick)) && na->nc == source.GetAccount()) + if ((na = NickServ::FindNick(nick)) && na->nc == source.GetAccount()) { source.Reply(_("You can not request a receipt when sending a memo to yourself.")); return; @@ -54,15 +54,15 @@ class CommandMSRSend : public Command source.Reply(_("Please wait %d seconds before using the %s command again."), Config->GetModule("memoserv")->Get<time_t>("senddelay"), source.command.c_str()); else if (result == MemoServ::MemoServService::MEMO_TARGET_FULL) source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str()); - else + else { source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); - bool ischan; - MemoInfo *mi = MemoInfo::GetMemoInfo(nick, ischan); + bool ischan, isregistered; + MemoServ::MemoInfo *mi = MemoServ::service->GetMemoInfo(nick, ischan, isregistered, false); if (mi == NULL) throw CoreException("NULL mi in ms_rsend"); - Memo *m = (mi->memos->size() ? mi->GetMemo(mi->memos->size() - 1) : NULL); + MemoServ::Memo *m = (mi->memos->size() ? mi->GetMemo(mi->memos->size() - 1) : NULL); if (m != NULL) m->receipt = true; } diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index c567b0ed3..a1c545ec2 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -30,9 +30,9 @@ class CommandMSSendAll : public Command Log(LOG_ADMIN, source, this) << "to send " << text; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetAccountList()) { - const NickCore *nc = it->second; + const NickServ::Account *nc = it.second; if (nc != source.nc) MemoServ::service->Send(source.GetNick(), nc->display, text); diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index 5e5591471..47acb177d 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -14,10 +14,10 @@ class CommandMSSet : public Command { private: - void DoNotify(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoInfo *mi) + void DoNotify(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoServ::MemoInfo *mi) { const Anope::string ¶m = params[1]; - NickCore *nc = source.nc; + NickServ::Account *nc = source.nc; BotInfo *MemoServ = Config->GetClient("MemoServ"); if (!MemoServ) @@ -67,7 +67,7 @@ class CommandMSSet : public Command this->OnSyntaxError(source, ""); } - void DoLimit(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoInfo *mi) + void DoLimit(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoServ::MemoInfo *mi) { Anope::string p1 = params[1]; @@ -75,8 +75,8 @@ class CommandMSSet : public Command Anope::string p3 = params.size() > 3 ? params[3] : ""; Anope::string user, chan; int16_t limit; - NickCore *nc = source.nc; - ChannelInfo *ci = NULL; + NickServ::Account *nc = source.nc; + ChanServ::Channel *ci = NULL; bool is_servadmin = source.HasPriv("memoserv/set-limit"); if (p1[0] == '#') @@ -86,7 +86,7 @@ class CommandMSSet : public Command p2 = p3; p3 = params.size() > 4 ? params[4] : ""; - ci = ChannelInfo::Find(chan); + ci = ChanServ::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -97,20 +97,20 @@ class CommandMSSet : public Command source.Reply(ACCESS_DENIED); return; } - mi = &ci->memos; + mi = ci->memos; } if (is_servadmin) { if (!p2.empty() && !p2.equals_ci("HARD") && chan.empty()) { - const NickAlias *na; - if (!(na = NickAlias::Find(p1))) + const NickServ::Nick *na; + if (!(na = NickServ::FindNick(p1))) { source.Reply(NICK_X_NOT_REGISTERED, p1.c_str()); return; } user = p1; - mi = &na->nc->memos; + mi = na->nc->memos; nc = na->nc; p1 = p2; p2 = p3; @@ -210,7 +210,7 @@ class CommandMSSet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &cmd = params[0]; - MemoInfo *mi = &source.nc->memos; + MemoServ::MemoInfo *mi = source.nc->memos; if (Anope::ReadOnly) source.Reply(_("Sorry, memo option setting is temporarily disabled.")); @@ -219,11 +219,7 @@ class CommandMSSet : public Command else if (cmd.equals_ci("LIMIT")) return this->DoLimit(source, params, mi); else - { this->OnSyntaxError(source, ""); - } - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index 125ef60fc..7e33b76b3 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -28,9 +28,9 @@ class CommandMSStaff : public Command const Anope::string &text = params[0]; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetAccountList()) { - const NickCore *nc = it->second; + const NickServ::Account *nc = it.second; if (source.nc != nc && nc->IsServicesOper()) MemoServ::service->Send(source.GetNick(), nc->display, text, true); diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 1df0bbe0e..e15f2abfd 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -15,7 +15,7 @@ class CommandNSAccess : public Command { private: - void DoAdd(CommandSource &source, NickCore *nc, const Anope::string &mask) + void DoAdd(CommandSource &source, NickServ::Account *nc, const Anope::string &mask) { if (mask.empty()) { @@ -48,7 +48,7 @@ class CommandNSAccess : public Command return; } - void DoDel(CommandSource &source, NickCore *nc, const Anope::string &mask) + void DoDel(CommandSource &source, NickServ::Account *nc, const Anope::string &mask) { if (mask.empty()) { @@ -75,7 +75,7 @@ class CommandNSAccess : public Command return; } - void DoList(CommandSource &source, NickCore *nc, const Anope::string &mask) + void DoList(CommandSource &source, NickServ::Account *nc, const Anope::string &mask) { unsigned i, end; @@ -118,10 +118,10 @@ class CommandNSAccess : public Command mask = params.size() > 1 ? params[params.size() - 1] : ""; } - NickCore *nc; + NickServ::Account *nc; if (!nick.empty()) { - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -199,7 +199,7 @@ class NSAccess : public Module { } - void OnNickRegister(User *u, NickAlias *na) override + void OnNickRegister(User *u, NickServ::Nick *na) override { if (u && Config->GetModule(this)->Get<bool>("addaccessonreg")) na->nc->AddAccess(u->Mask()); diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index 0967dbf61..834607028 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -21,7 +21,7 @@ struct AJoinList : Serialize::Checker<std::vector<AJoinEntry *> > struct AJoinEntry : Serializable { - Serialize::Reference<NickCore> owner; + Serialize::Reference<NickServ::Account> owner; Anope::string channel; Anope::string key; @@ -54,7 +54,7 @@ struct AJoinEntry : Serializable sd["owner"] >> sowner; - NickCore *nc = NickCore::Find(sowner); + NickServ::Account *nc = NickServ::FindAccount(sowner); if (nc == NULL) return NULL; @@ -88,7 +88,7 @@ AJoinList::~AJoinList() class CommandNSAJoin : public Command { - void DoList(CommandSource &source, NickCore *nc) + void DoList(CommandSource &source, NickServ::Account *nc) { AJoinList *channels = nc->Require<AJoinList>("ajoinlist"); @@ -118,7 +118,7 @@ class CommandNSAJoin : public Command } } - void DoAdd(CommandSource &source, NickCore *nc, const Anope::string &chans, const Anope::string &keys) + void DoAdd(CommandSource &source, NickServ::Account *nc, const Anope::string &chans, const Anope::string &keys) { AJoinList *channels = nc->Require<AJoinList>("ajoinlist"); @@ -184,7 +184,7 @@ class CommandNSAJoin : public Command source.Reply(_("%s added to %s's auto join list."), addedchans.c_str(), nc->display.c_str()); } - void DoDel(CommandSource &source, NickCore *nc, const Anope::string &chans) + void DoDel(CommandSource &source, NickServ::Account *nc, const Anope::string &chans) { AJoinList *channels = nc->Require<AJoinList>("ajoinlist"); Anope::string delchans; @@ -197,7 +197,7 @@ class CommandNSAJoin : public Command for (; i < (*channels)->size(); ++i) if ((*channels)->at(i)->channel.equals_ci(chan)) break; - + if (i == (*channels)->size()) notfoundchans += chan + ", "; else @@ -243,10 +243,10 @@ class CommandNSAJoin : public Command else nick = (params.size() > 2 && IRCD->IsChannelValid(params[2])) ? params[1] : ""; - NickCore *nc; + NickServ::Account *nc; if (!nick.empty()) { - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -333,17 +333,17 @@ class NSAJoin : public Module { AJoinEntry *entry = (*channels)->at(i); Channel *c = Channel::Find(entry->channel); - ChannelInfo *ci; + ChanServ::Channel *ci; if (c) ci = c->ci; else - ci = ChannelInfo::Find(entry->channel); + ci = ChanServ::Find(entry->channel); bool need_invite = false; Anope::string key = entry->key; - AccessGroup u_access; - + ChanServ::AccessGroup u_access; + if (ci != NULL) { if (ci->HasExt("CS_SUSPENDED")) @@ -364,7 +364,7 @@ class NSAJoin : public Module need_invite = true; else if (c->HasMode("INVITE") && c->MatchesList(u, "INVITEOVERRIDE") == false) need_invite = true; - + if (c->HasMode("KEY")) { Anope::string k; diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index 54216b190..ff3b5d037 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -13,7 +13,7 @@ class CommandNSAList : public Command { - static bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2) + static bool ChannelSort(ChanServ::Channel *ci1, ChanServ::Channel *ci2) { return ci::less()(ci1->name, ci2->name); } @@ -28,12 +28,12 @@ class CommandNSAList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { Anope::string nick = source.GetNick(); - NickCore *nc = source.nc; + NickServ::Account *nc = source.nc; if (params.size() && source.HasPriv("nickserv/alist")) { nick = params[0]; - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -47,13 +47,13 @@ class CommandNSAList : public Command list.AddColumn(_("Number")).AddColumn(_("Channel")).AddColumn(_("Access")).AddColumn(_("Description")); - std::deque<ChannelInfo *> queue; + std::deque<ChanServ::Channel *> queue; nc->GetChannelReferences(queue); std::sort(queue.begin(), queue.end(), ChannelSort); for (unsigned i = 0; i < queue.size(); ++i) { - ChannelInfo *ci = queue[i]; + ChanServ::Channel *ci = queue[i]; ListFormatter::ListEntry entry; if (ci->GetFounder() == nc) @@ -78,10 +78,10 @@ class CommandNSAList : public Command continue; } - AccessGroup access = ci->AccessFor(nc); + ChanServ::AccessGroup access = ci->AccessFor(nc); if (access.empty()) continue; - + ++chan_count; entry["Number"] = stringify(chan_count); diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index bda723981..4f2ab5270 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -13,16 +13,16 @@ #include "modules/ns_cert.h" #include "modules/nickserv.h" -static Anope::hash_map<NickCore *> certmap; +static Anope::hash_map<NickServ::Account *> certmap; static EventHandlers<Event::NickCertEvents> *events; struct CertServiceImpl : CertService { CertServiceImpl(Module *o) : CertService(o) { } - NickCore* FindAccountFromCert(const Anope::string &cert) override + NickServ::Account* FindAccountFromCert(const Anope::string &cert) override { - Anope::hash_map<NickCore *>::iterator it = certmap.find(cert); + Anope::hash_map<NickServ::Account *>::iterator it = certmap.find(cert); if (it != certmap.end()) return it->second; return NULL; @@ -31,11 +31,11 @@ struct CertServiceImpl : CertService struct NSCertListImpl : NSCertList { - Serialize::Reference<NickCore> nc; + Serialize::Reference<NickServ::Account> nc; std::vector<Anope::string> certs; public: - NSCertListImpl(Extensible *obj) : nc(anope_dynamic_static_cast<NickCore *>(obj)) { } + NSCertListImpl(Extensible *obj) : nc(anope_dynamic_static_cast<NickServ::Account *>(obj)) { } ~NSCertListImpl() { @@ -127,10 +127,10 @@ struct NSCertListImpl : NSCertList void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { - if (s->GetSerializableType()->GetName() != "NickCore") + if (s->GetSerializableType()->GetName() != "NickServ::Account") return; - const NickCore *n = anope_dynamic_static_cast<const NickCore *>(e); + const NickServ::Account *n = anope_dynamic_static_cast<const NickServ::Account *>(e); NSCertList *c = this->Get(n); if (c == NULL || !c->GetCertCount()) return; @@ -141,10 +141,10 @@ struct NSCertListImpl : NSCertList void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { - if (s->GetSerializableType()->GetName() != "NickCore") + if (s->GetSerializableType()->GetName() != "NickServ::Account") return; - NickCore *n = anope_dynamic_static_cast<NickCore *>(e); + NickServ::Account *n = anope_dynamic_static_cast<NickServ::Account *>(e); NSCertListImpl *c = this->Require(n); Anope::string buf; @@ -165,7 +165,7 @@ struct NSCertListImpl : NSCertList class CommandNSCert : public Command { private: - void DoAdd(CommandSource &source, NickCore *nc, Anope::string certfp) + void DoAdd(CommandSource &source, NickServ::Account *nc, Anope::string certfp) { NSCertList *cl = nc->Require<NSCertList>("certificates"); unsigned max = Config->GetModule(this->owner)->Get<unsigned>("max", "5"); @@ -206,7 +206,7 @@ class CommandNSCert : public Command source.Reply(_("\002%s\002 added to %s's certificate list."), certfp.c_str(), nc->display.c_str()); } - void DoDel(CommandSource &source, NickCore *nc, Anope::string certfp) + void DoDel(CommandSource &source, NickServ::Account *nc, Anope::string certfp) { NSCertList *cl = nc->Require<NSCertList>("certificates"); @@ -235,7 +235,7 @@ class CommandNSCert : public Command source.Reply(_("\002%s\002 deleted from %s's certificate list."), certfp.c_str(), nc->display.c_str()); } - void DoList(CommandSource &source, const NickCore *nc) + void DoList(CommandSource &source, const NickServ::Account *nc) { NSCertList *cl = nc->GetExt<NSCertList>("certificates"); @@ -275,10 +275,10 @@ class CommandNSCert : public Command certfp = params.size() > 1 ? params[params.size() - 1] : ""; } - NickCore *nc; + NickServ::Account *nc; if (!nick.empty()) { - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -371,11 +371,11 @@ class NSCert : public Module if (!NickServ || u->IsIdentified()) return; - NickCore *nc = cs.FindAccountFromCert(u->fingerprint); + NickServ::Account *nc = cs.FindAccountFromCert(u->fingerprint); if (!nc || nc->HasExt("NS_SUSPENDED")) return; - NickAlias *na = NickAlias::Find(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (na && na->nc == nc) u->Identify(na); else @@ -385,7 +385,7 @@ class NSCert : public Module Log(NickServ) << u->GetMask() << " automatically identified for account " << nc->display << " via SSL certificate fingerprint"; } - EventReturn OnNickValidate(User *u, NickAlias *na) override + EventReturn OnNickValidate(User *u, NickServ::Nick *na) override { NSCertList *cl = certs.Get(na->nc); if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint)) diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index fef7682da..bd5fd7305 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -33,7 +33,7 @@ class CommandNSDrop : public Command return; } - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp index 96845571c..b926b6756 100644 --- a/modules/commands/ns_getemail.cpp +++ b/modules/commands/ns_getemail.cpp @@ -31,9 +31,9 @@ class CommandNSGetEMail : public Command Log(LOG_ADMIN, source, this) << "on " << email; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetAccountList()) { - const NickCore *nc = it->second; + const NickServ::Account *nc = it.second; if (!nc->email.empty() && nc->email.equals_ci(email)) { @@ -66,7 +66,7 @@ class CommandNSGetEMail : public Command class NSGetEMail : public Module { CommandNSGetEMail commandnsgetemail; - + public: NSGetEMail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) , commandnsgetemail(this) diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp index c9bfc0402..344947988 100644 --- a/modules/commands/ns_getpass.cpp +++ b/modules/commands/ns_getpass.cpp @@ -24,9 +24,9 @@ class CommandNSGetPass : public Command { const Anope::string &nick = params[0]; Anope::string tmp_pass; - const NickAlias *na; + const NickServ::Nick *na; - if (!(na = NickAlias::Find(nick))) + if (!(na = NickServ::FindNick(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && na->nc->IsServicesOper()) source.Reply(_("You may not get the password of other Services Operators.")); diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index edd12f83d..bc61ee099 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -13,24 +13,24 @@ #include "modules/ns_cert.h" #include "modules/ns_group.h" -class NSGroupRequest : public IdentifyRequest +class NSGroupRequestListener : public NickServ::IdentifyRequestListener { EventHandlers<Event::NickGroup> &onnickgroup; CommandSource source; Command *cmd; Anope::string nick; - Reference<NickAlias> target; - + Reference<NickServ::Nick> target; + public: - NSGroupRequest(Module *o, EventHandlers<Event::NickGroup> &event, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), onnickgroup(event), source(src), cmd(c), nick(n), target(targ) { } + 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) { } - void OnSuccess() override + void OnSuccess(NickServ::IdentifyRequest *) override { if (!source.GetUser() || source.GetUser()->nick != nick || !target || !target->nc) return; User *u = source.GetUser(); - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); /* If the nick is already registered, drop it. */ if (na) { @@ -38,7 +38,7 @@ class NSGroupRequest : public IdentifyRequest delete na; } - na = new NickAlias(nick, target->nc); + na = NickServ::service->CreateNick(nick, target->nc); Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); na->last_usermask = last_usermask; @@ -55,19 +55,14 @@ class NSGroupRequest : public IdentifyRequest } - void OnFail() override + void OnFail(NickServ::IdentifyRequest *) override { if (!source.GetUser()) return; Log(LOG_COMMAND, source, cmd) << "and failed to group to " << target->nick; - if (NickAlias::Find(GetAccount()) != NULL) - { - source.Reply(PASSWORD_INCORRECT); - source.GetUser()->BadPassword(); - } - else - source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); + source.Reply(PASSWORD_INCORRECT); + source.GetUser()->BadPassword(); } }; @@ -91,7 +86,7 @@ class CommandNSGroup : public Command Anope::string nick; if (params.empty()) { - NickCore* core = u->Account(); + NickServ::Account* core = u->Account(); if (core) nick = core->display; } @@ -130,11 +125,11 @@ class CommandNSGroup : public Command } } - NickAlias *target, *na = NickAlias::Find(u->nick); + NickServ::Nick *target, *na = NickServ::FindNick(u->nick); const Anope::string &guestnick = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest"); time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay"); unsigned maxaliases = Config->GetModule(this->owner)->Get<unsigned>("maxaliases"); - if (!(target = NickAlias::Find(nick))) + if (!(target = NickServ::FindNick(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (Anope::CurTime < u->lastnickreg + reg_delay) source.Reply(_("Please wait %d seconds before using the GROUP command again."), (reg_delay + u->lastnickreg) - Anope::CurTime); @@ -169,18 +164,18 @@ class CommandNSGroup : public Command if (ok == false && !pass.empty()) { - NSGroupRequest *req = new NSGroupRequest(owner, this->onnickgroup, source, this, u->nick, target, pass); + NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSGroupRequestListener(onnickgroup, source, this, u->nick, target), owner, target->nc->display, pass); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req); req->Dispatch(); } else { - NSGroupRequest req(owner, this->onnickgroup, source, this, u->nick, target, pass); + NSGroupRequestListener req(onnickgroup, source, this, u->nick, target); if (ok) - req.OnSuccess(); + req.OnSuccess(nullptr); else - req.OnFail(); + req.OnFail(nullptr); } } } @@ -233,7 +228,7 @@ class CommandNSUngroup : public Command { User *u = source.GetUser(); Anope::string nick = !params.empty() ? params[0] : ""; - NickAlias *na = NickAlias::Find(!nick.empty() ? nick : u->nick); + NickServ::Nick *na = NickServ::FindNick(!nick.empty() ? nick : u->nick); if (u->Account()->aliases->size() == 1) source.Reply(_("Your nick is not grouped to anything, you can't ungroup it.")); @@ -243,16 +238,16 @@ class CommandNSUngroup : public Command source.Reply(_("Nick %s is not in your group."), na->nick.c_str()); else { - NickCore *oldcore = na->nc; + NickServ::Account *oldcore = na->nc; - std::vector<NickAlias *>::iterator it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na); + std::vector<NickServ::Nick *>::iterator it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na); if (it != oldcore->aliases->end()) oldcore->aliases->erase(it); if (na->nick.equals_ci(oldcore->display)) oldcore->SetDisplay(oldcore->aliases->front()); - NickCore *nc = new NickCore(na->nick); + NickServ::Account *nc = NickServ::service->CreateAccount(na->nick); na->nc = nc; nc->aliases->push_back(na); @@ -294,11 +289,11 @@ class CommandNSGList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = !params.empty() ? params[0] : ""; - const NickCore *nc; + const NickServ::Account *nc; if (!nick.empty()) { - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -321,7 +316,7 @@ class CommandNSGList : public Command unconfirmed_expire = Config->GetModule("nickserv")->Get<time_t>("unconfirmedexpire", "1d"); for (unsigned i = 0; i < nc->aliases->size(); ++i) { - const NickAlias *na2 = nc->aliases->at(i); + const NickServ::Nick *na2 = nc->aliases->at(i); Anope::string expires; if (na2->HasExt("NS_NO_EXPIRE")) @@ -342,7 +337,7 @@ class CommandNSGList : public Command source.Reply(!nick.empty() ? _("List of nicknames in the group of \002%s\002:") : _("List of nicknames in your group:"), nc->display.c_str()); std::vector<Anope::string> replies; list.Process(replies); - + for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index 5d7ed4c95..03c79c623 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -11,24 +11,24 @@ #include "module.h" -class NSIdentifyRequest : public IdentifyRequest +class NSIdentifyRequestListener : public NickServ::IdentifyRequestListener { CommandSource source; Command *cmd; public: - NSIdentifyRequest(Module *o, CommandSource &s, Command *c, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(o, acc, pass), source(s), cmd(c) { } + NSIdentifyRequestListener(CommandSource &s, Command *c) : source(s), cmd(c) { } - void OnSuccess() override + void OnSuccess(NickServ::IdentifyRequest *req) override { if (!source.GetUser()) return; User *u = source.GetUser(); - NickAlias *na = NickAlias::Find(GetAccount()); + NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (!na) - source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); + source.Reply(NICK_X_NOT_REGISTERED, req->GetAccount().c_str()); else { if (u->IsIdentified()) @@ -40,19 +40,19 @@ class NSIdentifyRequest : public IdentifyRequest } } - void OnFail() override + void OnFail(NickServ::IdentifyRequest *req) override { if (source.GetUser()) { - bool accountexists = NickAlias::Find(GetAccount()) != NULL; - Log(LOG_COMMAND, source, cmd) << "and failed to identify to" << (accountexists ? " " : " nonexistent ") << "account " << GetAccount(); + bool accountexists = NickServ::FindNick(req->GetAccount()) != NULL; + Log(LOG_COMMAND, source, cmd) << "and failed to identify to" << (accountexists ? " " : " nonexistent ") << "account " << req->GetAccount(); if (accountexists) { source.Reply(PASSWORD_INCORRECT); source.GetUser()->BadPassword(); } else - source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); + source.Reply(NICK_X_NOT_REGISTERED, req->GetAccount().c_str()); } } }; @@ -75,14 +75,14 @@ class CommandNSIdentify : public Command const Anope::string &nick = params.size() == 2 ? params[0] : u->nick; Anope::string pass = params[params.size() - 1]; - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (na && na->nc->HasExt("NS_SUSPENDED")) source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); else if (u->Account() && na && u->Account() == na->nc) source.Reply(_("You are already identified.")); else { - NSIdentifyRequest *req = new NSIdentifyRequest(owner, source, this, na ? na->nc->display : nick, pass); + NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSIdentifyRequestListener(source, this), owner, na ? na->nc->display : nick, pass); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, u, req); req->Dispatch(); } diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 16f51db07..5bf413591 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -29,7 +29,7 @@ class CommandNSInfo : public Command { const Anope::string &nick = params.size() ? params[0] : (source.nc ? source.nc->display : source.GetNick()); - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); bool has_auspex = source.HasPriv("nickserv/auspex"); if (!na) @@ -150,13 +150,13 @@ class CommandNSSetHide : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index 0037cbcc5..78daff7ef 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -26,7 +26,7 @@ class CommandNSList : public Command { Anope::string pattern = params[0]; - const NickCore *mync; + const NickServ::Account *mync; unsigned nnicks; bool is_servadmin = source.HasCommand("nickserv/list"); int count = 0, from = 0, to = 0; @@ -76,13 +76,13 @@ class CommandNSList : public Command list.AddColumn(_("Nick")).AddColumn(_("Last usermask")); - Anope::map<NickAlias *> ordered_map; - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) - ordered_map[it->first] = it->second; + Anope::map<NickServ::Nick *> ordered_map; + for (auto& it : NickServ::service->GetNickList()) + ordered_map[it.first] = it.second; - for (Anope::map<NickAlias *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it) + for (Anope::map<NickServ::Nick *>::const_iterator it = ordered_map.begin(), it_end = ordered_map.end(); it != it_end; ++it) { - const NickAlias *na = it->second; + const NickServ::Nick *na = it->second; /* Don't show private nicks to non-services admins. */ if (na->nc->HasExt("NS_PRIVATE") && !is_servadmin && na->nc != mync) @@ -121,7 +121,7 @@ class CommandNSList : public Command ++count; } } - + source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str()); std::vector<Anope::string> replies; @@ -197,13 +197,13 @@ class CommandNSSetPrivate : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) @@ -293,7 +293,7 @@ class NSList : public Module { } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_all) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_all) override { if (!show_all) return; diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index de83ea619..3307c6668 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -15,22 +15,23 @@ typedef std::map<Anope::string, ChannelStatus> NSRecoverInfo; -class NSRecoverRequest : public IdentifyRequest +class NSRecoverRequestListener : public NickServ::IdentifyRequestListener { CommandSource source; Command *cmd; Anope::string user; - + Anope::string pass; + public: - NSRecoverRequest(Module *o, CommandSource &src, Command *c, const Anope::string &nick, const Anope::string &pass) : IdentifyRequest(o, nick, pass), source(src), cmd(c), user(nick) { } + NSRecoverRequestListener(CommandSource &src, Command *c, const Anope::string &nick, const Anope::string &p) : source(src), cmd(c), user(nick), pass(p) { } - void OnSuccess() override + void OnSuccess(NickServ::IdentifyRequest *) override { User *u = User::Find(user, true); if (!source.GetUser() || !source.service) return; - NickAlias *na = NickAlias::Find(user); + NickServ::Nick *na = NickServ::FindNick(user); if (!na) return; @@ -66,7 +67,7 @@ class NSRecoverRequest : public IdentifyRequest } } - u->SendMessage(source.service, _("This nickname has been recovered by %s. If you did not do\n" + u->SendMessage(*source.service, _("This nickname has been recovered by %s. If you did not do\n" "this then %s may have your password, and you should change it."), source.GetNick().c_str(), source.GetNick().c_str()); @@ -76,7 +77,7 @@ class NSRecoverRequest : public IdentifyRequest source.Reply(_("Ghost with your nick has been killed.")); if (IRCD->CanSVSNick) - IRCD->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime); + IRCD->SendForceNickChange(source.GetUser(), user, Anope::CurTime); } /* User is not identified or not identified to the same account as the person using this command */ else @@ -87,7 +88,7 @@ class NSRecoverRequest : public IdentifyRequest Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << na->nick << " (" << na->nc->display << ")"; } - u->SendMessage(source.service, _("This nickname has been recovered by %s."), source.GetNick().c_str()); + u->SendMessage(*source.service, _("This nickname has been recovered by %s."), source.GetNick().c_str()); if (NickServ::service) NickServ::service->Collide(u, na); @@ -95,7 +96,7 @@ class NSRecoverRequest : public IdentifyRequest { /* If we can svsnick then release our hold and svsnick the user using the command */ NickServ::service->Release(na); - IRCD->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime); + IRCD->SendForceNickChange(source.GetUser(), user, Anope::CurTime); } else source.Reply(_("The user with your nick has been removed. Use this command again\n" @@ -103,20 +104,20 @@ class NSRecoverRequest : public IdentifyRequest } } - void OnFail() override + void OnFail(NickServ::IdentifyRequest *) override { - if (NickAlias::Find(GetAccount()) != NULL) + if (NickServ::FindNick(user) != NULL) { source.Reply(ACCESS_DENIED); - if (!GetPassword().empty()) + if (!pass.empty()) { - Log(LOG_COMMAND, source, cmd) << "with an invalid password for " << GetAccount(); + Log(LOG_COMMAND, source, cmd) << "with an invalid password for " << user; if (source.GetUser()) source.GetUser()->BadPassword(); } } else - source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); + source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); } }; @@ -143,7 +144,7 @@ class CommandNSRecover : public Command return; } - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { @@ -168,18 +169,18 @@ class CommandNSRecover : public Command if (ok == false && !pass.empty()) { - NSRecoverRequest *req = new NSRecoverRequest(owner, source, this, na->nick, pass); + NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSRecoverRequestListener(source, this, na->nick, pass), owner, na->nick, pass); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req); req->Dispatch(); } else { - NSRecoverRequest req(owner, source, this, na->nick, pass); + NSRecoverRequestListener req(source, this, na->nick, pass); if (ok) - req.OnSuccess(); + req.OnSuccess(nullptr); else - req.OnFail(); + req.OnFail(nullptr); } } diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index 802292c91..590ced8dc 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -12,7 +12,7 @@ #include "module.h" #include "modules/nickserv.h" -static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi); +static bool SendRegmail(User *u, const NickServ::Nick *na, BotInfo *bi); class CommandNSConfirm : public Command { @@ -30,7 +30,7 @@ class CommandNSConfirm : public Command if (source.nc && !source.nc->HasExt("UNCONFIRMED") && source.HasPriv("nickserv/confirm")) { - NickAlias *na = NickAlias::Find(passcode); + NickServ::Nick *na = NickServ::FindNick(passcode); if (na == NULL) source.Reply(NICK_X_NOT_REGISTERED, passcode.c_str()); else if (na->nc->HasExt("UNCONFIRMED") == false) @@ -47,7 +47,7 @@ class CommandNSConfirm : public Command Anope::string *code = source.nc->GetExt<Anope::string>("passcode"); if (code != NULL && *code == passcode) { - NickCore *nc = source.nc; + NickServ::Account *nc = source.nc; nc->Shrink<Anope::string>("passcode"); Log(LOG_COMMAND, source, this) << "to confirm their email"; source.Reply(_("Your email address of \002%s\002 has been confirmed."), source.nc->email.c_str()); @@ -55,7 +55,7 @@ class CommandNSConfirm : public Command if (source.GetUser()) { - NickAlias *na = NickAlias::Find(source.GetNick()); + NickServ::Nick *na = NickServ::FindNick(source.GetNick()); if (na) { IRCD->SendLogin(source.GetUser(), na); @@ -173,7 +173,7 @@ class CommandNSRegister : public Command this->OnSyntaxError(source, ""); else if (u && Anope::CurTime < u->lastnickreg + reg_delay) source.Reply(_("Please wait %d seconds before using the REGISTER command again."), (u->lastnickreg + reg_delay) - Anope::CurTime); - else if (NickAlias::Find(u_nick) != NULL) + else if (NickServ::FindNick(u_nick) != NULL) source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str()); else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5)) source.Reply(MORE_OBSCURE_PASSWORD); @@ -183,8 +183,8 @@ class CommandNSRegister : public Command source.Reply(MAIL_X_INVALID, email.c_str()); else { - NickCore *nc = new NickCore(u_nick); - NickAlias *na = new NickAlias(u_nick, nc); + NickServ::Account *nc = NickServ::service->CreateAccount(u_nick); + NickServ::Nick *na = NickServ::service->CreateNick(u_nick, nc); Anope::Encrypt(pass, nc->pass); if (!email.empty()) nc->email = email; @@ -291,7 +291,7 @@ class CommandNSResend : public Command return; } - const NickAlias *na = NickAlias::Find(source.GetNick()); + const NickServ::Nick *na = NickServ::FindNick(source.GetNick()); if (na == NULL) source.Reply(NICK_NOT_REGISTERED); @@ -367,7 +367,7 @@ class NSRegister : public Module u->SendMessage(NickServ, _("All new accounts must be validated by an administrator. Please wait for your registration to be confirmed.")); else u->SendMessage(NickServ, _("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you.")); - const NickAlias *this_na = NickAlias::Find(u->Account()->display); + const NickServ::Nick *this_na = NickServ::FindNick(u->Account()->display); time_t time_registered = Anope::CurTime - this_na->time_registered; time_t unconfirmed_expire = Config->GetModule(this)->Get<time_t>("unconfirmedexpire", "1d"); if (unconfirmed_expire > time_registered) @@ -375,7 +375,7 @@ class NSRegister : public Module } } - void OnPreNickExpire(NickAlias *na, bool &expire) override + void OnPreNickExpire(NickServ::Nick *na, bool &expire) override { if (unconfirmed.HasExt(na->nc)) { @@ -386,9 +386,9 @@ class NSRegister : public Module } }; -static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi) +static bool SendRegmail(User *u, const NickServ::Nick *na, BotInfo *bi) { - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; Anope::string *code = na->nc->GetExt<Anope::string>("passcode"); if (code == NULL) diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index af5c43cb7..d4171807d 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -11,7 +11,7 @@ #include "module.h" -static bool SendResetEmail(User *u, const NickAlias *na, BotInfo *bi); +static bool SendResetEmail(User *u, const NickServ::Nick *na, BotInfo *bi); class CommandNSResetPass : public Command { @@ -25,9 +25,9 @@ class CommandNSResetPass : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - const NickAlias *na; + const NickServ::Nick *na; - if (!(na = NickAlias::Find(params[0]))) + if (!(na = NickServ::FindNick(params[0]))) source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); else if (!na->nc->email.equals_ci(params[1])) source.Reply(_("Incorrect email address.")); @@ -85,12 +85,12 @@ class NSResetPass : public Module return EVENT_STOP; } - NickAlias *na = NickAlias::Find(params[0]); + NickServ::Nick *na = NickServ::FindNick(params[0]); ResetInfo *ri = na ? reset.Get(na->nc) : NULL; if (na && ri) { - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; const Anope::string &passcode = params[1]; if (ri->time < Anope::CurTime - 3600) { @@ -121,7 +121,7 @@ class NSResetPass : public Module } }; -static bool SendResetEmail(User *u, const NickAlias *na, BotInfo *bi) +static bool SendResetEmail(User *u, const NickServ::Nick *na, BotInfo *bi) { Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get<const Anope::string>("reset_subject").c_str()), message = Language::Translate(na->nc, Config->GetBlock("mail")->Get<const Anope::string>("reset_message").c_str()), diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 89f3c5e83..984f1d002 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -179,13 +179,13 @@ class CommandNSSASetPassword : public Command return; } - const NickAlias *setter_na = NickAlias::Find(params[0]); + const NickServ::Nick *setter_na = NickServ::FindNick(params[0]); if (setter_na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); return; } - NickCore *nc = setter_na->nc; + NickServ::Account *nc = setter_na->nc; size_t len = params[1].length(); @@ -241,13 +241,13 @@ class CommandNSSetAutoOp : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT; MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); @@ -333,7 +333,7 @@ class CommandNSSetDisplay : public Command return; } - const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); + const NickServ::Nick *user_na = NickServ::FindNick(user), *na = NickServ::FindNick(param); if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) { @@ -406,7 +406,7 @@ class CommandNSSetEmail : public Command static bool SendConfirmMail(User *u, BotInfo *bi, const Anope::string &new_email) { Anope::string code = Anope::Random(9); - + std::pair<Anope::string, Anope::string> *n = u->Account()->Extend<std::pair<Anope::string, Anope::string> >("ns_set_email"); n->first = new_email; n->second = code; @@ -444,13 +444,13 @@ class CommandNSSetEmail : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; if (nc->HasExt("UNCONFIRMED")) { @@ -557,13 +557,13 @@ class CommandNSSetKeepModes : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT; MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); @@ -650,13 +650,13 @@ class CommandNSSetKill : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT; MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); @@ -782,13 +782,13 @@ class CommandNSSetLanguage : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT; MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); @@ -891,13 +891,13 @@ class CommandNSSetMessage : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; if (!Config->GetBlock("options")->Get<bool>("useprivmsg")) { @@ -995,13 +995,13 @@ class CommandNSSetSecure : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT; MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); @@ -1090,7 +1090,7 @@ class CommandNSSASetNoexpire : public Command return; } - NickAlias *na = NickAlias::Find(params[0]); + NickServ::Nick *na = NickServ::FindNick(params[0]); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); @@ -1168,7 +1168,7 @@ class NSSet : public Module SerializableExtensibleItem<bool> autoop, killprotect, kill_quick, kill_immed, message, secure, noexpire; - + struct KeepModes : SerializableExtensibleItem<bool> { KeepModes(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { } @@ -1177,10 +1177,10 @@ class NSSet : public Module { SerializableExtensibleItem<bool>::ExtensibleSerialize(e, s, data); - if (s->GetSerializableType()->GetName() != "NickCore") + if (s->GetSerializableType()->GetName() != "NickServ::Account") return; - const NickCore *nc = anope_dynamic_static_cast<const NickCore *>(s); + const NickServ::Account *nc = anope_dynamic_static_cast<const NickServ::Account *>(s); Anope::string modes; for (User::ModeList::const_iterator it = nc->last_modes.begin(); it != nc->last_modes.end(); ++it) { @@ -1197,10 +1197,10 @@ class NSSet : public Module { SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data); - if (s->GetSerializableType()->GetName() != "NickCore") + if (s->GetSerializableType()->GetName() != "NickServ::Account") return; - NickCore *nc = anope_dynamic_static_cast<NickCore *>(s); + NickServ::Account *nc = anope_dynamic_static_cast<NickServ::Account *>(s); Anope::string modes; data["last_modes"] >> modes; for (spacesepstream sep(modes); sep.GetToken(modes);) @@ -1264,7 +1264,7 @@ class NSSet : public Module EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) override { - NickCore *uac = source.nc; + NickServ::Account *uac = source.nc; if (command->name == "nickserv/confirm" && !params.empty() && uac) { @@ -1285,7 +1285,7 @@ class NSSet : public Module return EVENT_CONTINUE; } - void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override + void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override { if (chan->ci) { @@ -1294,13 +1294,13 @@ class NSSet : public Module } } - void OnPreNickExpire(NickAlias *na, bool &expire) override + void OnPreNickExpire(NickServ::Nick *na, bool &expire) override { if (noexpire.HasExt(na)) expire = false; } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { if (!show_hidden) return; diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index bf3ea8660..4038b9cc1 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -37,7 +37,7 @@ struct NSMiscData : MiscData, Serializable { NSMiscData(Extensible *) : Serializable("NSMiscData") { } - NSMiscData(NickCore *ncore, const Anope::string &n, const Anope::string &d) : Serializable("NSMiscData") + NSMiscData(NickServ::Account *ncore, const Anope::string &n, const Anope::string &d) : Serializable("NSMiscData") { object = ncore->display; name = n; @@ -59,7 +59,7 @@ struct NSMiscData : MiscData, Serializable data["name"] >> sname; data["data"] >> sdata; - NickCore *nc = NickCore::Find(snc); + NickServ::Account *nc = NickServ::FindAccount(snc); if (nc == NULL) return NULL; @@ -106,13 +106,13 @@ class CommandNSSetMisc : public Command return; } - const NickAlias *na = NickAlias::Find(user); + const NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) @@ -206,7 +206,7 @@ class NSSetMisc : public Module for (int i = 0; i < conf->CountBlock("command"); ++i) { Configuration::Block *block = conf->GetBlock("command", i); - + const Anope::string &cmd = block->Get<const Anope::string>("command"); if (cmd != "nickserv/set/misc" && cmd != "nickserv/saset/misc") @@ -222,7 +222,7 @@ class NSSetMisc : public Module } } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool) override { for (Anope::map<ExtensibleItem<NSMiscData> *>::iterator it = items.begin(); it != items.end(); ++it) { diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp index f4c8c7192..24c901a52 100644 --- a/modules/commands/ns_status.cpp +++ b/modules/commands/ns_status.cpp @@ -24,7 +24,7 @@ class CommandNSStatus : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = !params.empty() ? params[0] : source.GetNick(); - const NickAlias *na = NickAlias::Find(nick); + const NickServ::Nick *na = NickServ::FindNick(nick); spacesepstream sep(nick); Anope::string nickbuf; diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index ca669d537..ae8dd20ee 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -37,7 +37,7 @@ struct NSSuspendInfo : SuspendInfo, Serializable si = anope_dynamic_static_cast<NSSuspendInfo *>(obj); else { - NickAlias *na = NickAlias::Find(snick); + NickServ::Nick *na = NickServ::FindNick(snick); if (!na) return NULL; si = na->nc->Extend<NSSuspendInfo>("NS_SUSPENDED"); @@ -90,7 +90,7 @@ class CommandNSSuspend : public Command } } - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -109,7 +109,7 @@ class CommandNSSuspend : public Command return; } - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; NSSuspendInfo *si = nc->Extend<NSSuspendInfo>("NS_SUSPENDED"); si->what = nc->display; @@ -120,7 +120,7 @@ class CommandNSSuspend : public Command for (unsigned i = 0; i < nc->aliases->size(); ++i) { - NickAlias *na2 = nc->aliases->at(i); + NickServ::Nick *na2 = nc->aliases->at(i); if (na2 && *na2->nc == *na->nc) { @@ -172,7 +172,7 @@ class CommandNSUnSuspend : public Command if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -231,7 +231,7 @@ class NSSuspend : public Module { } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { NSSuspendInfo *s = suspend.Get(na->nc); if (s) @@ -248,7 +248,7 @@ class NSSuspend : public Module } } - void OnPreNickExpire(NickAlias *na, bool &expire) override + void OnPreNickExpire(NickServ::Nick *na, bool &expire) override { NSSuspendInfo *s = suspend.Get(na->nc); if (!s) @@ -268,7 +268,7 @@ class NSSuspend : public Module } } - EventReturn OnNickValidate(User *u, NickAlias *na) override + EventReturn OnNickValidate(User *u, NickServ::Nick *na) override { NSSuspendInfo *s = suspend.Get(na->nc); if (!s) diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index 1fa9c5b36..682c57c6f 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -26,7 +26,7 @@ class CommandNSUpdate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); - NickAlias *na = NickAlias::Find(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (na && na->nc == source.GetAccount()) { diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index 971b284e5..bf2a1abe8 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -304,7 +304,7 @@ class CommandOSAKill : public Command else { source.Reply(_("Current AKILL list:")); - + std::vector<Anope::string> replies; list.Process(replies); diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index e81030bc9..e0ed86e8b 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -53,7 +53,7 @@ class CommandOSConfig : public Command const Anope::string show_blocks[] = { "serverinfo", "networkinfo", "options", "" }; Log(LOG_ADMIN, source, this) << "VIEW"; - + for (unsigned i = 0; !show_blocks[i].empty(); ++i) { Configuration::Block *block = Config->GetBlock(show_blocks[i]); diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 29e6638d4..2732f1a3e 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -81,19 +81,19 @@ struct DefconConfig { DefConModesOnParams.erase(name); } - + bool GetDefConParam(const Anope::string &name, Anope::string &buf) { std::map<Anope::string, Anope::string>::iterator it = DefConModesOnParams.find(name); - + buf.clear(); - + if (it != DefConModesOnParams.end()) { buf = it->second; return true; } - + return false; } }; @@ -334,7 +334,7 @@ class OSDefcon : public Module if ((cm = ModeManager::FindChannelModeByName("REDIRECT")) && DConfig.DefConModesOn.count(cm->name) && !DConfig.DefConModesOn.count("LIMIT")) { DConfig.DefConModesOn.erase("REDIRECT"); - + Log(this) << "DefConChanModes must lock mode +l as well to lock mode +L"; } } diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index d76ad451f..0f47eb3e8 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -423,7 +423,7 @@ class CommandOSDNS : public Command { DNSServer *s = DNSServer::Find(params[1]); const Anope::string &zone = params.size() > 2 ? params[2] : ""; - + if (!s) { source.Reply(_("Server %s does not exist."), params[1].c_str()); @@ -485,7 +485,7 @@ class CommandOSDNS : public Command void AddIP(CommandSource &source, const std::vector<Anope::string> ¶ms) { DNSServer *s = DNSServer::Find(params[1]); - + if (!s) { source.Reply(_("Server %s does not exist."), params[1].c_str()); @@ -520,11 +520,11 @@ class CommandOSDNS : public Command dnsmanager->Notify(*it); } } - + void DelIP(CommandSource &source, const std::vector<Anope::string> ¶ms) { DNSServer *s = DNSServer::Find(params[1]); - + if (!s) { source.Reply(_("Server %s does not exist."), params[1].c_str()); @@ -563,7 +563,7 @@ class CommandOSDNS : public Command void OnSet(CommandSource &source, const std::vector<Anope::string> ¶ms) { DNSServer *s = DNSServer::Find(params[1]); - + if (!s) { source.Reply(_("Server %s does not exist."), params[1].c_str()); @@ -596,7 +596,7 @@ class CommandOSDNS : public Command void OnPool(CommandSource &source, const std::vector<Anope::string> ¶ms) { DNSServer *s = DNSServer::Find(params[1]); - + if (!s) { source.Reply(_("Server %s does not exist."), params[1].c_str()); @@ -631,7 +631,7 @@ class CommandOSDNS : public Command void OnDepool(CommandSource &source, const std::vector<Anope::string> ¶ms) { DNSServer *s = DNSServer::Find(params[1]); - + if (!s) { source.Reply(_("Server %s does not exist."), params[1].c_str()); diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 1f54f804f..212beb1ed 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -214,7 +214,7 @@ class CommandOSForbid : public Command expiryt += Anope::CurTime; } - NickAlias *target = NickAlias::Find(entry); + NickServ::Nick *target = NickServ::FindNick(entry); if (target != NULL && Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && target->nc->IsServicesOper()) { source.Reply(ACCESS_DENIED); @@ -254,9 +254,9 @@ class CommandOSForbid : public Command for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) this->OnUserNickChange(it->second); - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end;) + for (auto it = NickServ::service->GetNickList().begin(); it != NickServ::service->GetNickList().end();) { - NickAlias *na = it->second; + NickServ::Nick *na = it->second; ++it; d = this->fs->FindForbid(na->nick, FT_NICK); @@ -312,9 +312,9 @@ class CommandOSForbid : public Command } } - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(); it != RegisteredChannelList->end();) + for (auto it = ChanServ::service->GetChannels().begin(); it != ChanServ::service->GetChannels().end();) { - ChannelInfo *ci = it->second; + ChanServ::Channel *ci = it->second; ++it; d = this->fs->FindForbid(ci->name, FT_CHAN); diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index fa6537a21..728fe1c1c 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -38,7 +38,7 @@ Serializable* IgnoreDataImpl::Unserialize(Serializable *obj, Serialize::Data &da { if (!ignore_service) return NULL; - + IgnoreDataImpl *ign; if (obj) ign = anope_dynamic_static_cast<IgnoreDataImpl *>(obj); @@ -94,7 +94,7 @@ class OSIgnoreService : public IgnoreService { User *u = User::Find(mask, true); std::vector<IgnoreData *>::iterator ign = this->ignores->begin(), ign_end = this->ignores->end(); - + if (u) { for (; ign != ign_end; ++ign) @@ -163,7 +163,7 @@ class CommandOSIgnore : public Command User *u = User::Find(mask, true); if (u) return "*!*@" + u->host; - + size_t host = mask.find('@'); /* Determine whether we get a nick or a mask. */ if (host != Anope::string::npos) diff --git a/modules/commands/os_info.cpp b/modules/commands/os_info.cpp index 53b5fecd6..03e98377e 100644 --- a/modules/commands/os_info.cpp +++ b/modules/commands/os_info.cpp @@ -20,7 +20,7 @@ struct OperInfo : Serializable OperInfo() : Serializable("OperInfo"), created(0) { } OperInfo(const Anope::string &t, const Anope::string &i, const Anope::string &a, time_t c) : Serializable("OperInfo"), target(t), info(i), adder(a), created(c) { } - + ~OperInfo(); void Serialize(Serialize::Data &data) const override @@ -46,10 +46,10 @@ struct OperInfos : Serialize::Checker<std::vector<OperInfo *> > static Extensible *Find(const Anope::string &target) { - NickAlias *na = NickAlias::Find(target); + NickServ::Nick *na = NickServ::FindNick(target); if (na) return na->nc; - return ChannelInfo::Find(target); + return ChanServ::Find(target); } }; @@ -76,7 +76,7 @@ Serializable *OperInfo::Unserialize(Serializable *obj, Serialize::Data &data) Extensible *e = OperInfos::Find(starget); if (!e) return NULL; - + OperInfos *oi = e->Require<OperInfos>("operinfo"); OperInfo *o; if (obj) @@ -113,7 +113,7 @@ class CommandOSInfo : public Command Extensible *e; if (IRCD->IsChannelValid(target)) { - ChannelInfo *ci = ChannelInfo::Find(target); + ChanServ::Channel *ci = ChanServ::Find(target); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, target.c_str()); @@ -124,7 +124,7 @@ class CommandOSInfo : public Command } else { - NickAlias *na = NickAlias::Find(target); + NickServ::Nick *na = NickServ::FindNick(target); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, target.c_str()); @@ -284,12 +284,12 @@ class OSInfo : public Module } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { OnInfo(source, na->nc, info); } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_hidden) override { OnInfo(source, ci, info); } diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp index cba659957..5650feaa2 100644 --- a/modules/commands/os_logsearch.cpp +++ b/modules/commands/os_logsearch.cpp @@ -18,7 +18,7 @@ class CommandOSLogSearch : public Command char timestamp[32]; tm *tm = localtime(&t); - + strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); return Anope::LogDir + "/" + file + "." + timestamp; diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 7358e4c78..4d94759df 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -152,7 +152,7 @@ class CommandOSUMode : public Command u2->SetModes(source.service, "%s", modes.c_str()); source.Reply(_("Changed usermodes of \002%s\002 to %s."), u2->nick.c_str(), modes.c_str()); - u2->SendMessage(source.service, _("\002%s\002 changed your usermodes to %s."), source.GetNick().c_str(), modes.c_str()); + u2->SendMessage(*source.service, _("\002%s\002 changed your usermodes to %s."), source.GetNick().c_str(), modes.c_str()); Log(LOG_ADMIN, source, this) << modes << " on " << target; } diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp index c4f814ee3..826fcabbb 100644 --- a/modules/commands/os_module.cpp +++ b/modules/commands/os_module.cpp @@ -139,7 +139,7 @@ class CommandOSModUnLoad : public Command source.Reply(_("Module \002%s\002 isn't loaded."), mname.c_str()); return; } - + if (!m->handle || m->GetPermanent() || m->type == PROTOCOL) { source.Reply(_("Unable to remove module \002%s\002."), m->name.c_str()); diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 62379e30a..0550146f3 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -115,7 +115,7 @@ class MyNewsService : public NewsService { this->newsItems[n->type].push_back(n); } - + void DelNewsItem(NewsItem *n) { std::vector<NewsItem *> &list = this->GetNewsList(n->type); diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp index 6d1d5d443..3cb521063 100644 --- a/modules/commands/os_oline.cpp +++ b/modules/commands/os_oline.cpp @@ -33,7 +33,7 @@ class CommandOSOLine : public Command { IRCD->SendSVSO(source.service, nick, flag); u2->SetMode(source.service, "OPER"); - u2->SendMessage(source.service, _("You are now an IRC Operator.")); + u2->SendMessage(*source.service, _("You are now an IRC Operator.")); source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str()); Log(LOG_ADMIN, source, this) << "for " << nick; } diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index a18b022ab..59619cb48 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -31,7 +31,7 @@ struct MyOper : Oper, Serializable OperType *ot = OperType::Find(stype); if (ot == NULL) return NULL; - NickCore *nc = NickCore::Find(sname); + NickServ::Account *nc = NickServ::FindAccount(sname); if (nc == NULL) return NULL; @@ -82,7 +82,7 @@ class CommandOSOper : public Command const Anope::string &oper = params[1]; const Anope::string &otype = params[2]; - const NickAlias *na = NickAlias::Find(oper); + const NickServ::Nick *na = NickServ::FindNick(oper); if (na == NULL) source.Reply(NICK_X_NOT_REGISTERED, oper.c_str()); else if (na->nc->o) @@ -115,7 +115,7 @@ class CommandOSOper : public Command { const Anope::string &oper = params[1]; - const NickAlias *na = NickAlias::Find(oper); + const NickServ::Nick *na = NickServ::FindNick(oper); if (na == NULL) source.Reply(NICK_X_NOT_REGISTERED, oper.c_str()); else if (!na->nc || !na->nc->o) @@ -137,9 +137,9 @@ class CommandOSOper : public Command else if (subcommand.equals_ci("LIST")) { source.Reply(_("Name Type")); - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetAccountList()) { - const NickCore *nc = it->second; + const NickServ::Account *nc = it.second; if (!nc->o) continue; @@ -160,7 +160,7 @@ class CommandOSOper : public Command if (params.size() > 2) fulltype += " " + params[2]; OperType *ot = OperType::Find(fulltype); - if (ot == NULL) + if (ot == NULL) source.Reply(_("Oper type \002%s\002 has not been configured."), fulltype.c_str()); else { @@ -243,9 +243,9 @@ class OSOper : public Module ~OSOper() { - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetAccountList()) { - NickCore *nc = it->second; + NickServ::Account *nc = it.second; if (nc->o && dynamic_cast<MyOper *>(nc->o)) { diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 9cb525b4d..03c807efb 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -68,7 +68,7 @@ class MySessionService : public SessionService Exception *e = *it; if (Anope::Match(u->host, e->mask) || Anope::Match(u->ip, e->mask)) return e; - + if (cidr(e->mask).match(sockaddrs(u->ip))) return e; } @@ -211,7 +211,7 @@ class CommandOSSession : public Command std::vector<Anope::string> replies; list.Process(replies); - + for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); } @@ -531,7 +531,7 @@ class CommandOSException : public Command else { source.Reply(_("Current Session Limit Exception list:")); - + std::vector<Anope::string> replies; list.Process(replies); diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp index bc58b7dc1..be5e980b1 100644 --- a/modules/commands/os_set.cpp +++ b/modules/commands/os_set.cpp @@ -129,7 +129,7 @@ class CommandOSSet : public Command return; } catch (const ConvertException &) { } - + source.Reply(_("Setting for DEBUG must be \002ON\002, \002OFF\002, or a positive number.")); } diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index d55bdb1dc..f325b3ab9 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -173,13 +173,13 @@ class CommandOSStats : public Command GetHashStats(ChannelList, entries, buckets, max_chain); source.Reply(_("Channels: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain); - GetHashStats(*RegisteredChannelList, entries, buckets, max_chain); + GetHashStats(ChanServ::service->GetChannels(), entries, buckets, max_chain); source.Reply(_("Registered channels: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain); - GetHashStats(*NickAliasList, entries, buckets, max_chain); + GetHashStats(NickServ::service->GetNickList(), entries, buckets, max_chain); source.Reply(_("Registered nicknames: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain); - GetHashStats(*NickCoreList, entries, buckets, max_chain); + GetHashStats(NickServ::service->GetAccountList(), entries, buckets, max_chain); source.Reply(_("Registered nick groups: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain); if (session_service) diff --git a/modules/cs_statusupdate.cpp b/modules/cs_statusupdate.cpp index 58498ff40..b65f8a6e5 100644 --- a/modules/cs_statusupdate.cpp +++ b/modules/cs_statusupdate.cpp @@ -19,17 +19,17 @@ class StatusUpdate : public Module } - void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) override + void OnAccessAdd(ChanServ::Channel *ci, CommandSource &, ChanServ::ChanAccess *access) override { if (ci->c) for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) { User *user = it->second->user; - ChanAccess::Path p; + ChanServ::ChanAccess::Path p; if (user->server != Me && access->Matches(user, user->Account(), p)) { - AccessGroup ag = ci->AccessFor(user); + ChanServ::AccessGroup ag = ci->AccessFor(user); for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) { @@ -42,17 +42,17 @@ class StatusUpdate : public Module } } - void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) override + void OnAccessDel(ChanServ::Channel *ci, CommandSource &, ChanServ::ChanAccess *access) override { if (ci->c) for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) { User *user = it->second->user; - ChanAccess::Path p; + ChanServ::ChanAccess::Path p; if (user->server != Me && access->Matches(user, user->Account(), p)) { - AccessGroup ag = ci->AccessFor(user); + ChanServ::AccessGroup ag = ci->AccessFor(user); for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) { diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 50f1412b1..266b79379 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -93,7 +93,7 @@ class LoadData : public Serialize::Data hash ^= Anope::hash_cs()(it->second); return hash; } - + void Reset() { id = 0; @@ -255,7 +255,7 @@ class DBFlatFile : public Module, public Pipe Serialize::Type *stype = Serialize::Type::Find(type_order[i]); if (!stype || stype->GetOwner()) continue; - + std::vector<std::streampos> &pos = positions[stype->GetName()]; for (unsigned j = 0; j < pos.size(); ++j) diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index f80d55d5a..c541104d9 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -142,7 +142,7 @@ enum LANG_PL /* Polish */ }; -static void process_mlock(ChannelInfo *ci, uint32_t lock, bool status, uint32_t *limit, Anope::string *key) +static void process_mlock(ChanServ::Channel *ci, uint32_t lock, bool status, uint32_t *limit, Anope::string *key) { ModeLocks *ml = ci->Require<ModeLocks>("modelocks"); for (unsigned i = 0; i < (sizeof(mlock_infos) / sizeof(mlock_info)); ++i) @@ -434,6 +434,8 @@ int read_int32(int32_t *ret, dbFILE *f) static void LoadNicks() { + if (!NickServ::service) + return; ServiceReference<ForbidService> forbid("ForbidService", "forbid"); dbFILE *f = open_db_read("NickServ", "nick.db", 14); if (f == NULL) @@ -444,7 +446,7 @@ static void LoadNicks() Anope::string buffer; READ(read_string(buffer, f)); - NickCore *nc = new NickCore(buffer); + NickServ::Account *nc = NickServ::service->CreateAccount(buffer); const Anope::string settings[] = { "killprotect", "kill_quick", "ns_secure", "ns_private", "hide_email", "hide_mask", "hide_quit", "memo_signon", "memo_receive", "autoop", "msg", "ns_keepmodes" }; @@ -573,27 +575,38 @@ static void LoadNicks() int16_t i16; READ(read_int16(&i16, f)); - READ(read_int16(&nc->memos.memomax, f)); + READ(read_int16(&i16, f)); + if (nc->memos) + nc->memos->memomax = i16; for (int16_t j = 0; j < i16; ++j) { - Memo *m = new Memo; + MemoServ::Memo *m = MemoServ::service ? MemoServ::service->CreateMemo() : nullptr; READ(read_uint32(&u32, f)); uint16_t flags; READ(read_uint16(&flags, f)); int32_t tmp32; READ(read_int32(&tmp32, f)); - m->time = tmp32; + if (m) + m->time = tmp32; char sbuf[32]; READ(read_buffer(sbuf, f)); - m->sender = sbuf; - READ(read_string(m->text, f)); - m->owner = nc->display; - nc->memos.memos->push_back(m); + if (m) + m->sender = sbuf; + Anope::string text; + READ(read_string(text, f)); + if (m) + m->text = text; + if (m) + m->owner = nc->display; + if (nc->memos && m) + nc->memos->memos->push_back(m); + else + delete m; } READ(read_uint16(&u16, f)); READ(read_int16(&i16, f)); - Log(LOG_DEBUG) << "Loaded NickCore " << nc->display; + Log(LOG_DEBUG) << "Loaded NickServ::Account " << nc->display; } for (int i = 0; i < 1024; ++i) @@ -618,7 +631,7 @@ static void LoadNicks() Anope::string core; READ(read_string(core, f)); - NickCore *nc = NickCore::Find(core); + NickServ::Account *nc = NickServ::FindAccount(core); if (nc == NULL) { Log() << "Skipping coreless nick " << nick << " with core " << core; @@ -651,7 +664,7 @@ static void LoadNicks() continue; } - NickAlias *na = new NickAlias(nick, nc); + NickServ::Nick *na = NickServ::service->CreateNick(nick, nc); na->last_usermask = last_usermask; na->last_realname = last_realname; na->last_quit = last_quit; @@ -661,7 +674,7 @@ static void LoadNicks() if (tmpu16 & OLD_NS_NO_EXPIRE) na->Extend<bool>("NS_NO_EXPIRE"); - Log(LOG_DEBUG) << "Loaded NickAlias " << na->nick; + Log(LOG_DEBUG) << "Loaded NickServ::Nick " << na->nick; } close_db(f); /* End of section Ia */ @@ -684,7 +697,7 @@ static void LoadVHosts() READ(read_string(creator, f)); READ(read_int32(&vtime, f)); - NickAlias *na = NickAlias::Find(nick); + NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { Log() << "Removing vhost for nonexistant nick " << nick; @@ -735,6 +748,9 @@ static void LoadBots() static void LoadChannels() { + if (!ChanServ::service) + return; + ServiceReference<ForbidService> forbid("ForbidService", "forbid"); dbFILE *f = open_db_read("ChanServ", "chan.db", 16); if (f == NULL) @@ -746,7 +762,7 @@ static void LoadChannels() Anope::string buffer; char namebuf[64]; READ(read_buffer(namebuf, f)); - ChannelInfo *ci = new ChannelInfo(namebuf); + ChanServ::Channel *ci = ChanServ::service->Create(namebuf); const Anope::string settings[] = { "keeptopic", "peace", "cs_private", "restricted", "cs_secure", "secureops", "securefounder", "signkick", "signkick_level", "topiclock", "persist", "noautoop", "cs_keepmodes" }; @@ -754,10 +770,10 @@ static void LoadChannels() ci->Shrink<bool>(settings[j].upper()); READ(read_string(buffer, f)); - ci->SetFounder(NickCore::Find(buffer)); + ci->SetFounder(NickServ::FindAccount(buffer)); READ(read_string(buffer, f)); - ci->SetSuccessor(NickCore::Find(buffer)); + ci->SetSuccessor(NickServ::FindAccount(buffer)); char pwbuf[32]; READ(read_buffer(pwbuf, f)); @@ -836,8 +852,8 @@ static void LoadChannels() int16_t level; READ(read_int16(&level, f)); - if (level == ACCESS_INVALID) - level = ACCESS_FOUNDER; + if (level == ChanServ::ACCESS_INVALID) + level = ChanServ::ACCESS_FOUNDER; if (j == 10 && level < 0) // NOJOIN ci->Shrink<bool>("RESTRICTED"); // If CSDefRestricted was enabled this can happen @@ -846,7 +862,7 @@ static void LoadChannels() } bool xop = tmpu32 & OLD_CI_XOP; - ServiceReference<AccessProvider> provider_access("AccessProvider", "access/access"), provider_xop("AccessProvider", "access/xop"); + ServiceReference<ChanServ::AccessProvider> provider_access("AccessProvider", "access/access"), provider_xop("AccessProvider", "access/xop"); uint16_t tmpu16; READ(read_uint16(&tmpu16, f)); for (uint16_t j = 0; j < tmpu16; ++j) @@ -855,8 +871,8 @@ static void LoadChannels() READ(read_uint16(&in_use, f)); if (in_use) { - ChanAccess *access = NULL; - + ChanServ::ChanAccess *access = NULL; + if (xop) { if (provider_xop) @@ -941,20 +957,31 @@ static void LoadChannels() READ(read_string(buffer, f)); // +L READ(read_int16(&tmp16, f)); - READ(read_int16(&ci->memos.memomax, f)); + READ(read_int16(&tmp16, f)); + if (ci->memos) + ci->memos->memomax = tmp16; for (int16_t j = 0; j < tmp16; ++j) { READ(read_uint32(&tmpu32, f)); READ(read_uint16(&tmpu16, f)); - Memo *m = new Memo; + MemoServ::Memo *m = MemoServ::service ? MemoServ::service->CreateMemo() : nullptr; READ(read_int32(&tmp32, f)); - m->time = tmp32; + if (m) + m->time = tmp32; char sbuf[32]; READ(read_buffer(sbuf, f)); - m->sender = sbuf; - READ(read_string(m->text, f)); - m->owner = ci->name; - ci->memos.memos->push_back(m); + if (m) + m->sender = sbuf; + Anope::string text; + READ(read_string(text, f)); + if (m) + m->text = text; + if (m) + m->owner = ci->name; + if (ci->memos && m) + ci->memos->memos->push_back(m); + else + delete m; } READ(read_string(buffer, f)); @@ -1211,7 +1238,7 @@ static void LoadExceptions() dbFILE *f = open_db_read("OperServ", "exception.db", 9); if (f == NULL) return; - + int16_t num; READ(read_int16(&num, f)); for (int i = 0; i < num; ++i) @@ -1330,9 +1357,11 @@ class DBOld : public Module void OnUplinkSync(Server *s) override { - for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + if (!ChanServ::service) + return; + for (auto& it : ChanServ::service->GetChannels()) { - ChannelInfo *ci = it->second; + ChanServ::Channel *ci = it.second; uint32_t *limit = mlock_limit.Get(ci); Anope::string *key = mlock_key.Get(ci); diff --git a/modules/database/db_redis.cpp b/modules/database/db_redis.cpp index 81b1f083f..dd5ff0301 100644 --- a/modules/database/db_redis.cpp +++ b/modules/database/db_redis.cpp @@ -214,7 +214,7 @@ class DatabaseRedis : public Module, public Pipe std::vector<Anope::string> args; args.push_back("SMEMBERS"); args.push_back("ids:" + sb->GetName()); - + redis->SendCommand(new TypeLoader(this, sb->GetName()), args); } @@ -469,14 +469,14 @@ void SubscriptionListener::OnResult(const Reply &r) */ if (r.multi_bulk.size() != 4) return; - + size_t sz = r.multi_bulk[2]->bulk.find(':'); if (sz == Anope::string::npos) return; - + const Anope::string &key = r.multi_bulk[2]->bulk.substr(sz + 1), &op = r.multi_bulk[3]->bulk; - + sz = key.rfind(':'); if (sz == Anope::string::npos) return; @@ -492,7 +492,7 @@ void SubscriptionListener::OnResult(const Reply &r) if (s_type == NULL) return; - + uint64_t obj_id; try { diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index ad10f0a7d..0377bcdd1 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -163,7 +163,7 @@ class DBMySQL : public Module, public Pipe void OnSerializableDestruct(Serializable *obj) override { - if (!this->CheckInit()) + if (!this->CheckInit()) return; Serialize::Type *s_type = obj->GetSerializableType(); if (s_type) diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp index 020bafe6e..296d81b53 100644 --- a/modules/encryption/enc_bcrypt.cpp +++ b/modules/encryption/enc_bcrypt.cpp @@ -839,6 +839,7 @@ char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count, #include "module.h" #include "modules/encryption.h" +#include "modules/nickserv.h" class EBCRYPT : public Module , public EventHook<Event::Encrypt> @@ -897,12 +898,12 @@ class EBCRYPT : public Module return EVENT_ALLOW; } - void OnCheckAuthentication(User *, IdentifyRequest *req) override + void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override { - const NickAlias *na = NickAlias::Find(req->GetAccount()); + const NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (na == NULL) return; - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; size_t pos = nc->pass.find(':'); if (pos == Anope::string::npos) diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp index 108fb2504..442918aa6 100644 --- a/modules/encryption/enc_md5.cpp +++ b/modules/encryption/enc_md5.cpp @@ -284,7 +284,7 @@ class MD5Context : public Encryption::Context /* MD5 finalization. Ends an MD5 message-digest opera * the message digest and zeroizing the context. - */ + */ void Finalize() override { unsigned char bits[8]; @@ -369,12 +369,12 @@ class EMD5 : public Module return EVENT_ALLOW; } - void OnCheckAuthentication(User *, IdentifyRequest *req) override + void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override { - const NickAlias *na = NickAlias::Find(req->GetAccount()); + const NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (na == NULL) return; - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; size_t pos = nc->pass.find(':'); if (pos == Anope::string::npos) diff --git a/modules/encryption/enc_none.cpp b/modules/encryption/enc_none.cpp index 1346177f7..8781be910 100644 --- a/modules/encryption/enc_none.cpp +++ b/modules/encryption/enc_none.cpp @@ -44,12 +44,12 @@ class ENone : public Module return EVENT_ALLOW; } - void OnCheckAuthentication(User *, IdentifyRequest *req) override + void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override { - const NickAlias *na = NickAlias::Find(req->GetAccount()); + const NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (na == NULL) return; - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; size_t pos = nc->pass.find(':'); if (pos == Anope::string::npos) diff --git a/modules/encryption/enc_old.cpp b/modules/encryption/enc_old.cpp index 671921c72..f36b2236b 100644 --- a/modules/encryption/enc_old.cpp +++ b/modules/encryption/enc_old.cpp @@ -85,12 +85,12 @@ class EOld : public Module return EVENT_ALLOW; } - void OnCheckAuthentication(User *, IdentifyRequest *req) override + void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override { - const NickAlias *na = NickAlias::Find(req->GetAccount()); + const NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (na == NULL) return; - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; size_t pos = nc->pass.find(':'); if (pos == Anope::string::npos) diff --git a/modules/encryption/enc_sha1.cpp b/modules/encryption/enc_sha1.cpp index df7de4f72..d2189a941 100644 --- a/modules/encryption/enc_sha1.cpp +++ b/modules/encryption/enc_sha1.cpp @@ -224,12 +224,12 @@ class ESHA1 : public Module return EVENT_ALLOW; } - void OnCheckAuthentication(User *, IdentifyRequest *req) override + void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override { - const NickAlias *na = NickAlias::Find(req->GetAccount()); + const NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (na == NULL) return; - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; size_t pos = nc->pass.find(':'); if (pos == Anope::string::npos) diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp index 9cd682c57..b8c5c8e76 100644 --- a/modules/encryption/enc_sha256.cpp +++ b/modules/encryption/enc_sha256.cpp @@ -306,12 +306,12 @@ class ESHA256 : public Module return EVENT_ALLOW; } - void OnCheckAuthentication(User *, IdentifyRequest *req) override + void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override { - const NickAlias *na = NickAlias::Find(req->GetAccount()); + const NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); if (na == NULL) return; - NickCore *nc = na->nc; + NickServ::Account *nc = na->nc; size_t pos = nc->pass.find(':'); if (pos == Anope::string::npos) diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index 1615d855c..efbef59f8 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -125,7 +125,7 @@ class LDAPService : public LDAPProvider, public Thread, public Condition ldap_unbind_ext(this->con, NULL, NULL); } - + LDAPQuery BindAsAdmin(LDAPInterface *i) { return this->Bind(i, this->admin_binddn, this->admin_pass); @@ -554,7 +554,7 @@ class ModuleLDAP : public Module, public Pipe } } s->Unlock(); - } + } } void OnNotify() override @@ -586,7 +586,7 @@ class ModuleLDAP : public Module, public Pipe delete r; } - } + } } }; diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index abd5cc33c..9f2550e69 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -22,7 +22,7 @@ struct IdentifyInfo { req->Hold(me); } - + ~IdentifyInfo() { req->Release(me); @@ -100,10 +100,10 @@ class IdentifyInterface : public LDAPInterface } else { - NickAlias *na = NickAlias::Find(ii->req->GetAccount()); + NickServ::Nick *na = NickServ::FindNick(ii->req->GetAccount()); if (na == NULL) { - na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount())); + na = new NickServ::Nick(ii->req->GetAccount(), new NickServ::Account(ii->req->GetAccount())); na->last_realname = ii->user ? ii->user->realname : ii->req->GetAccount(); NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, ii->user, na); BotInfo *NickServ = Config->GetClient("NickServ"); @@ -311,7 +311,7 @@ class NSIdentifyLDAP : public Module } } - void OnNickRegister(User *, NickAlias *na) override + void OnNickRegister(User *, NickServ::Nick *na) override { if (!this->disable_register_reason.empty() || !this->ldap) return; diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp index 7c6db48f5..ca6020c6a 100644 --- a/modules/extra/m_ldap_oper.cpp +++ b/modules/extra/m_ldap_oper.cpp @@ -30,7 +30,7 @@ class IdentifyInterface : public LDAPInterface if (!u || !u->Account()) return; - NickCore *nc = u->Account(); + NickServ::Account *nc = u->Account(); try { @@ -131,7 +131,7 @@ class LDAPOper : public Module } } - void OnDelCore(NickCore *nc) override + void OnDelCore(NickServ::Account *nc) override { if (nc->o != NULL && my_opers.count(nc->o) > 0) { diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index d0db90195..02d015ed8 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -438,7 +438,7 @@ Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Dat *it->second >> buf; query.SetValue(it->first, buf); } - + return query; } @@ -458,7 +458,7 @@ void MySQLService::Connect() if (!connect) throw SQL::Exception("Unable to connect to MySQL service " + this->name + ": " + mysql_error(this->sql)); - + Log(LOG_DEBUG) << "Successfully connected to MySQL service " << this->name << " at " << this->server << ":" << this->port; } diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index 65f0f2800..74e2554fa 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -38,11 +38,11 @@ class SQLAuthenticationResult : public SQL::Interface } catch (const SQL::Exception &) { } - NickAlias *na = NickAlias::Find(req->GetAccount()); + NickServ::Nick *na = NickServ::FindNick(req->GetAccount()); BotInfo *NickServ = Config->GetClient("NickServ"); if (na == NULL) { - na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); + na = new NickServ::Nick(req->GetAccount(), new NickServ::Account(req->GetAccount())); NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, user, na); if (user && NickServ) user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp index 90fab856a..8337252ba 100644 --- a/modules/extra/m_sql_oper.cpp +++ b/modules/extra/m_sql_oper.cpp @@ -105,9 +105,9 @@ class ModuleSQLOper : public Module ~ModuleSQLOper() { - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (nickcore_map::const_iterator it = NickServ::AccountList->begin(), it_end = NickServ::AccountList->end(); it != it_end; ++it) { - NickCore *nc = it->second; + NickServ::Account *nc = it->second; if (nc->o && dynamic_cast<SQLOper *>(nc->o)) { diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index c0f503141..32d335b1b 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -282,7 +282,7 @@ Query SQLiteService::BuildInsert(const Anope::string &table, unsigned int id, Da *it->second >> buf; query.SetValue(it->first, buf); } - + return query; } diff --git a/modules/extra/m_ssl_openssl.cpp b/modules/extra/m_ssl_openssl.cpp index 3344f1d28..7687b599e 100644 --- a/modules/extra/m_ssl_openssl.cpp +++ b/modules/extra/m_ssl_openssl.cpp @@ -181,7 +181,7 @@ void MySSLService::Init(Socket *s) { if (s->io != &NormalSocketIO) throw CoreException("Socket initializing SSL twice"); - + s->io = new SSLSocketIO(); } @@ -259,7 +259,7 @@ ClientSocket *SSLSocketIO::Accept(ListenSocket *s) newsocket->flags[SF_ACCEPTING] = true; this->FinishAccept(newsocket); - + return newsocket; } @@ -273,7 +273,7 @@ SocketFlag SSLSocketIO::FinishAccept(ClientSocket *cs) throw SocketException("SSLSocketIO::FinishAccept called for a socket not accepted nor accepting?"); SSLSocketIO *io = anope_dynamic_static_cast<SSLSocketIO *>(cs->io); - + int ret = SSL_accept(io->sslsock); if (ret <= 0) { @@ -354,7 +354,7 @@ SocketFlag SSLSocketIO::FinishConnect(ConnectionSocket *s) if (!SSL_set_fd(io->sslsock, s->GetFD())) throw SocketException("Unable to set SSL fd"); } - + int ret = SSL_connect(io->sslsock); if (ret <= 0) { diff --git a/modules/extra/stats/cs_fantasy_stats.cpp b/modules/extra/stats/cs_fantasy_stats.cpp index b400e23ed..4674e0892 100644 --- a/modules/extra/stats/cs_fantasy_stats.cpp +++ b/modules/extra/stats/cs_fantasy_stats.cpp @@ -113,7 +113,7 @@ class CSStats : public Module channel = params[0]; else { - if (NickAlias *na = NickAlias::Find(params[0])) + if (NickServ::Nick *na = NickServ::FindNick(params[0])) display = na->nc->display; else { diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp index 4efb1f430..d472fd55d 100644 --- a/modules/extra/stats/m_chanstats.cpp +++ b/modules/extra/stats/m_chanstats.cpp @@ -12,7 +12,7 @@ class CommandCSSetChanstats : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -65,7 +65,7 @@ class CommandNSSetChanstats : public Command } void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m, bool saset = false) { - NickAlias *na = NickAlias::Find(user); + NickServ::Nick *na = NickServ::FindNick(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); @@ -103,7 +103,7 @@ class CommandNSSetChanstats : public Command { this->Run(source, source.nc->display, params[0]); } - + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); @@ -501,7 +501,7 @@ class MChanstats : public Module Log(this) << "no database connection to " << engine; } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override { if (!show_all) return; @@ -509,7 +509,7 @@ class MChanstats : public Module info.AddOption(_("Chanstats")); } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { if (!show_hidden) return; @@ -610,14 +610,14 @@ class MChanstats : public Module this->RunQuery(query); } - void OnDelCore(NickCore *nc) override + void OnDelCore(NickServ::Account *nc) override { query = "DELETE FROM `" + prefix + "chanstats` WHERE `nick` = @nick@;"; query.SetValue("nick", nc->display); this->RunQuery(query); } - void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) override + void OnChangeCoreDisplay(NickServ::Account *nc, const Anope::string &newdisplay) override { query = "CALL " + prefix + "chanstats_proc_chgdisplay(@old_display@, @new_display@);"; query.SetValue("old_display", nc->display); @@ -625,20 +625,20 @@ class MChanstats : public Module this->RunQuery(query); } - void OnDelChan(ChannelInfo *ci) override + void OnDelChan(ChanServ::Channel *ci) override { query = "DELETE FROM `" + prefix + "chanstats` WHERE `chan` = @channel@;"; query.SetValue("channel", ci->name); this->RunQuery(query); } - void OnChanRegistered(ChannelInfo *ci) + void OnChanRegistered(ChanServ::Channel *ci) { if (CSDefChanstats) ci->Extend<bool>("CS_STATS"); } - void OnNickRegister(User *user, NickAlias *na) + void OnNickRegister(User *user, NickServ::Nick *na) { if (NSDefChanstats) na->nc->Extend<bool>("NS_STATS"); diff --git a/modules/fantasy.cpp b/modules/fantasy.cpp index e89b35365..ef95a83b3 100644 --- a/modules/fantasy.cpp +++ b/modules/fantasy.cpp @@ -23,7 +23,7 @@ class CommandBSSetFantasy : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string &value = params[1]; if (ci == NULL) @@ -47,7 +47,7 @@ class CommandBSSetFantasy : public Command if (value.equals_ci("ON")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy"; ci->Extend<bool>("BS_FANTASY"); source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str()); @@ -55,7 +55,7 @@ class CommandBSSetFantasy : public Command else if (value.equals_ci("OFF")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable fantasy"; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable fantasy"; ci->Shrink<bool>("BS_FANTASY"); source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str()); @@ -118,7 +118,7 @@ class Fantasy : public Module params[0].erase(params[0].begin()); else return; - + if (params.empty()) return; @@ -171,7 +171,7 @@ class Fantasy : public Module source.command = it->first; source.permission = info.permission; - AccessGroup ag = c->ci->AccessFor(u); + ChanServ::AccessGroup ag = c->ci->AccessFor(u); bool has_fantasia = ag.HasPriv("FANTASIA") || source.HasPriv("chanserv/administration"); EventReturn MOD_RESULT; @@ -194,14 +194,14 @@ class Fantasy : public Module if (MOD_RESULT == EVENT_STOP) return; - Reference<NickCore> nc_reference(u->Account()); + Reference<NickServ::Account> nc_reference(u->Account()); cmd->Execute(source, params); if (!nc_reference) source.nc = NULL; Event::OnPostCommand(&Event::PostCommand::OnPostCommand, source, cmd, params); } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) + void OnBotInfo(CommandSource &source, BotInfo *bi, ChanServ::Channel *ci, InfoFormatter &info) { if (fantasy.HasExt(ci)) info.AddOption(_("Fantasy")); diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp index dfe44516a..a4c2f21ac 100644 --- a/modules/m_dns.cpp +++ b/modules/m_dns.cpp @@ -106,7 +106,7 @@ class Packet : public Query return name; } - + Question UnpackQuestion(const unsigned char *input, unsigned short input_size, unsigned short &pos) { Question question; @@ -202,7 +202,7 @@ class Packet : public Query unsigned short id; /* Flags on the packet */ unsigned short flags; - + Packet(Manager *m, sockaddrs *a) : manager(m), id(0), flags(0) { if (a) @@ -238,7 +238,7 @@ class Packet : public Query for (unsigned i = 0; i < qdcount; ++i) this->questions.push_back(this->UnpackQuestion(input, len, packet_pos)); - + for (unsigned i = 0; i < ancount; ++i) this->answers.push_back(this->UnpackResourceRecord(input, len, packet_pos)); @@ -253,7 +253,7 @@ class Packet : public Query { if (output_size < HEADER_LENGTH) throw SocketException("Unable to pack packet"); - + unsigned short pos = 0; output[pos++] = this->id >> 8; @@ -416,7 +416,7 @@ class Packet : public Query l = htonl(manager->GetSerial()); memcpy(&output[pos], &l, 4); pos += 4; - + l = htonl(refresh); // Refresh memcpy(&output[pos], &l, 4); pos += 4; @@ -442,7 +442,7 @@ class Packet : public Query break; } } - + return pos; } }; @@ -461,7 +461,7 @@ namespace DNS class TCPSocket : public ListenSocket { Manager *manager; - + public: /* A TCP client */ class Client : public ClientSocket, public Timer, public ReplySocket @@ -470,7 +470,7 @@ class TCPSocket : public ListenSocket Packet *packet; unsigned char packet_buffer[524]; int length; - + public: Client(Manager *m, TCPSocket *l, int fd, const sockaddrs &addr) : Socket(fd, l->IsIPv6()), ClientSocket(l, addr), Timer(5), manager(m), packet(NULL), length(0) @@ -483,7 +483,7 @@ class TCPSocket : public ListenSocket Log(LOG_DEBUG_2) << "Resolver: Exiting client from " << clientaddr.addr(); delete packet; } - + /* Times out after a few seconds */ void Tick(time_t) override { } @@ -543,13 +543,13 @@ class TCPSocket : public ListenSocket }; TCPSocket(Manager *m, const Anope::string &ip, int port) : Socket(-1, ip.find(':') != Anope::string::npos), ListenSocket(ip, port, ip.find(':') != Anope::string::npos), manager(m) { } - + ClientSocket *OnAccept(int fd, const sockaddrs &addr) override { return new Client(this->manager, this, fd, addr); } }; - + /* Listens for UDP requests */ class UDPSocket : public ReplySocket { @@ -564,15 +564,15 @@ class UDPSocket : public ReplySocket for (unsigned i = 0; i < packets.size(); ++i) delete packets[i]; } - + void Reply(Packet *p) override { packets.push_back(p); SocketEngine::Change(this, true, SF_WRITABLE); } - + std::deque<Packet *>& GetPackets() { return packets; } - + bool ProcessRead() override { Log(LOG_DEBUG_2) << "Resolver: Reading from DNS UDP socket"; @@ -583,7 +583,7 @@ class UDPSocket : public ReplySocket int length = recvfrom(this->GetFD(), reinterpret_cast<char *>(&packet_buffer), sizeof(packet_buffer), 0, &from_server.sa, &x); return this->manager->HandlePacket(this, packet_buffer, length, &from_server); } - + bool ProcessWrite() override { Log(LOG_DEBUG_2) << "Resolver: Writing to DNS UDP socket"; @@ -606,7 +606,7 @@ class UDPSocket : public ReplySocket if (packets.empty()) SocketEngine::Change(this, false, SF_WRITABLE); - + return true; } }; @@ -672,7 +672,7 @@ class MyManager : public Manager, public Timer delete tcpsock; for (std::map<unsigned short, Request *>::iterator it = this->requests.begin(), it_end = this->requests.end(); it != it_end;) - { + { Request *request = it->second; ++it; @@ -750,7 +750,7 @@ class MyManager : public Manager, public Timer this->requests[req->id] = req; req->SetSecs(timeout); - + Packet *p = new Packet(this, &this->addrs); p->flags = QUERYFLAGS_RD; p->id = req->id; @@ -911,7 +911,7 @@ class MyManager : public Manager, public Timer request->OnLookupComplete(&recv_packet); this->AddCache(recv_packet); } - + delete request; return true; } @@ -972,7 +972,7 @@ class MyManager : public Manager, public Timer this->cache.erase(it); } } - + private: /** Add a record to the dns cache * @param r The record @@ -1000,7 +1000,7 @@ class MyManager : public Manager, public Timer return false; } - + }; class ModuleDNS : public Module diff --git a/modules/m_httpd.cpp b/modules/m_httpd.cpp index 314badc55..2d959ef14 100644 --- a/modules/m_httpd.cpp +++ b/modules/m_httpd.cpp @@ -148,7 +148,7 @@ class MyHTTPClient : public HTTPClient this->Serve(); } - + return true; } diff --git a/modules/m_rewrite.cpp b/modules/m_rewrite.cpp index 940308c12..adf702b9d 100644 --- a/modules/m_rewrite.cpp +++ b/modules/m_rewrite.cpp @@ -19,7 +19,7 @@ struct Rewrite for (unsigned i = 0; i < sm.size(); ++i) if (i >= message.size() || (sm[i] != "$" && !sm[i].equals_ci(message[i]))) return false; - + return true; } @@ -70,7 +70,7 @@ struct Rewrite } static std::vector<Rewrite> rewrites; - + static Rewrite *Find(const Anope::string &client, const Anope::string &cmd) { for (unsigned i = 0; i < rewrites.size(); ++i) diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp index e38e865ff..67c1148ee 100644 --- a/modules/m_sasl.cpp +++ b/modules/m_sasl.cpp @@ -40,10 +40,10 @@ class Plain : public Mechanism Anope::string acc = decoded.substr(0, p), pass = decoded.substr(p + 1); - if (acc.empty() || pass.empty()) + if (acc.empty() || pass.empty() || !NickServ::service) return; - SASL::IdentifyRequest *req = new SASL::IdentifyRequest(this->owner, m.source, acc, pass); + NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new IdentifyRequestListener(m.source), this->owner, acc, pass); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); } @@ -92,7 +92,7 @@ class External : public Mechanism return; } - NickCore *nc = certs->FindAccountFromCert(mysess->cert); + NickServ::Account *nc = certs->FindAccountFromCert(mysess->cert); if (!nc || nc->HasExt("NS_SUSPENDED")) { sasl->Fail(sess); @@ -208,7 +208,7 @@ class SASLService : public SASL::Service, public Timer IRCD->SendSASLMessage(msg); } - void Succeed(Session *session, NickCore *nc) override + void Succeed(Session *session, NickServ::Account *nc) override { IRCD->SendSVSLogin(session->uid, nc->display); this->SendMessage(session, "D", "S"); diff --git a/modules/m_xmlrpc_main.cpp b/modules/m_xmlrpc_main.cpp index 011b2d250..224b25a60 100644 --- a/modules/m_xmlrpc_main.cpp +++ b/modules/m_xmlrpc_main.cpp @@ -3,7 +3,7 @@ static Module *me; -class XMLRPCIdentifyRequest : public IdentifyRequest +class XMLRPCIdentifyRequest : public NickServ::IdentifyRequestListener { XMLRPCRequest request; HTTPReply repl; /* Request holds a reference to the HTTPReply, because we might exist long enough to invalidate it @@ -12,9 +12,9 @@ class XMLRPCIdentifyRequest : public IdentifyRequest Reference<XMLRPCServiceInterface> xinterface; public: - XMLRPCIdentifyRequest(Module *m, XMLRPCRequest& req, HTTPClient *c, XMLRPCServiceInterface* iface, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), repl(request.r), client(c), xinterface(iface) { } + XMLRPCIdentifyRequest(XMLRPCRequest& req, HTTPClient *c, XMLRPCServiceInterface* iface) : request(req), repl(request.r), client(c), xinterface(iface) { } - void OnSuccess() override + void OnSuccess(NickServ::IdentifyRequest *req) override { if (!xinterface || !client) return; @@ -22,13 +22,13 @@ class XMLRPCIdentifyRequest : public IdentifyRequest request.r = this->repl; request.reply("result", "Success"); - request.reply("account", GetAccount()); + request.reply("account", req->GetAccount()); xinterface->Reply(request); client->SendReply(&request.r); } - void OnFail() override + void OnFail(NickServ::IdentifyRequest *req) override { if (!xinterface || !client) return; @@ -81,7 +81,7 @@ class MyXMLRPCEvent : public XMLRPCEvent { request.reply("result", "Success"); - NickAlias *na = NickAlias::Find(user); + NickServ::Nick *na = NickServ::FindNick(user); Anope::string out; @@ -91,7 +91,7 @@ class MyXMLRPCEvent : public XMLRPCEvent XMLRPCommandReply(Anope::string &s) : str(s) { } - void SendMessage(BotInfo *, const Anope::string &msg) override + void SendMessage(const MessageSource &, const Anope::string &msg) override { str += msg + "\n"; }; @@ -112,16 +112,16 @@ class MyXMLRPCEvent : public XMLRPCEvent Anope::string username = request.data.size() > 0 ? request.data[0] : ""; Anope::string password = request.data.size() > 1 ? request.data[1] : ""; - if (username.empty() || password.empty()) + if (username.empty() || password.empty() || !NickServ::service) request.reply("error", "Invalid parameters"); else { - XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(me, request, client, iface, username, password); + NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new XMLRPCIdentifyRequest(request, client, iface), me, username, password); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); return false; } - + return true; } diff --git a/modules/ns_maxemail.cpp b/modules/ns_maxemail.cpp index a7e2f29ac..2ead0de86 100644 --- a/modules/ns_maxemail.cpp +++ b/modules/ns_maxemail.cpp @@ -33,16 +33,16 @@ class NSMaxEmail : public Module return true; } - int CountEmail(const Anope::string &email, NickCore *unc) + int CountEmail(const Anope::string &email, NickServ::Account *unc) { int count = 0; if (email.empty()) return 0; - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) + for (auto& it : NickServ::service->GetAccountList()) { - const NickCore *nc = it->second; + const NickServ::Account *nc = it.second; if (unc != nc && !nc->email.empty() && nc->email.equals_ci(email)) ++count; diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 5c1a23426..3b829d336 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -282,7 +282,7 @@ class BahamutIRCdProto : public IRCDProto UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; } - void SendLogin(User *u, NickAlias *) override + void SendLogin(User *u, NickServ::Nick *) override { IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon); } @@ -373,11 +373,11 @@ struct IRCDMessageNick : IRCDMessage return; } - NickAlias *na = NULL; + NickServ::Nick *na = NULL; time_t signon = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, stamp = params[7].is_pos_number_only() ? convertTo<time_t>(params[7]) : 0; - if (signon && signon == stamp) - na = NickAlias::Find(params[0]); + if (signon && signon == stamp && NickServ::service) + na = NickServ::service->FindNick(params[0]); User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? *na->nc : NULL); } diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 68bf31e76..e69de2b12 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -60,7 +60,7 @@ class CharybdisProto : public IRCDProto void SendChannel(Channel *c) override { ratbox->SendChannel(c); } void SendTopic(const MessageSource &source, Channel *c) override { ratbox->SendTopic(source, c); } bool IsIdentValid(const Anope::string &ident) override { return ratbox->IsIdentValid(ident); } - void SendLogin(User *u, NickAlias *na) override { ratbox->SendLogin(u, na); } + void SendLogin(User *u, NickServ::Nick *na) override { ratbox->SendLogin(u, na); } void SendLogout(User *u) override { ratbox->SendLogout(u); } void SendSQLine(User *, const XLine *x) override @@ -166,7 +166,7 @@ struct IRCDMessageEncap : IRCDMessage // In a burst, states that the source user is logged in as the account. if (params[1] == "LOGIN" || params[1] == "SU") { - NickCore *nc = NickCore::Find(params[2]); + NickServ::Account *nc = NickServ::FindAccount(params[2]); if (!nc) return; u->Login(nc); @@ -221,9 +221,9 @@ struct IRCDMessageEUID : IRCDMessage */ void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { - NickAlias *na = NULL; + NickServ::Nick *na = NULL; if (params[9] != "*") - na = NickAlias::Find(params[9]); + na = NickServ::FindNick(params[9]); User::OnIntroduce(params[0], params[4], params[8], params[5], params[6], source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime, params[3], params[7], na ? *na->nc : NULL); } @@ -304,7 +304,7 @@ class ProtoCharybdis : public Module ModeManager::AddUserMode(new UserMode("NOFORWARD", 'Q')); ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); ModeManager::AddUserMode(new UserModeOperOnly("OPERWALLS", 'z')); - ModeManager::AddUserMode(new UserModeNoone("SSL", 'Z')); + ModeManager::AddUserMode(new UserModeNoone("SSL", 'Z')); /* b/e/I */ ModeManager::AddChannelMode(new ChannelModeList("QUIET", 'q')); @@ -400,7 +400,7 @@ class ProtoCharybdis : public Module } } - EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override + EventReturn OnMLock(ChanServ::Channel *ci, ModeLock *lock) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); @@ -413,7 +413,7 @@ class ProtoCharybdis : public Module return EVENT_CONTINUE; } - EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override + EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index d2b5b935a..9dd906387 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -224,7 +224,7 @@ class HybridProto : public IRCDProto UplinkSocket::Message(source) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; } - void SendLogin(User *u, NickAlias *na) override + void SendLogin(User *u, NickServ::Nick *na) override { IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str()); } @@ -535,9 +535,9 @@ struct IRCDMessageUID : IRCDMessage if (ip == "0") /* Can be 0 for spoofed clients */ ip.clear(); - NickAlias *na = NULL; + NickServ::Nick *na = NULL; if (params[8] != "0") - na = NickAlias::Find(params[8]); + na = NickServ::FindNick(params[8]); /* Source is always the server */ User::OnIntroduce(params[0], params[4], params[5], "", diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 77ebb2fe6..1981b3cc5 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -361,7 +361,7 @@ class InspIRCd20Proto : public IRCDProto UplinkSocket::Message(source) << "SNONOTICE A :" << buf; } - void SendLogin(User *u, NickAlias *na) override + void SendLogin(User *u, NickServ::Nick *na) override { /* InspIRCd uses an account to bypass chmode +R, not umode +r, so we can't send this here */ if (na->nc->HasExt("UNCONFIRMED")) @@ -1166,7 +1166,7 @@ struct IRCDMessageMetadata : IRCDMessage if (params[1].equals_cs("accountname")) { User *u = User::Find(params[0]); - NickCore *nc = NickCore::Find(params[2]); + NickServ::Account *nc = NickServ::FindAccount(params[2]); if (u && nc) u->Login(nc); } @@ -1347,7 +1347,7 @@ struct IRCDMessageServer : IRCDMessage struct IRCDMessageSQuit : Message::SQuit { IRCDMessageSQuit(Module *creator) : Message::SQuit(creator) { } - + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { if (params[0] == rsquit_id || params[0] == rsquit_server) @@ -1401,7 +1401,7 @@ struct IRCDMessageUID : IRCDMessage for (unsigned i = 9; i < params.size() - 1; ++i) modes += " " + params[i]; - NickAlias *na = NULL; + NickServ::Nick *na = NULL; if (SASL::sasl) for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();) { @@ -1411,7 +1411,7 @@ struct IRCDMessageUID : IRCDMessage it = saslusers.erase(it); else if (u.uid == params[0]) { - na = NickAlias::Find(u.acc); + na = NickServ::FindNick(u.acc); it = saslusers.erase(it); } else @@ -1541,7 +1541,7 @@ class ProtoInspIRCd20 : public Module this->OnChanRegistered(c->ci); } - void OnChanRegistered(ChannelInfo *ci) override + void OnChanRegistered(ChanServ::Channel *ci) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); if (use_server_side_mlock && ci->c && modelocks && !modelocks->GetMLockAsString(false).empty()) @@ -1557,7 +1557,7 @@ class ProtoInspIRCd20 : public Module } } - void OnDelChan(ChannelInfo *ci) override + void OnDelChan(ChanServ::Channel *ci) override { if (use_server_side_mlock && ci->c) SendChannelMetadata(ci->c, "mlock", ""); @@ -1566,7 +1566,7 @@ class ProtoInspIRCd20 : public Module SendChannelMetadata(ci->c, "topiclock", ""); } - EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override + EventReturn OnMLock(ChanServ::Channel *ci, ModeLock *lock) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); @@ -1579,7 +1579,7 @@ class ProtoInspIRCd20 : public Module return EVENT_CONTINUE; } - EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override + EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); @@ -1592,7 +1592,7 @@ class ProtoInspIRCd20 : public Module return EVENT_CONTINUE; } - EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) override + EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChanServ::Channel *ci, const Anope::string &setting) override { if (cmd->name == "chanserv/topic" && ci->c) { diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 06790b2af..a18f8f770 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -118,7 +118,7 @@ class ngIRCdProto : public IRCDProto UplinkSocket::Message(source) << "KICK " << chan->name << " " << user->nick; } - void SendLogin(User *u, NickAlias *na) override + void SendLogin(User *u, NickServ::Nick *na) override { UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << na->nc->display; } @@ -126,7 +126,7 @@ class ngIRCdProto : public IRCDProto void SendLogout(User *u) override { UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :"; - } + } void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override { @@ -345,7 +345,7 @@ struct IRCDMessageMetadata : IRCDMessage } if (params[1].equals_cs("accountname")) { - NickCore *nc = NickCore::Find(params[2]); + NickServ::Account *nc = NickServ::FindAccount(params[2]); if (nc) u->Login(nc); } @@ -492,7 +492,7 @@ struct IRCDMessageNJoin : IRCDMessage continue; } users.push_back(sju); - } + } Message::Join::SJoin(source, params[0], 0, "", users); } diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index e4cc26e6a..0e22ba6c0 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -142,7 +142,7 @@ class PlexusProto : public IRCDProto UplinkSocket::Message(source) << "ENCAP * SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; } - void SendLogin(User *u, NickAlias *na) override + void SendLogin(User *u, NickServ::Nick *na) override { UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << na->nc->display; } @@ -184,7 +184,7 @@ struct IRCDMessageEncap : IRCDMessage if (params[1].equals_cs("SU")) { User *u = User::Find(params[2]); - NickCore *nc = NickCore::Find(params[3]); + NickServ::Account *nc = NickServ::FindAccount(params[3]); if (u && nc) { u->Login(nc); @@ -272,15 +272,15 @@ struct IRCDMessageUID : IRCDMessage ts = Anope::CurTime; } - NickAlias *na = NULL; + NickServ::Nick *na = NULL; try { if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == ts) - na = NickAlias::Find(params[0]); + na = NickServ::FindNick(params[0]); } catch (const ConvertException &) { } if (params[8] != "0" && !na) - na = NickAlias::Find(params[8]); + na = NickServ::FindNick(params[8]); User::OnIntroduce(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7], na ? *na->nc : NULL); } @@ -312,7 +312,7 @@ class ProtoPlexus : public Module Message::Topic message_topic; Message::Version message_version; Message::Whois message_whois; - + /* Hybrid message handlers */ ServiceAlias message_bmask, message_eob, message_join, message_nick, message_sid, message_sjoin, message_tburst, message_tmode; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 5cc80742f..ec946c391 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -81,7 +81,7 @@ class RatboxProto : public IRCDProto UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " :" << u->realname; } - void SendLogin(User *u, NickAlias *na) override + void SendLogin(User *u, NickServ::Nick *na) override { if (na->nc->HasExt("UNCONFIRMED")) return; @@ -125,7 +125,7 @@ struct IRCDMessageEncap : IRCDMessage { User *u = source.GetUser(); - NickCore *nc = NickCore::Find(params[2]); + NickServ::Account *nc = NickServ::FindAccount(params[2]); if (!nc) return; u->Login(nc); diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index eec4601ce..606f22270 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -343,7 +343,7 @@ class UnrealIRCdProto : public IRCDProto return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':'; } - void SendLogin(User *u, NickAlias *na) override + void SendLogin(User *u, NickServ::Nick *na) override { if (Servers::Capab.count("ESVID") > 0) IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str()); @@ -474,7 +474,7 @@ class UnrealExtBan : public ChannelModeList if (u->Account() && Anope::Match(u->Account()->display, real_mask)) return true; } - + return false; } }; @@ -496,7 +496,7 @@ class ChannelModeFlood : public ChannelModeParam return true; } catch (const ConvertException &) { } - + /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */ size_t end_bracket = value.find(']', 1); if (end_bracket == Anope::string::npos) @@ -840,19 +840,19 @@ struct IRCDMessageNick : IRCDMessage Log(LOG_DEBUG) << "User " << params[0] << " introduced from nonexistant server " << params[5] << "?"; return; } - - NickAlias *na = NULL; + + NickServ::Nick *na = NULL; if (params[6] == "0") ; else if (params[6].is_pos_number_only()) { if (convertTo<time_t>(params[6]) == user_ts) - na = NickAlias::Find(params[0]); + na = NickServ::FindNick(params[0]); } else { - na = NickAlias::Find(params[6]); + na = NickServ::FindNick(params[6]); } User::OnIntroduce(params[0], params[3], params[4], vhost, ip, s, params[10], user_ts, params[7], "", na ? *na->nc : NULL); @@ -889,7 +889,7 @@ struct IRCDMessageSASL : IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { size_t p = params[1].find('!'); - if (!SASL::sasl || p == Anope::string::npos) + if (!SASL::sasl || p == Anope::string::npos) return; SASL::Message m; @@ -1032,7 +1032,7 @@ struct IRCDMessageSJoin : IRCDMessage users.push_back(sju); } } - + time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; Message::Join::SJoin(source, params[1], ts, modes, users); @@ -1252,7 +1252,7 @@ class ProtoUnreal : public Module } } - void OnChanRegistered(ChannelInfo *ci) override + void OnChanRegistered(ChanServ::Channel *ci) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); if (!ci->c || !use_server_side_mlock || !modelocks || !Servers::Capab.count("MLOCK")) @@ -1261,14 +1261,14 @@ class ProtoUnreal : public Module UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes; } - void OnDelChan(ChannelInfo *ci) override + void OnDelChan(ChanServ::Channel *ci) override { if (!ci->c || !use_server_side_mlock || !Servers::Capab.count("MLOCK")) return; UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " :"; } - EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override + EventReturn OnMLock(ChanServ::Channel *ci, ModeLock *lock) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); @@ -1281,7 +1281,7 @@ class ProtoUnreal : public Module return EVENT_CONTINUE; } - EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override + EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) override { ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks"); ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); diff --git a/modules/pseudoclients/botserv/CMakeLists.txt b/modules/pseudoclients/botserv/CMakeLists.txt new file mode 100644 index 000000000..781f0ef1f --- /dev/null +++ b/modules/pseudoclients/botserv/CMakeLists.txt @@ -0,0 +1 @@ +build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv/botserv.cpp index 2f4511f32..cbb76599a 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv/botserv.cpp @@ -10,9 +10,10 @@ */ #include "module.h" +#include "modules/botserv.h" #include "modules/help.h" -class BotServCore : public Module +class BotServCore : public Module, public BotServ::BotServService , public EventHook<Event::SetCorrectModes> , public EventHook<Event::BotAssign> , public EventHook<Event::JoinChannel> @@ -28,6 +29,7 @@ class BotServCore : public Module public: BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , BotServ::BotServService(this) , EventHook<Event::SetCorrectModes>("OnSetCorrectModes") , EventHook<Event::BotAssign>("OnBotAssign") , EventHook<Event::JoinChannel>("OnJoinChannel") @@ -48,7 +50,7 @@ class BotServCore : public Module BotServ = BotInfo::Find(bsnick, true); } - void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override + void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override { /* Do not allow removing bot modes on our service bots */ if (chan->ci && chan->ci->bi == user) @@ -59,7 +61,7 @@ class BotServCore : public Module } } - void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) override + void OnBotAssign(User *sender, ChanServ::Channel *ci, BotInfo *bi) override { if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers")) { @@ -128,7 +130,7 @@ class BotServCore : public Module /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ if (c->ci && persist && persist->HasExt(c->ci)) return; - + /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly * We also don't part the bot here either, if necessary we will part it after the sync */ @@ -208,7 +210,7 @@ class BotServCore : public Module return EVENT_CONTINUE; } - void OnCreateChan(ChannelInfo *ci) override + void OnCreateChan(ChanServ::Channel *ci) override { /* Set default bot flags */ spacesepstream sep(Config->GetModule(this)->Get<const Anope::string>("defaults", "greet fantasy")); diff --git a/modules/pseudoclients/chanserv/CMakeLists.txt b/modules/pseudoclients/chanserv/CMakeLists.txt new file mode 100644 index 000000000..781f0ef1f --- /dev/null +++ b/modules/pseudoclients/chanserv/CMakeLists.txt @@ -0,0 +1 @@ +build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/pseudoclients/chanserv/channel.cpp b/modules/pseudoclients/chanserv/channel.cpp new file mode 100644 index 000000000..5364075ae --- /dev/null +++ b/modules/pseudoclients/chanserv/channel.cpp @@ -0,0 +1,605 @@ +/* Registered channel functions + * + * (C) 2003-2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + */ + +#include "module.h" +#include "channel.h" +#include "modules/cs_akick.h" + +ChannelImpl::ChannelImpl(const Anope::string &chname) +{ + if (chname.empty()) + throw CoreException("Empty channel passed to ChanServ::Channel constructor"); + + this->founder = NULL; + this->successor = NULL; + this->c = ::Channel::Find(chname); + if (this->c) + this->c->ci = this; + this->banexpire = 0; + this->bi = NULL; + this->last_topic_time = 0; + + this->name = chname; + + this->bantype = 2; + this->last_used = this->time_registered = Anope::CurTime; + + ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); + Channel* &ci = map[chname]; + if (ci) + Log(LOG_DEBUG) << "Duplicate channel " << this->name << " in registered channel table?"; + ci = this; + + Event::OnCreateChan(&Event::CreateChan::OnCreateChan, this); +} + +ChannelImpl::ChannelImpl(const ChanServ::Channel &ci) +{ + *this = ci; + + if (this->founder) + --this->founder->channelcount; + + this->access->clear(); + this->akick->clear(); + + for (unsigned i = 0; i < ci.GetAccessCount(); ++i) + { + const ChanServ::ChanAccess *taccess = ci.GetAccess(i); + ChanServ::AccessProvider *provider = taccess->provider; + + ChanServ::ChanAccess *newaccess = provider->Create(); + newaccess->ci = this; + newaccess->mask = taccess->mask; + newaccess->creator = taccess->creator; + newaccess->last_seen = taccess->last_seen; + newaccess->created = taccess->created; + newaccess->AccessUnserialize(taccess->AccessSerialize()); + + this->AddAccess(newaccess); + } + + for (unsigned i = 0; i < ci.GetAkickCount(); ++i) + { + const AutoKick *takick = ci.GetAkick(i); + if (takick->nc) + this->AddAkick(takick->creator, takick->nc, takick->reason, takick->addtime, takick->last_used); + else + this->AddAkick(takick->creator, takick->mask, takick->reason, takick->addtime, takick->last_used); + } + + Event::OnCreateChan(&Event::CreateChan::OnCreateChan, this); +} + +ChannelImpl::~ChannelImpl() +{ + Event::OnDelChan(&Event::DelChan::OnDelChan, this); + + Log(LOG_DEBUG) << "Deleting channel " << this->name; + + if (this->c) + { + if (this->bi && this->c->FindUser(this->bi)) + this->bi->Part(this->c); + + /* Parting the service bot can cause the channel to go away */ + + if (this->c) + { + if (this->c && this->c->CheckDelete()) + delete this->c; + + this->c = NULL; + } + } + + ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); + map.erase(this->name); + + this->SetFounder(NULL); + this->SetSuccessor(NULL); + + this->ClearAccess(); + this->ClearAkick(); + + if (this->memos) + { + for (unsigned i = 0, end = this->memos->memos->size(); i < end; ++i) + delete this->memos->GetMemo(i); + this->memos->memos->clear(); + delete memos; + } + + if (this->founder) + --this->founder->channelcount; +} + +void ChannelImpl::Serialize(Serialize::Data &data) const +{ + data["name"] << this->name; + if (this->founder) + data["founder"] << this->founder->display; + if (this->successor) + data["successor"] << this->successor->display; + data["description"] << this->desc; + data.SetType("time_registered", Serialize::Data::DT_INT); data["time_registered"] << this->time_registered; + data.SetType("last_used", Serialize::Data::DT_INT); data["last_used"] << this->last_used; + data["last_topic"] << this->last_topic; + data["last_topic_setter"] << this->last_topic_setter; + data.SetType("last_topic_time", Serialize::Data::DT_INT); data["last_topic_time"] << this->last_topic_time; + data.SetType("bantype", Serialize::Data::DT_INT); data["bantype"] << this->bantype; + { + Anope::string levels_buffer; + for (Anope::map<int16_t>::const_iterator it = this->levels.begin(), it_end = this->levels.end(); it != it_end; ++it) + levels_buffer += it->first + " " + stringify(it->second) + " "; + data["levels"] << levels_buffer; + } + if (this->bi) + data["bi"] << this->bi->nick; + data.SetType("banexpire", Serialize::Data::DT_INT); data["banexpire"] << this->banexpire; + if (memos) + { + data["memomax"] << this->memos->memomax; + for (unsigned i = 0; i < this->memos->ignores.size(); ++i) + data["memoignores"] << this->memos->ignores[i] << " "; + } + + Extensible::ExtensibleSerialize(this, this, data); +} + +Serializable* ChannelImpl::Unserialize(Serializable *obj, Serialize::Data &data) +{ + Anope::string sname, sfounder, ssuccessor, slevels, sbi; + + data["name"] >> sname; + data["founder"] >> sfounder; + data["successor"] >> ssuccessor; + data["levels"] >> slevels; + data["bi"] >> sbi; + + ChannelImpl *ci; + if (obj) + ci = anope_dynamic_static_cast<ChannelImpl *>(obj); + else + ci = new ChannelImpl(sname); + + ci->SetFounder(NickServ::FindAccount(sfounder)); + ci->SetSuccessor(NickServ::FindAccount(ssuccessor)); + + data["description"] >> ci->desc; + data["time_registered"] >> ci->time_registered; + data["last_used"] >> ci->last_used; + data["last_topic"] >> ci->last_topic; + data["last_topic_setter"] >> ci->last_topic_setter; + data["last_topic_time"] >> ci->last_topic_time; + data["bantype"] >> ci->bantype; + { + std::vector<Anope::string> v; + spacesepstream(slevels).GetTokens(v); + for (unsigned i = 0; i + 1 < v.size(); i += 2) + try + { + ci->levels[v[i]] = convertTo<int16_t>(v[i + 1]); + } + catch (const ConvertException &) { } + } + BotInfo *bi = BotInfo::Find(sbi); + if (*ci->bi != bi) + { + if (bi) + bi->Assign(NULL, ci); + else if (ci->bi) + ci->bi->UnAssign(NULL, ci); + } + data["banexpire"] >> ci->banexpire; + if (ci->memos) + { + data["memomax"] >> ci->memos->memomax; + { + Anope::string buf; + data["memoignores"] >> buf; + spacesepstream sep(buf); + ci->memos->ignores.clear(); + while (sep.GetToken(buf)) + ci->memos->ignores.push_back(buf); + } + } + + Extensible::ExtensibleUnserialize(ci, ci, data); + + /* compat */ + bool b; + b = false; + data["extensible:SECURE"] >> b; + if (b) + ci->Extend<bool>("CS_SECURE"); + b = false; + data["extensible:PRIVATE"] >> b; + if (b) + ci->Extend<bool>("CS_PRIVATE"); + b = false; + data["extensible:NO_EXPIRE"] >> b; + if (b) + ci->Extend<bool>("CS_NO_EXPIRE"); + b = false; + data["extensible:FANTASY"] >> b; + if (b) + ci->Extend<bool>("BS_FANTASY"); + b = false; + data["extensible:GREET"] >> b; + if (b) + ci->Extend<bool>("BS_GREET"); + b = false; + data["extensible:PEACE"] >> b; + if (b) + ci->Extend<bool>("PEACE"); + b = false; + data["extensible:SECUREFOUNDER"] >> b; + if (b) + ci->Extend<bool>("SECUREFOUNDER"); + b = false; + data["extensible:RESTRICTED"] >> b; + if (b) + ci->Extend<bool>("RESTRICTED"); + b = false; + data["extensible:KEEPTOPIC"] >> b; + if (b) + ci->Extend<bool>("KEEPTOPIC"); + b = false; + data["extensible:SIGNKICK"] >> b; + if (b) + ci->Extend<bool>("SIGNKICK"); + b = false; + data["extensible:SIGNKICK_LEVEL"] >> b; + if (b) + ci->Extend<bool>("SIGNKICK_LEVEL"); + /* end compat */ + + return ci; +} + + +void ChannelImpl::SetFounder(NickServ::Account *nc) +{ + if (this->founder) + { + --this->founder->channelcount; + this->founder->RemoveChannelReference(this); + } + + this->founder = nc; + + if (this->founder) + { + ++this->founder->channelcount; + this->founder->AddChannelReference(this); + } +} + +NickServ::Account *ChannelImpl::GetFounder() const +{ + return this->founder; +} + +void ChannelImpl::SetSuccessor(NickServ::Account *nc) +{ + if (this->successor) + this->successor->RemoveChannelReference(this); + this->successor = nc; + if (this->successor) + this->successor->AddChannelReference(this); +} + +NickServ::Account *ChannelImpl::GetSuccessor() const +{ + return this->successor; +} + +BotInfo *ChannelImpl::WhoSends() const +{ + if (this && this->bi) + return this->bi; + + BotInfo *ChanServ = Config->GetClient("ChanServ"); + if (ChanServ) + return ChanServ; + + if (!BotListByNick->empty()) + return BotListByNick->begin()->second; + + return NULL; +} + +void ChannelImpl::AddAccess(ChanServ::ChanAccess *taccess) +{ + this->access->push_back(taccess); + + const NickServ::Nick *na = NickServ::FindNick(taccess->mask); + if (na != NULL) + { + na->nc->AddChannelReference(this); + taccess->nc = na->nc; + } + else + { + ChanServ::Channel *ci = ChanServ::Find(taccess->mask); + if (ci != NULL) + ci->AddChannelReference(this->name); + } +} + +ChanServ::ChanAccess *ChannelImpl::GetAccess(unsigned index) const +{ + if (this->access->empty() || index >= this->access->size()) + return NULL; + + ChanServ::ChanAccess *acc = (*this->access)[index]; + acc->QueueUpdate(); + return acc; +} + +ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u) +{ + ChanServ::AccessGroup group; + + if (u == NULL) + return group; + + const NickServ::Account *nc = u->Account(); + if (nc == NULL && !this->HasExt("NS_SECURE") && u->IsRecognized()) + { + const NickServ::Nick *na = NickServ::FindNick(u->nick); + if (na != NULL) + nc = na->nc; + } + + group.super_admin = u->super_admin; + group.founder = IsFounder(u); + group.ci = this; + group.nc = nc; + + for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) + { + ChanServ::ChanAccess *a = this->GetAccess(i); + if (a->Matches(u, u->Account(), group.path)) + group.push_back(a); + } + + if (group.founder || !group.empty()) + { + this->last_used = Anope::CurTime; + + for (unsigned i = 0; i < group.size(); ++i) + group[i]->last_seen = Anope::CurTime; + } + + return group; +} + +ChanServ::AccessGroup ChannelImpl::AccessFor(const NickServ::Account *nc) +{ + ChanServ::AccessGroup group; + + group.founder = (this->founder && this->founder == nc); + group.ci = this; + group.nc = nc; + + for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) + { + ChanServ::ChanAccess *a = this->GetAccess(i); + if (a->Matches(NULL, nc, group.path)) + group.push_back(a); + } + + if (group.founder || !group.empty()) + this->last_used = Anope::CurTime; + + /* don't update access last seen here, this isn't the user requesting access */ + + return group; +} + +unsigned ChannelImpl::GetAccessCount() const +{ + return this->access->size(); +} + +unsigned ChannelImpl::GetDeepAccessCount() const +{ + ChanServ::ChanAccess::Path path; + for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) + { + ChanServ::ChanAccess *a = this->GetAccess(i); + a->Matches(NULL, NULL, path); + } + + unsigned count = this->GetAccessCount(); + std::set<const ChanServ::Channel *> channels; + channels.insert(this); + for (ChanServ::ChanAccess::Set::iterator it = path.first.begin(); it != path.first.end(); ++it) + { + const ChanServ::Channel *ci = it->first->ci; + if (!channels.count(ci)) + { + channels.count(ci); + count += ci->GetAccessCount(); + } + } + return count; +} + +ChanServ::ChanAccess *ChannelImpl::EraseAccess(unsigned index) +{ + if (this->access->empty() || index >= this->access->size()) + return NULL; + + ChanServ::ChanAccess *ca = this->access->at(index); + this->access->erase(this->access->begin() + index); + return ca; +} + +void ChannelImpl::ClearAccess() +{ + for (unsigned i = this->access->size(); i > 0; --i) + delete this->GetAccess(i - 1); +} + +AutoKick *ChannelImpl::AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t, time_t lu) +{ + if (!::akick) + return nullptr; + + AutoKick *autokick = ::akick->Create(); + autokick->ci = this; + autokick->nc = akicknc; + autokick->reason = reason; + autokick->creator = user; + autokick->addtime = t; + autokick->last_used = lu; + + this->akick->push_back(autokick); + + akicknc->AddChannelReference(this); + + return autokick; +} + +AutoKick *ChannelImpl::AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t, time_t lu) +{ + if (!::akick) + return nullptr; + + AutoKick *autokick = ::akick->Create(); + autokick->ci = this; + autokick->mask = mask; + autokick->nc = NULL; + autokick->reason = reason; + autokick->creator = user; + autokick->addtime = t; + autokick->last_used = lu; + + this->akick->push_back(autokick); + + return autokick; +} + +AutoKick *ChannelImpl::GetAkick(unsigned index) const +{ + if (this->akick->empty() || index >= this->akick->size()) + return NULL; + + AutoKick *ak = (*this->akick)[index]; + ak->QueueUpdate(); + return ak; +} + +unsigned ChannelImpl::GetAkickCount() const +{ + return this->akick->size(); +} + +void ChannelImpl::EraseAkick(unsigned index) +{ + if (this->akick->empty() || index >= this->akick->size()) + return; + + delete this->GetAkick(index); +} + +void ChannelImpl::ClearAkick() +{ + while (!this->akick->empty()) + delete this->akick->back(); +} + +int16_t ChannelImpl::GetLevel(const Anope::string &priv) const +{ + if (!ChanServ::service || !ChanServ::service->FindPrivilege(priv)) + { + Log(LOG_DEBUG) << "Unknown privilege " + priv; + return ChanServ::ACCESS_INVALID; + } + + Anope::map<int16_t>::const_iterator it = this->levels.find(priv); + if (it == this->levels.end()) + return 0; + return it->second; +} + +void ChannelImpl::SetLevel(const Anope::string &priv, int16_t level) +{ + this->levels[priv] = level; +} + +void ChannelImpl::RemoveLevel(const Anope::string &priv) +{ + this->levels.erase(priv); +} + +void ChannelImpl::ClearLevels() +{ + this->levels.clear(); +} + +Anope::string ChannelImpl::GetIdealBan(User *u) const +{ + int bt = this ? this->bantype : -1; + switch (bt) + { + case 0: + return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); + case 1: + if (u->GetVIdent()[0] == '~') + return "*!*" + u->GetVIdent() + "@" + u->GetDisplayedHost(); + else + return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); + case 3: + return "*!" + u->Mask(); + case 2: + default: + return "*!*@" + u->GetDisplayedHost(); + } +} + +bool ChannelImpl::IsFounder(const User *user) +{ + if (!user) + return false; + + if (user->super_admin) + return true; + + if (user->Account() && user->Account() == this->GetFounder()) + return true; + + return false; +} + + +void ChannelImpl::AddChannelReference(const Anope::string &what) +{ + ++references[what]; +} + +void ChannelImpl::RemoveChannelReference(const Anope::string &what) +{ + int &i = references[what]; + if (--i <= 0) + references.erase(what); +} + +void ChannelImpl::GetChannelReferences(std::deque<Anope::string> &chans) +{ + chans.clear(); + for (Anope::map<int>::iterator it = references.begin(); it != references.end(); ++it) + chans.push_back(it->first); +} diff --git a/modules/pseudoclients/chanserv/channel.h b/modules/pseudoclients/chanserv/channel.h new file mode 100644 index 000000000..c9a85dba6 --- /dev/null +++ b/modules/pseudoclients/chanserv/channel.h @@ -0,0 +1,41 @@ + + +class ChannelImpl : public ChanServ::Channel +{ + public: + ChannelImpl(const Anope::string &chname); + ChannelImpl(const ChanServ::Channel &ci); + ~ChannelImpl(); + + void Serialize(Serialize::Data &data) const override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &); + + bool IsFounder(const User *user) override; + void SetFounder(NickServ::Account *nc) override; + NickServ::Account *GetFounder() const override; + void SetSuccessor(NickServ::Account *nc) override; + NickServ::Account *GetSuccessor() const override; + BotInfo *WhoSends() const override; + void AddAccess(ChanServ::ChanAccess *access) override; + ChanServ::ChanAccess *GetAccess(unsigned index) const override; + ChanServ::AccessGroup AccessFor(const User *u) override; + ChanServ::AccessGroup AccessFor(const NickServ::Account *nc) override; + unsigned GetAccessCount() const override; + unsigned GetDeepAccessCount() const override; + ChanServ::ChanAccess *EraseAccess(unsigned index) override; + void ClearAccess() override; + AutoKick* AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) override; + AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) override; + AutoKick* GetAkick(unsigned index) const override; + unsigned GetAkickCount() const override; + void EraseAkick(unsigned index) override; + void ClearAkick() override; + int16_t GetLevel(const Anope::string &priv) const override; + void SetLevel(const Anope::string &priv, int16_t level) override; + void RemoveLevel(const Anope::string &priv) override; + void ClearLevels() override; + Anope::string GetIdealBan(User *u) const override; + void AddChannelReference(const Anope::string &what) override; + void RemoveChannelReference(const Anope::string &what) override; + void GetChannelReferences(std::deque<Anope::string> &chans) override; +}; diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv/chanserv.cpp index 419f25fc3..d4f3aa1c7 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv/chanserv.cpp @@ -10,14 +10,17 @@ */ #include "module.h" +#include "channel.h" #include "modules/cs_mode.h" #include "modules/help.h" #include "modules/bs_bot.h" #include "modules/chanserv.h" #include "modules/cs_info.h" +#include "modules/cs_akick.h" class ChanServCore : public Module , public ChanServ::ChanServService + , public EventHook<Event::ChannelCreate> , public EventHook<Event::BotDelete> , public EventHook<Event::BotPrivmsg> , public EventHook<Event::DelCore> @@ -44,10 +47,15 @@ class ChanServCore : public Module bool always_lower; EventHandlers<ChanServ::Event::PreChanExpire> OnPreChanExpire; EventHandlers<ChanServ::Event::ChanExpire> OnChanExpire; + std::vector<ChanServ::Privilege> Privileges; + std::vector<ChanServ::AccessProvider *> Providers; + Serialize::Checker<ChanServ::registered_channel_map> registered_channels; + Serialize::Type channel_type, access_type; public: ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) , ChanServService(this) + , EventHook<Event::ChannelCreate>("OnChannelCreate") , EventHook<Event::BotDelete>("OnBotDelete") , EventHook<Event::BotPrivmsg>("OnBotPrivmsg") , EventHook<Event::DelCore>("OnDelCore") @@ -71,9 +79,33 @@ class ChanServCore : public Module , always_lower(false) , OnPreChanExpire(this, "OnPreChanExpire") , OnChanExpire(this, "OnChanExpire") + , registered_channels("ChannelInfo") + , channel_type("ChannelInfo", ChannelImpl::Unserialize) + , access_type("ChanAccess", Unserialize) { } + ChanServ::Channel *Create(const Anope::string &name) override + { + return new ChannelImpl(name); + } + + ChanServ::Channel *Create(const ChanServ::Channel &ci) override + { + return new ChannelImpl(ci); + } + + ChanServ::Channel *Find(const Anope::string &name) override + { + auto it = registered_channels->find(name); + return it != registered_channels->end() ? it->second : nullptr; + } + + ChanServ::registered_channel_map& GetChannels() override + { + return registered_channels; + } + void Hold(Channel *c) override { /** A timer used to keep the BotServ bot/ChanServ in the channel @@ -86,7 +118,7 @@ class ChanServCore : public Module Reference<Channel> c; public: - /** Constructor + /** Constructor * @param chan The channel */ ChanServTimer(Reference<BotInfo> &cs, ExtensibleItem<bool> &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), ChanServ(cs), inhabit(i), c(chan) @@ -137,6 +169,166 @@ class ChanServCore : public Module new ChanServTimer(ChanServ, inhabit, this->owner, c); } + void AddPrivilege(ChanServ::Privilege p) override + { + unsigned i; + for (i = 0; i < Privileges.size(); ++i) + { + ChanServ::Privilege &priv = Privileges[i]; + + if (priv.rank > p.rank) + break; + } + + Privileges.insert(Privileges.begin() + i, p); + } + + void RemovePrivilege(ChanServ::Privilege &p) override + { + std::vector<ChanServ::Privilege>::iterator it = std::find(Privileges.begin(), Privileges.end(), p); + if (it != Privileges.end()) + Privileges.erase(it); + + for (auto& cit : GetChannels()) + { + ChanServ::Channel *ci = cit.second; + ci->QueueUpdate(); + ci->RemoveLevel(p.name); + } + } + + ChanServ::Privilege *FindPrivilege(const Anope::string &name) override + { + for (unsigned i = Privileges.size(); i > 0; --i) + if (Privileges[i - 1].name.equals_ci(name)) + return &Privileges[i - 1]; + return NULL; + } + + std::vector<ChanServ::Privilege> &GetPrivileges() override + { + return Privileges; + } + + void ClearPrivileges() override + { + Privileges.clear(); + } + + std::vector<ChanServ::AccessProvider *>& GetProviders() override + { + return Providers; + } + + void Destruct(ChanServ::ChanAccess *access) override + { + if (access->ci) + { + std::vector<ChanServ::ChanAccess *>::iterator it = std::find(access->ci->access->begin(), access->ci->access->end(), access); + if (it != access->ci->access->end()) + access->ci->access->erase(it); + + const NickServ::Nick *na = NickServ::FindNick(access->mask); + if (na != NULL) + na->nc->RemoveChannelReference(access->ci); + else + { + ChanServ::Channel *c = this->Find(access->mask); + if (c) + c->RemoveChannelReference(access->ci->name); + } + } + } + + void Serialize(const ChanServ::ChanAccess *, Serialize::Data &data) override + { + } + + bool Matches(const ChanServ::ChanAccess *access, const User *u, const NickServ::Account *acc, ChanServ::ChanAccess::Path &p) override + { + if (access->nc) + return access->nc == acc; + + if (u) + { + bool is_mask = access->mask.find_first_of("!@?*") != Anope::string::npos; + if (is_mask && Anope::Match(u->nick, access->mask)) + return true; + else if (Anope::Match(u->GetDisplayedMask(), access->mask)) + return true; + } + + if (acc) + { + for (unsigned i = 0; i < acc->aliases->size(); ++i) + { + const NickServ::Nick *na = acc->aliases->at(i); + if (Anope::Match(na->nick, access->mask)) + return true; + } + } + + if (IRCD->IsChannelValid(access->mask)) + { + ChanServ::Channel *tci = Find(access->mask); + if (tci) + { + for (unsigned i = 0; i < tci->GetAccessCount(); ++i) + { + ChanServ::ChanAccess *a = tci->GetAccess(i); + std::pair<const ChanServ::ChanAccess *, const ChanServ::ChanAccess *> pair = std::make_pair(access, a); + + std::pair<Set::iterator, Set::iterator> range = p.first.equal_range(access); + for (; range.first != range.second; ++range.first) + if (range.first->first == pair.first && range.first->second == pair.second) + goto cont; + + p.first.insert(pair); + if (a->Matches(u, acc, p)) + p.second.insert(pair); + + cont:; + } + + return p.second.count(access) > 0; + } + } + + return false; + } + + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) + { + Anope::string provider, chan; + + data["provider"] >> provider; + data["ci"] >> chan; + + ServiceReference<ChanServ::AccessProvider> aprovider("AccessProvider", provider); + ChanServ::Channel *ci = ChanServ::service->Find(chan); + if (!aprovider || !ci) + return NULL; + + ChanServ::ChanAccess *access; + if (obj) + access = anope_dynamic_static_cast<ChanServ::ChanAccess *>(obj); + else + access = aprovider->Create(); + access->ci = ci; + data["mask"] >> access->mask; + data["creator"] >> access->creator; + data["last_seen"] >> access->last_seen; + data["created"] >> access->created; + + Anope::string adata; + data["data"] >> adata; + access->AccessUnserialize(adata); + + if (!obj) + ci->AddAccess(access); + return access; + } + void OnReload(Configuration::Conf *conf) override { const Anope::string &channick = conf->GetModule(this)->Get<const Anope::string>("client"); @@ -150,6 +342,18 @@ class ChanServCore : public Module ChanServ = bi; + ClearPrivileges(); + for (int i = 0; i < conf->CountBlock("privilege"); ++i) + { + Configuration::Block *privilege = conf->GetBlock("privilege", i); + + const Anope::string &nname = privilege->Get<const Anope::string>("name"), + &desc = privilege->Get<const Anope::string>("desc"); + int rank = privilege->Get<int>("rank"); + + AddPrivilege(ChanServ::Privilege(nname, desc, rank)); + } + spacesepstream(conf->GetModule(this)->Get<const Anope::string>("defaults", "greet fantasy")).GetTokens(defaults); if (defaults.empty()) { @@ -164,6 +368,13 @@ class ChanServCore : public Module always_lower = conf->GetModule(this)->Get<bool>("always_lower_ts"); } + void OnChannelCreate(Channel *c) override + { + c->ci = Find(c->name); + if (c->ci) + c->ci->c = c; + } + void OnBotDelete(BotInfo *bi) override { if (bi == ChanServ) @@ -181,28 +392,28 @@ class ChanServCore : public Module return EVENT_CONTINUE; } - void OnDelCore(NickCore *nc) override + void OnDelCore(NickServ::Account *nc) override { - std::deque<ChannelInfo *> chans; + std::deque<ChanServ::Channel *> chans; nc->GetChannelReferences(chans); int max_reg = Config->GetModule(this)->Get<int>("maxregistered"); for (unsigned i = 0; i < chans.size(); ++i) { - ChannelInfo *ci = chans[i]; + ChanServ::Channel *ci = chans[i]; if (ci->GetFounder() == nc) { - NickCore *newowner = NULL; + NickServ::Account *newowner = NULL; if (ci->GetSuccessor() && ci->GetSuccessor() != nc && (ci->GetSuccessor()->IsServicesOper() || !max_reg || ci->GetSuccessor()->channelcount < max_reg)) newowner = ci->GetSuccessor(); else { - const ChanAccess *highest = NULL; + const ChanServ::ChanAccess *highest = NULL; for (unsigned j = 0; j < ci->GetAccessCount(); ++j) { - const ChanAccess *ca = ci->GetAccess(j); - const NickCore *anc = NickCore::Find(ca->mask); + const ChanServ::ChanAccess *ca = ci->GetAccess(j); + const NickServ::Account *anc = NickServ::FindAccount(ca->mask); if (!anc || (!anc->IsServicesOper() && max_reg && anc->channelcount >= max_reg) || (anc == nc)) continue; @@ -210,7 +421,7 @@ class ChanServCore : public Module highest = ca; } if (highest) - newowner = NickCore::Find(highest->mask); + newowner = NickServ::FindAccount(highest->mask); } if (newowner) @@ -233,8 +444,8 @@ class ChanServCore : public Module for (unsigned j = 0; j < ci->GetAccessCount(); ++j) { - const ChanAccess *ca = ci->GetAccess(j); - const NickCore *anc = NickCore::Find(ca->mask); + const ChanServ::ChanAccess *ca = ci->GetAccess(j); + const NickServ::Account *anc = NickServ::FindAccount(ca->mask); if (anc && anc == nc) { @@ -245,8 +456,8 @@ class ChanServCore : public Module for (unsigned j = 0; j < ci->GetAkickCount(); ++j) { - const AutoKick *akick = ci->GetAkick(j); - if (akick->nc == nc) + const AutoKick *ak = ci->GetAkick(j); + if (ak->nc == nc) { ci->EraseAkick(j); break; @@ -255,7 +466,7 @@ class ChanServCore : public Module } } - void OnDelChan(ChannelInfo *ci) override + void OnDelChan(ChanServ::Channel *ci) override { /* remove access entries that are this channel */ @@ -264,13 +475,13 @@ class ChanServCore : public Module for (unsigned i = 0; i < chans.size(); ++i) { - ChannelInfo *c = ChannelInfo::Find(chans[i]); + ChanServ::Channel *c = ChanServ::Find(chans[i]); if (!c) continue; for (unsigned j = 0; j < c->GetAccessCount(); ++j) { - ChanAccess *a = c->GetAccess(j); + ChanServ::ChanAccess *a = c->GetAccess(j); if (a->mask.equals_ci(ci->name)) { @@ -342,7 +553,7 @@ class ChanServCore : public Module } } - void OnCreateChan(ChannelInfo *ci) override + void OnCreateChan(ChanServ::Channel *ci) override { /* Set default chan flags */ for (unsigned i = 0; i < defaults.size(); ++i) @@ -379,9 +590,9 @@ class ChanServCore : public Module if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly) return; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ) + for (auto it = registered_channels->begin(); it != registered_channels->end();) { - ChannelInfo *ci = it->second; + ChanServ::Channel *ci = it->second; ++it; bool expire = false; @@ -428,9 +639,9 @@ class ChanServCore : public Module if (!persist) return; /* Find all persistent channels and create them, as we are about to finish burst to our uplink */ - for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + for (auto& it : *registered_channels) { - ChannelInfo *ci = it->second; + ChanServ::Channel *ci = it.second; if (persist->Get(ci)) { bool c; @@ -456,8 +667,8 @@ class ChanServCore : public Module } } - - void OnChanRegistered(ChannelInfo *ci) override + + void OnChanRegistered(ChanServ::Channel *ci) override { if (!persist || !ci->c) return; @@ -499,7 +710,7 @@ class ChanServCore : public Module return EVENT_CONTINUE; } - void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) override + void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override { if (!show_all) return; @@ -509,7 +720,7 @@ class ChanServCore : public Module info[_("Expires")] = Anope::strftime(ci->last_used + chanserv_expire, source.GetAccount()); } - void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) override + void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override { if (always_lower) // Since we always lower the TS, the other side will remove the modes if the channel ts lowers, so we don't diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index e7577db47..42b629af6 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -79,7 +79,7 @@ class GlobalCore : public Module if (!gl.empty()) this->SendGlobal(Global, "", gl); } - + void OnShutdown() override { const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycledown"); diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp index 373275e59..f99d0712a 100644 --- a/modules/pseudoclients/hostserv.cpp +++ b/modules/pseudoclients/hostserv.cpp @@ -22,7 +22,7 @@ class HostServCore : public Module , public EventHook<Event::DeleteVhost> { Reference<BotInfo> HostServ; - + public: HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) , EventHook<Event::UserLogin>("OnUserLogin") @@ -54,9 +54,9 @@ class HostServCore : public Module if (!IRCD->CanSetVHost) return; - const NickAlias *na = NickAlias::Find(u->nick); + const NickServ::Nick *na = NickServ::FindNick(u->nick); if (!na || na->nc != u->Account() || !na->HasVhost()) - na = NickAlias::Find(u->Account()->display); + na = NickServ::FindNick(u->Account()->display); if (!na || !na->HasVhost()) return; @@ -73,9 +73,9 @@ class HostServCore : public Module if (HostServ) { if (!na->GetVhostIdent().empty()) - u->SendMessage(HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); + u->SendMessage(*HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - u->SendMessage(HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); + u->SendMessage(*HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); } } } @@ -97,7 +97,7 @@ class HostServCore : public Module { } - void OnSetVhost(NickAlias *na) override + void OnSetVhost(NickServ::Nick *na) override { if (Config->GetModule(this)->Get<bool>("activate_on_set")) { @@ -116,15 +116,15 @@ class HostServCore : public Module if (HostServ) { if (!na->GetVhostIdent().empty()) - u->SendMessage(HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); + u->SendMessage(*HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - u->SendMessage(HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); + u->SendMessage(*HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); } } } } - void OnDeleteVhost(NickAlias *na) override + void OnDeleteVhost(NickServ::Nick *na) override { if (Config->GetModule(this)->Get<bool>("activate_on_set")) { diff --git a/modules/pseudoclients/memoserv/CMakeLists.txt b/modules/pseudoclients/memoserv/CMakeLists.txt new file mode 100644 index 000000000..781f0ef1f --- /dev/null +++ b/modules/pseudoclients/memoserv/CMakeLists.txt @@ -0,0 +1 @@ +build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/pseudoclients/memoserv/memo.cpp b/modules/pseudoclients/memoserv/memo.cpp new file mode 100644 index 000000000..9383e3b8b --- /dev/null +++ b/modules/pseudoclients/memoserv/memo.cpp @@ -0,0 +1,58 @@ +#include "memo.h" + +MemoImpl::MemoImpl() +{ + unread = receipt = false; +} + +MemoImpl::~MemoImpl() +{ + bool ischan, isregistered; + MemoServ::MemoInfo *mi = MemoServ::service->GetMemoInfo(this->owner, ischan, isregistered, false); + if (mi) + { + std::vector<Memo *>::iterator it = std::find(mi->memos->begin(), mi->memos->end(), this); + + if (it != mi->memos->end()) + mi->memos->erase(it); + } +} + +void MemoImpl::Serialize(Serialize::Data &data) const +{ + data["owner"] << this->owner; + data.SetType("time", Serialize::Data::DT_INT); data["time"] << this->time; + data["sender"] << this->sender; + data["text"] << this->text; + data["unread"] << this->unread; + data["receipt"] << this->receipt; +} + +Serializable* MemoImpl::Unserialize(Serializable *obj, Serialize::Data &data) +{ + Anope::string owner; + + data["owner"] >> owner; + + bool ischan, isregistered; + MemoServ::MemoInfo *mi = MemoServ::service->GetMemoInfo(owner, ischan, isregistered, true); + if (!mi) + return NULL; + + Memo *m; + if (obj) + m = anope_dynamic_static_cast<Memo *>(obj); + else + m = new MemoImpl(); + + m->owner = owner; + data["time"] >> m->time; + data["sender"] >> m->sender; + data["text"] >> m->text; + data["unread"] >> m->unread; + data["receipt"] >> m->receipt; + + if (obj == NULL) + mi->memos->push_back(m); + return m; +} diff --git a/modules/pseudoclients/memoserv/memo.h b/modules/pseudoclients/memoserv/memo.h new file mode 100644 index 000000000..fbe8734a6 --- /dev/null +++ b/modules/pseudoclients/memoserv/memo.h @@ -0,0 +1,11 @@ +#include "modules/memoserv.h" + +class MemoImpl : public MemoServ::Memo +{ + public: + MemoImpl(); + ~MemoImpl(); + + void Serialize(Serialize::Data &data) const override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &); +}; diff --git a/modules/pseudoclients/memoserv/memoinfo.cpp b/modules/pseudoclients/memoserv/memoinfo.cpp new file mode 100644 index 000000000..a51cd4e6a --- /dev/null +++ b/modules/pseudoclients/memoserv/memoinfo.cpp @@ -0,0 +1,33 @@ +#include "memoinfo.h" + +MemoServ::Memo *MemoInfoImpl::GetMemo(unsigned index) const +{ + if (index >= this->memos->size()) + return NULL; + MemoServ::Memo *m = (*memos)[index]; + m->QueueUpdate(); + return m; +} + +unsigned MemoInfoImpl::GetIndex(MemoServ::Memo *m) const +{ + for (unsigned i = 0; i < this->memos->size(); ++i) + if (this->GetMemo(i) == m) + return i; + return -1; +} + +void MemoInfoImpl::Del(unsigned index) +{ + if (index >= this->memos->size()) + return; + delete this->GetMemo(index); +} + +bool MemoInfoImpl::HasIgnore(User *u) +{ + for (unsigned i = 0; i < this->ignores.size(); ++i) + if (u->nick.equals_ci(this->ignores[i]) || (u->Account() && u->Account()->display.equals_ci(this->ignores[i])) || Anope::Match(u->GetMask(), Anope::string(this->ignores[i]))) + return true; + return false; +} diff --git a/modules/pseudoclients/memoserv/memoinfo.h b/modules/pseudoclients/memoserv/memoinfo.h new file mode 100644 index 000000000..06bea0682 --- /dev/null +++ b/modules/pseudoclients/memoserv/memoinfo.h @@ -0,0 +1,10 @@ +#include "modules/memoserv.h" + +struct MemoInfoImpl : MemoServ::MemoInfo +{ + MemoServ::Memo *GetMemo(unsigned index) const override; + unsigned GetIndex(MemoServ::Memo *m) const override; + void Del(unsigned index) override; + bool HasIgnore(User *u) override; +}; + diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv/memoserv.cpp index c9b11d294..c0a1022d0 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv/memoserv.cpp @@ -14,6 +14,8 @@ #include "modules/help.h" #include "modules/bs_bot.h" #include "modules/memoserv.h" +#include "memoinfo.h" +#include "memo.h" class MemoServCore : public Module, public MemoServ::MemoServService , public EventHook<Event::NickCoreCreate> @@ -28,8 +30,9 @@ class MemoServCore : public Module, public MemoServ::MemoServService Reference<BotInfo> MemoServ; EventHandlers<MemoServ::Event::MemoSend> onmemosend; EventHandlers<MemoServ::Event::MemoDel> onmemodel; + Serialize::Type memo_type; - bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m) + bool SendMemoMail(NickServ::Account *nc, MemoServ::MemoInfo *mi, MemoServ::Memo *m) { Anope::string subject = Language::Translate(nc, Config->GetBlock("mail")->Get<const Anope::string>("memo_subject").c_str()), message = Language::Translate(Config->GetBlock("mail")->Get<const Anope::string>("memo_message").c_str()); @@ -62,13 +65,14 @@ class MemoServCore : public Module, public MemoServ::MemoServService , EventHook<Event::Help>("OnHelp") , onmemosend(this, "OnMemoSend") , onmemodel(this, "OnMemoDel") + , memo_type("Memo", MemoImpl::Unserialize) { } MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) override { - bool ischan; - MemoInfo *mi = MemoInfo::GetMemoInfo(target, ischan); + bool ischan, isregistered; + MemoServ::MemoInfo *mi = GetMemoInfo(target, ischan, isregistered, true); if (mi == NULL) return MEMO_INVALID_TARGET; @@ -90,7 +94,7 @@ class MemoServCore : public Module, public MemoServ::MemoServService if (sender != NULL) sender->lastmemosend = Anope::CurTime; - Memo *m = new Memo(); + MemoServ::Memo *m = new MemoImpl(); mi->memos->push_back(m); m->owner = target; m->sender = source; @@ -102,7 +106,7 @@ class MemoServCore : public Module, public MemoServ::MemoServService if (ischan) { - ChannelInfo *ci = ChannelInfo::Find(target); + ChanServ::Channel *ci = ChanServ::Find(target); if (ci->c) { @@ -113,23 +117,23 @@ class MemoServCore : public Module, public MemoServ::MemoServService if (ci->AccessFor(cu->user).HasPriv("MEMO")) { if (cu->user->Account() && cu->user->Account()->HasExt("MEMO_RECEIVE")) - cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), ci->name.c_str(), mi->memos->size()); + cu->user->SendMessage(*MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), ci->name.c_str(), mi->memos->size()); } } } } else { - NickCore *nc = NickAlias::Find(target)->nc; + NickServ::Account *nc = NickServ::FindNick(target)->nc; if (nc->HasExt("MEMO_RECEIVE")) { for (unsigned i = 0; i < nc->aliases->size(); ++i) { - const NickAlias *na = nc->aliases->at(i); + const NickServ::Nick *na = nc->aliases->at(i); User *user = User::Find(na->nick); if (user && user->IsIdentified()) - user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), mi->memos->size()); + user->SendMessage(*MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), mi->memos->size()); } } @@ -141,27 +145,66 @@ class MemoServCore : public Module, public MemoServ::MemoServService return MEMO_SUCCESS; } - void Check(User *u) + void Check(User *u) override { - const NickCore *nc = u->Account(); - if (!nc) + const NickServ::Account *nc = u->Account(); + if (!nc || !nc->memos) return; - unsigned i = 0, end = nc->memos.memos->size(), newcnt = 0; + unsigned i = 0, end = nc->memos->memos->size(), newcnt = 0; for (; i < end; ++i) - if (nc->memos.GetMemo(i)->unread) + if (nc->memos->GetMemo(i)->unread) ++newcnt; if (newcnt > 0) - u->SendMessage(MemoServ, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt); - if (nc->memos.memomax > 0 && nc->memos.memos->size() >= static_cast<unsigned>(nc->memos.memomax)) + u->SendMessage(*MemoServ, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt); + if (nc->memos->memomax > 0 && nc->memos->memos->size() >= static_cast<unsigned>(nc->memos->memomax)) { - if (nc->memos.memos->size() > static_cast<unsigned>(nc->memos.memomax)) - u->SendMessage(MemoServ, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax); + if (nc->memos->memos->size() > static_cast<unsigned>(nc->memos->memomax)) + u->SendMessage(*MemoServ, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos->memomax); else - u->SendMessage(MemoServ, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax); + u->SendMessage(*MemoServ, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos->memomax); } } + MemoServ::Memo *CreateMemo() override + { + return new MemoImpl(); + } + + MemoServ::MemoInfo *GetMemoInfo(const Anope::string &target, bool &is_registered, bool &ischan, bool create) override + { + if (!target.empty() && target[0] == '#') + { + ischan = true; + ChanServ::Channel *ci = ChanServ::Find(target); + if (ci != NULL) + { + is_registered = true; + if (create && !ci->memos) + ci->memos = new MemoInfoImpl(); + return ci->memos; + } + else + is_registered = false; + } + else + { + ischan = false; + NickServ::Nick *na = NickServ::FindNick(target); + if (na != NULL) + { + is_registered = true; + if (create && !na->nc->memos) + na->nc->memos = new MemoInfoImpl(); + return na->nc->memos; + } + else + is_registered = false; + } + + return NULL; + } + void OnReload(Configuration::Conf *conf) override { const Anope::string &msnick = conf->GetModule(this)->Get<const Anope::string>("client"); @@ -176,14 +219,16 @@ class MemoServCore : public Module, public MemoServ::MemoServService MemoServ = bi; } - void OnNickCoreCreate(NickCore *nc) override + void OnNickCoreCreate(NickServ::Account *nc) override { - nc->memos.memomax = Config->GetModule(this)->Get<int>("maxmemos"); + nc->memos = new MemoInfoImpl(); + nc->memos->memomax = Config->GetModule(this)->Get<int>("maxmemos"); } - void OnCreateChan(ChannelInfo *ci) override + void OnCreateChan(ChanServ::Channel *ci) override { - ci->memos.memomax = Config->GetModule(this)->Get<int>("maxmemos"); + ci->memos = new MemoInfoImpl(); + ci->memos->memomax = Config->GetModule(this)->Get<int>("maxmemos"); } void OnBotDelete(BotInfo *bi) override @@ -199,12 +244,12 @@ class MemoServCore : public Module, public MemoServ::MemoServService void OnJoinChannel(User *u, Channel *c) override { - if (c->ci && !c->ci->memos.memos->empty() && c->ci->AccessFor(u).HasPriv("MEMO")) + if (c->ci && c->ci->memos && !c->ci->memos->memos->empty() && c->ci->AccessFor(u).HasPriv("MEMO")) { - if (c->ci->memos.memos->size() == 1) - u->SendMessage(MemoServ, _("There is \002%d\002 memo on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str()); + if (c->ci->memos->memos->size() == 1) + u->SendMessage(*MemoServ, _("There is \002%d\002 memo on channel %s."), c->ci->memos->memos->size(), c->ci->name.c_str()); else - u->SendMessage(MemoServ, _("There are \002%d\002 memos on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str()); + u->SendMessage(*MemoServ, _("There are \002%d\002 memos on channel %s."), c->ci->memos->memos->size(), c->ci->name.c_str()); } } diff --git a/modules/pseudoclients/nickserv/CMakeLists.txt b/modules/pseudoclients/nickserv/CMakeLists.txt new file mode 100644 index 000000000..781f0ef1f --- /dev/null +++ b/modules/pseudoclients/nickserv/CMakeLists.txt @@ -0,0 +1 @@ +build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/pseudoclients/nickserv/account.cpp b/modules/pseudoclients/nickserv/account.cpp new file mode 100644 index 000000000..55c537a0c --- /dev/null +++ b/modules/pseudoclients/nickserv/account.cpp @@ -0,0 +1,264 @@ +/* + * + * (C) 2003-2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + */ + +#include "module.h" +#include "account.h" + +AccountImpl::AccountImpl(const Anope::string &coredisplay) +{ + if (coredisplay.empty()) + throw CoreException("Empty display passed to NickServ::Account constructor"); + + this->o = NULL; + this->channelcount = 0; + this->lastmail = 0; + + this->display = coredisplay; + + NickServ::nickcore_map& map = NickServ::service->GetAccountList(); + NickServ::Account* &nc = map[this->display]; + if (nc) + Log(LOG_DEBUG) << "Duplicate account " << coredisplay << " in nickcore table?"; + nc = this; + + Event::OnNickCoreCreate(&Event::NickCoreCreate::OnNickCoreCreate, this); +} + +AccountImpl::~AccountImpl() +{ + Event::OnDelCore(&Event::DelCore::OnDelCore, this); + + if (!this->chanaccess->empty()) + Log(LOG_DEBUG) << "Non-empty chanaccess list in destructor!"; + + for (std::list<User *>::iterator it = this->users.begin(); it != this->users.end();) + { + User *user = *it++; + user->Logout(); + } + this->users.clear(); + + NickServ::nickcore_map& map = NickServ::service->GetAccountList(); + map.erase(this->display); + + this->ClearAccess(); + + if (memos) + { + for (unsigned i = 0, end = this->memos->memos->size(); i < end; ++i) + delete this->memos->GetMemo(i); + this->memos->memos->clear(); + delete memos; + } +} + +void AccountImpl::Serialize(Serialize::Data &data) const +{ + data["display"] << this->display; + data["pass"] << this->pass; + data["email"] << this->email; + data["language"] << this->language; + for (unsigned i = 0; i < this->access.size(); ++i) + data["access"] << this->access[i] << " "; + if (memos) + { + data["memomax"] << this->memos->memomax; + for (unsigned i = 0; i < this->memos->ignores.size(); ++i) + data["memoignores"] << this->memos->ignores[i] << " "; + } + Extensible::ExtensibleSerialize(this, this, data); +} + +Serializable* AccountImpl::Unserialize(Serializable *obj, Serialize::Data &data) +{ + NickServ::Account *nc; + + Anope::string sdisplay; + + data["display"] >> sdisplay; + + if (obj) + nc = anope_dynamic_static_cast<NickServ::Account *>(obj); + else + nc = new AccountImpl(sdisplay); + + data["pass"] >> nc->pass; + data["email"] >> nc->email; + data["language"] >> nc->language; + { + Anope::string buf; + data["access"] >> buf; + spacesepstream sep(buf); + nc->access.clear(); + while (sep.GetToken(buf)) + nc->access.push_back(buf); + } + if (nc->memos) + { + data["memomax"] >> nc->memos->memomax; + { + Anope::string buf; + data["memoignores"] >> buf; + spacesepstream sep(buf); + nc->memos->ignores.clear(); + while (sep.GetToken(buf)) + nc->memos->ignores.push_back(buf); + } + } + + Extensible::ExtensibleUnserialize(nc, nc, data); + + /* compat */ + bool b; + b = false; + data["extensible:SECURE"] >> b; + if (b) + nc->Extend<bool>("NS_SECURE"); + b = false; + data["extensible:PRIVATE"] >> b; + if (b) + nc->Extend<bool>("NS_PRIVATE"); + b = false; + data["extensible:AUTOOP"] >> b; + if (b) + nc->Extend<bool>("AUTOOP"); + b = false; + data["extensible:HIDE_EMAIL"] >> b; + if (b) + nc->Extend<bool>("HIDE_EMAIL"); + b = false; + data["extensible:HIDE_QUIT"] >> b; + if (b) + nc->Extend<bool>("HIDE_QUIT"); + b = false; + data["extensible:MEMO_RECEIVE"] >> b; + if (b) + nc->Extend<bool>("MEMO_RECEIVE"); + b = false; + data["extensible:MEMO_SIGNON"] >> b; + if (b) + nc->Extend<bool>("MEMO_SIGNON"); + b = false; + data["extensible:KILLPROTECT"] >> b; + if (b) + nc->Extend<bool>("KILLPROTECT"); + /* end compat */ + + return nc; +} + +void AccountImpl::SetDisplay(const NickServ::Nick *na) +{ + if (na->nc != this || na->nick == this->display) + return; + + Event::OnChangeCoreDisplay(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, this, na->nick); + + NickServ::nickcore_map& map = NickServ::service->GetAccountList(); + + /* Remove the core from the list */ + map.erase(this->display); + + this->display = na->nick; + + NickServ::Account* &nc = map[this->display]; + if (nc) + Log(LOG_DEBUG) << "Duplicate account " << display << " in nickcore table?"; + + nc = this; +} + +bool AccountImpl::IsServicesOper() const +{ + return this->o != NULL; +} + +void AccountImpl::AddAccess(const Anope::string &entry) +{ + this->access.push_back(entry); + Event::OnNickAddAccess(&Event::NickAddAccess::OnNickAddAccess, this, entry); +} + +Anope::string AccountImpl::GetAccess(unsigned entry) const +{ + if (this->access.empty() || entry >= this->access.size()) + return ""; + return this->access[entry]; +} + +unsigned AccountImpl::GetAccessCount() const +{ + return this->access.size(); +} + +bool AccountImpl::FindAccess(const Anope::string &entry) +{ + for (unsigned i = 0, end = this->access.size(); i < end; ++i) + if (this->access[i] == entry) + return true; + + return false; +} + +void AccountImpl::EraseAccess(const Anope::string &entry) +{ + for (unsigned i = 0, end = this->access.size(); i < end; ++i) + if (this->access[i] == entry) + { + Event::OnNickEraseAccess(&Event::NickEraseAccess::OnNickEraseAccess, this, entry); + this->access.erase(this->access.begin() + i); + break; + } +} + +void AccountImpl::ClearAccess() +{ + Event::OnNickClearAccess(&Event::NickClearAccess::OnNickClearAccess, this); + this->access.clear(); +} + +bool AccountImpl::IsOnAccess(const User *u) const +{ + Anope::string buf = u->GetIdent() + "@" + u->host, buf2, buf3; + if (!u->vhost.empty()) + buf2 = u->GetIdent() + "@" + u->vhost; + if (!u->GetCloakedHost().empty()) + buf3 = u->GetIdent() + "@" + u->GetCloakedHost(); + + for (unsigned i = 0, end = this->access.size(); i < end; ++i) + { + Anope::string a = this->GetAccess(i); + if (Anope::Match(buf, a) || (!buf2.empty() && Anope::Match(buf2, a)) || (!buf3.empty() && Anope::Match(buf3, a))) + return true; + } + return false; +} + +void AccountImpl::AddChannelReference(ChanServ::Channel *ci) +{ + ++(*this->chanaccess)[ci]; +} + +void AccountImpl::RemoveChannelReference(ChanServ::Channel *ci) +{ + int& i = (*this->chanaccess)[ci]; + if (--i <= 0) + this->chanaccess->erase(ci); +} + +void AccountImpl::GetChannelReferences(std::deque<ChanServ::Channel *> &queue) +{ + queue.clear(); + for (std::map<ChanServ::Channel *, int>::iterator it = this->chanaccess->begin(), it_end = this->chanaccess->end(); it != it_end; ++it) + queue.push_back(it->first); +} + diff --git a/modules/pseudoclients/nickserv/account.h b/modules/pseudoclients/nickserv/account.h new file mode 100644 index 000000000..ec154e8d0 --- /dev/null +++ b/modules/pseudoclients/nickserv/account.h @@ -0,0 +1,22 @@ +#include "modules/nickserv.h" + +class AccountImpl : public NickServ::Account +{ + public: + AccountImpl(const Anope::string &nickdisplay); + ~AccountImpl(); + void Serialize(Serialize::Data &data) const override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &); + void SetDisplay(const NickServ::Nick *na) override; + bool IsServicesOper() const override; + void AddAccess(const Anope::string &entry) override; + Anope::string GetAccess(unsigned entry) const override; + unsigned GetAccessCount() const override; + bool FindAccess(const Anope::string &entry) override; + void EraseAccess(const Anope::string &entry) override; + void ClearAccess() override; + bool IsOnAccess(const User *u) const override; + void AddChannelReference(ChanServ::Channel *ci); + void RemoveChannelReference(ChanServ::Channel *ci) override; + void GetChannelReferences(std::deque<ChanServ::Channel *> &queue) override; +}; diff --git a/modules/pseudoclients/nickserv/identifyrequest.cpp b/modules/pseudoclients/nickserv/identifyrequest.cpp new file mode 100644 index 000000000..4fc2f9989 --- /dev/null +++ b/modules/pseudoclients/nickserv/identifyrequest.cpp @@ -0,0 +1,51 @@ +#include "identifyrequest.h" + +IdentifyRequestImpl::IdentifyRequestImpl(NickServ::IdentifyRequestListener *li, Module *o, const Anope::string &acc, const Anope::string &pass) : NickServ::IdentifyRequest(li, o, acc, pass) +{ + std::set<NickServ::IdentifyRequest *> &requests = NickServ::service->GetIdentifyRequests(); + requests.insert(this); +} + +IdentifyRequestImpl::~IdentifyRequestImpl() +{ + std::set<NickServ::IdentifyRequest *> &requests = NickServ::service->GetIdentifyRequests(); + requests.erase(this); + delete l; +} + +void IdentifyRequestImpl::Hold(Module *m) +{ + holds.insert(m); +} + +void IdentifyRequestImpl::Release(Module *m) +{ + holds.erase(m); + if (holds.empty() && dispatched) + { + if (!success) + l->OnFail(this); + delete this; + } +} + +void IdentifyRequestImpl::Success(Module *m) +{ + if (!success) + { + l->OnSuccess(this); + success = true; + } +} + +void IdentifyRequestImpl::Dispatch() +{ + if (holds.empty()) + { + if (!success) + l->OnFail(this); + delete this; + } + else + dispatched = true; +} diff --git a/modules/pseudoclients/nickserv/identifyrequest.h b/modules/pseudoclients/nickserv/identifyrequest.h new file mode 100644 index 000000000..e74d3129e --- /dev/null +++ b/modules/pseudoclients/nickserv/identifyrequest.h @@ -0,0 +1,13 @@ +#include "modules/nickserv.h" + +class IdentifyRequestImpl : public NickServ::IdentifyRequest +{ + public: + IdentifyRequestImpl(NickServ::IdentifyRequestListener *, Module *o, const Anope::string &acc, const Anope::string &pass); + virtual ~IdentifyRequestImpl(); + + void Hold(Module *m) override; + void Release(Module *m) override; + void Success(Module *m) override; + void Dispatch() override; +}; diff --git a/modules/pseudoclients/nickserv/nick.cpp b/modules/pseudoclients/nickserv/nick.cpp new file mode 100644 index 000000000..acba58b1e --- /dev/null +++ b/modules/pseudoclients/nickserv/nick.cpp @@ -0,0 +1,198 @@ +/* + * + * (C) 2003-2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + */ + +#include "module.h" +#include "nick.h" + +NickImpl::NickImpl(const Anope::string &nickname, NickServ::Account* nickcore) +{ + if (nickname.empty()) + throw CoreException("Empty nick passed to NickServ::Nick constructor"); + else if (!nickcore) + throw CoreException("Empty nickcore passed to NickServ::Nick constructor"); + + this->time_registered = this->last_seen = Anope::CurTime; + this->nick = nickname; + this->nc = nickcore; + nickcore->aliases->push_back(this); + + NickServ::nickalias_map &map = NickServ::service->GetNickList(); + NickServ::Nick* &na = map[this->nick]; + if (na) + Log(LOG_DEBUG) << "Duplicate nick " << nickname << " in nickalias table"; + na = this; + + if (this->nc->o == NULL) + { + Oper *o = Oper::Find(this->nick); + if (o == NULL) + o = Oper::Find(this->nc->display); + nickcore->o = o; + if (this->nc->o != NULL) + Log() << "Tied oper " << this->nc->display << " to type " << this->nc->o->ot->GetName(); + } +} + +NickImpl::~NickImpl() +{ + Event::OnDelNick(&Event::DelNick::OnDelNick, this); + + /* Accept nicks that have no core, because of database load functions */ + if (this->nc) + { + /* Next: see if our core is still useful. */ + std::vector<NickServ::Nick *>::iterator it = std::find(this->nc->aliases->begin(), this->nc->aliases->end(), this); + if (it != this->nc->aliases->end()) + this->nc->aliases->erase(it); + if (this->nc->aliases->empty()) + { + delete this->nc; + this->nc = NULL; + } + else + { + /* Display updating stuff */ + if (this->nick.equals_ci(this->nc->display)) + this->nc->SetDisplay(this->nc->aliases->front()); + } + } + + /* Remove us from the aliases list */ + NickServ::nickalias_map &map = NickServ::service->GetNickList(); + map.erase(this->nick); +} + +void NickImpl::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created) +{ + this->vhost_ident = ident; + this->vhost_host = host; + this->vhost_creator = creator; + this->vhost_created = created; +} + +void NickImpl::RemoveVhost() +{ + this->vhost_ident.clear(); + this->vhost_host.clear(); + this->vhost_creator.clear(); + this->vhost_created = 0; +} + +bool NickImpl::HasVhost() const +{ + return !this->vhost_host.empty(); +} + +const Anope::string &NickImpl::GetVhostIdent() const +{ + return this->vhost_ident; +} + +const Anope::string &NickImpl::GetVhostHost() const +{ + return this->vhost_host; +} + +const Anope::string &NickImpl::GetVhostCreator() const +{ + return this->vhost_creator; +} + +time_t NickImpl::GetVhostCreated() const +{ + return this->vhost_created; +} + +void NickImpl::Serialize(Serialize::Data &data) const +{ + data["nick"] << this->nick; + data["last_quit"] << this->last_quit; + data["last_realname"] << this->last_realname; + data["last_usermask"] << this->last_usermask; + data["last_realhost"] << this->last_realhost; + data.SetType("time_registered", Serialize::Data::DT_INT); data["time_registered"] << this->time_registered; + data.SetType("last_seen", Serialize::Data::DT_INT); data["last_seen"] << this->last_seen; + data["nc"] << this->nc->display; + + if (this->HasVhost()) + { + data["vhost_ident"] << this->GetVhostIdent(); + data["vhost_host"] << this->GetVhostHost(); + data["vhost_creator"] << this->GetVhostCreator(); + data["vhost_time"] << this->GetVhostCreated(); + } + + Extensible::ExtensibleSerialize(this, this, data); +} + +Serializable* NickImpl::Unserialize(Serializable *obj, Serialize::Data &data) +{ + Anope::string snc, snick; + + data["nc"] >> snc; + data["nick"] >> snick; + + NickServ::Account *core = NickServ::FindAccount(snc); + if (core == NULL) + return NULL; + + NickServ::Nick *na; + if (obj) + na = anope_dynamic_static_cast<NickServ::Nick *>(obj); + else + na = new NickImpl(snick, core); + + if (na->nc != core) + { + std::vector<NickServ::Nick *>::iterator it = std::find(na->nc->aliases->begin(), na->nc->aliases->end(), na); + if (it != na->nc->aliases->end()) + na->nc->aliases->erase(it); + + if (na->nc->aliases->empty()) + delete na->nc; + else if (na->nick.equals_ci(na->nc->display)) + na->nc->SetDisplay(na->nc->aliases->front()); + + na->nc = core; + core->aliases->push_back(na); + } + + data["last_quit"] >> na->last_quit; + data["last_realname"] >> na->last_realname; + data["last_usermask"] >> na->last_usermask; + data["last_realhost"] >> na->last_realhost; + data["time_registered"] >> na->time_registered; + data["last_seen"] >> na->last_seen; + + Anope::string vhost_ident, vhost_host, vhost_creator; + time_t vhost_time; + + data["vhost_ident"] >> vhost_ident; + data["vhost_host"] >> vhost_host; + data["vhost_creator"] >> vhost_creator; + data["vhost_time"] >> vhost_time; + + na->SetVhost(vhost_ident, vhost_host, vhost_creator, vhost_time); + + Extensible::ExtensibleUnserialize(na, na, data); + + /* compat */ + bool b; + b = false; + data["extensible:NO_EXPIRE"] >> b; + if (b) + na->Extend<bool>("NS_NO_EXPIRE"); + /* end compat */ + + return na; +} + diff --git a/modules/pseudoclients/nickserv/nick.h b/modules/pseudoclients/nickserv/nick.h new file mode 100644 index 000000000..76c948f1e --- /dev/null +++ b/modules/pseudoclients/nickserv/nick.h @@ -0,0 +1,18 @@ + +class NickImpl : public NickServ::Nick +{ + public: + NickImpl(const Anope::string &nickname, NickServ::Account *nickcore); + ~NickImpl(); + + void Serialize(Serialize::Data &data) const override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &); + + void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime); + void RemoveVhost(); + bool HasVhost() const; + const Anope::string &GetVhostIdent() const override; + const Anope::string &GetVhostHost() const override; + const Anope::string &GetVhostCreator() const override; + time_t GetVhostCreated() const override; +}; diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv/nickserv.cpp index f29b1aa02..b58fe3ccc 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv/nickserv.cpp @@ -15,6 +15,9 @@ #include "modules/ns_update.h" #include "modules/help.h" #include "modules/nickserv.h" +#include "nick.h" +#include "account.h" +#include "identifyrequest.h" /** Timer for colliding nicks to force people off of nicknames */ @@ -23,10 +26,10 @@ class NickServCollide : public Timer NickServ::NickServService *service; Reference<User> u; time_t ts; - Reference<NickAlias> na; + Reference<NickServ::Nick> na; public: - NickServCollide(NickServ::NickServService *nss, User *user, NickAlias *nick, time_t delay) : Timer(delay), service(nss), u(user), ts(user->timestamp), na(nick) + NickServCollide(NickServ::NickServService *nss, User *user, NickServ::Nick *nick, time_t delay) : Timer(delay), service(nss), u(user), ts(user->timestamp), na(nick) { } @@ -46,10 +49,10 @@ class NickServCollide : public Timer */ class NickServHeld : public Timer { - Reference<NickAlias> na; + Reference<NickServ::Nick> na; Anope::string nick; public: - NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick) + NickServHeld(NickServ::Nick *n, long l) : Timer(l), na(n), nick(na->nick) { n->Extend<bool>("HELD"); } @@ -71,7 +74,7 @@ class NickServRelease : public User, public Timer Anope::string nick; public: - NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetModule("nickserv")->Get<const Anope::string>("enforceruser", "user"), + NickServRelease(NickServ::Nick *na, time_t delay) : User(na->nick, Config->GetModule("nickserv")->Get<const Anope::string>("enforceruser", "user"), Config->GetModule("nickserv")->Get<const Anope::string>("enforcerhost", "services.localhost.net"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve(), NULL), Timer(delay), nick(na->nick) { /* Erase the current release timer and use the new one */ @@ -114,6 +117,9 @@ class NickServCore : public Module, public NickServ::NickServService , public EventHook<Event::Help> , public EventHook<Event::ExpireTick> , public EventHook<Event::NickInfo> + , public EventHook<Event::ModuleUnload> + , public EventHook<Event::NickCoreCreate> + , public EventHook<Event::UserQuit> { Reference<BotInfo> NickServ; std::vector<Anope::string> defaults; @@ -122,8 +128,12 @@ class NickServCore : public Module, public NickServ::NickServService EventHandlers<NickServ::Event::NickExpire> onnickexpire; EventHandlers<NickServ::Event::NickRegister> onnickregister; EventHandlers<NickServ::Event::NickValidate> onnickvalidate; + std::set<NickServ::IdentifyRequest *> identifyrequests; + Serialize::Checker<NickServ::nickalias_map> NickList; + Serialize::Checker<NickServ::nickcore_map> AccountList; + Serialize::Type nick_type, account_type; - void OnCancel(User *u, NickAlias *na) + void OnCancel(User *u, NickServ::Nick *na) { if (collided.HasExt(na)) { @@ -158,12 +168,19 @@ class NickServCore : public Module, public NickServ::NickServService , EventHook<Event::Help>("OnHelp") , EventHook<Event::ExpireTick>("OnExpireTick") , EventHook<Event::NickInfo>("OnNickInfo") + , EventHook<Event::ModuleUnload>("OnModuleUnload") + , EventHook<Event::NickCoreCreate>("OnNickCoreCreate") + , EventHook<Event::UserQuit>("OnUserQuit") , held(this, "HELD") , collided(this, "COLLIDED") , onprenickexpire(this, "OnPreNickExpire") , onnickexpire(this, "OnNickExpire") , onnickregister(this, "OnNickRegister") , onnickvalidate(this, "OnNickValidate") + , NickList("NickAlias") + , AccountList("NickCore") + , nick_type("NickAlias", NickImpl::Unserialize) + , account_type("NickCore", AccountImpl::Unserialize) { } @@ -177,8 +194,8 @@ class NickServCore : public Module, public NickServ::NickServService /* On shutdown, restart, or mod unload, remove all of our holds for nicks (svshold or qlines) * because some IRCds do not allow us to have these automatically expire */ - for (nickalias_map::const_iterator it = NickAliasList->begin(); it != NickAliasList->end(); ++it) - this->Release(it->second); + for (auto& it : *NickList) + this->Release(it.second); } void OnRestart() override @@ -188,7 +205,7 @@ class NickServCore : public Module, public NickServ::NickServService void Validate(User *u) override { - NickAlias *na = NickAlias::Find(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (!na) return; @@ -217,27 +234,27 @@ class NickServCore : public Module, public NickServ::NickServService if (on_access || !na->nc->HasExt("KILL_IMMED")) { if (na->nc->HasExt("NS_SECURE")) - u->SendMessage(NickServ, NICK_IS_SECURE, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); + u->SendMessage(*NickServ, NICK_IS_SECURE, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); else - u->SendMessage(NickServ, NICK_IS_REGISTERED, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); + u->SendMessage(*NickServ, NICK_IS_REGISTERED, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); } if (na->nc->HasExt("KILLPROTECT") && !on_access) { if (na->nc->HasExt("KILL_IMMED")) { - u->SendMessage(NickServ, FORCENICKCHANGE_NOW); + u->SendMessage(*NickServ, FORCENICKCHANGE_NOW); this->Collide(u, na); } else if (na->nc->HasExt("KILL_QUICK")) { time_t killquick = Config->GetModule("nickserv")->Get<time_t>("killquick", "20s"); - u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(killquick, u->Account()).c_str()); + u->SendMessage(*NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(killquick, u->Account()).c_str()); new NickServCollide(this, u, na, killquick); } else { time_t kill = Config->GetModule("nickserv")->Get<time_t>("kill", "60s"); - u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(kill, u->Account()).c_str()); + u->SendMessage(*NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(kill, u->Account()).c_str()); new NickServCollide(this, u, na, kill); } } @@ -246,7 +263,7 @@ class NickServCore : public Module, public NickServ::NickServService void OnUserLogin(User *u) override { - NickAlias *na = NickAlias::Find(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (na && *na->nc == u->Account() && !Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); @@ -255,7 +272,7 @@ class NickServCore : public Module, public NickServ::NickServService u->SetModes(NickServ, "%s", modesonid.c_str()); } - void Collide(User *u, NickAlias *na) override + void Collide(User *u, NickServ::Nick *na) override { if (na) collided.Set(na); @@ -281,7 +298,7 @@ class NickServCore : public Module, public NickServ::NickServService else { if (NickServ) - u->SendMessage(NickServ, _("Your nickname is now being changed to \002%s\002"), guestnick.c_str()); + u->SendMessage(*NickServ, _("Your nickname is now being changed to \002%s\002"), guestnick.c_str()); IRCD->SendForceNickChange(u, guestnick, Anope::CurTime); } } @@ -289,7 +306,7 @@ class NickServCore : public Module, public NickServ::NickServService u->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill"); } - void Release(NickAlias *na) override + void Release(NickServ::Nick *na) override { if (held.HasExt(na)) { @@ -308,6 +325,48 @@ class NickServCore : public Module, public NickServ::NickServService } } + NickServ::IdentifyRequest *CreateIdentifyRequest(NickServ::IdentifyRequestListener *l, Module *o, const Anope::string &acc, const Anope::string &pass) override + { + return new IdentifyRequestImpl(l, o, acc, pass); + } + + std::set<NickServ::IdentifyRequest *>& GetIdentifyRequests() override + { + return identifyrequests; + } + + NickServ::nickalias_map& GetNickList() override + { + return NickList; + } + + NickServ::nickcore_map& GetAccountList() override + { + return AccountList; + } + + NickServ::Nick *CreateNick(const Anope::string &nick, NickServ::Account *acc) override + { + return new NickImpl(nick, acc); + } + + NickServ::Account *CreateAccount(const Anope::string &acc) override + { + return new AccountImpl(acc); + } + + NickServ::Nick *FindNick(const Anope::string &nick) override + { + auto it = NickList->find(nick); + return it != NickList->end() ? it->second : nullptr; + } + + NickServ::Account *FindAccount(const Anope::string &acc) override + { + auto it = AccountList->find(acc); + return it != AccountList->end() ? it->second : nullptr; + } + void OnReload(Configuration::Conf *conf) override { const Anope::string &nsnick = conf->GetModule(this)->Get<const Anope::string>("client"); @@ -332,7 +391,7 @@ class NickServCore : public Module, public NickServ::NickServService defaults.clear(); } - void OnDelNick(NickAlias *na) override + void OnDelNick(NickServ::Nick *na) override { User *u = User::Find(na->nick); if (u && u->Account() == na->nc) @@ -343,7 +402,7 @@ class NickServCore : public Module, public NickServ::NickServService } } - void OnDelCore(NickCore *nc) override + void OnDelCore(NickServ::Account *nc) override { Log(NickServ, "nick") << "Deleting nickname group " << nc->display; @@ -359,7 +418,7 @@ class NickServCore : public Module, public NickServ::NickServService nc->users.clear(); } - void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) override + void OnChangeCoreDisplay(NickServ::Account *nc, const Anope::string &newdisplay) override { Log(LOG_NORMAL, "nick", NickServ) << "Changing " << nc->display << " nickname group display to " << newdisplay; } @@ -384,16 +443,16 @@ class NickServCore : public Module, public NickServ::NickServService if (block->Get<bool>("forceemail", "yes") && u->Account()->email.empty()) { - u->SendMessage(NickServ, _("You must now supply an e-mail for your nick.\n" + u->SendMessage(*NickServ, _("You must now supply an e-mail for your nick.\n" "This e-mail will allow you to retrieve your password in\n" "case you forget it.")); - u->SendMessage(NickServ, _("Type \002%s%s SET EMAIL \037e-mail\037\002 in order to set your e-mail.\n" + u->SendMessage(*NickServ, _("Type \002%s%s SET EMAIL \037e-mail\037\002 in order to set your e-mail.\n" "Your privacy is respected; this e-mail won't be given to\n" "any third-party person."), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); } } - void OnNickGroup(User *u, NickAlias *target) override + void OnNickGroup(User *u, NickServ::Nick *target) override { if (!target->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); @@ -415,18 +474,18 @@ class NickServCore : public Module, public NickServ::NickServService if (u->Quitting() || !u->server->IsSynced() || u->server->IsULined()) return; - const NickAlias *na = NickAlias::Find(u->nick); + const NickServ::Nick *na = NickServ::FindNick(u->nick); const Anope::string &unregistered_notice = Config->GetModule(this)->Get<const Anope::string>("unregistered_notice"); if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !unregistered_notice.empty() && !na && !u->Account()) - u->SendMessage(NickServ, unregistered_notice); + u->SendMessage(*NickServ, unregistered_notice); else if (na && !u->IsIdentified(true)) this->Validate(u); } void OnPostUserLogoff(User *u) override { - NickAlias *na = NickAlias::Find(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (na) OnCancel(u, na); } @@ -449,7 +508,7 @@ class NickServCore : public Module, public NickServ::NickServService void OnUserNickChange(User *u, const Anope::string &oldnick) override { - NickAlias *old_na = NickAlias::Find(oldnick), *na = NickAlias::Find(u->nick); + NickServ::Nick *old_na = NickServ::FindNick(oldnick), *na = NickServ::FindNick(u->nick); /* If the new nick isn't registered or it's registered and not yours */ if (!na || na->nc != u->Account()) { @@ -521,20 +580,20 @@ class NickServCore : public Module, public NickServ::NickServService "nickname(s)."), NickServ->nick.c_str()); } - void OnNickCoreCreate(NickCore *nc) + void OnNickCoreCreate(NickServ::Account *nc) override { /* Set default flags */ for (unsigned i = 0; i < defaults.size(); ++i) nc->Extend<bool>(defaults[i].upper()); } - void OnUserQuit(User *u, const Anope::string &msg) + void OnUserQuit(User *u, const Anope::string &msg) override { if (u->server && !u->server->GetQuitReason().empty() && Config->GetModule(this)->Get<bool>("hidenetsplitquit")) return; /* Update last quit and last seen for the user */ - NickAlias *na = NickAlias::Find(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (na && !na->nc->HasExt("NS_SUSPENDED") && (u->IsRecognized() || u->IsIdentified(true))) { na->last_seen = Anope::CurTime; @@ -549,9 +608,9 @@ class NickServCore : public Module, public NickServ::NickServService time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "21d"); - for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ) + for (auto it = NickList->begin(); it != NickList->end();) { - NickAlias *na = it->second; + NickServ::Nick *na = it->second; ++it; User *u = User::Find(na->nick); @@ -564,7 +623,7 @@ class NickServCore : public Module, public NickServ::NickServService expire = true; this->onprenickexpire(&NickServ::Event::PreNickExpire::OnPreNickExpire, na, expire); - + if (expire) { Log(LOG_NORMAL, "nickserv/expire", NickServ) << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; @@ -574,7 +633,7 @@ class NickServCore : public Module, public NickServ::NickServService } } - void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override + void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { if (!na->nc->HasExt("UNCONFIRMED")) { @@ -588,6 +647,19 @@ class NickServCore : public Module, public NickServ::NickServService info[_("Expires")] = Anope::strftime(na->time_registered + unconfirmed_expire, source.GetAccount()); } } + + void OnModuleUnload(User *u, Module *m) override + { + for (std::set<NickServ::IdentifyRequest *>::iterator it = identifyrequests.begin(), it_end = identifyrequests.end(); it != it_end;) + { + NickServ::IdentifyRequest *ir = *it; + ++it; + + ir->Release(m); + if (ir->GetOwner() == m) + delete ir; + } + } }; MODULE_INIT(NickServCore) diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index 91d7f1add..2d2d56425 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -27,7 +27,7 @@ class SGLineManager : public XLineManager { ::Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->mask << "\002 has expired"; } - + void Send(User *u, XLine *x) override { IRCD->SendAkill(u, x); diff --git a/modules/webcpanel/pages/chanserv/access.cpp b/modules/webcpanel/pages/chanserv/access.cpp index d87613ed7..058acc457 100644 --- a/modules/webcpanel/pages/chanserv/access.cpp +++ b/modules/webcpanel/pages/chanserv/access.cpp @@ -12,7 +12,7 @@ WebCPanel::ChanServ::Access::Access(const Anope::string &cat, const Anope::strin { } -bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { TemplateFileServer Page("chanserv/access.html"); const Anope::string &chname = message.get_data["channel"]; @@ -25,7 +25,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s return true; } - ChannelInfo *ci = ChannelInfo::Find(chname); + ::ChanServ::Channel *ci = ::ChanServ::Find(chname); if (!ci) { @@ -34,7 +34,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s return true; } - AccessGroup u_access = ci->AccessFor(na->nc); + ::ChanServ::AccessGroup u_access = ci->AccessFor(na->nc); bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/access/modify"); if (!u_access.HasPriv("ACCESS_LIST") && !has_priv) @@ -46,8 +46,8 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s replacements["ACCESS_LIST"] = "YES"; - const ChanAccess *highest = u_access.Highest(); - + const ::ChanServ::ChanAccess *highest = u_access.Highest(); + if (u_access.HasPriv("ACCESS_CHANGE") || has_priv) { if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false) @@ -62,10 +62,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s else if (message.post_data["mask"].empty() == false && message.post_data["access"].empty() == false && message.post_data["provider"].empty() == false) { // Generic access add code here, works with any provider (so we can't call a command exactly) - AccessProvider *a = NULL; - for (std::list<AccessProvider *>::const_iterator it = AccessProvider::GetProviders().begin(); it != AccessProvider::GetProviders().end(); ++it) - if ((*it)->name == message.post_data["provider"]) - a = *it; + ServiceReference<::ChanServ::AccessProvider> a("AccessProvider", "access/" + message.post_data["provider"]); if (a) { @@ -73,7 +70,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { - ChanAccess *acc = ci->GetAccess(i); + ::ChanServ::ChanAccess *acc = ci->GetAccess(i); if (acc->mask == message.post_data["mask"]) { @@ -94,7 +91,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s replacements["MESSAGES"] = "Sorry, you can only have " + stringify(access_max) + " access entries on a channel."; else if (!denied) { - ChanAccess *new_acc = a->Create(); + ::ChanServ::ChanAccess *new_acc = a->Create(); new_acc->ci = ci; new_acc->mask = message.post_data["mask"]; new_acc->creator = na->nc->display; @@ -136,18 +133,16 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s for (unsigned i = 0; i < ci->GetAccessCount(); ++i) { - ChanAccess *access = ci->GetAccess(i); + ::ChanServ::ChanAccess *access = ci->GetAccess(i); replacements["MASKS"] = HTTPUtils::Escape(access->mask); replacements["ACCESSES"] = HTTPUtils::Escape(access->AccessSerialize()); replacements["CREATORS"] = HTTPUtils::Escape(access->creator); } - for (std::list<AccessProvider *>::const_iterator it = AccessProvider::GetProviders().begin(); it != AccessProvider::GetProviders().end(); ++it) - { - const AccessProvider *a = *it; - replacements["PROVIDERS"] = a->name; - } + if (::ChanServ::service) + for (::ChanServ::AccessProvider *p : ::ChanServ::service->GetProviders()) + replacements["PROVIDERS"] = p->name; Page.Serve(server, page_name, client, message, reply, replacements); return true; diff --git a/modules/webcpanel/pages/chanserv/access.h b/modules/webcpanel/pages/chanserv/access.h index 9ff77c486..a22521ada 100644 --- a/modules/webcpanel/pages/chanserv/access.h +++ b/modules/webcpanel/pages/chanserv/access.h @@ -16,7 +16,7 @@ class Access : public WebPanelProtectedPage public: Access(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; std::set<Anope::string> GetData() override; }; diff --git a/modules/webcpanel/pages/chanserv/akick.cpp b/modules/webcpanel/pages/chanserv/akick.cpp index bff38910c..a77995048 100644 --- a/modules/webcpanel/pages/chanserv/akick.cpp +++ b/modules/webcpanel/pages/chanserv/akick.cpp @@ -7,12 +7,13 @@ #include "../../webcpanel.h" #include "utils.h" +#include "modules/cs_akick.h" WebCPanel::ChanServ::Akick::Akick(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u) { } -bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { const Anope::string &chname = message.get_data["channel"]; TemplateFileServer Page("chanserv/akick.html"); @@ -25,7 +26,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st return true; } - ChannelInfo *ci = ChannelInfo::Find(chname); + ::ChanServ::Channel *ci = ::ChanServ::Find(chname); if (!ci) { @@ -34,7 +35,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st return true; } - AccessGroup u_access = ci->AccessFor(na->nc); + ::ChanServ::AccessGroup u_access = ci->AccessFor(na->nc); bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/access/modify"); if (!u_access.HasPriv("AKICK") && !has_priv) @@ -71,14 +72,14 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st for (unsigned i = 0; i < ci->GetAkickCount(); ++i) { - AutoKick *akick = ci->GetAkick(i); + AutoKick *ak = ci->GetAkick(i); - if (akick->nc) - replacements["MASKS"] = HTTPUtils::Escape(akick->nc->display); + if (ak->nc) + replacements["MASKS"] = HTTPUtils::Escape(ak->nc->display); else - replacements["MASKS"] = HTTPUtils::Escape(akick->mask); - replacements["CREATORS"] = HTTPUtils::Escape(akick->creator); - replacements["REASONS"] = HTTPUtils::Escape(akick->reason); + replacements["MASKS"] = HTTPUtils::Escape(ak->mask); + replacements["CREATORS"] = HTTPUtils::Escape(ak->creator); + replacements["REASONS"] = HTTPUtils::Escape(ak->reason); } Page.Serve(server, page_name, client, message, reply, replacements); diff --git a/modules/webcpanel/pages/chanserv/akick.h b/modules/webcpanel/pages/chanserv/akick.h index 938dbde04..0df08d3b3 100644 --- a/modules/webcpanel/pages/chanserv/akick.h +++ b/modules/webcpanel/pages/chanserv/akick.h @@ -16,7 +16,7 @@ class Akick : public WebPanelProtectedPage public: Akick(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; std::set<Anope::string> GetData() override; }; diff --git a/modules/webcpanel/pages/chanserv/drop.cpp b/modules/webcpanel/pages/chanserv/drop.cpp index 5fa37b5a2..c81543c57 100644 --- a/modules/webcpanel/pages/chanserv/drop.cpp +++ b/modules/webcpanel/pages/chanserv/drop.cpp @@ -13,7 +13,7 @@ WebCPanel::ChanServ::Drop::Drop(const Anope::string &cat, const Anope::string &u } -bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { if (message.post_data.count("channel") > 0 && message.post_data.count("confChan") > 0) @@ -31,11 +31,11 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str replacements["MESSAGES"] = "Invalid Confirmation"; } - std::deque<ChannelInfo *> queue; + std::deque<::ChanServ::Channel *> queue; na->nc->GetChannelReferences(queue); for (unsigned i = 0; i < queue.size(); ++i) { - ChannelInfo *ci = queue[i]; + ::ChanServ::Channel *ci = queue[i]; if ((ci->HasExt("SECUREFOUNDER") ? ci->AccessFor(na->nc).founder : ci->AccessFor(na->nc).HasPriv("FOUNDER")) || (na->nc->IsServicesOper() && na->nc->o->ot->HasCommand("chanserv/drop"))) { replacements["CHANNEL_NAMES"] = ci->name; diff --git a/modules/webcpanel/pages/chanserv/drop.h b/modules/webcpanel/pages/chanserv/drop.h index 684562453..773dfe789 100644 --- a/modules/webcpanel/pages/chanserv/drop.h +++ b/modules/webcpanel/pages/chanserv/drop.h @@ -16,7 +16,7 @@ namespace WebCPanel public: Drop(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; diff --git a/modules/webcpanel/pages/chanserv/info.cpp b/modules/webcpanel/pages/chanserv/info.cpp index c16c3eaec..725446958 100644 --- a/modules/webcpanel/pages/chanserv/info.cpp +++ b/modules/webcpanel/pages/chanserv/info.cpp @@ -12,7 +12,7 @@ WebCPanel::ChanServ::Info::Info(const Anope::string &cat, const Anope::string &u { } -bool WebCPanel::ChanServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::ChanServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { const Anope::string &chname = message.get_data["channel"]; diff --git a/modules/webcpanel/pages/chanserv/info.h b/modules/webcpanel/pages/chanserv/info.h index 8f70f13b2..2e9888ede 100644 --- a/modules/webcpanel/pages/chanserv/info.h +++ b/modules/webcpanel/pages/chanserv/info.h @@ -16,7 +16,7 @@ class Info : public WebPanelProtectedPage public: Info(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/chanserv/modes.cpp b/modules/webcpanel/pages/chanserv/modes.cpp index f087b86a9..61c170ee2 100644 --- a/modules/webcpanel/pages/chanserv/modes.cpp +++ b/modules/webcpanel/pages/chanserv/modes.cpp @@ -12,7 +12,7 @@ WebCPanel::ChanServ::Modes::Modes(const Anope::string &cat, const Anope::string { } -bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { const Anope::string &chname = message.get_data["channel"]; const Anope::string &mode = message.get_data["m"]; @@ -27,7 +27,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st } replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname); - ChannelInfo *ci = ChannelInfo::Find(chname); + ::ChanServ::Channel *ci = ::ChanServ::Find(chname); if (!ci) { @@ -44,7 +44,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st return true; } - AccessGroup u_access = ci->AccessFor(na->nc); + ::ChanServ::AccessGroup u_access = ci->AccessFor(na->nc); bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/administration"); if (!u_access.HasPriv("MODE") && !has_priv) diff --git a/modules/webcpanel/pages/chanserv/modes.h b/modules/webcpanel/pages/chanserv/modes.h index 5fd69e07f..33197b1f4 100644 --- a/modules/webcpanel/pages/chanserv/modes.h +++ b/modules/webcpanel/pages/chanserv/modes.h @@ -16,7 +16,7 @@ class Modes : public WebPanelProtectedPage public: Modes(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; std::set<Anope::string> GetData() override; }; diff --git a/modules/webcpanel/pages/chanserv/set.cpp b/modules/webcpanel/pages/chanserv/set.cpp index f763ba13b..c2ea480d4 100644 --- a/modules/webcpanel/pages/chanserv/set.cpp +++ b/modules/webcpanel/pages/chanserv/set.cpp @@ -12,7 +12,7 @@ WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u) { } -bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { const Anope::string &chname = message.get_data["channel"]; bool can_set = false; @@ -26,7 +26,7 @@ bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::stri return true; } - ChannelInfo *ci = ChannelInfo::Find(chname); + ::ChanServ::Channel *ci = ::ChanServ::Find(chname); if (!ci) { diff --git a/modules/webcpanel/pages/chanserv/set.h b/modules/webcpanel/pages/chanserv/set.h index 12c94dcf0..3c6af8adb 100644 --- a/modules/webcpanel/pages/chanserv/set.h +++ b/modules/webcpanel/pages/chanserv/set.h @@ -16,7 +16,7 @@ class Set : public WebPanelProtectedPage public: Set(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; std::set<Anope::string> GetData() override; }; diff --git a/modules/webcpanel/pages/chanserv/utils.cpp b/modules/webcpanel/pages/chanserv/utils.cpp index b4571b74c..f14595a82 100644 --- a/modules/webcpanel/pages/chanserv/utils.cpp +++ b/modules/webcpanel/pages/chanserv/utils.cpp @@ -9,7 +9,7 @@ namespace { - bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2) + bool ChannelSort(ChanServ::Channel *ci1, ChanServ::Channel *ci2) { return ci::less()(ci1->name, ci2->name); } @@ -21,15 +21,15 @@ namespace WebCPanel namespace ChanServ { -void BuildChanList(NickAlias *na, TemplateFileServer::Replacements &replacements) +void BuildChanList(::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { - std::deque<ChannelInfo *> queue; + std::deque<::ChanServ::Channel *> queue; na->nc->GetChannelReferences(queue); std::sort(queue.begin(), queue.end(), ChannelSort); for (unsigned i = 0; i < queue.size(); ++i) { - ChannelInfo *ci = queue[i]; + ::ChanServ::Channel *ci = queue[i]; if (na->nc != ci->GetFounder() && ci->AccessFor(na->nc).empty()) continue; diff --git a/modules/webcpanel/pages/chanserv/utils.h b/modules/webcpanel/pages/chanserv/utils.h index 111abb4ad..34e82999f 100644 --- a/modules/webcpanel/pages/chanserv/utils.h +++ b/modules/webcpanel/pages/chanserv/utils.h @@ -11,7 +11,7 @@ namespace WebCPanel namespace ChanServ { -extern void BuildChanList(NickAlias *, TemplateFileServer::Replacements &); +extern void BuildChanList(::NickServ::Nick *, TemplateFileServer::Replacements &); } diff --git a/modules/webcpanel/pages/hostserv/request.cpp b/modules/webcpanel/pages/hostserv/request.cpp index ee6356214..605e0082c 100644 --- a/modules/webcpanel/pages/hostserv/request.cpp +++ b/modules/webcpanel/pages/hostserv/request.cpp @@ -7,11 +7,11 @@ #include "../../webcpanel.h" -WebCPanel::HostServ::Request::Request(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage (cat, u) +WebCPanel::HostServ::Request::Request(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage (cat, u) { } -bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { if (message.post_data.count("req") > 0) { diff --git a/modules/webcpanel/pages/hostserv/request.h b/modules/webcpanel/pages/hostserv/request.h index 53e72c1bc..c8a518361 100644 --- a/modules/webcpanel/pages/hostserv/request.h +++ b/modules/webcpanel/pages/hostserv/request.h @@ -16,7 +16,7 @@ class Request : public WebPanelProtectedPage public: Request(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp index 0b2ce3d9c..d2a99becd 100644 --- a/modules/webcpanel/pages/index.cpp +++ b/modules/webcpanel/pages/index.cpp @@ -6,8 +6,9 @@ */ #include "../webcpanel.h" +#include "modules/nickserv.h" -class WebpanelRequest : public IdentifyRequest +class WebpanelRequest : public NickServ::IdentifyRequestListener { HTTPReply reply; HTTPMessage message; @@ -17,16 +18,16 @@ class WebpanelRequest : public IdentifyRequest TemplateFileServer::Replacements replacements; public: - WebpanelRequest(Module *o, HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(o, user, pass), reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { } + WebpanelRequest(HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re) : reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { } - void OnSuccess() override + void OnSuccess(NickServ::IdentifyRequest *req) override { if (!client || !server) return; - NickAlias *na = NickAlias::Find(this->GetAccount()); + ::NickServ::Nick *na = ::NickServ::FindNick(req->GetAccount()); if (!na) { - this->OnFail(); + this->OnFail(req); return; } @@ -50,7 +51,7 @@ class WebpanelRequest : public IdentifyRequest reply.cookies.push_back(c); } - { + { HTTPReply::cookie c; c.push_back(std::make_pair("id", id)); c.push_back(std::make_pair("Path", "/")); @@ -63,7 +64,7 @@ class WebpanelRequest : public IdentifyRequest client->SendReply(&reply); } - void OnFail() override + void OnFail(NickServ::IdentifyRequest *req) override { if (!client || !server) return; @@ -82,11 +83,11 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page replacements["TITLE"] = page_title; - if (!user.empty() && !pass.empty()) + if (!user.empty() && !pass.empty() && ::NickServ::service) { - // Rate limit check. + // XXX Rate limit check. - WebpanelRequest *req = new WebpanelRequest(me, reply, message, server, page_name, client, replacements, user, pass); + ::NickServ::IdentifyRequest *req = ::NickServ::service->CreateIdentifyRequest(new WebpanelRequest(reply, message, server, page_name, client, replacements), me, user, pass); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); return false; diff --git a/modules/webcpanel/pages/logout.cpp b/modules/webcpanel/pages/logout.cpp index d9f5432a3..648b277cc 100644 --- a/modules/webcpanel/pages/logout.cpp +++ b/modules/webcpanel/pages/logout.cpp @@ -11,7 +11,7 @@ WebCPanel::Logout::Logout(const Anope::string &u) : WebPanelProtectedPage("", u) { } -bool WebCPanel::Logout::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::Logout::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { na->Shrink<Anope::string>("webcpanel_id"); na->Shrink<Anope::string>("webcpanel_ip"); diff --git a/modules/webcpanel/pages/logout.h b/modules/webcpanel/pages/logout.h index f44f3aad5..d3e6cb1ff 100644 --- a/modules/webcpanel/pages/logout.h +++ b/modules/webcpanel/pages/logout.h @@ -13,7 +13,7 @@ class Logout : public WebPanelProtectedPage public: Logout(const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/memoserv/memos.cpp b/modules/webcpanel/pages/memoserv/memos.cpp index 944864cdd..845e7becd 100644 --- a/modules/webcpanel/pages/memoserv/memos.cpp +++ b/modules/webcpanel/pages/memoserv/memos.cpp @@ -11,41 +11,42 @@ WebCPanel::MemoServ::Memos::Memos(const Anope::string &cat, const Anope::string { } -bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { const Anope::string &chname = message.get_data["channel"]; - ChannelInfo *ci; - const MemoInfo *mi; - Memo *m; + ::ChanServ::Channel *ci; + const ::MemoServ::MemoInfo *mi; + ::MemoServ::Memo *m; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) - { - ci = it->second; - - if (ci->AccessFor(na->nc).HasPriv("MEMO")) + if (::ChanServ::service) + for (auto& it : ::ChanServ::service->GetChannels()) { - replacements["CHANNEL_NAMES"] = ci->name; - replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name); + ci = it.second; + + if (ci->AccessFor(na->nc).HasPriv("MEMO")) + { + replacements["CHANNEL_NAMES"] = ci->name; + replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name); + } } - } if (chname.empty()) { replacements["MESSAGES"] = "No Channel specified, displaying the memos for your Nick"; - mi = &na->nc->memos; + mi = na->nc->memos; } else { - ci = ChannelInfo::Find(chname); + ci = ::ChanServ::Find(chname); if (ci) { replacements["MESSAGES"] = "Displaying the memos for " + chname + "."; - mi = &ci->memos; + mi = ci->memos; } else { replacements["MESSAGES"] = "Channel " + chname + " not found, displaying the memos for your nick"; - mi = &na->nc->memos; + mi = na->nc->memos; } replacements["CHANNEL_NAME"] = ci->name; @@ -84,7 +85,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st if (number > 0) { - m = mi->GetMemo(number-1); + m = mi ? mi->GetMemo(number-1) : nullptr; if (!m) replacements["MESSAGES"] = "ERROR - invalid memo number."; @@ -95,18 +96,19 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st } } - for (unsigned i = 0; i < mi->memos->size(); ++i) - { - m = mi->GetMemo(i); - replacements["NUMBER"] = stringify(i+1); - replacements["SENDER"] = m->sender; - replacements["TIME"] = Anope::strftime(m->time); - replacements["TEXT"] = HTTPUtils::Escape(m->text); - if (m->unread) - replacements["UNREAD"] = "YES"; - else - replacements["UNREAD"] = "NO"; - } + if (mi) + for (unsigned i = 0; i < mi->memos->size(); ++i) + { + m = mi->GetMemo(i); + replacements["NUMBER"] = stringify(i+1); + replacements["SENDER"] = m->sender; + replacements["TIME"] = Anope::strftime(m->time); + replacements["TEXT"] = HTTPUtils::Escape(m->text); + if (m->unread) + replacements["UNREAD"] = "YES"; + else + replacements["UNREAD"] = "NO"; + } TemplateFileServer page("memoserv/memos.html"); page.Serve(server, page_name, client, message, reply, replacements); diff --git a/modules/webcpanel/pages/memoserv/memos.h b/modules/webcpanel/pages/memoserv/memos.h index afe9067b8..e841007d8 100644 --- a/modules/webcpanel/pages/memoserv/memos.h +++ b/modules/webcpanel/pages/memoserv/memos.h @@ -16,7 +16,7 @@ class Memos : public WebPanelProtectedPage public: Memos(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/nickserv/access.cpp b/modules/webcpanel/pages/nickserv/access.cpp index de7809591..59082d307 100644 --- a/modules/webcpanel/pages/nickserv/access.cpp +++ b/modules/webcpanel/pages/nickserv/access.cpp @@ -11,7 +11,7 @@ WebCPanel::NickServ::Access::Access(const Anope::string &cat, const Anope::strin { } -bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { if (message.post_data.count("access") > 0) { diff --git a/modules/webcpanel/pages/nickserv/access.h b/modules/webcpanel/pages/nickserv/access.h index 0752fc1b0..ff2caaa69 100644 --- a/modules/webcpanel/pages/nickserv/access.h +++ b/modules/webcpanel/pages/nickserv/access.h @@ -16,7 +16,7 @@ class Access : public WebPanelProtectedPage public: Access(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/nickserv/alist.cpp b/modules/webcpanel/pages/nickserv/alist.cpp index 21e281f5f..04d1d1cd4 100644 --- a/modules/webcpanel/pages/nickserv/alist.cpp +++ b/modules/webcpanel/pages/nickserv/alist.cpp @@ -7,7 +7,7 @@ #include "../../webcpanel.h" -static bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2) +static bool ChannelSort(ChanServ::Channel *ci1, ChanServ::Channel *ci2) { return ci::less()(ci1->name, ci2->name); } @@ -16,9 +16,9 @@ WebCPanel::NickServ::Alist::Alist(const Anope::string &cat, const Anope::string { } -bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { - std::deque<ChannelInfo *> queue; + std::deque<::ChanServ::Channel *> queue; na->nc->GetChannelReferences(queue); std::sort(queue.begin(), queue.end(), ChannelSort); @@ -26,7 +26,7 @@ bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::st for (unsigned q = 0; q < queue.size(); ++q) { - ChannelInfo *ci = queue[q]; + ::ChanServ::Channel *ci = queue[q]; if (ci->GetFounder() == na->nc) { @@ -38,10 +38,10 @@ bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::st continue; } - AccessGroup access = ci->AccessFor(na->nc); + ::ChanServ::AccessGroup access = ci->AccessFor(na->nc); if (access.empty()) continue; - + ++chan_count; replacements["NUMBERS"] = stringify(chan_count); diff --git a/modules/webcpanel/pages/nickserv/alist.h b/modules/webcpanel/pages/nickserv/alist.h index ba2ca1a7a..97a02e959 100644 --- a/modules/webcpanel/pages/nickserv/alist.h +++ b/modules/webcpanel/pages/nickserv/alist.h @@ -16,7 +16,7 @@ class Alist : public WebPanelProtectedPage public: Alist(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/nickserv/cert.cpp b/modules/webcpanel/pages/nickserv/cert.cpp index eb86f4bd8..52c5a31a0 100644 --- a/modules/webcpanel/pages/nickserv/cert.cpp +++ b/modules/webcpanel/pages/nickserv/cert.cpp @@ -12,7 +12,7 @@ WebCPanel::NickServ::Cert::Cert(const Anope::string &cat, const Anope::string &u { } -bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { if (message.post_data.count("certfp") > 0) { diff --git a/modules/webcpanel/pages/nickserv/cert.h b/modules/webcpanel/pages/nickserv/cert.h index 32c5d1aa9..bf534c739 100644 --- a/modules/webcpanel/pages/nickserv/cert.h +++ b/modules/webcpanel/pages/nickserv/cert.h @@ -16,7 +16,7 @@ class Cert : public WebPanelProtectedPage public: Cert(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp index f8753d83f..1e9e660b4 100644 --- a/modules/webcpanel/pages/nickserv/info.cpp +++ b/modules/webcpanel/pages/nickserv/info.cpp @@ -11,7 +11,7 @@ WebCPanel::NickServ::Info::Info(const Anope::string &cat, const Anope::string &u { } -bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { if (message.post_data.empty() == false) { @@ -110,7 +110,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str replacements["KILL_QUICK"]; if (!na->nc->HasExt("KILLPROTECT") && !na->nc->HasExt("KILL_QUICK")) replacements["KILL_OFF"]; - + TemplateFileServer page("nickserv/info.html"); page.Serve(server, page_name, client, message, reply, replacements); return true; diff --git a/modules/webcpanel/pages/nickserv/info.h b/modules/webcpanel/pages/nickserv/info.h index 1b70a3827..b94fe0f6c 100644 --- a/modules/webcpanel/pages/nickserv/info.h +++ b/modules/webcpanel/pages/nickserv/info.h @@ -16,7 +16,7 @@ class Info : public WebPanelProtectedPage public: Info(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/pages/operserv/akill.cpp b/modules/webcpanel/pages/operserv/akill.cpp index e23141915..20633c0f4 100644 --- a/modules/webcpanel/pages/operserv/akill.cpp +++ b/modules/webcpanel/pages/operserv/akill.cpp @@ -11,7 +11,7 @@ WebCPanel::OperServ::Akill::Akill(const Anope::string &cat, const Anope::string { } -bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements) { static ServiceReference<XLineManager> akills("XLineManager","xlinemanager/sgline"); diff --git a/modules/webcpanel/pages/operserv/akill.h b/modules/webcpanel/pages/operserv/akill.h index 1cabaf205..7367f593f 100644 --- a/modules/webcpanel/pages/operserv/akill.h +++ b/modules/webcpanel/pages/operserv/akill.h @@ -16,7 +16,7 @@ class Akill : public WebPanelProtectedPage public: Akill(const Anope::string &cat, const Anope::string &u); - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override; + bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, ::NickServ::Nick *, TemplateFileServer::Replacements &) override; }; } diff --git a/modules/webcpanel/static_fileserver.cpp b/modules/webcpanel/static_fileserver.cpp index 21f4e7052..b6ced6461 100644 --- a/modules/webcpanel/static_fileserver.cpp +++ b/modules/webcpanel/static_fileserver.cpp @@ -35,7 +35,7 @@ bool StaticFileServer::OnRequest(HTTPProvider *server, const Anope::string &page char buffer[BUFSIZE]; while ((i = read(fd, buffer, sizeof(buffer))) > 0) reply.Write(buffer, i); - + close(fd); return true; } diff --git a/modules/webcpanel/template_fileserver.cpp b/modules/webcpanel/template_fileserver.cpp index dc950b330..0eba381be 100644 --- a/modules/webcpanel/template_fileserver.cpp +++ b/modules/webcpanel/template_fileserver.cpp @@ -79,7 +79,7 @@ static Anope::string FindReplacement(const TemplateFileServer::Replacements &r, } } } - + TemplateFileServer::Replacements::const_iterator it = r.find(key); if (it != r.end()) return it->second; @@ -110,7 +110,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n buffer[i] = 0; buf += buffer; } - + close(fd); Anope::string finished; @@ -235,7 +235,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n // If the if stack is empty or we are in a true statement bool ifok = IfStack.empty() || IfStack.top(); bool forok = ForLoop::Stack.empty() || !ForLoop::Stack.back().finished(r); - + if (ifok && forok) { const Anope::string &replacement = FindReplacement(r, content.substr(0, f - 1)); @@ -252,7 +252,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n // If the if stack is empty or we are in a true statement bool ifok = IfStack.empty() || IfStack.top(); bool forok = ForLoop::Stack.empty() || !ForLoop::Stack.back().finished(r); - + if (ifok && forok) finished += buf[j]; } diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp index 17a64529b..077ed5f15 100644 --- a/modules/webcpanel/webcpanel.cpp +++ b/modules/webcpanel/webcpanel.cpp @@ -238,7 +238,7 @@ class ModuleWebCPanel : public Module provider->UnregisterPage(&this->chanserv_drop); provider->UnregisterPage(&this->memoserv_memos); - + provider->UnregisterPage(&this->hostserv_request); provider->UnregisterPage(&this->operserv_akill); @@ -248,7 +248,7 @@ class ModuleWebCPanel : public Module namespace WebPanel { - void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) + void RunCommand(const Anope::string &user, NickServ::Account *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) { ServiceReference<Command> cmd("Command", c); if (!cmd) @@ -275,7 +275,7 @@ namespace WebPanel MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { } - void SendMessage(BotInfo *source, const Anope::string &msg) override + void SendMessage(const MessageSource &, const Anope::string &msg) override { re[k] = msg; } diff --git a/modules/webcpanel/webcpanel.h b/modules/webcpanel/webcpanel.h index e03e45ed1..771e6b797 100644 --- a/modules/webcpanel/webcpanel.h +++ b/modules/webcpanel/webcpanel.h @@ -35,7 +35,7 @@ class Panel : public Section, public Service std::vector<Section> sections; - NickAlias *GetNickFromSession(HTTPClient *client, HTTPMessage &msg) + NickServ::Nick *GetNickFromSession(HTTPClient *client, HTTPMessage &msg) { if (!client) return NULL; @@ -45,7 +45,7 @@ class Panel : public Section, public Service if (acc.empty() || id.empty()) return NULL; - NickAlias *na = NickAlias::Find(acc); + NickServ::Nick *na = NickServ::FindNick(acc); if (na == NULL) return NULL; @@ -83,7 +83,7 @@ class WebPanelProtectedPage : public WebPanelPage bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override final { ServiceReference<Panel> panel("Panel", "webcpanel"); - NickAlias *na; + NickServ::Nick *na; if (!panel || !(na = panel->GetNickFromSession(client, message))) { @@ -134,7 +134,7 @@ class WebPanelProtectedPage : public WebPanelPage return this->OnRequest(provider, page_name, client, message, reply, na, replacements); } - virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) = 0; + virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickServ::Nick *, TemplateFileServer::Replacements &) = 0; /* What get data should be appended to links in the navbar */ virtual std::set<Anope::string> GetData() { return std::set<Anope::string>(); } @@ -151,7 +151,7 @@ namespace WebPanel * @param r Replacements, reply from command goes back here into key * @param key The key to put the replies into r */ - extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); + extern void RunCommand(const Anope::string &user, NickServ::Account *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); } #include "pages/index.h" |
