From c933f324085d025d4b1b96f4405cdffff52e9256 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 5 Dec 2015 16:42:17 +0100 Subject: m_cap Make Capability objects compatible with dynamic_references, add Cap::Reference --- include/modules/cap.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include') diff --git a/include/modules/cap.h b/include/modules/cap.h index 9ff5faca9..e6f9340e8 100644 --- a/include/modules/cap.h +++ b/include/modules/cap.h @@ -285,4 +285,32 @@ namespace Cap return NULL; } }; + + /** Reference to a cap. The cap may be provided by another module. + */ + class Reference + { + dynamic_reference_nocheck ref; + + public: + /** Constructor, initializes the capability reference + * @param mod Module creating this object + * @param Name Raw name of the cap as used in the protocol (CAP LS, etc.) + */ + Reference(Module* mod, const std::string& Name) + : ref(mod, "cap/" + Name) + { + } + + /** Check whether a user has the referenced capability turned on. + * @param user User to check + * @return True if the user is using the referenced capability, false otherwise + */ + bool get(LocalUser* user) + { + if (ref) + return ref->get(user); + return false; + } + }; } -- cgit v1.2.3