diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-12-05 15:50:07 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-12-05 15:50:07 +0100 |
commit | b9c6792cd6123d9c6c0c30df75b0afe09258376f (patch) | |
tree | e59e4ae5e01b8538c0395d06c2d9138f8590a25e /src/modules | |
parent | a58f0c00f1153f90701db07b033cf0576e9999e9 (diff) |
m_cap Add Capability::GetCapValue(), list capabilities with values
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_cap.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp index 8ba28001e..12de0de08 100644 --- a/src/modules/m_cap.cpp +++ b/src/modules/m_cap.cpp @@ -149,7 +149,7 @@ class Cap::ManagerImpl : public Cap::Manager return true; } - void HandleList(std::string& out, LocalUser* user, bool show_all, bool minus_prefix = false) const + void HandleList(std::string& out, LocalUser* user, bool show_all, bool show_values, bool minus_prefix = false) const { Ext show_caps = (show_all ? ~0 : capext.get(user)); @@ -164,13 +164,24 @@ class Cap::ManagerImpl : public Cap::Manager if (minus_prefix) out.push_back('-'); - out.append(cap->GetName()).push_back(' '); + out.append(cap->GetName()); + + if (show_values) + { + const std::string* capvalue = cap->GetValue(user); + if ((capvalue) && (!capvalue->empty()) && (capvalue->find(' ') == std::string::npos)) + { + out.push_back('='); + out.append(*capvalue, 0, MAX_VALUE_LENGTH); + } + } + out.push_back(' '); } } void HandleClear(LocalUser* user, std::string& result) { - HandleList(result, user, false, true); + HandleList(result, user, false, false, true); capext.unset(user); } }; @@ -225,7 +236,8 @@ class CommandCap : public SplitCommand manager.Set302Protocol(user); std::string result = subcommand + " :"; - manager.HandleList(result, user, is_ls); + // Show values only if supports v3.2 and doing LS + manager.HandleList(result, user, is_ls, ((is_ls) && (manager.GetProtocol(user) != Cap::CAP_LEGACY))); DisplayResult(user, result); } else if ((subcommand == "CLEAR") && (manager.GetProtocol(user) == Cap::CAP_LEGACY)) |