summaryrefslogtreecommitdiffstats
path: root/kit
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2021-09-14 01:32:43 +0530
committerTor Lillqvist <tml@iki.fi>2021-10-21 12:28:13 +0300
commit88601440d02a36c20e2aeada1b04c03eeab4ff8e (patch)
treed2ae700647f914b9df7ba00ea8d22541b6add1ee /kit
parentfreemium: renamed Freemium namespace to CommandControl (diff)
downloadonline-88601440d02a36c20e2aeada1b04c03eeab4ff8e.tar.gz
online-88601440d02a36c20e2aeada1b04c03eeab4ff8e.zip
introduce way to hide/restrict uno commands
Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: I1225190a67f726832e5b38a7c3f690b51c1385f3
Diffstat (limited to 'kit')
-rw-r--r--kit/ChildSession.cpp22
-rw-r--r--kit/ChildSession.hpp3
2 files changed, 25 insertions, 0 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index b4f4eefaa7..cfaf0e2d55 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -303,6 +303,12 @@ bool ChildSession::_handleInput(const char *buffer, int length)
return updateFreemiumStatus(buffer, length, tokens);
#endif
}
+ else if (tokens.equals(0, "restrictionstatus"))
+ {
+#ifdef ENABLE_FEATURE_RESTRICTION
+ return updateRestrictionStatus(buffer, length, tokens);
+#endif
+ }
else
{
// All other commands are such that they always require a LibreOfficeKitDocument session,
@@ -2693,6 +2699,22 @@ bool ChildSession::updateFreemiumStatus(const char* /*buffer*/, int /*length*/,
}
#endif
+#ifdef ENABLE_FEATURE_RESTRICTION
+bool ChildSession::updateRestrictionStatus(const char* /*buffer*/, int /*length*/, const StringVector& tokens)
+{
+ std::string status;
+ if (tokens.size() < 2 || !getTokenString(tokens[1], "isRestrictedUser", status))
+ {
+ sendTextFrameAndLogError("error: cmd=restrictionstatus kind=failure");
+ return false;
+ }
+
+ getLOKitDocument()->setRestrictedCommandList(CommandControl::RestrictionManager::getRestrictedCommandListString().c_str());
+ getLOKitDocument()->setRestrictedView(_viewId, status == "true");
+ return true;
+}
+#endif
+
void ChildSession::loKitCallback(const int type, const std::string& payload)
{
const char* const typeName = lokCallbackTypeToString(type);
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 263fe66b99..e20c34ec79 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -321,6 +321,9 @@ private:
#ifdef ENABLE_FREEMIUM
bool updateFreemiumStatus(const char* buffer, int length, const StringVector& tokens);
#endif
+#ifdef ENABLE_FEATURE_RESTRICTION
+ bool updateRestrictionStatus(const char* /*buffer*/, int /*length*/, const StringVector& tokens);
+#endif
bool formFieldEvent(const char* buffer, int length, const StringVector& tokens);
bool renderSearchResult(const char* buffer, int length, const StringVector& tokens);