summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2021-09-15 23:39:32 +0530
committerTor Lillqvist <tml@collabora.com>2021-10-18 15:16:54 +0200
commitbe717e5062f353526e78749b74f3c9888ecfcc5c (patch)
treed97b40438ed0c9471badd967b4bc05f6b382ba0f /comphelper
parent5393f9bf41f4a35385526205bb51f9b29bf8c20d (diff)
LOK: unify freemium APIs and uno command restriction APIs
Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: I3badb038822331ab5cb30df6a66ce9a0640cf340 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122162 Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/lok.cxx64
1 files changed, 35 insertions, 29 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 659765f802da..d3b3e9bdec2d 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -35,9 +35,9 @@ static bool g_bLocalRendering(false);
static Compat g_eCompatFlags(Compat::none);
-static std::vector<OUString> g_vFreemiumDenyList;
+static std::unordered_set<OUString> g_vFreemiumDenyList;
-static std::vector<OUString> g_vRestrictedCommandList;
+static std::unordered_set<OUString> g_vRestrictedCommandList;
namespace
{
@@ -289,54 +289,60 @@ void statusIndicatorFinish()
pStatusIndicatorCallback(pStatusIndicatorCallbackData, statusIndicatorCallbackType::Finish, 0, nullptr);
}
-void setFreemiumDenyList(const char* freemiumDenyList)
+void setBlockedCommandList(const char* bolckedCommandList)
{
- if(!g_vFreemiumDenyList.empty())
- return;
- OUString DenyListString(freemiumDenyList, strlen(freemiumDenyList), RTL_TEXTENCODING_UTF8);
+ OUString BolckedListString(bolckedCommandList, strlen(bolckedCommandList), RTL_TEXTENCODING_UTF8);
- OUString command = DenyListString.getToken(0, ' ');
- for (size_t i = 1; !command.isEmpty(); i++)
+ OUString type = BolckedListString.getToken(0, '-');
+
+ if (type == "freemium")
{
- g_vFreemiumDenyList.emplace_back(command);
- command = DenyListString.getToken(i, ' ');
+ if(!g_vFreemiumDenyList.empty())
+ return;
+ OUString commands = BolckedListString.getToken(1, '-');
+
+ OUString command = commands.getToken(0, ' ');
+ for (size_t i = 1; !command.isEmpty(); i++)
+ {
+ g_vFreemiumDenyList.emplace(command);
+ command = commands.getToken(i, ' ');
+ }
+ }
+ else
+ {
+ if(!g_vRestrictedCommandList.empty())
+ return;
+
+ OUString commands = BolckedListString.getToken(1, '-');
+
+ OUString command = commands.getToken(0, ' ');
+ for (size_t i = 1; !command.isEmpty(); i++)
+ {
+ g_vRestrictedCommandList.emplace(command);
+ command = commands.getToken(i, ' ');
+ }
}
}
-const std::vector<OUString>& getFreemiumDenyList()
+const std::unordered_set<OUString>& getFreemiumDenyList()
{
return g_vFreemiumDenyList;
}
bool isCommandFreemiumDenied(const OUString& command)
{
- return std::find(g_vFreemiumDenyList.begin(), g_vFreemiumDenyList.end(), command) != g_vFreemiumDenyList.end();
-}
-
-void setRestrictedCommandList(const char* restrictedCommandList)
-{
- if(!g_vRestrictedCommandList.empty())
- return;
-
- OUString RestrictedListString(restrictedCommandList, strlen(restrictedCommandList), RTL_TEXTENCODING_UTF8);
-
- OUString command = RestrictedListString.getToken(0, ' ');
- for (size_t i = 1; !command.isEmpty(); i++)
- {
- g_vRestrictedCommandList.emplace_back(command);
- command = RestrictedListString.getToken(i, ' ');
- }
+ return g_vFreemiumDenyList.find(command) != g_vFreemiumDenyList.end();
}
-const std::vector<OUString>& getRestrictedCommandList()
+const std::unordered_set<OUString>& getRestrictedCommandList()
{
return g_vRestrictedCommandList;
}
bool isRestrictedCommand(const OUString& command)
{
- return std::find(g_vRestrictedCommandList.begin(), g_vRestrictedCommandList.end(), command) != g_vRestrictedCommandList.end();
+ return g_vRestrictedCommandList.find(command) != g_vRestrictedCommandList.end();
}
} // namespace