]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/cap.h
Fix build errors on CentOS 6 and OpenBSD.
[user/henk/code/inspircd.git] / include / modules / cap.h
index 6f91f5aeefbb6575029c2109654eccb14c281f05..e6f9340e83b0177669d3d398bd1acfd7a32c79e7 100644 (file)
@@ -28,7 +28,14 @@ namespace Cap
        static const unsigned int MAX_VALUE_LENGTH = 100;
 
        typedef intptr_t Ext;
-       typedef LocalIntExt ExtItem;
+       class ExtItem : public LocalIntExt
+       {
+        public:
+               ExtItem(Module* mod);
+               std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
+               void unserialize(SerializeFormat format, Extensible* container, const std::string& value);
+       };
+
        class Capability;
 
        enum Protocol
@@ -278,4 +285,32 @@ namespace Cap
                        return NULL;
                }
        };
+
+       /** Reference to a cap. The cap may be provided by another module.
+        */
+       class Reference
+       {
+               dynamic_reference_nocheck<Capability> 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;
+               }
+       };
 }