]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/cap.h
Remove the Kiwi links from the readme.
[user/henk/code/inspircd.git] / include / modules / cap.h
index e6f9340e83b0177669d3d398bd1acfd7a32c79e7..0bbd745c0ca40a5eb1d3e2c0a2865512d4dccd8b 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2018-2021 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2015-2016, 2018 Attila Molnar <attilamolnar@hush.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -32,8 +33,9 @@ namespace Cap
        {
         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);
+               void FromInternal(Extensible* container, const std::string& value) CXX11_OVERRIDE;
+               std::string ToHuman(const Extensible* container, void* item) const CXX11_OVERRIDE;
+               std::string ToInternal(const Extensible* container, void* item) const CXX11_OVERRIDE;
        };
 
        class Capability;
@@ -197,7 +199,7 @@ namespace Cap
                        if (!IsRegistered())
                                return false;
                        Ext caps = extitem->get(user);
-                       return (caps & GetMask());
+                       return ((caps & GetMask()) != 0);
                }
 
                /** Turn the capability on/off for a user. If the cap is not registered this method has no effect.
@@ -302,6 +304,12 @@ namespace Cap
                {
                }
 
+               /** Retrieves the underlying cap. */
+               operator const Cap::Capability*() const
+               {
+                       return ref ? *ref : NULL;
+               }
+
                /** 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
@@ -313,4 +321,23 @@ namespace Cap
                        return false;
                }
        };
+
+       class MessageBase : public ClientProtocol::Message
+       {
+        public:
+               MessageBase(const std::string& subcmd)
+                       : ClientProtocol::Message("CAP", ServerInstance->Config->GetServerName())
+               {
+                       PushParamPlaceholder();
+                       PushParam(subcmd);
+               }
+
+               void SetUser(LocalUser* user)
+               {
+                       if (user->registered & REG_NICK)
+                               ReplaceParamRef(0, user->nick);
+                       else
+                               ReplaceParam(0, "*");
+               }
+       };
 }