summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-12-05 15:45:20 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-12-05 15:45:20 +0100
commit9ac2eae1f0d663cb3b2fc05d6d37b07dcfd9025e (patch)
tree904eb6cb6ece728486192a69cf48df325e659359 /include
parent3e08629e8342cfbd17388aa14facf3a3a963233f (diff)
m_cap Learn the supported capability negotiation protocol of a client from CAP LS
Let modules implementing caps query this information
Diffstat (limited to 'include')
-rw-r--r--include/modules/cap.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/modules/cap.h b/include/modules/cap.h
index a00089260..1ad2ff2f1 100644
--- a/include/modules/cap.h
+++ b/include/modules/cap.h
@@ -23,11 +23,24 @@
namespace Cap
{
- static const unsigned int MAX_CAPS = sizeof(intptr_t) * 8;
+ static const unsigned int MAX_CAPS = (sizeof(intptr_t) * 8) - 1;
+ static const intptr_t CAP_302_BIT = (intptr_t)1 << MAX_CAPS;
+
typedef intptr_t Ext;
typedef LocalIntExt ExtItem;
class Capability;
+ enum Protocol
+ {
+ /** Supports capability negotiation protocol v3.1, or none
+ */
+ CAP_LEGACY,
+
+ /** Supports capability negotiation v3.2
+ */
+ CAP_302
+ };
+
class Manager : public DataProvider
{
public:
@@ -190,6 +203,16 @@ namespace Cap
*/
bool IsRegistered() const { return (extitem != NULL); }
+ /** Get the CAP negotiation protocol version of a user.
+ * The cap must be registered for this to return anything other than CAP_LEGACY.
+ * @param user User whose negotiation protocol version to query
+ * @return One of the Capability::Protocol enum indicating the highest supported capability negotiation protocol version
+ */
+ Protocol GetProtocol(LocalUser* user) const
+ {
+ return ((IsRegistered() && (extitem->get(user) & CAP_302_BIT)) ? CAP_302 : CAP_LEGACY);
+ }
+
/** Called when a user requests to turn this capability on or off.
* @param user User requesting to change the state of the cap
* @param add True if requesting to turn the cap on, false if requesting to turn it off