diff options
| author | Adam <Adam@anope.org> | 2017-02-07 17:20:07 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2017-02-07 17:20:07 -0500 |
| commit | 09dca29c8898916772c2a2a6b86b625c812007ed (patch) | |
| tree | 1b28f4751feec3ea2b46fa0afb061da7926f3a47 /modules/memoserv | |
| parent | 8b694bc392c36551e428b84454efb81cdbc8bcd3 (diff) | |
Normalize databases by not allowing generic Object references
Remove redis database support
Diffstat (limited to 'modules/memoserv')
| -rw-r--r-- | modules/memoserv/main/memoinfo.cpp | 19 | ||||
| -rw-r--r-- | modules/memoserv/main/memoinfo.h | 10 | ||||
| -rw-r--r-- | modules/memoserv/main/memoinfotype.cpp | 3 | ||||
| -rw-r--r-- | modules/memoserv/main/memoinfotype.h | 3 | ||||
| -rw-r--r-- | modules/memoserv/main/memoserv.cpp | 8 |
5 files changed, 30 insertions, 13 deletions
diff --git a/modules/memoserv/main/memoinfo.cpp b/modules/memoserv/main/memoinfo.cpp index aa5ca71e4..8f5efc3fd 100644 --- a/modules/memoserv/main/memoinfo.cpp +++ b/modules/memoserv/main/memoinfo.cpp @@ -37,6 +37,7 @@ unsigned MemoInfoImpl::GetIndex(MemoServ::Memo *m) void MemoInfoImpl::Del(unsigned index) { +#warning "delete on serializable" delete GetMemo(index); } @@ -51,14 +52,24 @@ bool MemoInfoImpl::HasIgnore(User *u) return false; } -Serialize::Object *MemoInfoImpl::GetOwner() +NickServ::Account *MemoInfoImpl::GetAccount() { - return Get(&MemoInfoType::owner); + return Get(&MemoInfoType::account); } -void MemoInfoImpl::SetOwner(Serialize::Object *o) +void MemoInfoImpl::SetAccount(NickServ::Account *account) { - Set(&MemoInfoType::owner, o); + Set(&MemoInfoType::account, account); +} + +ChanServ::Channel *MemoInfoImpl::GetChannel() +{ + return Get(&MemoInfoType::channel); +} + +void MemoInfoImpl::SetChannel(ChanServ::Channel *channel) +{ + Set(&MemoInfoType::channel, channel); } int16_t MemoInfoImpl::GetMemoMax() diff --git a/modules/memoserv/main/memoinfo.h b/modules/memoserv/main/memoinfo.h index cbe37e456..78d6f005b 100644 --- a/modules/memoserv/main/memoinfo.h +++ b/modules/memoserv/main/memoinfo.h @@ -23,7 +23,8 @@ class MemoInfoImpl : public MemoServ::MemoInfo { friend class MemoInfoType; - Serialize::Storage<Serialize::Object *> owner; + Serialize::Storage<NickServ::Account *> account; + Serialize::Storage<ChanServ::Channel *> channel; Serialize::Storage<int16_t> memomax; Serialize::Storage<bool> hardmax; @@ -35,8 +36,11 @@ class MemoInfoImpl : public MemoServ::MemoInfo void Del(unsigned index) override; bool HasIgnore(User *u) override; - Serialize::Object *GetOwner() override; - void SetOwner(Serialize::Object *) override; + NickServ::Account *GetAccount() override; + void SetAccount(NickServ::Account *) override; + + ChanServ::Channel *GetChannel() override; + void SetChannel(ChanServ::Channel *) override; int16_t GetMemoMax() override; void SetMemoMax(const int16_t &) override; diff --git a/modules/memoserv/main/memoinfotype.cpp b/modules/memoserv/main/memoinfotype.cpp index 27e3bba75..1dcccec98 100644 --- a/modules/memoserv/main/memoinfotype.cpp +++ b/modules/memoserv/main/memoinfotype.cpp @@ -21,7 +21,8 @@ #include "memoinfotype.h" MemoInfoType::MemoInfoType(Module *me) : Serialize::Type<MemoInfoImpl>(me) - , owner(this, "owner", &MemoInfoImpl::owner, true) + , account(this, "account", &MemoInfoImpl::account, true) + , channel(this, "channel", &MemoInfoImpl::channel, true) , memomax(this, "memomax", &MemoInfoImpl::memomax) , hardmax(this, "hardmax", &MemoInfoImpl::hardmax) { diff --git a/modules/memoserv/main/memoinfotype.h b/modules/memoserv/main/memoinfotype.h index 1a45b361a..94cc8fde4 100644 --- a/modules/memoserv/main/memoinfotype.h +++ b/modules/memoserv/main/memoinfotype.h @@ -22,7 +22,8 @@ class MemoInfoType : public Serialize::Type<MemoInfoImpl> { public: - Serialize::ObjectField<MemoInfoImpl, Serialize::Object *> owner; + Serialize::ObjectField<MemoInfoImpl, NickServ::Account *> account; + Serialize::ObjectField<MemoInfoImpl, ChanServ::Channel *> channel; Serialize::Field<MemoInfoImpl, int16_t> memomax; Serialize::Field<MemoInfoImpl, bool> hardmax; diff --git a/modules/memoserv/main/memoserv.cpp b/modules/memoserv/main/memoserv.cpp index 3b2b7cd17..757b95563 100644 --- a/modules/memoserv/main/memoserv.cpp +++ b/modules/memoserv/main/memoserv.cpp @@ -189,7 +189,7 @@ class MemoServCore : public Module, public MemoServ::MemoServService if (create && !ci->GetMemos()) { MemoServ::MemoInfo *mi = Serialize::New<MemoServ::MemoInfo *>(); - mi->SetOwner(ci); + mi->SetChannel(ci); } return ci->GetMemos(); } @@ -208,7 +208,7 @@ class MemoServCore : public Module, public MemoServ::MemoServService if (create && !na->GetAccount()->GetMemos()) { MemoServ::MemoInfo *mi = Serialize::New<MemoServ::MemoInfo *>(); - mi->SetOwner(na->GetAccount()); + mi->SetAccount(na->GetAccount()); } return na->GetAccount()->GetMemos(); } @@ -238,14 +238,14 @@ class MemoServCore : public Module, public MemoServ::MemoServService void OnNickRegister(User *, NickServ::Nick *na, const Anope::string &) override { MemoServ::MemoInfo *mi = Serialize::New<MemoServ::MemoInfo *>(); - mi->SetOwner(na->GetAccount()); + mi->SetAccount(na->GetAccount()); mi->SetMemoMax(Config->GetModule(this)->Get<int>("maxmemos")); } void OnChanRegistered(ChanServ::Channel *ci) override { MemoServ::MemoInfo *mi = Serialize::New<MemoServ::MemoInfo *>(); - mi->SetOwner(ci); + mi->SetChannel(ci); mi->SetMemoMax(Config->GetModule(this)->Get<int>("maxmemos")); } |
