summaryrefslogtreecommitdiff
path: root/include/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-10-09 19:51:39 -0400
committerAdam <Adam@anope.org>2016-10-09 19:51:39 -0400
commite7dd7159b1e1ab5b3edabc44ece5338672f8fbb4 (patch)
tree9517f02ca1c29fa247f6914398f35a44052c22ff /include/modules
parent8ceca4fd3f9cb82bc93801d5eb682d27b2ad2f54 (diff)
Make vhosts assignable to accounts, not nicks. Allow multiple vhosts per account.
Diffstat (limited to 'include/modules')
-rw-r--r--include/modules/hostserv.h48
-rw-r--r--include/modules/nickserv.h4
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