diff options
Diffstat (limited to 'include/modules')
-rw-r--r-- | include/modules/hostserv.h | 48 | ||||
-rw-r--r-- | include/modules/nickserv.h | 4 |
2 files changed, 48 insertions, 4 deletions
diff --git a/include/modules/hostserv.h b/include/modules/hostserv.h index 4e6661faa..6934c813e 100644 --- a/include/modules/hostserv.h +++ b/include/modules/hostserv.h @@ -45,6 +45,54 @@ namespace HostServ virtual time_t GetCreated() anope_abstract; virtual void SetCreated(time_t) anope_abstract; + + virtual bool IsDefault() anope_abstract; + virtual void SetDefault(bool) anope_abstract; + + inline Anope::string Mask() + { + Anope::string ident = GetIdent(), host = GetHost(); + if (!ident.empty()) + return ident + "@" + host; + else + return host; + } }; + + /** Find the default vhost for an object, or the first + * if there is no default. + * @return The object's vhost + */ + inline VHost *FindVHost(Serialize::Object *obj) + { + VHost *first = nullptr; + + for (VHost *v : obj->GetRefs<VHost *>()) + { + if (first == nullptr) + first = v; + + if (v->IsDefault()) + { + first = v; + break; + } + } + + return first; + } + + inline VHost *FindVHost(Serialize::Object *obj, const Anope::string &v) + { + for (VHost *vhost : obj->GetRefs<VHost *>()) + { + if (vhost->Mask().equals_ci(v)) + { + return vhost; + } + } + + return nullptr; + } } diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h index 1ecb2a933..ef06bcb0c 100644 --- a/include/modules/nickserv.h +++ b/include/modules/nickserv.h @@ -22,7 +22,6 @@ #include "event.h" #include "service.h" #include "serialize.h" -#include "hostserv.h" namespace NickServ { @@ -169,9 +168,6 @@ namespace NickServ virtual Account *GetAccount() anope_abstract; virtual void SetAccount(Account *acc) anope_abstract; - - virtual HostServ::VHost *GetVHost() anope_abstract; - virtual void SetVHost(HostServ::VHost *) anope_abstract; }; /* A registered account. Each account must have a Nick with the same nick as the |