diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2021-09-15 23:39:32 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-10-22 16:54:20 +0200 |
commit | d05c69a892535b910943fe98fbce42f5cc860aa4 (patch) | |
tree | 10dfcfc58a5456627821d3903f7c013a8f585e6c /comphelper | |
parent | 6c9909dee4b06948ca6932397caa338d77ec7290 (diff) |
LOK: unify freemium APIs and uno command restriction APIs
Conflicts:
include/LibreOfficeKit/LibreOfficeKit.hxx
sfx2/source/control/unoctitm.cxx
Change-Id: I3badb038822331ab5cb30df6a66ce9a0640cf340
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124047
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/lok.cxx | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index c4ab97ed2f06..26c798eeaff4 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 { @@ -287,54 +287,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 |