diff options
| author | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
| commit | 42238034490fb5479d787bd1695750387d508200 (patch) | |
| tree | c93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/pseudoclients | |
| parent | d492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff) | |
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most
object relationships implicitly defined, and use the graph to trace
references between objects to determine relationships. Edges may
also be marked as having a dependency of the object they point to,
which allows for automatic cleanup and deletion of most objects when
no longer needed.
Additionally, this allows not having to require in-memory copies of
everything when using external databases. db_sql has been rewritten
for this and now always requires a database to function. db_sql with
MySQL now requires InnoDB to make use of transactions and foreign
key constraints.
Diffstat (limited to 'modules/pseudoclients')
40 files changed, 1431 insertions, 1135 deletions
diff --git a/modules/pseudoclients/botserv/botserv.cpp b/modules/pseudoclients/botserv/botserv.cpp index c4f1c3381..a2cfe7335 100644 --- a/modules/pseudoclients/botserv/botserv.cpp +++ b/modules/pseudoclients/botserv/botserv.cpp @@ -24,8 +24,8 @@ class BotServCore : public Module, public BotServ::BotServService , public EventHook<Event::UserKicked> , public EventHook<Event::CreateBot> { - Reference<BotInfo> BotServ; - ExtensibleRef<bool> persist, inhabit; + Reference<ServiceBot> BotServ; + ExtensibleRef<bool> persist, inhabit;//XXX? public: BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) @@ -47,21 +47,21 @@ class BotServCore : public Module, public BotServ::BotServService void OnReload(Configuration::Conf *conf) override { const Anope::string &bsnick = conf->GetModule(this)->Get<const Anope::string>("client"); - BotServ = BotInfo::Find(bsnick, true); + BotServ = ServiceBot::Find(bsnick, true); } 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) + if (chan->ci && chan->ci->GetBot() == user) { const Anope::string &botmodes = Config->GetModule(this)->Get<const Anope::string>("botmodes"); for (unsigned i = 0; i < botmodes.length(); ++i) - chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->bi->GetUID()); + chan->SetMode(chan->ci->GetBot(), ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->GetBot()->GetUID()); } } - void OnBotAssign(User *sender, ChanServ::Channel *ci, BotInfo *bi) override + void OnBotAssign(User *sender, ChanServ::Channel *ci, ServiceBot *bi) override { if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers")) { @@ -75,7 +75,7 @@ class BotServCore : public Module, public BotServ::BotServService if (!Config || !IRCD) return; - BotInfo *bi = user->server == Me ? dynamic_cast<BotInfo *>(user) : NULL; + ServiceBot *bi = user->server == Me ? dynamic_cast<ServiceBot *>(user) : NULL; if (bi && Config->GetModule(this)->Get<bool>("smartjoin")) { std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = c->GetModeList("BAN"); @@ -108,7 +108,7 @@ class BotServCore : public Module, public BotServ::BotServService ModeManager::ProcessModes(); } - if (user->server != Me && c->ci && c->ci->bi) + if (user->server != Me && c->ci && c->ci->GetBot()) { /** * We let the bot join even if it was an ignored user, as if we don't, @@ -117,10 +117,10 @@ class BotServCore : public Module, public BotServ::BotServService * legit users - Rob **/ /* This is before the user has joined the channel, so check usercount + 1 */ - if (c->users.size() + 1 >= Config->GetModule(this)->Get<unsigned>("minusers") && !c->FindUser(c->ci->bi)) + if (c->users.size() + 1 >= Config->GetModule(this)->Get<unsigned>("minusers") && !c->FindUser(c->ci->GetBot())) { ChannelStatus status(Config->GetModule(this)->Get<const Anope::string>("botmodes")); - c->ci->bi->Join(c, &status); + c->ci->GetBot()->Join(c, &status); } } } @@ -142,8 +142,8 @@ class BotServCore : public Module, public BotServ::BotServService return; /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ - if (c->ci && c->ci->bi && u != *c->ci->bi && c->users.size() - 1 <= Config->GetModule(this)->Get<unsigned>("minusers") && c->FindUser(c->ci->bi)) - c->ci->bi->Part(c->ci->c); + if (c->ci && c->ci->GetBot() && u != c->ci->GetBot() && c->users.size() - 1 <= Config->GetModule(this)->Get<unsigned>("minusers") && c->FindUser(c->ci->GetBot())) + c->ci->GetBot()->Part(c->ci->c); } EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) override @@ -198,9 +198,9 @@ class BotServCore : public Module, public BotServ::BotServService EventReturn OnChannelModeSet(Channel *c, const MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { - if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) + if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->GetBot() && c->FindUser(c->ci->GetBot())) { - BotInfo *bi = c->ci->bi; + ServiceBot *bi = c->ci->GetBot(); Entry ban("BAN", param); if (ban.Matches(bi)) @@ -215,18 +215,18 @@ class BotServCore : public Module, public BotServ::BotServService /* Set default bot flags */ spacesepstream sep(Config->GetModule(this)->Get<const Anope::string>("defaults", "greet fantasy")); for (Anope::string token; sep.GetToken(token);) - ci->Extend<bool>("BS_" + token.upper()); + ci->SetS<bool>("BS_" + token.upper(), true); } void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) override { - BotInfo *bi = BotInfo::Find(target->GetUID()); + ServiceBot *bi = ServiceBot::Find(target->GetUID()); if (bi) /* Bots get rejoined */ bi->Join(channel, &status); } - void OnCreateBot(BotInfo *bi) override + void OnCreateBot(ServiceBot *bi) override { if (bi->botmodes.empty()) bi->botmodes = Config->GetModule(this)->Get<const Anope::string>("botumodes"); diff --git a/modules/pseudoclients/chanserv/channel.cpp b/modules/pseudoclients/chanserv/channel.cpp index 98840186f..8b349dc1f 100644 --- a/modules/pseudoclients/chanserv/channel.cpp +++ b/modules/pseudoclients/chanserv/channel.cpp @@ -11,84 +11,32 @@ */ #include "module.h" -#include "channel.h" +#include "channeltype.h" #include "modules/cs_akick.h" -ChannelImpl::ChannelImpl(const Anope::string &chname) +ChannelImpl::ChannelImpl(Serialize::TypeBase *type, const Anope::string &chname) : ChanServ::Channel(type) { - 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); + SetName(chname); + SetTimeRegistered(Anope::CurTime); + SetLastUsed(Anope::CurTime); } -ChannelImpl::ChannelImpl(const ChanServ::Channel &ci) +ChannelImpl::~ChannelImpl() { - *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->SetMask(taccess->Mask(), this); - 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); + ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); + map.erase(this->GetName()); } -ChannelImpl::~ChannelImpl() +void ChannelImpl::Delete() { Event::OnDelChan(&Event::DelChan::OnDelChan, this); - Log(LOG_DEBUG) << "Deleting channel " << this->name; + Log(LOG_DEBUG) << "Deleting channel " << this->GetName(); if (this->c) { - if (this->bi && this->c->FindUser(this->bi)) - this->bi->Part(this->c); + if (this->GetBot() && this->c->FindUser(this->GetBot())) + this->GetBot()->Part(this->c); /* Parting the service bot can cause the channel to go away */ @@ -101,236 +49,149 @@ ChannelImpl::~ChannelImpl() } } - ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); - map.erase(this->name); + return Serialize::Object::Delete(); +} - this->SetFounder(NULL); - this->SetSuccessor(NULL); +Anope::string ChannelImpl::GetName() +{ + return Get<Anope::string>(&ChannelType::name); +} - this->ClearAccess(); - this->ClearAkick(); +void ChannelImpl::SetName(const Anope::string &name) +{ + Set(&ChannelType::name, name); +} - 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; - } +Anope::string ChannelImpl::GetDesc() +{ + return Get(&ChannelType::desc); +} - if (this->founder) - --this->founder->channelcount; +void ChannelImpl::SetDesc(const Anope::string &desc) +{ + Set(&ChannelType::desc, desc); } -void ChannelImpl::Serialize(Serialize::Data &data) const +time_t ChannelImpl::GetTimeRegistered() { - 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] << " "; - } + return Get(&ChannelType::time_registered); +} - Extensible::ExtensibleSerialize(this, this, data); +void ChannelImpl::SetTimeRegistered(const time_t &t) +{ + Set(&ChannelType::time_registered, t); } -Serializable* ChannelImpl::Unserialize(Serializable *obj, Serialize::Data &data) +time_t ChannelImpl::GetLastUsed() { - Anope::string sname, sfounder, ssuccessor, slevels, sbi; + return Get(&ChannelType::last_used); +} - data["name"] >> sname; - data["founder"] >> sfounder; - data["successor"] >> ssuccessor; - data["levels"] >> slevels; - data["bi"] >> sbi; +void ChannelImpl::SetLastUsed(const time_t &t) +{ + Set(&ChannelType::last_used, t); +} + +Anope::string ChannelImpl::GetLastTopic() +{ + return Get(&ChannelType::last_topic); +} - ChannelImpl *ci; - if (obj) - ci = anope_dynamic_static_cast<ChannelImpl *>(obj); - else - ci = new ChannelImpl(sname); +void ChannelImpl::SetLastTopic(const Anope::string &topic) +{ + Set(&ChannelType::last_topic, topic); +} - ci->SetFounder(NickServ::FindAccount(sfounder)); - ci->SetSuccessor(NickServ::FindAccount(ssuccessor)); +Anope::string ChannelImpl::GetLastTopicSetter() +{ + return Get(&ChannelType::last_topic_setter); +} - 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, true); - 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); - } - } +void ChannelImpl::SetLastTopicSetter(const Anope::string &setter) +{ + Set(&ChannelType::last_topic_setter, setter); +} - 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; +time_t ChannelImpl::GetLastTopicTime() +{ + return Get(&ChannelType::last_topic_time); } +void ChannelImpl::SetLastTopicTime(const time_t &t) +{ + Set(&ChannelType::last_topic_time, t); +} -void ChannelImpl::SetFounder(NickServ::Account *nc) +int16_t ChannelImpl::GetBanType() { - if (this->founder) - { - --this->founder->channelcount; - this->founder->RemoveChannelReference(this); - } + return Get(&ChannelType::bantype); +} - this->founder = nc; +void ChannelImpl::SetBanType(const int16_t &i) +{ + Set(&ChannelType::bantype, i); +} - if (this->founder) - { - ++this->founder->channelcount; - this->founder->AddChannelReference(this); - } +time_t ChannelImpl::GetBanExpire() +{ + return Get(&ChannelType::banexpire); } -NickServ::Account *ChannelImpl::GetFounder() const +void ChannelImpl::SetBanExpire(const time_t &t) { - return this->founder; + Set(&ChannelType::banexpire, t); } -void ChannelImpl::SetSuccessor(NickServ::Account *nc) +BotInfo *ChannelImpl::GetBI() { - if (this->successor) - this->successor->RemoveChannelReference(this); - this->successor = nc; - if (this->successor) - this->successor->AddChannelReference(this); + return Get(&ChannelType::bi); } -NickServ::Account *ChannelImpl::GetSuccessor() const +void ChannelImpl::SetBI(BotInfo *bi) { - return this->successor; + Set(&ChannelType::bi, bi); } -BotInfo *ChannelImpl::WhoSends() const +ServiceBot *ChannelImpl::GetBot() { - if (this && this->bi) - return this->bi; + BotInfo *bi = GetBI(); + return bi ? bi->bot : nullptr; +} - BotInfo *ChanServ = Config->GetClient("ChanServ"); - if (ChanServ) - return ChanServ; +void ChannelImpl::SetBot(ServiceBot *bi) +{ + SetBI(bi->bi); +} - if (!BotListByNick->empty()) - return BotListByNick->begin()->second; +MemoServ::MemoInfo *ChannelImpl::GetMemos() +{ + return GetRef<MemoServ::MemoInfo *>(MemoServ::memoinfo); +} + +void ChannelImpl::SetFounder(NickServ::Account *nc) +{ + Set(&ChannelType::founder, nc); +} - return NULL; +NickServ::Account *ChannelImpl::GetFounder() +{ + return Get(&ChannelType::founder); } -void ChannelImpl::AddAccess(ChanServ::ChanAccess *taccess) +void ChannelImpl::SetSuccessor(NickServ::Account *nc) { - this->access->push_back(taccess); + Set(&ChannelType::successor, nc); } -ChanServ::ChanAccess *ChannelImpl::GetAccess(unsigned index) const +NickServ::Account *ChannelImpl::GetSuccessor() { - if (this->access->empty() || index >= this->access->size()) - return NULL; + return Get(&ChannelType::successor); +} - ChanServ::ChanAccess *acc = (*this->access)[index]; - acc->QueueUpdate(); - return acc; +ChanServ::ChanAccess *ChannelImpl::GetAccess(unsigned index) +{ + std::vector<ChanServ::ChanAccess *> a = GetRefs<ChanServ::ChanAccess *>(ChanServ::chanaccess); + return a.size() > index ? a[index] : nullptr; } ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u) @@ -341,11 +202,11 @@ ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u) return group; const NickServ::Account *nc = u->Account(); - if (nc == NULL && !this->HasExt("NS_SECURE") && u->IsRecognized()) + if (nc == NULL && !this->HasFieldS("NS_SECURE") && u->IsRecognized()) { - const NickServ::Nick *na = NickServ::FindNick(u->nick); + NickServ::Nick *na = NickServ::FindNick(u->nick); if (na != NULL) - nc = na->nc; + nc = na->GetAccount(); } group.super_admin = u->super_admin; @@ -362,20 +223,20 @@ ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u) if (group.founder || !group.empty()) { - this->last_used = Anope::CurTime; + this->SetLastUsed(Anope::CurTime); for (unsigned i = 0; i < group.size(); ++i) - group[i]->last_seen = Anope::CurTime; + group[i]->SetLastSeen(Anope::CurTime); } return group; } -ChanServ::AccessGroup ChannelImpl::AccessFor(const NickServ::Account *nc) +ChanServ::AccessGroup ChannelImpl::AccessFor(NickServ::Account *nc) { ChanServ::AccessGroup group; - group.founder = (this->founder && this->founder == nc); + group.founder = GetFounder() && GetFounder() == nc; group.ci = this; group.nc = nc; @@ -387,20 +248,22 @@ ChanServ::AccessGroup ChannelImpl::AccessFor(const NickServ::Account *nc) } if (group.founder || !group.empty()) - this->last_used = Anope::CurTime; + this->SetLastUsed(Anope::CurTime); - /* don't update access last seen here, this isn't the user requesting access */ + /* don't update access last seen here, this isn't the user requesting access */ return group; } -unsigned ChannelImpl::GetAccessCount() const +unsigned ChannelImpl::GetAccessCount() { - return this->access->size(); + return GetRefs<ChanServ::ChanAccess *>(ChanServ::chanaccess).size(); } unsigned ChannelImpl::GetDeepAccessCount() const { + return 0; +#if 0 ChanServ::ChanAccess::Path path; for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) { @@ -413,7 +276,7 @@ unsigned ChannelImpl::GetDeepAccessCount() const channels.insert(this); for (ChanServ::ChanAccess::Set::iterator it = path.first.begin(); it != path.first.end(); ++it) { - const ChanServ::Channel *ci = it->first->ci; + const ChanServ::Channel *ci = it->first->GetChannel(); if (!channels.count(ci)) { channels.count(ci); @@ -421,124 +284,109 @@ unsigned ChannelImpl::GetDeepAccessCount() const } } 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; +#endif } void ChannelImpl::ClearAccess() { - for (unsigned i = this->access->size(); i > 0; --i) - delete this->GetAccess(i - 1); + for (ChanServ::ChanAccess *a : GetRefs<ChanServ::ChanAccess *>(ChanServ::chanaccess)) + a->Delete(); } 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); + AutoKick *ak = ::autokick.Create(); + ak->SetChannel(this); + ak->SetAccount(akicknc); + ak->SetReason(reason); + ak->SetCreator(user); + ak->SetAddTime(t); + ak->SetLastUsed(lu); - akicknc->AddChannelReference(this); - - return autokick; + return ak; } 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 = ::autokick.Create(); + ak->SetChannel(this); + ak->SetMask(mask); + ak->SetReason(reason); + ak->SetCreator(user); + ak->SetAddTime(t); + ak->SetLastUsed(lu); - AutoKick *ak = (*this->akick)[index]; - ak->QueueUpdate(); return ak; } -unsigned ChannelImpl::GetAkickCount |
