wsd: new config entry to add unlock_link for feature lock dialog per alias_group
- also added unlock_link option in dynamic configuration Signed-off-by: Rash419 <rashesh.padia@collabora.com> Change-Id: I075a4aed4f82059714412def965a8ed4d3581b2fpull/5049/head
parent
9bb0b6fabd
commit
c91b8b01b4
|
@ -20,8 +20,10 @@ std::unordered_set<std::string> LockManager::LockedCommandList;
|
|||
std::string LockManager::LockedCommandListString;
|
||||
Util::RegexListMatcher LockManager::readOnlyWopiHosts;
|
||||
Util::RegexListMatcher LockManager::disabledCommandWopiHosts;
|
||||
std::map<std::string, std::string> LockManager::unlockLinkMap;
|
||||
bool LockManager::lockHostEnabled = false;
|
||||
std::string LockManager::translationPath = std::string();
|
||||
std::string LockManager::unlockLink = std::string();
|
||||
|
||||
LockManager::LockManager() {}
|
||||
|
||||
|
@ -136,6 +138,18 @@ void LockManager::setTranslationPath(const std::string& lockedDialogLang)
|
|||
}
|
||||
}
|
||||
}
|
||||
void LockManager::mapUnlockLink(const std::string& host, const std::string& path)
|
||||
{
|
||||
if (!config::has(path + ".unlock_link"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const std::string link = config::getString(path + ".unlock_link" , "");
|
||||
if (!link.empty())
|
||||
{
|
||||
unlockLinkMap.insert({host, link });
|
||||
}
|
||||
}
|
||||
|
||||
bool RestrictionManager::_isRestrictedUser = false;
|
||||
std::unordered_set<std::string> RestrictionManager::RestrictedCommandList;
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
// Allow/deny Locked hosts
|
||||
static Util::RegexListMatcher readOnlyWopiHosts;
|
||||
static Util::RegexListMatcher disabledCommandWopiHosts;
|
||||
static std::map<std::string, std::string> unlockLinkMap;
|
||||
static std::string unlockLink;
|
||||
static bool lockHostEnabled;
|
||||
|
||||
static void parseLockedHost(Poco::Util::LayeredConfiguration& conf);
|
||||
|
@ -62,6 +64,8 @@ public:
|
|||
}
|
||||
static std::string getUnlockLink()
|
||||
{
|
||||
if (!unlockLink.empty())
|
||||
return unlockLink;
|
||||
return config::getString("feature_lock.unlock_link", "");
|
||||
}
|
||||
static std::string getUnlockDescription()
|
||||
|
@ -111,9 +115,11 @@ public:
|
|||
}
|
||||
return Poco::URI();
|
||||
}
|
||||
static void resetTransalatioPath()
|
||||
static void resetTransalatioPath() { translationPath = std::string(); }
|
||||
static void mapUnlockLink(const std::string& host, const std::string& path);
|
||||
static void setUnlockLink(const std::string& host)
|
||||
{
|
||||
translationPath = std::string();
|
||||
unlockLink = Util::getValue(unlockLinkMap, host);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
12
configure.ac
12
configure.ac
|
@ -1437,15 +1437,15 @@ if test "$enable_feature_lock" = "yes"; then
|
|||
<unlock_title desc=\"Title to show user when prompting the unlock popup\" default=\"$UNLOCK_TITLE\">$UNLOCK_TITLE</unlock_title>
|
||||
<unlock_link desc=\"Link from where user can unlock the features\" default=\"$UNLOCK_LINK\">$UNLOCK_LINK</unlock_link>
|
||||
<unlock_description desc=\"Description about unlocking features\" default=\"$UNLOCK_DESCRIPTION\">$UNLOCK_DESCRIPTION</unlock_description>
|
||||
<unlock_image desc=\"URL of image shown when unlock dialog get displayed\" default=\"\"></unlock_image><!-- URL structure - https://<hostname>/static/<image_path> -->
|
||||
<unlock_image desc=\"URL of image shown when unlock dialog get displayed\" default=\"\"></unlock_image><!-- URL structure - https://<hostname>/static/<image_endpoint> -->
|
||||
<writer_unlock_highlights desc=\"Short note about Writer benefits of unlocking\" default=\"$WRITER_UNLOCK_HIGHLIGHTS\">$WRITER_UNLOCK_HIGHLIGHTS</writer_unlock_highlights>
|
||||
<calc_unlock_highlights desc=\"Short note about Calc benefits of unlocking\" default=\"$CALC_UNLOCK_HIGHLIGHTS\">$CALC_UNLOCK_HIGHLIGHTS</calc_unlock_highlights>
|
||||
<impress_unlock_highlights desc=\"Short note about Impress benefits of unlocking\" default=\"$IMPRESS_UNLOCK_HIGHLIGHTS\">$IMPRESS_UNLOCK_HIGHLIGHTS</impress_unlock_highlights>
|
||||
<draw_unlock_highlights desc=\"Short note about Draw benefits of unlocking\" default=\"$DRAW_UNLOCK_HIGHLIGHTS\">$DRAW_UNLOCK_HIGHLIGHTS</draw_unlock_highlights>
|
||||
|
||||
<translations>
|
||||
<!-- Example to add german language for feature lock dialog -->
|
||||
<!--
|
||||
Example to add german language for feature lock dialog
|
||||
<language name=\"de\">
|
||||
<unlock_title desc=\"Title to show user when prompting the unlock popup\" default=\"Entfesseln Sie Ihr Potenzial\">Entfesseln Sie Ihr Potenzial</unlock_title>
|
||||
<unlock_description desc=\"Description about unlocking features\" default=\"Gehen Sie zur Detailseite und entdecken Sie alle Funktionen:\">Gehen Sie zur Detailseite und entdecken Sie alle Funktionen:</unlock_description>
|
||||
|
@ -1462,6 +1462,14 @@ fi
|
|||
AC_SUBST(LOCK_CONFIGURATION)
|
||||
AM_SUBST_NOTMAKE(LOCK_CONFIGURATION)
|
||||
|
||||
UNLOCK_LINK_PER_HOST=
|
||||
if test "$enable_feature_lock" = "yes"; then
|
||||
UNLOCK_LINK_PER_HOST="<unlock_link desc=\"Link from where user can unlock the features, which will get mapped with alias_group. According to hostname coolwsd will set the unlock link for feature unlock dialog. If not specified it will fallback to feature_lock.unlock_link entry\" default=\"\"></unlock_link>"
|
||||
fi
|
||||
|
||||
AC_SUBST(UNLOCK_LINK_PER_HOST)
|
||||
AM_SUBST_NOTMAKE(UNLOCK_LINK_PER_HOST)
|
||||
|
||||
AS_IF([test "$enable_feature_restriction" = "yes"],
|
||||
[AC_DEFINE([ENABLE_FEATURE_RESTRICTION],1,[Whether to compile and enable feature restrictions])])
|
||||
|
||||
|
|
|
@ -218,6 +218,7 @@
|
|||
<host desc="hostname to allow or deny." allow="true">scheme://hostname:port</host>
|
||||
<alias desc="regex pattern of aliasname">scheme://aliasname1:port</alias>
|
||||
<alias desc="regex pattern of aliasname">scheme://aliasname2:port</alias>
|
||||
@UNLOCK_LINK_PER_HOST@
|
||||
</group>-->
|
||||
<!-- More "group"s possible here -->
|
||||
</alias_groups>
|
||||
|
|
|
@ -1364,7 +1364,11 @@ public:
|
|||
|
||||
newAppConfig.insert(std::make_pair(path + ".host", host));
|
||||
newAppConfig.insert(std::make_pair(path + ".host[@allow]", booleanToString(allow)));
|
||||
|
||||
#ifdef ENABLE_FEATURE_LOCK
|
||||
std::string unlockLink;
|
||||
JsonUtil::findJSONValue(group, "unlock_link", unlockLink);
|
||||
newAppConfig.insert(std::make_pair(path + ".unlock_link", unlockLink));
|
||||
#endif
|
||||
Poco::JSON::Array::Ptr aliases = group->getArray("aliases");
|
||||
|
||||
auto it = aliases->begin();
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "HostUtil.hpp"
|
||||
#include <common/ConfigUtil.hpp>
|
||||
#include <common/Log.hpp>
|
||||
#include <common/CommandControl.hpp>
|
||||
#include <config.h>
|
||||
|
||||
Util::RegexListMatcher HostUtil::WopiHosts;
|
||||
std::map<std::string, std::string> HostUtil::AliasHosts;
|
||||
|
@ -78,6 +80,9 @@ void HostUtil::parseAliases(Poco::Util::LayeredConfiguration& conf)
|
|||
}
|
||||
|
||||
AliasHosts.clear();
|
||||
#ifdef ENABLE_FEATURE_LOCK
|
||||
CommandControl::LockManager::unlockLinkMap.clear();
|
||||
#endif
|
||||
|
||||
for (size_t i = 0;; i++)
|
||||
{
|
||||
|
@ -97,6 +102,9 @@ void HostUtil::parseAliases(Poco::Util::LayeredConfiguration& conf)
|
|||
try
|
||||
{
|
||||
const Poco::URI realUri(uri);
|
||||
#ifdef ENABLE_FEATURE_LOCK
|
||||
CommandControl::LockManager::mapUnlockLink(realUri.getHost(), path);
|
||||
#endif
|
||||
HostUtil::hostList.insert(realUri.getHost());
|
||||
HostUtil::addWopiHost(realUri.getHost(), allow);
|
||||
}
|
||||
|
@ -129,6 +137,9 @@ void HostUtil::parseAliases(Poco::Util::LayeredConfiguration& conf)
|
|||
const Poco::URI aUri(aliasUri.getScheme() + "://" + x + ':' +
|
||||
std::to_string(aliasUri.getPort()));
|
||||
AliasHosts.insert({ aUri.getAuthority(), realUri.getAuthority() });
|
||||
#ifdef ENABLE_FEATURE_LOCK
|
||||
CommandControl::LockManager::mapUnlockLink(aUri.getHost(), path);
|
||||
#endif
|
||||
HostUtil::addWopiHost(aUri.getHost(), allow);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -868,7 +868,7 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo &fileInfo,
|
|||
{
|
||||
bool isReadOnly = false;
|
||||
isUserLocked = false;
|
||||
|
||||
CommandControl::LockManager::setUnlockLink(uriObject.getHost());
|
||||
Poco::URI newUri(HostUtil::getNewLockedUri(uriObject));
|
||||
const std::string host = newUri.getHost();
|
||||
|
||||
|
|
Loading…
Reference in New Issue