From 34f5a5a5e482f47476f1a37684d837c1d21d79b0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 28 Oct 2021 16:56:35 +0200 Subject: ucb: webdav-curl: remove SerfLockStore::getLockToken() Looking rather obsolete, plus NonInteractive_LOCK() can just get the token as a parameter since it's called only by LockStore. Change-Id: I4c5c84135592fbab20f36c93d0c99b80fccb0976 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124453 Tested-by: Michael Stahl Reviewed-by: Michael Stahl --- ucb/source/ucp/webdav-curl/CurlSession.cxx | 20 ++++++++++---------- ucb/source/ucp/webdav-curl/CurlSession.hxx | 5 +++-- ucb/source/ucp/webdav-curl/SerfLockStore.cxx | 17 ++--------------- ucb/source/ucp/webdav-curl/SerfLockStore.hxx | 1 - 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index d7a0f62ce606..d075c67132c8 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -1799,8 +1799,8 @@ auto CurlSession::PUT(OUString const& rURIReference, { throw uno::RuntimeException("curl_slist_append failed"); } - OUString const token(g_Init.LockStore.getLockToken(uri.GetURI())); - if (!token.isEmpty()) + OUString const* const pToken(g_Init.LockStore.getLockTokenForURI(uri.GetURI(), nullptr)); + if (pToken) { OString const utf8If("If: " // disabled as Sharepoint 2013 workaround, it accepts only @@ -1810,7 +1810,7 @@ auto CurlSession::PUT(OUString const& rURIReference, + "> " #endif "(<" - + OUStringToOString(token, RTL_TEXTENCODING_ASCII_US) + ">)"); + + OUStringToOString(*pToken, RTL_TEXTENCODING_ASCII_US) + ">)"); pList.reset(curl_slist_append(pList.release(), utf8If.getStr())); if (!pList) { @@ -2162,14 +2162,14 @@ auto CurlSession::LOCK(OUString const& rURIReference, ucb::Lock /*const*/& rLock auto CurlProcessor::Unlock(CurlSession& rSession, CurlUri const& rURI, DAVRequestEnvironment const* const pEnv) -> void { - OUString const token(g_Init.LockStore.getLockToken(rURI.GetURI())); - if (token.isEmpty()) + OUString const* const pToken(g_Init.LockStore.getLockTokenForURI(rURI.GetURI(), nullptr)); + if (!pToken) { SAL_WARN("ucb.ucp.webdav.curl", "attempt to unlock but not locked"); throw DAVException(DAVException::DAV_NOT_LOCKED); } OString const utf8LockToken("Lock-Token: <" - + OUStringToOString(token, RTL_TEXTENCODING_ASCII_US) + ">"); + + OUStringToOString(*pToken, RTL_TEXTENCODING_ASCII_US) + ">"); ::std::unique_ptr> pList( curl_slist_append(nullptr, utf8LockToken.getStr())); if (!pList) @@ -2197,7 +2197,7 @@ auto CurlSession::UNLOCK(OUString const& rURIReference, DAVRequestEnvironment co g_Init.LockStore.removeLock(uri.GetURI()); } -auto CurlSession::NonInteractive_LOCK(OUString const& rURI, +auto CurlSession::NonInteractive_LOCK(OUString const& rURI, ::std::u16string_view const rLockToken, sal_Int32& o_rLastChanceToSendRefreshRequest, bool& o_rIsAuthFailed) -> bool { @@ -2211,9 +2211,9 @@ auto CurlSession::NonInteractive_LOCK(OUString const& rURI, ::std::unique_ptr> pList( curl_slist_append(nullptr, "Timeout: Second-180")); - OUString const token(g_Init.LockStore.getLockToken(rURI)); - assert(!token.isEmpty()); // LockStore is the caller - OString const utf8If("If: (<" + OUStringToOString(token, RTL_TEXTENCODING_ASCII_US) + ">)"); + assert(!rLockToken.empty()); // LockStore is the caller + OString const utf8If("If: (<" + OUStringToOString(rLockToken, RTL_TEXTENCODING_ASCII_US) + + ">)"); pList.reset(curl_slist_append(pList.release(), utf8If.getStr())); if (!pList) { diff --git a/ucb/source/ucp/webdav-curl/CurlSession.hxx b/ucb/source/ucp/webdav-curl/CurlSession.hxx index 73b32096f6ea..706aa54c19e5 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.hxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.hxx @@ -134,8 +134,9 @@ public: virtual auto abort() -> void override; - auto NonInteractive_LOCK(OUString const& rURI, sal_Int32& o_rLastChanceToSendRefreshRequest, - bool& o_rIsAuthFailed) -> bool; + auto NonInteractive_LOCK(OUString const& rURI, ::std::u16string_view rLockToken, + sal_Int32& o_rLastChanceToSendRefreshRequest, bool& o_rIsAuthFailed) + -> bool; auto NonInteractive_UNLOCK(OUString const& rURI) -> void; }; diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx index ef9534dbe58f..0de397986f8f 100644 --- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx +++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx @@ -141,20 +141,6 @@ void SerfLockStore::stopTicker(osl::ClearableMutexGuard & rGuard) } } -OUString SerfLockStore::getLockToken(const OUString& rURI) -{ - assert(rURI.startsWith("http://") || rURI.startsWith("https://")); - - osl::MutexGuard aGuard( m_aMutex ); - - LockInfoMap::const_iterator const it( m_aLockInfoMap.find(rURI) ); - if ( it != m_aLockInfoMap.end() ) - return (*it).second.m_sToken; - - SAL_WARN("ucb.ucp.webdav", "SerfLockStore::getLockToken: lock not found!" ); - return OUString(); -} - OUString const* SerfLockStore::getLockTokenForURI(OUString const& rURI, css::ucb::Lock const*const pLock) { @@ -257,7 +243,8 @@ void SerfLockStore::refreshLocks() sal_Int32 nlastChanceToSendRefreshRequest = -1; bool isAuthFailed(false); if (rInfo.m_xSession->NonInteractive_LOCK( - rLockInfo.first, nlastChanceToSendRefreshRequest, + rLockInfo.first, rLockInfo.second.m_sToken, + nlastChanceToSendRefreshRequest, isAuthFailed)) { rInfo.m_nLastChanceToSendRefreshRequest diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx index 7a420187813c..fc0ed6120532 100644 --- a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx +++ b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx @@ -68,7 +68,6 @@ public: ~SerfLockStore(); bool finishing() const; - OUString getLockToken(const OUString& rURI); OUString const* getLockTokenForURI(OUString const& rURI, css::ucb::Lock const* pLock); -- cgit