[Libreoffice-commits] core.git: ucb/source

2023-12-04 Thread Caolán McNamara (via logerrit)
 ucb/source/ucp/tdoc/tdoc_datasupplier.cxx |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 9ddca3616fc8b91973b9f261fd53797f9c84570f
Author: Caolán McNamara 
AuthorDate: Sun Dec 3 19:50:30 2023 +
Commit: Caolán McNamara 
CommitDate: Mon Dec 4 10:48:36 2023 +0100

cid#1546455 COPY_INSTEAD_OF_MOVE

Change-Id: I9ea3cad738f5cbef0036fde9112b391893aff615
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160277
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx 
b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
index f4291f4a5043..9930f80d6e3c 100644
--- a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
@@ -380,9 +380,8 @@ bool 
ResultSetDataSupplier::queryNamesOfChildren(std::unique_lock& /
 OUString
 ResultSetDataSupplier::assembleChildURL( std::u16string_view aName )
 {
-OUString aContURL
+OUString aURL
 = m_xContent->getIdentifier()->getContentIdentifier();
-OUString aURL( aContURL );
 
 sal_Int32 nUrlEnd = aURL.lastIndexOf( '/' );
 if ( nUrlEnd != aURL.getLength() - 1 )


[Libreoffice-commits] core.git: ucb/source

2023-11-29 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 24cc5f55a04eeb6a9f286066c1389191b153a910
Author: Stephan Bergmann 
AuthorDate: Wed Nov 29 14:37:42 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 29 20:00:04 2023 +0100

Extended loplugin:ostr: ucb

Change-Id: If6f818506ef7a596a6ea3af4185859b09c6d4d75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160096
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index c07919b6d4b7..a54e9d1addfb 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1591,13 +1591,13 @@ auto CurlProcessor::PropFind(
 switch (nDepth)
 {
 case DAVZERO:
-depth = "Depth: 0";
+depth = "Depth: 0"_ostr;
 break;
 case DAVONE:
-depth = "Depth: 1";
+depth = "Depth: 1"_ostr;
 break;
 case DAVINFINITY:
-depth = "Depth: infinity";
+depth = "Depth: infinity"_ostr;
 break;
 default:
 assert(false);
@@ -2275,13 +2275,13 @@ auto CurlSession::LOCK(OUString const& rURIReference, 
ucb::Lock /*const*/& rLock
 switch (rLock.Depth)
 {
 case ucb::LockDepth_ZERO:
-depth = "Depth: 0";
+depth = "Depth: 0"_ostr;
 break;
 case ucb::LockDepth_ONE:
-depth = "Depth: 1";
+depth = "Depth: 1"_ostr;
 break;
 case ucb::LockDepth_INFINITY:
-depth = "Depth: infinity";
+depth = "Depth: infinity"_ostr;
 break;
 default:
 assert(false);
@@ -2295,10 +2295,10 @@ auto CurlSession::LOCK(OUString const& rURIReference, 
ucb::Lock /*const*/& rLock
 switch (rLock.Timeout)
 {
 case -1:
-timeout = "Timeout: Infinite";
+timeout = "Timeout: Infinite"_ostr;
 break;
 case 0:
-timeout = "Timeout: Second-180";
+timeout = "Timeout: Second-180"_ostr;
 break;
 default:
 timeout = "Timeout: Second-" + OString::number(rLock.Timeout);


[Libreoffice-commits] core.git: ucb/source

2023-11-19 Thread Julien Nabet (via logerrit)
 ucb/source/ucp/file/filtask.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7068754492563710d3a5db06abeb0520effdf8a2
Author: Julien Nabet 
AuthorDate: Sun Nov 19 21:32:07 2023 +0100
Commit: Julien Nabet 
CommitDate: Mon Nov 20 07:45:14 2023 +0100

c++20: use std::erase(_if) instead of std::remove(_if)+erase (ucb)

Change-Id: I9ce4ae0246f78acd7bfed89f52103c2f5e571c14
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159706
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index e909c53071c0..80f4785d773e 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -507,7 +507,7 @@ TaskManager::deregisterNotifier( const OUString& 
aUnqPath,Notifier* pNotifier )
 if( it == m_aContent.end() )
 return;
 
-it->second.notifier.erase(std::remove(it->second.notifier.begin(), 
it->second.notifier.end(), pNotifier), it->second.notifier.end());
+std::erase(it->second.notifier, pNotifier);
 
 if( it->second.notifier.empty() )
 m_aContent.erase( it );


[Libreoffice-commits] core.git: ucb/source

2023-10-28 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/tdoc/tdoc_docmgr.cxx |   17 +
 ucb/source/ucp/tdoc/tdoc_docmgr.hxx |4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 4d85dfd54942e1fc442f3d1a424207ab61b65806
Author: Noel Grandin 
AuthorDate: Fri Oct 27 21:14:28 2023 +0200
Commit: Noel Grandin 
CommitDate: Sat Oct 28 14:27:44 2023 +0200

use more XModel3::getArgs2

to avoid needing to query other, rather expensive properties

Change-Id: I34ebc7a03e468f0a7fa9964954e5690ad336016a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158579
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx 
b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index 0e11f546bb1e..39fa5bc828b5 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -556,13 +556,20 @@ void 
OfficeDocumentsManager::updateStreamDateModified(OUString const & uri) {
 
 
 bool OfficeDocumentsManager::isDocumentPreview(
-const uno::Reference< frame::XModel > & xModel )
+const uno::Reference< frame::XModel3 > & xModel )
 {
 if ( !xModel.is() )
 return false;
 
-bool bIsPreview = ::comphelper::NamedValueCollection::getOrDefault( 
xModel->getArgs(), u"Preview", false );
-return bIsPreview;
+uno::Sequence props = xModel->getArgs2( { "Preview" 
} );
+for (const auto & rProp : props)
+if (rProp.Name == "Preview")
+{
+bool bIsPreview = false;
+rProp.Value >>= bIsPreview;
+return bIsPreview;
+}
+return false;
 }
 
 
@@ -664,11 +671,13 @@ bool OfficeDocumentsManager::isOfficeDocument(
 xStorageBasedDoc( xModel, uno::UNO_QUERY );
 if ( !xStorageBasedDoc.is() )
 return false;
+uno::Reference< frame::XModel3 > xModel3( xDoc, uno::UNO_QUERY );
+assert(xModel3 && "anything implementing frame:XModel is expected to 
implement XModel3 as well");
 
 if ( !isWithoutOrInTopLevelFrame( xModel ) )
 return false;
 
-if ( isDocumentPreview( xModel ) )
+if ( isDocumentPreview( xModel3 ) )
 return false;
 
 if ( isHelpDocument( xModel ) )
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx 
b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
index 8daf9eba60e4..7115d0fe8e99 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
@@ -25,7 +25,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -133,7 +133,7 @@ namespace tdoc_ucp {
 const css::uno::Reference< css::uno::XInterface > & xDoc );
 
 static bool isDocumentPreview(
-const css::uno::Reference< css::frame::XModel > & xModel );
+const css::uno::Reference< css::frame::XModel3 > & xModel );
 
 static bool isWithoutOrInTopLevelFrame(
 const css::uno::Reference< css::frame::XModel > & xModel );


[Libreoffice-commits] core.git: ucb/source

2023-10-20 Thread Stephan Bergmann (via logerrit)
 ucb/source/cacher/cachedcontentresultset.cxx|4 +-
 ucb/source/core/FileAccess.cxx  |2 -
 ucb/source/core/ucbcmds.cxx |2 -
 ucb/source/core/ucbstore.cxx|8 ++---
 ucb/source/ucp/ext/ucpext_provider.cxx  |2 -
 ucb/source/ucp/file/bc.cxx  |2 -
 ucb/source/ucp/file/filglob.cxx |8 ++---
 ucb/source/ucp/file/filtask.cxx |   30 ++--
 ucb/source/ucp/ftp/ftpcontent.cxx   |8 ++---
 ucb/source/ucp/hierarchy/hierarchydata.cxx  |4 +-
 ucb/source/ucp/hierarchy/hierarchydatasource.cxx|   10 +++---
 ucb/source/ucp/hierarchy/hierarchyuri.cxx   |6 ++--
 ucb/source/ucp/webdav-curl/UCBDeadPropertyValue.cxx |   18 ++--
 13 files changed, 52 insertions(+), 52 deletions(-)

New commits:
commit dab91084b576410f0d76b4da5f5479bb1578ec0c
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:36 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Oct 20 16:56:53 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: ucb

Change-Id: Ic3123585203ebcdf2fe791709d38551e7a326d04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158246
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/cacher/cachedcontentresultset.cxx 
b/ucb/source/cacher/cachedcontentresultset.cxx
index 7c1f316d1c65..769c162fd2ae 100644
--- a/ucb/source/cacher/cachedcontentresultset.cxx
+++ b/ucb/source/cacher/cachedcontentresultset.cxx
@@ -408,8 +408,8 @@ public:
 //some helping variables ( names for my special properties )
 const char16_t g_sPropertyNameForCount[] = u"RowCount";
 const char16_t g_sPropertyNameForFinalCount[] = u"IsRowCountFinal";
-constexpr OUStringLiteral g_sPropertyNameForFetchSize(u"FetchSize");
-constexpr OUStringLiteral g_sPropertyNameForFetchDirection(u"FetchDirection");
+constexpr OUString g_sPropertyNameForFetchSize(u"FetchSize"_ustr);
+constexpr OUString g_sPropertyNameForFetchDirection(u"FetchDirection"_ustr);
 
 CCRS_PropertySetInfo::CCRS_PropertySetInfo(
 Reference< XPropertySetInfo > const & xInfo )
diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx
index 5a83f9699bed..889655dc3ef2 100644
--- a/ucb/source/core/FileAccess.cxx
+++ b/ucb/source/core/FileAccess.cxx
@@ -53,7 +53,7 @@
 
 #include 
 
-constexpr OUStringLiteral SERVICE_NAME = u"com.sun.star.ucb.SimpleFileAccess";
+constexpr OUString SERVICE_NAME = u"com.sun.star.ucb.SimpleFileAccess"_ustr;
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx
index 8b95f48c0702..c8a102b9c1b2 100644
--- a/ucb/source/core/ucbcmds.cxx
+++ b/ucb/source/core/ucbcmds.cxx
@@ -1501,7 +1501,7 @@ void globalTransfer_(
 0,
 rContext.xEnv );
 
-static constexpr OUStringLiteral cmdName(u"flush");
+static constexpr OUString cmdName(u"flush"_ustr);
 if((aAny >>= xci) && xci->hasCommandByName(cmdName))
 xcp->execute(
 ucb::Command(
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 6800b5db0e96..10dafddc81a5 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -99,10 +99,10 @@ static OUString makeHierarchalNameSegment( 
std::u16string_view rIn  )
 return aBuffer.makeStringAndClear();
 }
 
-constexpr OUStringLiteral STORE_CONTENTPROPERTIES_KEY = 
u"/org.openoffice.ucb.Store/ContentProperties";
+constexpr OUString STORE_CONTENTPROPERTIES_KEY = 
u"/org.openoffice.ucb.Store/ContentProperties"_ustr;
 
 // describe path of cfg entry
-constexpr OUStringLiteral CFGPROPERTY_NODEPATH = u"nodepath";
+constexpr OUString CFGPROPERTY_NODEPATH = u"nodepath"_ustr;
 
 class PropertySetInfo_Impl : public cppu::WeakImplHelper < XPropertySetInfo >
 {
@@ -878,7 +878,7 @@ Reference< XInterface > 
PropertySetRegistry::getRootConfigReadAccessImpl(std::un
 {
 Sequence aArguments(comphelper::InitAnyPropertySequence(
 {
-{CFGPROPERTY_NODEPATH,  Any(OUString( 
STORE_CONTENTPROPERTIES_KEY ))}
+{CFGPROPERTY_NODEPATH,  Any(STORE_CONTENTPROPERTIES_KEY)}
 }));
 
 m_bTriedToGetRootReadAccess = true;
@@ -939,7 +939,7 @@ Reference< XInterface > 
PropertySetRegistry::getConfigWriteAccessImpl(std::uniqu
 {
 Sequence aArguments(comphelper::InitAnyPropertySequence(
 {
-{CFGPROPERTY_NODEPATH,  Any(OUString( 
STORE_CONTENTPROPERTIES_KEY ))}
+{CFGPROPERTY_NODEPATH,  Any(STORE_CONTENTPROPERTIES_KEY)}
 }));
 
 m_bTriedToGetRootWriteAccess = true;
diff --git a/ucb/source/ucp/ext/ucpext_provider.cxx 
b/ucb/source/ucp/ext/ucpext_p

[Libreoffice-commits] core.git: ucb/source

2023-06-30 Thread Mike Kaganski (via logerrit)
 ucb/source/core/FileAccess.cxx  |4 
 ucb/source/core/ucb.cxx |8 -
 ucb/source/core/ucbstore.cxx|8 -
 ucb/source/ucp/cmis/cmis_content.cxx|   32 ++---
 ucb/source/ucp/cmis/cmis_repo_content.cxx   |2 
 ucb/source/ucp/cmis/std_inputstream.cxx |2 
 ucb/source/ucp/expand/ucpexpand.cxx |6 -
 ucb/source/ucp/ext/ucpext_content.cxx   |2 
 ucb/source/ucp/file/bc.cxx  |2 
 ucb/source/ucp/file/filrset.cxx |2 
 ucb/source/ucp/file/filstr.cxx  |2 
 ucb/source/ucp/ftp/ftpcontent.cxx   |   20 +--
 ucb/source/ucp/gio/gio_content.cxx  |   28 ++--
 ucb/source/ucp/gio/gio_inputstream.cxx  |2 
 ucb/source/ucp/gio/gio_outputstream.cxx |4 
 ucb/source/ucp/gio/gio_seekable.cxx |   10 -
 ucb/source/ucp/hierarchy/hierarchycontent.cxx   |   62 +-
 ucb/source/ucp/hierarchy/hierarchydatasource.cxx|4 
 ucb/source/ucp/package/pkgcontent.cxx   |   72 ++--
 ucb/source/ucp/tdoc/tdoc_content.cxx|   91 +++
 ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx |2 
 ucb/source/ucp/tdoc/tdoc_provider.cxx   |6 -
 ucb/source/ucp/tdoc/tdoc_stgelems.cxx   |6 -
 ucb/source/ucp/webdav-curl/webdavcontent.cxx|  116 ++--
 24 files changed, 242 insertions(+), 251 deletions(-)

New commits:
commit e693d340a86e4e5f16c3beda062aaec3a71e5e2e
Author: Mike Kaganski 
AuthorDate: Sun Apr 23 20:15:18 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sat Jul 1 04:55:21 2023 +0200

Use getXWeak in ucb

Change-Id: Id94a89596bd473ed8c83d7be89ba673d8dc1bba1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150878
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx
index 24674ac07edd..5a83f9699bed 100644
--- a/ucb/source/core/FileAccess.cxx
+++ b/ucb/source/core/FileAccess.cxx
@@ -240,7 +240,7 @@ void OFileAccess::transferImpl( const OUString& rSource,
 css::uno::Any anyEx = cppu::getCaughtException();
 throw css::lang::WrappedTargetRuntimeException(
 "OFileAccess::transferrImpl - Unable to obtain destination 
folder URL!",
-static_cast< cppu::OWeakObject * >( this ), anyEx );
+getXWeak(), anyEx );
 }
 
 transferImpl( rSource, aDestURL, bMoveData );
@@ -249,7 +249,7 @@ void OFileAccess::transferImpl( const OUString& rSource,
 
 throw RuntimeException(
"OFileAccess::transferrImpl - Unable to obtain destination 
folder URL!",
-static_cast< cppu::OWeakObject * >( this ) );
+getXWeak() );
 
 }
 
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index 27c49c229c75..56dd74bb4d8a 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -319,7 +319,7 @@ void SAL_CALL UniversalContentBroker::initialize( const 
css::uno::Sequence< Any
 {
 throw IllegalArgumentException(
 "UCB reinitialized with different arguments",
-static_cast< cppu::OWeakObject * >(this), 0);
+getXWeak(), 0);
 }
 return;
 }
@@ -581,7 +581,7 @@ Any SAL_CALL UniversalContentBroker::execute(
 ucbhelper::cancelCommandExecution(
 Any( IllegalArgumentException(
 "Wrong argument type!",
-static_cast< cppu::OWeakObject * >( this ),
+getXWeak(),
 -1 ) ),
 Environment );
 // Unreachable
@@ -605,7 +605,7 @@ Any SAL_CALL UniversalContentBroker::execute(
 ucbhelper::cancelCommandExecution(
 Any( IllegalArgumentException(
 "Wrong argument type!",
-static_cast< cppu::OWeakObject * >( this ),
+getXWeak(),
 -1 ) ),
 Environment );
 // Unreachable
@@ -621,7 +621,7 @@ Any SAL_CALL UniversalContentBroker::execute(
 ucbhelper::cancelCommandExecution(
 Any( UnsupportedCommandException(
 OUString(),
-static_cast< cppu::OWeakObject * >( this ) ) ),
+getXWeak() ) ),
 Environment );
 // Unreachable
 }
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 7f04a9a534ab..6800b5db0e96 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/sour

[Libreoffice-commits] core.git: ucb/source

2023-06-15 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/webdav-curl/CurlUri.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 977878814a3573627026e31edb8a51c8f30c8a0c
Author: Stephan Bergmann 
AuthorDate: Wed Jun 14 16:05:54 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jun 15 09:01:18 2023 +0200

ooo#41037 Reject URLs containing unencoded NUL characters

Change-Id: I45bbd342734f190ce918b610441ca911a47830b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153062
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/webdav-curl/CurlUri.cxx 
b/ucb/source/ucp/webdav-curl/CurlUri.cxx
index c5440423a2db..3ee218d5aca3 100644
--- a/ucb/source/ucp/webdav-curl/CurlUri.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlUri.cxx
@@ -115,6 +115,10 @@ CurlUri::CurlUri(::std::u16string_view const rURI)
 }
 
 // use curl to parse the URI, to get a consistent interpretation
+if (rURI.find(u'\0') != std::u16string_view::npos)
+{
+throw DAVException(DAVException::DAV_INVALID_ARG);
+}
 OString const utf8URI(OUStringToOString(rURI, RTL_TEXTENCODING_UTF8));
 auto uc = curl_url_set(m_pUrl.get(), CURLUPART_URL, utf8URI.getStr(), 0);
 if (uc != CURLUE_OK)


[Libreoffice-commits] core.git: ucb/source

2023-06-07 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 86828ea2e323eaba0b0cfa2da73089ee810caacf
Author: Michael Stahl 
AuthorDate: Tue Jun 6 14:06:35 2023 +0200
Commit: Michael Stahl 
CommitDate: Wed Jun 7 11:23:51 2023 +0200

ucb: webdav-curl: auth data is invalid when receiving 401

Even if it used to be valid before; unfortunately newly entered
credentials weren't actually used because the flag was never reset.

Change-Id: Ib36689f40ff780596b9cfe6fe589a6f2e79cfcd2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152679
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 8071301f261d..b9161767c829 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1397,6 +1397,10 @@ auto CurlProcessor::ProcessRequest(
 case SC_UNAUTHORIZED:
 case SC_PROXY_AUTHENTICATION_REQUIRED:
 {
+(statusCode != SC_PROXY_AUTHENTICATION_REQUIRED
+ ? rSession.m_isAuthenticated
+ : rSession.m_isAuthenticatedProxy)
+= false; // any auth data in m_pCurl is invalid
 auto& rnAuthRequests(statusCode == SC_UNAUTHORIZED ? 
nAuthRequests
: 
nAuthRequestsProxy);
 if (rnAuthRequests == 10)


[Libreoffice-commits] core.git: ucb/source

2023-04-25 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/DAVTypes.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit bb0e041a237a1c4ad4f5c0bd092fc3da5c18b7f1
Author: Michael Stahl 
AuthorDate: Tue Apr 18 14:25:37 2023 +0200
Commit: Thorsten Behrens 
CommitDate: Tue Apr 25 17:17:27 2023 +0200

Fix tdf#155004: ucb: webdav-curl: carry over Class1 bit only if set

With d6182cb6704c06f33d284874b9fe96c85cce5bf5 there are cases when a
webdav server inadvertendly releases the lock. Lets apply the fix only
if the Class1 flag is actually set.

Change-Id: I85e5253c7df0980f373d2dea788c331b81ed4a82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150552
Tested-by: László Németh 
Reviewed-by: László Németh 
Tested-by: Jenkins

diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.cxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
index d5b255c175cd..e41c5426e959 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
@@ -168,7 +168,10 @@ void DAVOptionsCache::addDAVOptions( DAVOptions & 
rDAVOptions, const sal_uInt32
 // tdf#153642 keep cached Class1 bit at aDAVOptionsException to avoid 
of
 // losing the ability to resave the document within the lifetime 
because
 // of disabled DAV detection in getResourceType()
-rDAVOptions.setClass1( (*it).second.isClass1() );
+if ((*it).second.isClass1())
+{
+rDAVOptions.setClass1( (*it).second.isClass1() );
+}
 }
 // not in cache, add it
 TimeValue t1;


[Libreoffice-commits] core.git: ucb/source

2023-04-03 Thread Mike Kaganski (via logerrit)
 ucb/source/ucp/cmis/cmis_content.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit be9919f4719aee2154fe2cbaef70b3537e49fe8b
Author: Mike Kaganski 
AuthorDate: Mon Apr 3 14:15:59 2023 +0200
Commit: Mike Kaganski 
CommitDate: Mon Apr 3 16:50:24 2023 +0200

Optimize a bit

Change-Id: I5a2c37e4ff1e19cfbc29e1e61b025f44d067b95a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149893
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/ucb/source/ucp/cmis/cmis_content.cxx 
b/ucb/source/ucp/cmis/cmis_content.cxx
index 0bd38ea31f65..a9781c233054 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -67,8 +67,8 @@
 #include "std_inputstream.hxx"
 #include "std_outputstream.hxx"
 
-#define OUSTR_TO_STDSTR(s) std::string( OUStringToOString( s, 
RTL_TEXTENCODING_UTF8 ).getStr() )
-#define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), 
RTL_TEXTENCODING_UTF8 )
+#define OUSTR_TO_STDSTR(s) std::string( OUStringToOString( s, 
RTL_TEXTENCODING_UTF8 ) )
+#define STD_TO_OUSTR( str ) OStringToOUString( str, RTL_TEXTENCODING_UTF8 )
 
 using namespace com::sun::star;
 
@@ -191,7 +191,7 @@ namespace
 uno::Sequence< sal_Bool > seqValue;
 value >>= seqValue;
 std::transform(std::cbegin(seqValue), std::cend(seqValue), 
std::back_inserter(values),
-[](const bool nValue) -> std::string { return OUSTR_TO_STDSTR( 
OUString::boolean( nValue ) ); });
+[](const bool nValue) -> std::string { return std::string( 
OString::boolean( nValue ) ); });
 type = libcmis::PropertyType::Bool;
 }
 else if ( prop.Type == CMIS_TYPE_INTEGER )
@@ -199,7 +199,7 @@ namespace
 uno::Sequence< sal_Int64 > seqValue;
 value >>= seqValue;
 std::transform(std::cbegin(seqValue), std::cend(seqValue), 
std::back_inserter(values),
-[](const sal_Int64 nValue) -> std::string { return 
OUSTR_TO_STDSTR( OUString::number( nValue ) ); });
+[](const sal_Int64 nValue) -> std::string { return 
std::string( OString::number( nValue ) ); });
 type = libcmis::PropertyType::Integer;
 }
 else if ( prop.Type == CMIS_TYPE_DECIMAL )
@@ -207,7 +207,7 @@ namespace
 uno::Sequence< double > seqValue;
 value >>= seqValue;
 std::transform(std::cbegin(seqValue), std::cend(seqValue), 
std::back_inserter(values),
-[](const double fValue) -> std::string { return 
OUSTR_TO_STDSTR( OUString::number( fValue ) ); });
+[](const double fValue) -> std::string { return std::string( 
OString::number( fValue ) ); });
 type = libcmis::PropertyType::Decimal;
 }
 else if ( prop.Type == CMIS_TYPE_DATETIME )


[Libreoffice-commits] core.git: ucb/source

2023-03-30 Thread Noel Grandin (via logerrit)
 ucb/source/core/ucb.cxx   |   15 +--
 ucb/source/core/ucbstore.cxx  |3 +--
 ucb/source/regexp/regexp.cxx  |6 ++
 ucb/source/ucp/ext/ucpext_provider.cxx|6 ++
 ucb/source/ucp/ftp/ftpurl.cxx |7 ++-
 ucb/source/ucp/hierarchy/hierarchydata.cxx|6 ++
 ucb/source/ucp/inc/urihelper.hxx  |   10 ++
 ucb/source/ucp/tdoc/tdoc_content.cxx  |   10 ++
 ucb/source/ucp/webdav-curl/CurlSession.cxx|6 +++---
 ucb/source/ucp/webdav-curl/CurlUri.cxx|7 ++-
 ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx |   13 +
 11 files changed, 28 insertions(+), 61 deletions(-)

New commits:
commit 6ffdcbdd29f014fcce290dfdb969fb6ff66a95ed
Author: Noel Grandin 
AuthorDate: Thu Mar 30 10:23:19 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Mar 30 13:36:11 2023 +

loplugin:stringadd in ucb

when applying my upcoming patch to also consider O[U]StringBuffer

Change-Id: I2445a69dc46314c73f54c190a0c498c0309be06b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149750
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index 26476a90562b..27c49c229c75 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -78,24 +78,21 @@ bool fillPlaceholders(OUString const & rInput,
 && p[0] == 'a' && p[1] == 'm' && p[2] == 'p'
 && p[3] == ';')
 {
-aBuffer.append(pCopy, p - 1 - pCopy);
-aBuffer.append('&');
+aBuffer.append(OUString::Concat(std::u16string_view(pCopy, 
p - 1 - pCopy)) + "&");
 p += 4;
 pCopy = p;
 }
 else if (pEnd - p >= 3
  && p[0] == 'l' && p[1] == 't' && p[2] == ';')
 {
-aBuffer.append(pCopy, p - 1 - pCopy);
-aBuffer.append('<');
+aBuffer.append(OUString::Concat(std::u16string_view(pCopy, 
p - 1 - pCopy)) + "<");
 p += 3;
 pCopy = p;
 }
 else if (pEnd - p >= 3
  && p[0] == 'g' && p[1] == 't' && p[2] == ';')
 {
-aBuffer.append(pCopy, p - 1 - pCopy);
-aBuffer.append('>');
+aBuffer.append(OUString::Concat(std::u16string_view(pCopy, 
p - 1 - pCopy)) + ">");
 p += 3;
 pCopy = p;
 }
@@ -124,8 +121,7 @@ bool fillPlaceholders(OUString const & rInput,
 }
 if (!bFound)
 return false;
-aBuffer.append(pCopy, p - 1 - pCopy);
-aBuffer.append(aValue);
+aBuffer.append(std::u16string_view(pCopy, p - 1 - pCopy) + 
aValue);
 p = q + 1;
 pCopy = p;
 break;
@@ -827,8 +823,7 @@ bool UniversalContentBroker::getContentProviderData(
 
 ContentProviderData aInfo;
 
-OUStringBuffer aElemBuffer;
-aElemBuffer.append( "['" );
+OUStringBuffer aElemBuffer( "['" );
 makeAndAppendXMLName( aElemBuffer, rElem );
 aElemBuffer.append( "']" );
 
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 7a090788f776..882e0773ddd6 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -61,8 +61,7 @@ using namespace cppu;
 
 static OUString makeHierarchalNameSegment( std::u16string_view rIn  )
 {
-OUStringBuffer aBuffer;
-aBuffer.append( "['" );
+OUStringBuffer aBuffer( "['" );
 
 size_t nCount = rIn.size();
 for ( size_t n = 0; n < nCount; ++n )
diff --git a/ucb/source/regexp/regexp.cxx b/ucb/source/regexp/regexp.cxx
index 0eeac4a4a80f..8b8dcbc85b8f 100644
--- a/ucb/source/regexp/regexp.cxx
+++ b/ucb/source/regexp/regexp.cxx
@@ -189,8 +189,7 @@ OUString Regexp::getRegexp() const
 break;
 
 case KIND_DOMAIN:
-aBuffer.append("([^/?#]");
-aBuffer.append(sal_Unicode(m_bEmptyDomain ? '*' : '+'));
+aBuffer.append("([^/?#]" + 
OUStringChar(sal_Unicode(m_bEmptyDomain ? '*' : '+')));
 if (!m_aInfix.isEmpty())
 appendStringLiteral(&aBuffer, m_aInfix);
 aBuffer.append("([/?#].*)?)");
@@ -220,8 +219,7 @@ OUString Regexp::getRegexp() const
 break;
 
 case KIND_DOMAIN:
-aBuffer.append("[^/?#]");
-aBuffer.append( m_bEmptyDomain ? '*' : '+' );
+aBuffer.append("[^/?#]" + OUStringChar( m_bEmptyDomain ? '*' : 
'+'

[Libreoffice-commits] core.git: ucb/source

2023-02-24 Thread László Németh (via logerrit)
 ucb/source/ucp/webdav-curl/DAVTypes.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit d6182cb6704c06f33d284874b9fe96c85cce5bf5
Author: László Németh 
AuthorDate: Thu Feb 23 15:50:49 2023 +0100
Commit: László Németh 
CommitDate: Fri Feb 24 09:43:55 2023 +

tdf#153642 ucb: fix broken save with cached DAVOptions

Trying to save a document within the lifetime of the
cached connection, e.g. re-save within a few seconds after
the first and successful save failed with an error message
in the case of Vibe 4.0.6 WebDAV server. Waiting 5-10 seconds
after the last try was the only workaround to re-save the
document.

Details: aDAVOptionsException in Content::getPropertyValues()
removed the isClass1 bit of the cached DAVOptions of the
same TargetURL (note: of the folder of the WebDAV document).
This disabled the DAV detection part of Content::getResourceType(),
and later the correct HTTP redirect for the DAV connection.
Fix this by keeping the cached bit in that case, too, when the
added connection has a different lifetime, than the cached one.

Follow-up to commit 30ca48f4dc0e65a3798e6b21574bc80f6d4953fa
"tdf#152493 ucb WebDAV: fix upload using HTTP 1.0 fallback".

Change-Id: I5d4578232581a4df654f76198fdddf096cba5267
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147570
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.cxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
index 972f70cbc17a..d5b255c175cd 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
@@ -164,6 +164,11 @@ void DAVOptionsCache::addDAVOptions( DAVOptions & 
rDAVOptions, const sal_uInt32
 { // already in cache, check LifeTime
 if ( (*it).second.getRequestedTimeLife() == nLifeTime )
 return; // same lifetime, do nothing
+
+// tdf#153642 keep cached Class1 bit at aDAVOptionsException to avoid 
of
+// losing the ability to resave the document within the lifetime 
because
+// of disabled DAV detection in getResourceType()
+rDAVOptions.setClass1( (*it).second.isClass1() );
 }
 // not in cache, add it
 TimeValue t1;


[Libreoffice-commits] core.git: ucb/source

2023-02-17 Thread Noel Grandin (via logerrit)
 ucb/source/sorter/sortdynres.cxx |6 +++---
 ucb/source/sorter/sortdynres.hxx |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit eefa8e8110c432be36e1cd5d166b5f5676a7e5ca
Author: Noel Grandin 
AuthorDate: Thu Feb 16 19:50:32 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Feb 17 08:19:52 2023 +

osl::Mutex->std::mutex in SortedDynamicResultSetListener

Change-Id: I70b20a616cb84c5c066431be50359def5d041b3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147188
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/sorter/sortdynres.cxx b/ucb/source/sorter/sortdynres.cxx
index fe142c2b53f4..a3bf493a2ba0 100644
--- a/ucb/source/sorter/sortdynres.cxx
+++ b/ucb/source/sorter/sortdynres.cxx
@@ -474,7 +474,7 @@ 
SortedDynamicResultSetListener::~SortedDynamicResultSetListener()
 void SAL_CALL
 SortedDynamicResultSetListener::disposing( const EventObject& /*Source*/ )
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
 if ( mpOwner )
 mpOwner->impl_disposing();
@@ -486,7 +486,7 @@ SortedDynamicResultSetListener::disposing( const 
EventObject& /*Source*/ )
 void SAL_CALL
 SortedDynamicResultSetListener::notify( const ListEvent& Changes )
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
 if ( mpOwner )
 mpOwner->impl_notify( Changes );
@@ -497,7 +497,7 @@ SortedDynamicResultSetListener::notify( const ListEvent& 
Changes )
 void
 SortedDynamicResultSetListener::impl_OwnerDies()
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 mpOwner = nullptr;
 }
 
diff --git a/ucb/source/sorter/sortdynres.hxx b/ucb/source/sorter/sortdynres.hxx
index 320e4d9ddb8e..2bb8f24aa8c2 100644
--- a/ucb/source/sorter/sortdynres.hxx
+++ b/ucb/source/sorter/sortdynres.hxx
@@ -113,7 +113,7 @@ class SortedDynamicResultSetListener: public 
cppu::WeakImplHelper <
 css::ucb::XDynamicResultSetListener >
 {
 SortedDynamicResultSet  *mpOwner;
-osl::Mutex  maMutex;
+std::mutex   maMutex;
 
 public:
  SortedDynamicResultSetListener( SortedDynamicResultSet *mOwner );


[Libreoffice-commits] core.git: ucb/source

2023-02-16 Thread Noel Grandin (via logerrit)
 ucb/source/sorter/sortdynres.cxx |   44 ++-
 ucb/source/sorter/sortdynres.hxx |6 ++---
 2 files changed, 19 insertions(+), 31 deletions(-)

New commits:
commit f8dc080dd021e352054d41b3c3f34e46028ecf5a
Author: Noel Grandin 
AuthorDate: Thu Feb 16 20:06:14 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Feb 17 07:20:13 2023 +

osl::Mutex->std::mutex in SortedDynamicResultSet

Change-Id: I21b98831645e2d7942bdf630225c136f9af3dca3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147189
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/sorter/sortdynres.cxx b/ucb/source/sorter/sortdynres.cxx
index 2f7039b55a0a..fe142c2b53f4 100644
--- a/ucb/source/sorter/sortdynres.cxx
+++ b/ucb/source/sorter/sortdynres.cxx
@@ -36,15 +36,6 @@ using namespace com::sun::star::uno;
 using namespace comphelper;
 
 
-//  The mutex to synchronize access to containers.
-static osl::Mutex& getContainerMutex()
-{
-static osl::Mutex ourMutex;
-
-return ourMutex;
-}
-
-
 // SortedDynamicResultSet
 
 SortedDynamicResultSet::SortedDynamicResultSet(
@@ -53,7 +44,6 @@ SortedDynamicResultSet::SortedDynamicResultSet(
 const Reference < XAnyCompareFactory > &xCompFac,
 const Reference < XComponentContext > &rxContext )
 {
-mpDisposeEventListeners = nullptr;
 mxOwnListener   = new SortedDynamicResultSetListener( this );
 
 mxOriginal  = xOriginal;
@@ -72,7 +62,10 @@ SortedDynamicResultSet::~SortedDynamicResultSet()
 mxOwnListener->impl_OwnerDies();
 mxOwnListener.clear();
 
-mpDisposeEventListeners.reset();
+{
+std::unique_lock aGuard(maMutex);
+maDisposeEventListeners.clear(aGuard);
+}
 
 mxOne.clear();
 mxTwo.clear();
@@ -100,13 +93,13 @@ css::uno::Sequence< OUString > SAL_CALL 
SortedDynamicResultSet::getSupportedServ
 
 void SAL_CALL SortedDynamicResultSet::dispose()
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
-if ( mpDisposeEventListeners && mpDisposeEventListeners->getLength() )
+if ( maDisposeEventListeners.getLength(aGuard) )
 {
 EventObject aEvt;
 aEvt.Source = static_cast< XComponent * >( this );
-mpDisposeEventListeners->disposeAndClear( aEvt );
+maDisposeEventListeners.disposeAndClear( aGuard, aEvt );
 }
 
 mxOne.clear();
@@ -119,22 +112,17 @@ void SAL_CALL SortedDynamicResultSet::dispose()
 void SAL_CALL SortedDynamicResultSet::addEventListener(
 const Reference< XEventListener >& Listener )
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
-
-if ( !mpDisposeEventListeners )
-mpDisposeEventListeners.reset(
-new OInterfaceContainerHelper3( 
getContainerMutex() ) );
+std::unique_lock aGuard( maMutex );
 
-mpDisposeEventListeners->addInterface( Listener );
+maDisposeEventListeners.addInterface( aGuard, Listener );
 }
 
 void SAL_CALL SortedDynamicResultSet::removeEventListener(
 const Reference< XEventListener >& Listener )
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
-if ( mpDisposeEventListeners )
-mpDisposeEventListeners->removeInterface( Listener );
+maDisposeEventListeners.removeInterface( aGuard, Listener );
 }
 
 
@@ -143,7 +131,7 @@ void SAL_CALL SortedDynamicResultSet::removeEventListener(
 Reference< XResultSet > SAL_CALL
 SortedDynamicResultSet::getStaticResultSet()
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
 if ( mxListener.is() )
 throw ListenerAlreadySetException();
@@ -163,12 +151,12 @@ SortedDynamicResultSet::getStaticResultSet()
 void SAL_CALL
 SortedDynamicResultSet::setListener( const Reference< 
XDynamicResultSetListener >& Listener )
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
 if ( mxListener.is() )
 throw ListenerAlreadySetException();
 
-addEventListener( Listener );
+maDisposeEventListeners.addInterface( aGuard, Listener );
 
 mxListener = Listener;
 
@@ -211,7 +199,7 @@ SortedDynamicResultSet::connectToCache( const Reference< 
XDynamicResultSet > & x
 
 sal_Int16 SAL_CALL SortedDynamicResultSet::getCapabilities()
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
 sal_Int16 nCaps = 0;
 
@@ -244,7 +232,7 @@ sal_Int16 SAL_CALL SortedDynamicResultSet::getCapabilities()
 */
 void SortedDynamicResultSet::impl_notify( const ListEvent& Changes )
 {
-osl::Guard< osl::Mutex > aGuard( maMutex );
+std::unique_lock aGuard( maMutex );
 
 bool bHasNew = false;
 bool bHasModified = false;
diff --git a/ucb/source/sorter/sortdynres.hxx b/ucb/source/sorter/sortdynres.hxx
index 1098f223a6c1..320e4d9ddb8e 100644
--- a/ucb/source/sorter/sortdynres.h

[Libreoffice-commits] core.git: ucb/source

2023-02-16 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/tdoc/tdoc_datasupplier.cxx |   50 +++---
 ucb/source/ucp/tdoc/tdoc_datasupplier.hxx |   15 ++---
 2 files changed, 43 insertions(+), 22 deletions(-)

New commits:
commit 9301f4d486b13dac2a66b797d5e24eb6dc9f7582
Author: Noel Grandin 
AuthorDate: Thu Feb 16 14:31:25 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Feb 16 18:49:33 2023 +

osl::Mutex->std::mutex in ResultSetDataSupplier

Change-Id: I75cbf133e2e632c41759515fdf8894faed599c8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147159
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx 
b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
index 206751eff193..f4291f4a5043 100644
--- a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
@@ -72,8 +72,13 @@ ResultSetDataSupplier::~ResultSetDataSupplier()
 OUString
 ResultSetDataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return queryContentIdentifierStringImpl(aGuard, nIndex);
+}
 
+OUString
+ResultSetDataSupplier::queryContentIdentifierStringImpl( 
std::unique_lock& /*rGuard*/, sal_uInt32 nIndex )
+{
 if ( nIndex < m_aResults.size() )
 {
 OUString aId = m_aResults[ nIndex ].aURL;
@@ -96,8 +101,13 @@ ResultSetDataSupplier::queryContentIdentifierString( 
sal_uInt32 nIndex )
 uno::Reference< ucb::XContentIdentifier >
 ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return queryContentIdentifierImpl(aGuard, nIndex);
+}
 
+uno::Reference< ucb::XContentIdentifier >
+ResultSetDataSupplier::queryContentIdentifierImpl( 
std::unique_lock& rGuard, sal_uInt32 nIndex )
+{
 if ( nIndex < m_aResults.size() )
 {
 uno::Reference< ucb::XContentIdentifier > xId
@@ -109,7 +119,7 @@ ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 
nIndex )
 }
 }
 
-OUString aId = queryContentIdentifierString( nIndex );
+OUString aId = queryContentIdentifierStringImpl( rGuard, nIndex );
 if ( !aId.isEmpty() )
 {
 uno::Reference< ucb::XContentIdentifier > xId
@@ -124,7 +134,7 @@ ResultSetDataSupplier::queryContentIdentifier( sal_uInt32 
nIndex )
 uno::Reference< ucb::XContent >
 ResultSetDataSupplier::queryContent( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( nIndex < m_aResults.size() )
 {
@@ -138,7 +148,7 @@ ResultSetDataSupplier::queryContent( sal_uInt32 nIndex )
 }
 
 uno::Reference< ucb::XContentIdentifier > xId
-= queryContentIdentifier( nIndex );
+= queryContentIdentifierImpl( aGuard, nIndex );
 if ( xId.is() )
 {
 try
@@ -159,8 +169,12 @@ ResultSetDataSupplier::queryContent( sal_uInt32 nIndex )
 // virtual
 bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex )
 {
-osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return getResultImpl(aGuard, nIndex);
+}
 
+bool ResultSetDataSupplier::getResultImpl( std::unique_lock& 
rGuard, sal_uInt32 nIndex )
+{
 if ( m_aResults.size() > nIndex )
 {
 // Result already present.
@@ -177,7 +191,7 @@ bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex )
 sal_uInt32 nOldCount = m_aResults.size();
 bool bFound = false;
 
-if ( queryNamesOfChildren() )
+if ( queryNamesOfChildren(rGuard) )
 {
 for ( sal_uInt32 n = nOldCount;
   n < sal::static_int_cast(
@@ -214,13 +228,15 @@ bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex )
 if ( xResultSet.is() )
 {
 // Callbacks follow!
-aGuard.clear();
+rGuard.unlock();
 
 if ( nOldCount < m_aResults.size() )
 xResultSet->rowCountChanged( nOldCount, m_aResults.size() );
 
 if ( m_bCountFinal )
 xResultSet->rowCountFinal();
+
+rGuard.lock();
 }
 
 return bFound;
@@ -229,14 +245,14 @@ bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex )
 // virtual
 sal_uInt32 ResultSetDataSupplier::totalCount()
 {
-osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( m_bCountFinal )
 return m_aResults.size();
 
 sal_uInt32 nOldCount = m_aResults.size();
 
-if ( queryNamesOfChildren() )
+if ( queryNamesOfChildren(aGuard) )
 {
 for ( sal_uInt32 n = nOldCount;
   n < sal::static_int_cast(
@@ -265,7 +281,7 @@ sal_uInt32 ResultSetDataSupplier::totalCount()
 if ( xResultSet.is() )
 {
 // Callbacks follow!
-aGuard.clear();
+aGuard.unlock();
 
 if ( nOldCount < m_aResults.size() )
 xResultSet->rowCountChanged( nOldCount, m_aResults.si

[Libreoffice-commits] core.git: ucb/source

2023-02-15 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/ext/ucpext_datasupplier.cxx |   14 +++---
 ucb/source/ucp/ext/ucpext_datasupplier.hxx |3 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 46ceb1ccb792b1a9ee12b73c499c4763502ef1e3
Author: Noel Grandin 
AuthorDate: Wed Feb 15 15:33:05 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Feb 16 07:10:32 2023 +

osl::Mutex->std::mutex in ucb::ucp::ext::DataSupplier

Change-Id: Id195c7cb676d4c7e0741adeb31f4b1a9854e8230
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147100
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx 
b/ucb/source/ucp/ext/ucpext_datasupplier.cxx
index b718ef076c34..9470cdeb4c1e 100644
--- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx
+++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx
@@ -151,7 +151,7 @@ namespace ucb::ucp::ext
 
 OUString DataSupplier::queryContentIdentifierString( sal_uInt32 i_nIndex )
 {
-::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( i_nIndex < m_aResults.size() )
 {
@@ -167,7 +167,7 @@ namespace ucb::ucp::ext
 
 Reference< XContentIdentifier > DataSupplier::queryContentIdentifier( 
sal_uInt32 i_nIndex )
 {
-::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( i_nIndex < m_aResults.size() )
 {
@@ -190,7 +190,7 @@ namespace ucb::ucp::ext
 
 Reference< XContent > DataSupplier::queryContent( sal_uInt32 i_nIndex )
 {
-::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 ENSURE_OR_RETURN( i_nIndex < m_aResults.size(), "illegal index!", 
nullptr );
 
 
@@ -222,7 +222,7 @@ namespace ucb::ucp::ext
 
 bool DataSupplier::getResult( sal_uInt32 i_nIndex )
 {
-::osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 // true if result already present.
 return m_aResults.size() > i_nIndex;
@@ -231,7 +231,7 @@ namespace ucb::ucp::ext
 
 sal_uInt32 DataSupplier::totalCount()
 {
-::osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 return m_aResults.size();
 }
 
@@ -250,7 +250,7 @@ namespace ucb::ucp::ext
 
 Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 i_nIndex  )
 {
-::osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 ENSURE_OR_RETURN( i_nIndex < m_aResults.size(), 
"DataSupplier::queryPropertyValues: illegal index!", nullptr );
 
 Reference< XRow > xRow = m_aResults[ i_nIndex ].xRow;
@@ -291,7 +291,7 @@ namespace ucb::ucp::ext
 
 void DataSupplier::releasePropertyValues( sal_uInt32 i_nIndex )
 {
-::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( i_nIndex < m_aResults.size() )
 m_aResults[ i_nIndex ].xRow.clear();
diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.hxx 
b/ucb/source/ucp/ext/ucpext_datasupplier.hxx
index f0bea109e683..a7198fc9ba3b 100644
--- a/ucb/source/ucp/ext/ucpext_datasupplier.hxx
+++ b/ucb/source/ucp/ext/ucpext_datasupplier.hxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 
@@ -75,7 +76,7 @@ namespace ucb::ucp::ext
 css::uno::Reference< css::sdbc::XRow >  xRow;
 };
 typedef ::std::vector< ResultListEntry >ResultList;
-::osl::Mutexm_aMutex;
+std::mutex  m_aMutex;
 ResultList  m_aResults;
 ::rtl::Reference< Content > m_xContent;
 css::uno::Reference< css::uno::XComponentContext > m_xContext;


[Libreoffice-commits] core.git: ucb/source

2023-02-14 Thread Noel Grandin (via logerrit)
 ucb/source/cacher/contentresultsetwrapper.cxx |   66 --
 ucb/source/cacher/contentresultsetwrapper.hxx |   14 +
 ucb/source/core/ucbstore.cxx  |   24 +++--
 ucb/source/core/ucbstore.hxx  |2 
 4 files changed, 37 insertions(+), 69 deletions(-)

New commits:
commit 9e8f06979902e5dbd6acf7ac8290ba5ece9da667
Author: Noel Grandin 
AuthorDate: Tue Feb 14 15:46:27 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Feb 15 06:15:51 2023 +

no need to use unique_ptr for OMultiTypeInterfaceContainerHelperVar4

it has an empty size of two words, so it saves very little memory to use
unique_ptr.

Change-Id: I2958a83c41929dec3d33db27f084dafec385d74d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147014
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx 
b/ucb/source/cacher/contentresultsetwrapper.cxx
index 14393ff497f4..f6e7c0058a65 100644
--- a/ucb/source/cacher/contentresultsetwrapper.cxx
+++ b/ucb/source/cacher/contentresultsetwrapper.cxx
@@ -129,35 +129,18 @@ void 
ContentResultSetWrapper::impl_EnsureNotDisposed(std::unique_lock&
 /*rGuard*/)
-{
-if ( !m_pPropertyChangeListeners )
-m_pPropertyChangeListeners.reset(
-new PropertyChangeListenerContainer_Impl() );
-}
-
-void 
ContentResultSetWrapper::impl_getVetoableChangeListenerContainer(std::unique_lock&
 /*rGuard*/)
-{
-if ( !m_pVetoableChangeListeners )
-m_pVetoableChangeListeners.reset(
-new VetoableChangeListenerContainer_Impl() );
-}
-
 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( 
std::unique_lock& rGuard, const PropertyChangeEvent& rEvt )
 {
-if( !m_pPropertyChangeListeners )
-return;
-
 // Notify listeners interested especially in the changed property.
 OInterfaceContainerHelper4* pContainer =
-m_pPropertyChangeListeners->getContainer( rGuard, 
rEvt.PropertyName );
+m_aPropertyChangeListeners.getContainer( rGuard, rEvt.PropertyName 
);
 if( pContainer )
 {
 pContainer->notifyEach( rGuard, 
&XPropertyChangeListener::propertyChange, rEvt );
 }
 
 // Notify listeners interested in all properties.
-pContainer = m_pPropertyChangeListeners->getContainer( rGuard, OUString() 
);
+pContainer = m_aPropertyChangeListeners.getContainer( rGuard, OUString() );
 if( pContainer )
 {
 pContainer->notifyEach( rGuard, 
&XPropertyChangeListener::propertyChange, rEvt );
@@ -166,19 +149,16 @@ void 
ContentResultSetWrapper::impl_notifyPropertyChangeListeners( std::unique_lo
 
 void ContentResultSetWrapper::impl_notifyVetoableChangeListeners( 
std::unique_lock& rGuard, const PropertyChangeEvent& rEvt )
 {
-if( !m_pVetoableChangeListeners )
-return;
-
 // Notify listeners interested especially in the changed property.
 OInterfaceContainerHelper4* pContainer =
-m_pVetoableChangeListeners->getContainer( rGuard, 
rEvt.PropertyName );
+m_aVetoableChangeListeners.getContainer( rGuard, rEvt.PropertyName 
);
 if( pContainer )
 {
 pContainer->notifyEach( rGuard, 
&XVetoableChangeListener::vetoableChange, rEvt );
 }
 
 // Notify listeners interested in all properties.
-pContainer = m_pVetoableChangeListeners->getContainer( rGuard, OUString() 
);
+pContainer = m_aVetoableChangeListeners.getContainer( rGuard, OUString() );
 if( pContainer )
 {
 pContainer->notifyEach( rGuard, 
&XVetoableChangeListener::vetoableChange, rEvt );
@@ -306,18 +286,18 @@ void SAL_CALL ContentResultSetWrapper::dispose()
 m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
 }
 
-if( m_pPropertyChangeListeners )
+if( m_aPropertyChangeListeners.hasContainedTypes(aGuard) )
 {
 EventObject aEvt;
 aEvt.Source = static_cast< XPropertySet * >( this );
-m_pPropertyChangeListeners->disposeAndClear( aGuard, aEvt );
+m_aPropertyChangeListeners.disposeAndClear( aGuard, aEvt );
 }
 
-if( m_pVetoableChangeListeners )
+if( m_aVetoableChangeListeners.hasContainedTypes(aGuard) )
 {
 EventObject aEvt;
 aEvt.Source = static_cast< XPropertySet * >( this );
-m_pVetoableChangeListeners->disposeAndClear( aGuard, aEvt );
+m_aVetoableChangeListeners.disposeAndClear( aGuard, aEvt );
 }
 
 m_bDisposed = true;
@@ -458,9 +438,8 @@ void SAL_CALL 
ContentResultSetWrapper::addPropertyChangeListener( const OUString
 //throws UnknownPropertyException, if so
 }
 
-impl_getPropertyChangeListenerContainer(aGuard);
-bool bNeedRegister = 
!m_pPropertyChangeListeners->hasContainedTypes(aGuard);
-m_pPropertyChangeListeners->addInterface( aGuard, aPropertyName, xListener 
);
+bool bNeedRegister = !m_aPropertyChangeListeners.hasContainedTypes(aGuard);
+m_aPropertyChangeListeners.addInterface( a

[Libreoffice-commits] core.git: ucb/source

2023-02-14 Thread Noel Grandin (via logerrit)
 ucb/source/core/ucbstore.cxx |   34 +-
 ucb/source/core/ucbstore.hxx |2 ++
 2 files changed, 15 insertions(+), 21 deletions(-)

New commits:
commit 20f3339834bedd4a62731f69c954dc6e6607bec5
Author: Noel Grandin 
AuthorDate: Tue Feb 14 11:32:24 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Feb 14 10:45:43 2023 +

fix locking in PersistentPropertySet

after
commit 756185b5795c95180d32d02abfbd65951779b40e
Author: Noel Grandin 
Date:   Mon Feb 13 09:06:02 2023 +0200
osl::Mutex->std::mutex in PersistentPropertySet

Change-Id: Ie52432ea1566b840bd88692f00f4753eea7896f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146998
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 191605dd1f7f..65c0e531e2e2 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -1187,10 +1187,7 @@ void SAL_CALL PersistentPropertySet::setPropertyValue( 
const OUString& aProperty
 aEvt.OldValue   = aOldValue;
 aEvt.NewValue   = aValue;
 
-// Callback follows!
-aCGuard.unlock();
-
-notifyPropertyChangeEvent( aEvt );
+notifyPropertyChangeEvent( aCGuard, aEvt );
 }
 return;
 }
@@ -1442,7 +1439,7 @@ void SAL_CALL PersistentPropertySet::addProperty(
 Name,
 -1,
 PropertySetInfoChange::PROPERTY_INSERTED );
-notifyPropertySetInfoChange( evt );
+notifyPropertySetInfoChange(aGuard, evt);
 }
 
 // Success.
@@ -1600,7 +1597,7 @@ void SAL_CALL PersistentPropertySet::removeProperty( 
const OUString& Name )
 Name,
 nHandle,
 PropertySetInfoChange::PROPERTY_REMOVED );
-notifyPropertySetInfoChange( evt );
+notifyPropertySetInfoChange( aGuard, evt );
 }
 
 // Success.
@@ -1883,13 +1880,10 @@ void SAL_CALL PersistentPropertySet::setPropertyValues(
 
 if ( m_pPropertyChangeListeners )
 {
-// Callback follows!
-aCGuard.unlock();
-
 // Notify property changes.
 for (auto const& event : aEvents)
 {
-notifyPropertyChangeEvent( event );
+notifyPropertyChangeEvent( aCGuard, event );
 }
 }
 
@@ -1904,38 +1898,36 @@ void SAL_CALL PersistentPropertySet::setPropertyValues(
 
 
 void PersistentPropertySet::notifyPropertyChangeEvent(
+std::unique_lock& rGuard,
 const PropertyChangeEvent& rEvent ) const
 {
-std::unique_lock aGuard(m_aMutex);
-
 // Get "normal" listeners for the property.
 OInterfaceContainerHelper4* pContainer =
-m_pPropertyChangeListeners->getContainer( aGuard, 
rEvent.PropertyName );
-if ( pContainer && pContainer->getLength(aGuard) )
+m_pPropertyChangeListeners->getContainer( rGuard, 
rEvent.PropertyName );
+if ( pContainer && pContainer->getLength(rGuard) )
 {
-pContainer->notifyEach( aGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
+pContainer->notifyEach( rGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
 }
 
 // Get "normal" listeners for all properties.
 OInterfaceContainerHelper4* pNoNameContainer =
-m_pPropertyChangeListeners->getContainer( aGuard, OUString() );
-if ( pNoNameContainer && pNoNameContainer->getLength(aGuard) )
+m_pPropertyChangeListeners->getContainer( rGuard, OUString() );
+if ( pNoNameContainer && pNoNameContainer->getLength(rGuard) )
 {
-pNoNameContainer->notifyEach( aGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
+pNoNameContainer->notifyEach( rGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
 }
 }
 
 
 void PersistentPropertySet::notifyPropertySetInfoChange(
+std::unique_lock& rGuard,
 const PropertySetInfoChangeEvent& evt ) const
 {
-std::unique_lock aGuard(m_aMutex);
-
 if ( !m_pPropSetChangeListeners )
 return;
 
 // Notify event listeners.
-m_pPropSetChangeListeners->notifyEach( aGuard, 
&XPropertySetInfoChangeListener::propertySetInfoChange, evt );
+m_pPropSetChangeListeners->notifyEach( rGuard, 
&XPropertySetInfoChangeListener::propertySetInfoChange, evt );
 }
 
 
diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx
index dceb65733864..5f431fa8ac0d 100644
--- a/ucb

[Libreoffice-commits] core.git: ucb/source

2023-02-13 Thread Stephan Bergmann (via logerrit)
 ucb/source/core/ucbstore.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit bc65001a161f898809248eb899c36341ad2d550b
Author: Stephan Bergmann 
AuthorDate: Mon Feb 13 19:52:14 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Mon Feb 13 19:00:13 2023 +

Fix the build

...after 756185b5795c95180d32d02abfbd65951779b40e "osl::Mutex->std::mutex in
PersistentPropertySet" caused

> ucb/source/core/ucbstore.cxx:1913:75: error: too few arguments to 
function call, expected 2, have 1
> m_pPropertyChangeListeners->getContainer( rEvent.PropertyName 
);
>   
^
> include/comphelper/multiinterfacecontainer4.hxx:71:50: note: 
'getContainer' declared here
> inline OInterfaceContainerHelper4* 
getContainer(std::unique_lock& rGuard,
>  ^
> ucb/source/core/ucbstore.cxx:1921:66: error: too few arguments to 
function call, expected 2, have 1
> m_pPropertyChangeListeners->getContainer( OUString() );
>  ^
> include/comphelper/multiinterfacecontainer4.hxx:71:50: note: 
'getContainer' declared here
> inline OInterfaceContainerHelper4* 
getContainer(std::unique_lock& rGuard,
 ^

Change-Id: Ie13c7bf17d066607ec7095b3e45ab7d6ecea1cb6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146940
Tested-by: Stephan Bergmann 
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index b1b42730f249..191605dd1f7f 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -1910,7 +1910,7 @@ void PersistentPropertySet::notifyPropertyChangeEvent(
 
 // Get "normal" listeners for the property.
 OInterfaceContainerHelper4* pContainer =
-m_pPropertyChangeListeners->getContainer( rEvent.PropertyName );
+m_pPropertyChangeListeners->getContainer( aGuard, 
rEvent.PropertyName );
 if ( pContainer && pContainer->getLength(aGuard) )
 {
 pContainer->notifyEach( aGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
@@ -1918,7 +1918,7 @@ void PersistentPropertySet::notifyPropertyChangeEvent(
 
 // Get "normal" listeners for all properties.
 OInterfaceContainerHelper4* pNoNameContainer =
-m_pPropertyChangeListeners->getContainer( OUString() );
+m_pPropertyChangeListeners->getContainer( aGuard, OUString() );
 if ( pNoNameContainer && pNoNameContainer->getLength(aGuard) )
 {
 pNoNameContainer->notifyEach( aGuard, 
&XPropertyChangeListener::propertyChange, rEvent );


[Libreoffice-commits] core.git: ucb/source

2023-02-13 Thread Noel Grandin (via logerrit)
 ucb/source/cacher/dynamicresultsetwrapper.cxx |6 +++---
 ucb/source/cacher/dynamicresultsetwrapper.hxx |4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 0fdee9f9864f7f119e0503e1d9e1b7ff7250025e
Author: Noel Grandin 
AuthorDate: Mon Feb 13 14:18:29 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Feb 13 16:07:51 2023 +

osl::Mutex->std::mutex in DynamicResultSetWrapperListener

Change-Id: Ie8673462fac30132f4e6b3cf7792d8554bf4f14a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146901
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/cacher/dynamicresultsetwrapper.cxx 
b/ucb/source/cacher/dynamicresultsetwrapper.cxx
index fb37a5fa6864..cf2b4fd9c3dd 100644
--- a/ucb/source/cacher/dynamicresultsetwrapper.cxx
+++ b/ucb/source/cacher/dynamicresultsetwrapper.cxx
@@ -459,7 +459,7 @@ css::uno::Any SAL_CALL 
DynamicResultSetWrapperListener::queryInterface( const cs
 //virtual
 void SAL_CALL DynamicResultSetWrapperListener::disposing( const EventObject& 
rEventObject )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if( m_pOwner )
 m_pOwner->impl_disposing( rEventObject );
@@ -468,7 +468,7 @@ void SAL_CALL DynamicResultSetWrapperListener::disposing( 
const EventObject& rEv
 //virtual
 void SAL_CALL DynamicResultSetWrapperListener::notify( const ListEvent& 
Changes )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if( m_pOwner )
 m_pOwner->impl_notify( Changes );
@@ -480,7 +480,7 @@ void SAL_CALL DynamicResultSetWrapperListener::notify( 
const ListEvent& Changes
 
 void DynamicResultSetWrapperListener::impl_OwnerDies()
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 m_pOwner = nullptr;
 }
diff --git a/ucb/source/cacher/dynamicresultsetwrapper.hxx 
b/ucb/source/cacher/dynamicresultsetwrapper.hxx
index c6a363cff796..66aec8194145 100644
--- a/ucb/source/cacher/dynamicresultsetwrapper.hxx
+++ b/ucb/source/cacher/dynamicresultsetwrapper.hxx
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -150,7 +150,7 @@ class DynamicResultSetWrapperListener
 , public css::ucb::XDynamicResultSetListener
 {
 DynamicResultSetWrapper*m_pOwner;
-osl::Mutex  m_aMutex;
+std::mutex  m_aMutex;
 
 public:
 DynamicResultSetWrapperListener( DynamicResultSetWrapper* pOwner );


[Libreoffice-commits] core.git: ucb/source

2023-01-30 Thread László Németh (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx  |   24 
 ucb/source/ucp/webdav-curl/DAVException.hxx |1 +
 2 files changed, 25 insertions(+)

New commits:
commit 30ca48f4dc0e65a3798e6b21574bc80f6d4953fa
Author: László Németh 
AuthorDate: Wed Jan 25 12:08:14 2023 +0100
Commit: László Németh 
CommitDate: Mon Jan 30 08:29:35 2023 +

tdf#152493 ucb WebDAV: fix upload using HTTP 1.0 fallback

Fix broken libcurl upload to Vibe 4.0.6 WebDAV server
using HTTP 1.0 fallback.

Regression from commit 023ebf17898db4bca63129f079fd90b5cf76c1a9
"ucb: remove --with-webdav=neon" (Neon had no such upload
problem).

HTTP 1.0 fallback found by Pál Zoltán Kochis.
Fallback for CURLE_UNSUPPORTED_PROTOCOL
suggested by Michael Stahl. Thanks for their and
Attila Bakos' help.

Michael Stahl's comment: "'HTTP/0.9' in the [curl] error
message is very misleading: it simply means that a header
was expected but there was no header, so what is received
is interpreted as body.

Note: the HTTP/1.0 works because it does not use the
'Expect: 100-continue' so there should be no intermediate
100 Continue response from the server at all - instead
libcurl directly sends the XML document for the PROPFIND
and the server sends the response, and the problem does
not occur."

Co-authored-by: Michael Stahl 

Change-Id: I8bd79154de14b6425e0324f4d8f6e64512c08264
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146067
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 0f06363ce68f..bb1d4689a53c 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -964,6 +964,8 @@ auto CurlProcessor::ProcessRequestImpl(
  "curl_easy_perform failed: " << GetErrorString(rc, 
rSession.m_ErrorBuffer));
 switch (rc)
 {
+case CURLE_UNSUPPORTED_PROTOCOL:
+throw DAVException(DAVException::DAV_UNSUPPORTED);
 case CURLE_COULDNT_RESOLVE_PROXY:
 throw DAVException(
 DAVException::DAV_HTTP_LOOKUP,
@@ -1250,6 +1252,7 @@ auto CurlProcessor::ProcessRequest(
 }
 }
 bool isRetry(false);
+bool isFallbackHTTP10(false);
 int nAuthRequests(0);
 int nAuthRequestsProxy(0);
 
@@ -1473,6 +1476,27 @@ auto CurlProcessor::ProcessRequest(
 }
 }
 }
+else if (rException.getError() == DAVException::DAV_UNSUPPORTED)
+{
+// tdf#152493 libcurl can't handle "Transfer-Encoding: chunked"
+// in HTTP/1.1 100 Continue response.
+// workaround: if HTTP/1.1 didn't work, try HTTP/1.0
+// (but fallback only once - to prevent infinite loop)
+if (isFallbackHTTP10)
+{
+throw DAVException(DAVException::DAV_HTTP_ERROR);
+}
+isFallbackHTTP10 = true;
+// note: this is not reset - future requests to this URI use 
it!
+auto rc = curl_easy_setopt(rSession.m_pCurl.get(), 
CURLOPT_HTTP_VERSION,
+   CURL_HTTP_VERSION_1_0);
+if (rc != CURLE_OK)
+{
+throw DAVException(DAVException::DAV_HTTP_ERROR);
+}
+SAL_INFO("ucb.ucp.webdav.curl", "attempting fallback to 
HTTP/1.0");
+isRetry = true;
+}
 if (!isRetry)
 {
 throw; // everything else: re-throw
diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx 
b/ucb/source/ucp/webdav-curl/DAVException.hxx
index 84dba895485c..759e43f25f8e 100644
--- a/ucb/source/ucp/webdav-curl/DAVException.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVException.hxx
@@ -130,6 +130,7 @@ class DAVException : public std::exception
 DAV_SESSION_CREATE, // session creation error,
 // mData = server[:port]
 DAV_INVALID_ARG,// invalid argument
+DAV_UNSUPPORTED,// internal to CurlSession
 
 DAV_LOCK_EXPIRED,   // DAV lock expired
 


[Libreoffice-commits] core.git: ucb/source

2023-01-19 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 261b1237532f431963358a7b4ac5fd1ad6e5d223
Author: Michael Stahl 
AuthorDate: Thu Jan 19 12:28:57 2023 +0100
Commit: Michael Stahl 
CommitDate: Thu Jan 19 15:05:57 2023 +

tdf#153039 ucb: webdav-curl: fix POST, which was actually doing PUT

The problem is that first CURLOPT_POST was set and later CURLOPT_UPLOAD,
which overrides the HTTP method to PUT.  Move this out to the 4
functions that need it.

Change-Id: Ibd555dcc00a03baa1bb300a9ab9905f383179c67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145786
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 7353c8c9fa7e..1632881cb824 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -875,9 +875,6 @@ auto CurlProcessor::ProcessRequestImpl(
 oUploadSource.emplace(*pInData);
 rc = curl_easy_setopt(rSession.m_pCurl.get(), CURLOPT_READDATA, 
&*oUploadSource);
 assert(rc == CURLE_OK);
-// libcurl won't upload without setting this
-rc = curl_easy_setopt(rSession.m_pCurl.get(), CURLOPT_UPLOAD, 1L);
-assert(rc == CURLE_OK);
 }
 rSession.m_ErrorBuffer[0] = '\0';
 
@@ -1638,6 +1635,7 @@ auto CurlProcessor::PropFind(
 curl_off_t const len(xSeqOutStream->getWrittenBytes().getLength());
 
 ::std::vector const options{
+{ CURLOPT_UPLOAD, 1L, nullptr },
 { CURLOPT_CUSTOMREQUEST, "PROPFIND", "CURLOPT_CUSTOMREQUEST" },
 // note: Sharepoint cannot handle "Transfer-Encoding: chunked"
 { CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
@@ -1792,6 +1790,7 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference,
 curl_off_t const len(xSeqOutStream->getWrittenBytes().getLength());
 
 ::std::vector const options{
+{ CURLOPT_UPLOAD, 1L, nullptr },
 { CURLOPT_CUSTOMREQUEST, "PROPPATCH", "CURLOPT_CUSTOMREQUEST" },
 // note: Sharepoint cannot handle "Transfer-Encoding: chunked"
 { CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
@@ -1945,8 +1944,10 @@ auto CurlSession::PUT(OUString const& rURIReference,
 // lock m_Mutex after accessing global LockStore to avoid deadlock
 
 // note: Nextcloud 20 cannot handle "Transfer-Encoding: chunked"
-::std::vector const options{ { CURLOPT_INFILESIZE_LARGE, len, 
nullptr,
-   CurlOption::Type::CurlOffT } };
+::std::vector const options{
+{ CURLOPT_UPLOAD, 1L, nullptr }, // libcurl won't upload without 
setting this
+{ CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
+};
 
 CurlProcessor::ProcessRequest(*this, uri, "PUT", options, &rEnv, 
::std::move(pList), nullptr,
   &rxInStream, nullptr);
@@ -2127,6 +2128,7 @@ auto CurlProcessor::Lock(
 }
 
 ::std::vector const options{
+{ CURLOPT_UPLOAD, 1L, nullptr },
 { CURLOPT_CUSTOMREQUEST, "LOCK", "CURLOPT_CUSTOMREQUEST" },
 // note: Sharepoint cannot handle "Transfer-Encoding: chunked"
 { CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }


[Libreoffice-commits] core.git: ucb/source

2022-12-14 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/ext/ucpext_content.cxx  |   11 +++
 ucb/source/ucp/ext/ucpext_content.hxx  |8 +++-
 ucb/source/ucp/ext/ucpext_datasupplier.cxx |3 ++-
 3 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 8ee6cfc9655ce9de4617cea1a0d9cb9d7a4fbfac
Author: Stephan Bergmann 
AuthorDate: Thu Dec 8 10:03:03 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Dec 14 09:54:12 2022 +

loplugin:unocast (ucb::ucp::ext::Content)

(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)

Change-Id: If35b179b83383d8252a356c5bf43ae6ebb1d63f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144148
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/ext/ucpext_content.cxx 
b/ucb/source/ucp/ext/ucpext_content.cxx
index a1d2df55a092..6747c397f952 100644
--- a/ucb/source/ucp/ext/ucpext_content.cxx
+++ b/ucb/source/ucp/ext/ucpext_content.cxx
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -435,6 +436,16 @@ namespace ucb::ucp::ext
 }
 
 
+sal_Int64 Content::getSomething(css::uno::Sequence const & 
aIdentifier) {
+return comphelper::getSomethingImpl(aIdentifier, this);
+}
+
+css::uno::Sequence const & Content::getUnoTunnelId() {
+static comphelper::UnoIdInit const id;
+return id.getSeq();
+}
+
+
 Reference< XRow > Content::getPropertyValues( const Sequence< Property >& 
i_rProperties, const Reference< XCommandEnvironment >& i_rEnv )
 {
 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
diff --git a/ucb/source/ucp/ext/ucpext_content.hxx 
b/ucb/source/ucp/ext/ucpext_content.hxx
index 99df646f73c4..58157c37e769 100644
--- a/ucb/source/ucp/ext/ucpext_content.hxx
+++ b/ucb/source/ucp/ext/ucpext_content.hxx
@@ -21,7 +21,9 @@
 
 #include 
 #include 
+#include 
 
+#include 
 #include 
 
 #include 
@@ -45,7 +47,8 @@ namespace ucb::ucp::ext
 
 //= ContentProvider
 
-typedef ::ucbhelper::ContentImplHelper  Content_Base;
+typedef cppu::ImplInheritanceHelper<::ucbhelper::ContentImplHelper, 
css::lang::XUnoTunnel>
+Content_Base;
 class Content : public Content_Base
 {
 public:
@@ -82,6 +85,9 @@ namespace ucb::ucp::ext
 */
 OUString getPhysicalURL() const;
 
+sal_Int64 SAL_CALL getSomething(css::uno::Sequence const & 
aIdentifier) override;
+static css::uno::Sequence const & getUnoTunnelId();
+
 protected:
 virtual ~Content() override;
 
diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx 
b/ucb/source/ucp/ext/ucpext_datasupplier.cxx
index b718ef076c34..e0490075d7c9 100644
--- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx
+++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -204,7 +205,7 @@ namespace ucb::ucp::ext
 try
 {
 Reference< XContent > xContent( 
m_xContent->getProvider()->queryContent( xId ) );
-pContent.set( dynamic_cast< Content* >( xContent.get() ) );
+pContent.set( comphelper::getFromUnoTunnel< Content >( 
xContent ) );
 OSL_ENSURE( pContent.is() || !xContent.is(), 
"DataSupplier::queryContent: invalid content implementation!" );
 m_aResults[ i_nIndex ].pContent = pContent;
 return pContent;


[Libreoffice-commits] core.git: ucb/source

2022-11-11 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/webdav-curl/DAVTypes.hxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit dbbfcfed6f877ad2446daefe1083f42994f28a1f
Author: Stephan Bergmann 
AuthorDate: Thu Nov 10 18:56:56 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Nov 11 12:29:28 2022 +0100

Drop counterproductive top-level consts

...that were apparently left by accident by
b4b4c129e9f00189978cd7b71fd74d0dca4c9ebc "clang-tidy 
modernize-pass-by-value in
ucb", thwarting the use of std::move here.

(I came across this code with an upcoming loplugin:constmove that flags
suspicious uses of std::move involving const-qualified types.)

Change-Id: I95867aea623913ed37d57cb7d9593654ec57487d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142564
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.hxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
index 66b0aee8ec49..e0f2e856030a 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
@@ -191,8 +191,8 @@ namespace http_dav_ucp
 css::uno::Any const   value;
 
 ProppatchValue( const ProppatchOperation o,
-const OUString n,
-const css::uno::Any v )
+OUString n,
+css::uno::Any v )
 : operation( o ), name( std::move(n) ), value( std::move(v) ) {}
 };
 } // namespace http_dav_ucp


[Libreoffice-commits] core.git: ucb/source

2022-10-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/ftp/ftpcontent.cxx |   15 +++
 1 file changed, 15 insertions(+)

New commits:
commit 022e476af44c0dfc97403dc0f3a3b63e731903e6
Author: Michael Stahl 
AuthorDate: Wed Oct 26 14:58:09 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed Oct 26 16:02:25 2022 +0200

ucb: FTP UCP: report CURLE_URL_MALFORMAT as IllegalIdentifierException

With curl 7.86, the test JunitTest_ucb_complex starts to fail:

.ftp://noname:nopasswd@*nohost.invalid
now executing open
com.sun.star.ucb.InteractiveAugmentedIOException:
at com.sun.proxy.$Proxy15.execute(Unknown Source)
at complex.ucb.UCB.executeCommand(UCB.java:63)
at complex.ucb.UCB.checkWrongFtpConnection(UCB.java:119)

because curl_easy_perform() now returns CURLE_URL_MALFORMAT where
previously it was CURLE_COULDNT_RESOLVE_HOST.

Map this to an exception the test expects.

Change-Id: Ifdb672946726ddb4cb4d9426b7e70eefac63f040
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141877
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx 
b/ucb/source/ucp/ftp/ftpcontent.cxx
index 0294cea7b9f8..65e2b86f8f21 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -63,6 +63,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -226,6 +227,7 @@ enum ACTION { NOACTION,
   THROWAUTHENTICATIONREQUEST,
   THROWACCESSDENIED,
   THROWINTERACTIVECONNECT,
+  THROWMALFORMED,
   THROWRESOLVENAME,
   THROWQUOTE,
   THROWNOFILE,
@@ -344,6 +346,15 @@ Any SAL_CALL FTPContent::execute( const Command& aCommand,
 Environment);
 break;
 }
+case THROWMALFORMED:
+{
+IllegalIdentifierException ex;
+aRet <<= ex;
+ucbhelper::cancelCommandExecution(
+aRet,
+Environment);
+break;
+}
 case THROWRESOLVENAME:
 {
 InteractiveNetworkResolveNameException excep;
@@ -538,6 +549,10 @@ Any SAL_CALL FTPContent::execute( const Command& aCommand,
 {
 if(e.code() == CURLE_COULDNT_CONNECT)
 action = THROWINTERACTIVECONNECT;
+else if (e.code() == CURLE_URL_MALFORMAT)
+{
+action = THROWMALFORMED;
+}
 else if(e.code() == CURLE_COULDNT_RESOLVE_HOST )
 action = THROWRESOLVENAME;
 else if(e.code() == CURLE_FTP_USER_PASSWORD_INCORRECT ||


[Libreoffice-commits] core.git: ucb/source

2022-09-28 Thread Noel Grandin (via logerrit)
 ucb/source/core/ucb.cxx  |   12 ++--
 ucb/source/core/ucb.hxx  |4 ++--
 ucb/source/core/ucbstore.cxx |6 +++---
 ucb/source/ucp/ext/ucpext_content.cxx|8 
 ucb/source/ucp/ext/ucpext_content.hxx|2 +-
 ucb/source/ucp/file/filglob.cxx  |   15 ---
 ucb/source/ucp/file/filglob.hxx  |8 
 ucb/source/ucp/hierarchy/hierarchydata.cxx   |6 +++---
 ucb/source/ucp/webdav-curl/CurlSession.cxx   |   14 --
 ucb/source/ucp/webdav-curl/CurlUri.cxx   |   19 ++-
 ucb/source/ucp/webdav-curl/CurlUri.hxx   |2 +-
 ucb/source/ucp/webdav-curl/DAVProperties.cxx |   26 ++
 ucb/source/ucp/webdav-curl/DAVProperties.hxx |2 +-
 13 files changed, 65 insertions(+), 59 deletions(-)

New commits:
commit aa770d615ec5722411cc4ab1f88de89d4cad5809
Author: Noel Grandin 
AuthorDate: Wed Sep 28 15:00:28 2022 +0200
Commit: Noel Grandin 
CommitDate: Wed Sep 28 16:04:31 2022 +0200

use more string_view in ucb

Change-Id: Id1d35aca0c8f62b3eb03eca9850a3f3c9799df98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140706
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index e0e6953a63a7..26476a90562b 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -136,10 +136,10 @@ bool fillPlaceholders(OUString const & rInput,
 }
 
 void makeAndAppendXMLName(
-OUStringBuffer & rBuffer, const OUString & rIn )
+OUStringBuffer & rBuffer, std::u16string_view rIn )
 {
-sal_Int32 nCount = rIn.getLength();
-for ( sal_Int32 n = 0; n < nCount; ++n )
+size_t nCount = rIn.size();
+for ( size_t n = 0; n < nCount; ++n )
 {
 const sal_Unicode c = rIn[ n ];
 switch ( c )
@@ -767,11 +767,11 @@ void UniversalContentBroker::prepareAndRegister(
 
 
 bool UniversalContentBroker::getContentProviderData(
-const OUString & rKey1,
-const OUString & rKey2,
+std::u16string_view rKey1,
+std::u16string_view rKey2,
 ContentProviderDataList & rListToFill )
 {
-if ( !m_xContext.is() || rKey1.isEmpty() || rKey2.isEmpty() )
+if ( !m_xContext.is() || rKey1.empty() || rKey2.empty() )
 {
 OSL_FAIL( "UniversalContentBroker::getContentProviderData - Invalid 
argument!" );
 return false;
diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx
index 49c6e0b37d8d..001987ed54c4 100644
--- a/ucb/source/core/ucb.hxx
+++ b/ucb/source/core/ucb.hxx
@@ -136,8 +136,8 @@ private:
 void configureUcb();
 
 bool getContentProviderData(
-const OUString & rKey1,
-const OUString & rKey2,
+std::u16string_view rKey1,
+std::u16string_view rKey2,
 ucbhelper::ContentProviderDataList & rListToFill);
 
 void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData);
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index be97f81f636f..5757f8369f40 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -59,13 +59,13 @@ using namespace com::sun::star::util;
 using namespace comphelper;
 using namespace cppu;
 
-static OUString makeHierarchalNameSegment( const OUString & rIn  )
+static OUString makeHierarchalNameSegment( std::u16string_view rIn  )
 {
 OUStringBuffer aBuffer;
 aBuffer.append( "['" );
 
-sal_Int32 nCount = rIn.getLength();
-for ( sal_Int32 n = 0; n < nCount; ++n )
+size_t nCount = rIn.size();
+for ( size_t n = 0; n < nCount; ++n )
 {
 const sal_Unicode c = rIn[ n ];
 switch ( c )
diff --git a/ucb/source/ucp/ext/ucpext_content.cxx 
b/ucb/source/ucp/ext/ucpext_content.cxx
index a04da9a96ecd..a1d2df55a092 100644
--- a/ucb/source/ucp/ext/ucpext_content.cxx
+++ b/ucb/source/ucp/ext/ucpext_content.cxx
@@ -279,16 +279,16 @@ namespace ucb::ucp::ext
 }
 
 
-bool Content::denotesRootContent( const OUString& i_rContentIdentifier )
+bool Content::denotesRootContent( std::u16string_view i_rContentIdentifier 
)
 {
 const OUString sRootURL( ContentProvider::getRootURL() );
 if ( i_rContentIdentifier == sRootURL )
 return true;
 
 // the root URL contains only two trailing /, but we also recognize 3 
of them as denoting the root URL
-if  (   i_rContentIdentifier.match( sRootURL )
-&&  ( i_rContentIdentifier.getLength() == sRootURL.getLength() + 1 
)
-&&  ( i_rContentIdentifier[ i_rContentIdentifier.getLength() - 1 ] 
== '/' )
+if  (   o3tl::starts_with(i_rContentIdentifier,  sRootURL )
+&&  ( sal_Int32(i_rContentIdentifier.size()) == 
sRootURL.getLength() + 1 )
+&&  ( i_rContentIdentifier[ i_rContentIdentifier.size() - 1 ] == 
'/' )
 )
  

[Libreoffice-commits] core.git: ucb/source

2022-09-14 Thread Caolán McNamara (via logerrit)
 ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit e30f85f5b4de09a2e9fbe7f4c4af5ca7364e96ae
Author: Caolán McNamara 
AuthorDate: Mon Sep 12 16:13:21 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Sep 14 09:52:43 2022 +0200

cid#1500603 Resource leak

don't mix std::unique_ptr and rtl::Reference

I don't know why mess around with osl_atomic_increment/osl_atomic_decrement,
but at least sync with the pattern in use at
ucb/source/ucp/tdoc/tdoc_storage.cxx StorageElementFactory::createStorage

Change-Id: I25fc57d8e886bab3990a63543212efa67ac9772f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139811
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx 
b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
index f2379d2cc33c..910e7f04b959 100644
--- a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
@@ -44,12 +44,12 @@ rtl::Reference< DAVSession > 
DAVSessionFactory::createDAVSession(
 
 if ( aIt == m_aMap.end() )
 {
-std::unique_ptr< DAVSession > xElement(
+rtl::Reference< CurlSession > xElement(
 new CurlSession(rxContext, this, inUri, rFlags, *m_xProxyDecider) 
);
 
 aIt = m_aMap.emplace(  inUri, xElement.get() ).first;
+
 aIt->second->m_aContainerIt = aIt;
-xElement.release();
 return aIt->second;
 }
 else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 )
@@ -63,9 +63,10 @@ rtl::Reference< DAVSession > 
DAVSessionFactory::createDAVSession(
 osl_atomic_decrement( &aIt->second->m_nRefCount );
 aIt->second->m_aContainerIt = m_aMap.end();
 
-aIt->second = new CurlSession(rxContext, this, inUri, rFlags, 
*m_xProxyDecider);
+rtl::Reference< CurlSession > xNewStorage = new CurlSession(rxContext, 
this, inUri, rFlags, *m_xProxyDecider);
+aIt->second = xNewStorage.get();
 aIt->second->m_aContainerIt = aIt;
-return aIt->second;
+return xNewStorage;
 }
 }
 


[Libreoffice-commits] core.git: ucb/source

2022-08-15 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit f6a0ca0e92e41ad8fea71acdacdc7ec5e775dc59
Author: Michael Stahl 
AuthorDate: Fri Aug 12 16:43:12 2022 +0200
Commit: Michael Stahl 
CommitDate: Mon Aug 15 10:34:27 2022 +0200

tdf#149921 ucb: webdav-curl: WNT: certificate revocation check

- don't require it to be successful.

Trying to connect to a server with self-signed CA results in:


warn:ucb.ucp.webdav.curl:6796:6568:ucb/source/ucp/webdav-curl/CurlSession.cxx:946:
curl_easy_perform failed: (35) schannel: next InitializeSecurityContext 
failed:
Unknown error (0x80092012) - The revocation function was unable to check 
revocation for the certificate.

Apparently schannel wants to check by default (called with
SCH_CRED_REVOCATION_CHECK_CHAIN) that all the certificates aren't
revoked, but the self-signed CA doesn't specify how to check.

Set it to only check revocation when the way to do so actually works,
via CURLSSLOPT_REVOKE_BEST_EFFORT, which sets these flags:
SCH_CRED_IGNORE_NO_REVOCATION_CHECK | SCH_CRED_IGNORE_REVOCATION_OFFLINE | 
SCH_CRED_REVOCATION_CHECK_CHAIN

Change-Id: I6d77ca23fe2012d8a5d65000b14775070b5c9a0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138204
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index a966e779543c..a7303fb7b3bc 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -678,8 +678,17 @@ 
CurlSession::CurlSession(uno::Reference xContext,
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_READFUNCTION, &read_callback);
 assert(rc == CURLE_OK);
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_HEADERFUNCTION, 
&header_callback);
-// set this initially, may be overwritten during authentication
 assert(rc == CURLE_OK);
+// tdf#149921 by default, with schannel (WNT) connection fails if 
revocation
+// lists cannot be checked; try to limit the checking to when revocation
+// lists can actually be retrieved (usually not the case for self-signed 
CA)
+#if CURL_AT_LEAST_VERSION(7, 70, 0)
+rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_SSL_OPTIONS, 
CURLSSLOPT_REVOKE_BEST_EFFORT);
+assert(rc == CURLE_OK);
+rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_PROXY_SSL_OPTIONS, 
CURLSSLOPT_REVOKE_BEST_EFFORT);
+assert(rc == CURLE_OK);
+#endif
+// set this initially, may be overwritten during authentication
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_HTTPAUTH, CURLAUTH_ANY);
 assert(rc == CURLE_OK); // ANY is always available
 // always set CURLOPT_PROXY to suppress proxy detection in libcurl


[Libreoffice-commits] core.git: ucb/source

2022-08-04 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/cmis/auth_provider.hxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit cc8106f66ea26c0ae2874a5c1168f43a6263a564
Author: Noel Grandin 
AuthorDate: Thu Aug 4 14:50:35 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 4 18:55:56 2022 +0200

cid#1507745 return local

regression from
commit b4b4c129e9f00189978cd7b71fd74d0dca4c9ebc
Author: Noel Grandin 
Date:   Mon Aug 1 09:09:05 2022 +0200
clang-tidy modernize-pass-by-value in ucb

Change-Id: Ie5d7d78ebde6fdee1234a0da496ff9692ee3c2c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137796
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/cmis/auth_provider.hxx 
b/ucb/source/ucp/cmis/auth_provider.hxx
index c350617e226c..1768c12173f0 100644
--- a/ucb/source/ucp/cmis/auth_provider.hxx
+++ b/ucb/source/ucp/cmis/auth_provider.hxx
@@ -31,10 +31,10 @@ namespace cmis
 OUString m_sBindingUrl;
 
 public:
-AuthProvider ( css::uno::Reference< css::ucb::XCommandEnvironment> 
xEnv,
+AuthProvider ( const css::uno::Reference< 
css::ucb::XCommandEnvironment> & xEnv,
OUString sUrl,
OUString sBindingUrl ):
-m_xEnv( std::move(xEnv) ), m_sUrl( std::move(sUrl) ), 
m_sBindingUrl( std::move(sBindingUrl) ) { }
+m_xEnv( xEnv ), m_sUrl( std::move(sUrl) ), m_sBindingUrl( 
std::move(sBindingUrl) ) { }
 
 bool authenticationQuery( std::string& username, std::string& 
password ) override;
 


[Libreoffice-commits] core.git: ucb/source

2022-08-01 Thread Noel Grandin (via logerrit)
 ucb/source/core/identify.cxx |6 +++--
 ucb/source/core/identify.hxx |2 -
 ucb/source/core/providermap.hxx  |4 +--
 ucb/source/core/provprox.cxx |5 ++--
 ucb/source/core/provprox.hxx |2 -
 ucb/source/core/ucbcmds.cxx  |   19 +
 ucb/source/core/ucbstore.cxx |5 ++--
 ucb/source/core/ucbstore.hxx |2 -
 ucb/source/inc/regexp.hxx|6 ++---
 ucb/source/inc/regexpmap.hxx |   10 -
 ucb/source/regexp/regexp.cxx |   13 ++-
 ucb/source/ucp/cmis/auth_provider.hxx|8 +++
 ucb/source/ucp/cmis/certvalidation_handler.hxx   |5 ++--
 ucb/source/ucp/cmis/cmis_content.cxx |5 ++--
 ucb/source/ucp/cmis/cmis_content.hxx |2 -
 ucb/source/ucp/cmis/cmis_datasupplier.hxx|2 -
 ucb/source/ucp/cmis/std_inputstream.cxx  |5 ++--
 ucb/source/ucp/cmis/std_inputstream.hxx  |2 -
 ucb/source/ucp/cmis/std_outputstream.cxx |5 ++--
 ucb/source/ucp/cmis/std_outputstream.hxx |2 -
 ucb/source/ucp/ext/ucpext_datasupplier.cxx   |5 ++--
 ucb/source/ucp/ext/ucpext_datasupplier.hxx   |2 -
 ucb/source/ucp/ext/ucpext_resultset.cxx  |5 ++--
 ucb/source/ucp/ext/ucpext_resultset.hxx  |2 -
 ucb/source/ucp/file/bc.cxx   |9 
 ucb/source/ucp/file/bc.hxx   |4 +--
 ucb/source/ucp/file/filtask.hxx  |4 +--
 ucb/source/ucp/ftp/ftpcontent.cxx|5 ++--
 ucb/source/ucp/ftp/ftpcontent.hxx|2 -
 ucb/source/ucp/ftp/ftpcontentidentifier.cxx  |6 +++--
 ucb/source/ucp/ftp/ftpcontentidentifier.hxx  |2 -
 ucb/source/ucp/ftp/ftpresultsetbase.cxx  |9 
 ucb/source/ucp/ftp/ftpresultsetbase.hxx  |4 +--
 ucb/source/ucp/gio/gio_datasupplier.cxx  |5 ++--
 ucb/source/ucp/gio/gio_datasupplier.hxx  |2 -
 ucb/source/ucp/gio/gio_resultset.cxx |6 +++--
 ucb/source/ucp/gio/gio_resultset.hxx |2 -
 ucb/source/ucp/hierarchy/dynamicresultset.cxx|6 +++--
 ucb/source/ucp/hierarchy/dynamicresultset.hxx|2 -
 ucb/source/ucp/hierarchy/hierarchycontent.cxx|5 ++--
 ucb/source/ucp/hierarchy/hierarchycontent.hxx|2 -
 ucb/source/ucp/hierarchy/hierarchydata.cxx   |5 ++--
 ucb/source/ucp/hierarchy/hierarchydata.hxx   |2 -
 ucb/source/ucp/hierarchy/hierarchydatasource.cxx |   15 +++--
 ucb/source/ucp/hierarchy/hierarchydatasource.hxx |2 -
 ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx   |3 +-
 ucb/source/ucp/hierarchy/hierarchyuri.hxx|4 +--
 ucb/source/ucp/image/ucpimage.cxx|5 ++--
 ucb/source/ucp/package/pkgcontent.cxx|   21 +--
 ucb/source/ucp/package/pkgcontent.hxx|   10 -
 ucb/source/ucp/package/pkgdatasupplier.cxx   |5 ++--
 ucb/source/ucp/package/pkgdatasupplier.hxx   |5 ++--
 ucb/source/ucp/package/pkgprovider.cxx   |7 +++---
 ucb/source/ucp/package/pkgresultset.cxx  |   10 +
 ucb/source/ucp/package/pkgresultset.hxx  |4 +--
 ucb/source/ucp/package/pkguri.hxx|5 ++--
 ucb/source/ucp/tdoc/tdoc_content.cxx |5 ++--
 ucb/source/ucp/tdoc/tdoc_content.hxx |7 +++---
 ucb/source/ucp/tdoc/tdoc_datasupplier.cxx|7 +++---
 ucb/source/ucp/tdoc/tdoc_datasupplier.hxx|7 +++---
 ucb/source/ucp/tdoc/tdoc_docmgr.hxx  |9 
 ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx  |5 ++--
 ucb/source/ucp/tdoc/tdoc_documentcontentfactory.hxx  |2 -
 ucb/source/ucp/tdoc/tdoc_resultset.cxx   |5 ++--
 ucb/source/ucp/tdoc/tdoc_resultset.hxx   |2 -
 ucb/source/ucp/tdoc/tdoc_stgelems.cxx|9 
 ucb/source/ucp/tdoc/tdoc_stgelems.hxx|4 +--
 ucb/source/ucp/tdoc/tdoc_storage.cxx |9 
 ucb/source/ucp/tdoc/tdoc_storage.hxx |4 +--
 ucb/source/ucp/tdoc/tdoc_uri.hxx |5 ++--
 ucb/source/ucp/webdav-curl/ContentProperties.hxx |5 ++--
 ucb/source/ucp/webdav-curl/CurlSession.cxx   |   20 +-
 ucb/source/ucp/webdav-curl/CurlSession.hxx   |2 -
 ucb/source/ucp/webdav-curl/DAVAuthListenerImpl.hxx   |7 +++---
 ucb/source/ucp/webdav-curl/DAVException.hxx  |9 
 ucb

[Libreoffice-commits] core.git: ucb/source

2022-06-19 Thread Julien Nabet (via logerrit)
 ucb/source/ucp/gio/gio_content.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 2a38c834c8b7712421f1125aa0e382de70767b55
Author: Julien Nabet 
AuthorDate: Sat Jun 18 15:14:33 2022 +0200
Commit: Julien Nabet 
CommitDate: Sun Jun 19 20:42:43 2022 +0200

tdf#128196: filenames containing # get truncated when saving to GVFS

+ replace getLength() by a call to isEmpty() since we're here

Change-Id: I77a318ea3e8ceeeddd6c64cee25aa6700cb3457b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136084
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/ucb/source/ucp/gio/gio_content.cxx 
b/ucb/source/ucp/gio/gio_content.cxx
index 44037217882b..fc31965a990f 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -19,6 +19,7 @@
 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -1090,8 +1091,13 @@ void Content::transfer( const css::ucb::TransferInfo& 
aTransferInfo, const css::
 if (!sDest.endsWith("/")) {
 sDest += "/";
 }
-if (aTransferInfo.NewTitle.getLength())
-sDest += aTransferInfo.NewTitle;
+if (!aTransferInfo.NewTitle.isEmpty())
+{
+sDest += rtl::Uri::encode( aTransferInfo.NewTitle,
+ rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 );
+}
 else
 sDest += OUString::createFromAscii(g_file_get_basename(getGFile()));
 


[Libreoffice-commits] core.git: ucb/source

2022-05-23 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/file/filtask.cxx |9 +
 ucb/source/ucp/file/filtask.hxx |   15 ---
 2 files changed, 9 insertions(+), 15 deletions(-)

New commits:
commit 86c95d195dfb1af7511cc0e70a93de9813284855
Author: Noel Grandin 
AuthorDate: Mon May 23 11:05:10 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 23 18:48:25 2022 +0200

std::unordered_set->o3tl::sorted_vector in TaskManager

avoids repeated allocation

Change-Id: Ie3f380ab2f38314b9c8a51fdcd1985329254f5dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134804
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 122ad052618c..7c87f5652be7 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -539,7 +539,7 @@ TaskManager::associate( const OUString& aUnqPath,
 beans::PropertyState_DEFAULT_VALUE,
 Attributes );
 
-TaskManager::PropertySet::iterator it1 = m_aDefaultProperties.find( 
newProperty );
+auto it1 = m_aDefaultProperties.find( newProperty );
 if( it1 != m_aDefaultProperties.end() )
 throw beans::PropertyExistException( THROW_WHERE );
 
@@ -570,7 +570,7 @@ TaskManager::deassociate( const OUString& aUnqPath,
 {
 MyProperty oldProperty( PropertyName );
 
-TaskManager::PropertySet::iterator it1 = m_aDefaultProperties.find( 
oldProperty );
+auto it1 = m_aDefaultProperties.find( oldProperty );
 if( it1 != m_aDefaultProperties.end() )
 throw beans::NotRemoveableException( THROW_WHERE );
 
@@ -845,7 +845,7 @@ TaskManager::setv( const OUString& aUnqPath,
 
 TaskManager::ContentMap::iterator it = m_aContent.find( aUnqPath );
 PropertySet& properties = it->second.properties;
-TaskManager::PropertySet::iterator it1;
+TaskManager::PropertySet::const_iterator it1;
 uno::Any aAny;
 
 for( sal_Int32 i = 0; i < values.getLength(); ++i )
@@ -1934,6 +1934,7 @@ void TaskManager::insertDefaultProperties( const 
OUString& aUnqPath )
 PropertySet& properties = it->second.properties;
 bool ContentNotDefau = properties.find( ContentTProperty ) != 
properties.end();
 
+properties.reserve(properties.size() + m_aDefaultProperties.size());
 for (auto const& defaultprop : m_aDefaultProperties)
 {
 if( !ContentNotDefau || defaultprop.getPropertyName() != ContentType )
@@ -2243,7 +2244,7 @@ void
 TaskManager::commit( const TaskManager::ContentMap::iterator& it,
const osl::FileStatus& aFileStatus )
 {
-TaskManager::PropertySet::iterator it1;
+TaskManager::PropertySet::const_iterator it1;
 
 if( it->second.properties.empty() )
 {
diff --git a/ucb/source/ucp/file/filtask.hxx b/ucb/source/ucp/file/filtask.hxx
index 3fa4b85752ed..c7199159fb44 100644
--- a/ucb/source/ucp/file/filtask.hxx
+++ b/ucb/source/ucp/file/filtask.hxx
@@ -18,6 +18,7 @@
  */
 #pragma once
 
+#include 
 #include 
 #include 
 
@@ -186,23 +187,15 @@ namespace fileaccess
 inline void setState( const css::beans::PropertyState& theState ) 
const;
 };
 
-struct eMyProperty
+struct MyPropertyLess
 {
 bool operator()( const MyProperty& rKey1, const MyProperty& rKey2 
) const
 {
-return rKey1.getPropertyName() == rKey2.getPropertyName();
+return rKey1.getPropertyName() < rKey2.getPropertyName();
 }
 };
 
-struct hMyProperty
-{
-size_t operator()( const MyProperty& rName ) const
-{
-return rName.getPropertyName().hashCode();
-}
-};
-
-typedef std::unordered_set< MyProperty,hMyProperty,eMyProperty > 
PropertySet;
+typedef o3tl::sorted_vector< MyProperty, MyPropertyLess > PropertySet;
 
 class UnqPathData
 {


[Libreoffice-commits] core.git: ucb/source

2022-05-20 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/package/pkgdatasupplier.cxx |   43 +++--
 ucb/source/ucp/package/pkgdatasupplier.hxx |7 
 2 files changed, 35 insertions(+), 15 deletions(-)

New commits:
commit 37ce4266d66323f158b20b9e0ec0388209f5e9f6
Author: Noel Grandin 
AuthorDate: Fri May 20 12:51:14 2022 +0200
Commit: Noel Grandin 
CommitDate: Fri May 20 17:16:36 2022 +0200

osl::Mutex->std::mutex in DataSupplier

Change-Id: I60fccc5d419d42571e768bd4b4ec5fe14d709896
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134676
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/package/pkgdatasupplier.cxx 
b/ucb/source/ucp/package/pkgdatasupplier.cxx
index a1337c2646ca..242c94e14b07 100644
--- a/ucb/source/ucp/package/pkgdatasupplier.cxx
+++ b/ucb/source/ucp/package/pkgdatasupplier.cxx
@@ -61,8 +61,12 @@ DataSupplier::~DataSupplier()
 // virtual
 OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return queryContentIdentifierStringImpl(aGuard, nIndex);
+}
 
+OUString DataSupplier::queryContentIdentifierStringImpl( 
std::unique_lock& rGuard, sal_uInt32 nIndex )
+{
 if ( nIndex < m_aResults.size() )
 {
 OUString aId = m_aResults[ nIndex ].aURL;
@@ -73,7 +77,7 @@ OUString DataSupplier::queryContentIdentifierString( 
sal_uInt32 nIndex )
 }
 }
 
-if ( getResult( nIndex ) )
+if ( getResultImpl( rGuard, nIndex ) )
 {
 // Note: getResult fills m_aResults[ nIndex ].aURL.
 return m_aResults[ nIndex ].aURL;
@@ -86,8 +90,13 @@ OUString DataSupplier::queryContentIdentifierString( 
sal_uInt32 nIndex )
 uno::Reference< ucb::XContentIdentifier >
 DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return queryContentIdentifierImpl(aGuard, nIndex);
+}
 
+uno::Reference< ucb::XContentIdentifier >
+DataSupplier::queryContentIdentifierImpl( std::unique_lock& 
rGuard, sal_uInt32 nIndex )
+{
 if ( nIndex < m_aResults.size() )
 {
 uno::Reference< ucb::XContentIdentifier >& xId
@@ -99,7 +108,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
 }
 }
 
-OUString aId = queryContentIdentifierString( nIndex );
+OUString aId = queryContentIdentifierStringImpl( rGuard, nIndex );
 if ( !aId.isEmpty() )
 {
 uno::Reference< ucb::XContentIdentifier > xId
@@ -115,7 +124,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
 uno::Reference< ucb::XContent > DataSupplier::queryContent(
 sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( nIndex < m_aResults.size() )
 {
@@ -129,7 +138,7 @@ uno::Reference< ucb::XContent > DataSupplier::queryContent(
 }
 
 uno::Reference< ucb::XContentIdentifier > xId
-= queryContentIdentifier( nIndex );
+= queryContentIdentifierImpl( aGuard, nIndex );
 if ( xId.is() )
 {
 try
@@ -151,8 +160,12 @@ uno::Reference< ucb::XContent > DataSupplier::queryContent(
 // virtual
 bool DataSupplier::getResult( sal_uInt32 nIndex )
 {
-osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return getResultImpl(aGuard, nIndex);
+}
 
+bool DataSupplier::getResultImpl( std::unique_lock& rGuard, 
sal_uInt32 nIndex )
+{
 if ( m_aResults.size() > nIndex )
 {
 // Result already present.
@@ -224,7 +237,7 @@ bool DataSupplier::getResult( sal_uInt32 nIndex )
 if ( xResultSet.is() )
 {
 // Callbacks follow!
-aGuard.clear();
+rGuard.unlock();
 
 if ( nOldCount < m_aResults.size() )
 xResultSet->rowCountChanged(
@@ -232,6 +245,8 @@ bool DataSupplier::getResult( sal_uInt32 nIndex )
 
 if ( m_bCountFinal )
 xResultSet->rowCountFinal();
+
+rGuard.lock();
 }
 
 return bFound;
@@ -241,7 +256,7 @@ bool DataSupplier::getResult( sal_uInt32 nIndex )
 // virtual
 sal_uInt32 DataSupplier::totalCount()
 {
-osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( m_bCountFinal )
 return m_aResults.size();
@@ -292,7 +307,7 @@ sal_uInt32 DataSupplier::totalCount()
 if ( xResultSet.is() )
 {
 // Callbacks follow!
-aGuard.clear();
+aGuard.unlock();
 
 if ( nOldCount < m_aResults.size() )
 xResultSet->rowCountChanged(
@@ -323,7 +338,7 @@ bool DataSupplier::isCountFinal()
 uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues(
 sal_uInt32 nIndex  )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( n

[Libreoffice-commits] core.git: ucb/source

2022-05-17 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/hierarchy/hierarchydatasource.cxx |   23 ---
 ucb/source/ucp/hierarchy/hierarchydatasource.hxx |8 
 2 files changed, 12 insertions(+), 19 deletions(-)

New commits:
commit f08c890482952820bf95b04872260c68082ef083
Author: Noel Grandin 
AuthorDate: Mon May 9 17:48:38 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 17 15:40:00 2022 +0200

osl::Mutex->std::mutex in HierarchyDataSource

HierarchyDataSource::createInstanceWithArguments does
not need locking since it does not access local state.

Change-Id: Ia29f9a5ca20095d51e4eb168cdc0a080d178f9bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134087
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx 
b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
index c42ebe2af20e..9c5fa97ae2ee 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
@@ -223,13 +223,13 @@ ucb_HierarchyDataSource_get_implementation(
 // virtual
 void SAL_CALL HierarchyDataSource::dispose()
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+if ( m_aDisposeEventListeners.getLength(aGuard) )
 {
 lang::EventObject aEvt;
 aEvt.Source = static_cast< lang::XComponent * >( this );
-m_pDisposeEventListeners->disposeAndClear( aEvt );
+m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
 }
 }
 
@@ -238,13 +238,9 @@ void SAL_CALL HierarchyDataSource::dispose()
 void SAL_CALL HierarchyDataSource::addEventListener(
 const uno::Reference< lang::XEventListener > & Listener )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( !m_pDisposeEventListeners )
-m_pDisposeEventListeners.reset(
-new comphelper::OInterfaceContainerHelper3( 
m_aMutex ) );
-
-m_pDisposeEventListeners->addInterface( Listener );
+m_aDisposeEventListeners.addInterface( aGuard, Listener );
 }
 
 
@@ -252,10 +248,9 @@ void SAL_CALL HierarchyDataSource::addEventListener(
 void SAL_CALL HierarchyDataSource::removeEventListener(
 const uno::Reference< lang::XEventListener > & Listener )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( m_pDisposeEventListeners )
-m_pDisposeEventListeners->removeInterface( Listener );
+m_aDisposeEventListeners.removeInterface( aGuard, Listener );
 }
 
 
@@ -304,8 +299,6 @@ HierarchyDataSource::createInstanceWithArguments(
 const uno::Sequence< uno::Any > & Arguments,
 bool bCheckArgs )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
 // Check service specifier.
 bool bReadOnly  = ServiceSpecifier == READ_SERVICE_NAME;
 bool bReadWrite = !bReadOnly && ServiceSpecifier == READWRITE_SERVICE_NAME;
@@ -420,7 +413,7 @@ HierarchyDataSource::getConfigProvider()
 {
 if ( !m_xConfigProvider.is() )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 if ( !m_xConfigProvider.is() )
 {
 try
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx 
b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
index 39dfdb8a424d..b4bff294d22b 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
@@ -19,14 +19,14 @@
 
 #pragma once
 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
+#include 
 #include 
 
 
@@ -38,10 +38,10 @@ class HierarchyDataSource : public cppu::WeakImplHelper<
 css::lang::XComponent,
 css::lang::XMultiServiceFactory>
 {
-osl::Mutex m_aMutex;
+std::mutex m_aMutex;
 css::uno::Reference< css::uno::XComponentContext > m_xContext;
 css::uno::Reference< css::lang::XMultiServiceFactory >  m_xConfigProvider;
-
std::unique_ptr>
 m_pDisposeEventListeners;
+comphelper::OInterfaceContainerHelper4 
m_aDisposeEventListeners;
 
 public:
 explicit HierarchyDataSource( const css::uno::Reference< 
css::uno::XComponentContext > & rxContext );


[Libreoffice-commits] core.git: ucb/source

2022-05-17 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx |   38 +
 ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx |   10 +++--
 2 files changed, 32 insertions(+), 16 deletions(-)

New commits:
commit ef3c759357cb3dbe4fee46afd24105a1c2e24126
Author: Noel Grandin 
AuthorDate: Sun May 8 21:39:01 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 17 13:22:40 2022 +0200

osl::Mutex->std::mutex in HierarchyResultSetDataSupplier

Change-Id: I61bcbc85fbbae469c5463a69dc835b7d1ac0575c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134086
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx 
b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
index 77747883bcbb..1a2f29f6b30c 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
@@ -60,8 +60,14 @@ 
HierarchyResultSetDataSupplier::~HierarchyResultSetDataSupplier()
 OUString HierarchyResultSetDataSupplier::queryContentIdentifierString(
 sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return queryContentIdentifierStringImpl(aGuard, nIndex);
+}
 
+OUString HierarchyResultSetDataSupplier::queryContentIdentifierStringImpl(
+std::unique_lock& 
rGuard,
+sal_uInt32 nIndex )
+{
 if ( nIndex < m_aResults.size() )
 {
 OUString aId = m_aResults[ nIndex ]->aId;
@@ -72,7 +78,7 @@ OUString 
HierarchyResultSetDataSupplier::queryContentIdentifierString(
 }
 }
 
-if ( getResult( nIndex ) )
+if ( getResultImpl( rGuard, nIndex ) )
 {
 OUString aId
 = m_xContent->getIdentifier()->getContentIdentifier();
@@ -93,7 +99,7 @@ OUString 
HierarchyResultSetDataSupplier::queryContentIdentifierString(
 uno::Reference< ucb::XContentIdentifier >
 HierarchyResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( nIndex < m_aResults.size() )
 {
@@ -106,7 +112,7 @@ HierarchyResultSetDataSupplier::queryContentIdentifier( 
sal_uInt32 nIndex )
 }
 }
 
-OUString aId = queryContentIdentifierString( nIndex );
+OUString aId = queryContentIdentifierStringImpl( aGuard, nIndex );
 if ( !aId.isEmpty() )
 {
 uno::Reference< ucb::XContentIdentifier > xId
@@ -122,7 +128,7 @@ HierarchyResultSetDataSupplier::queryContentIdentifier( 
sal_uInt32 nIndex )
 uno::Reference< ucb::XContent >
 HierarchyResultSetDataSupplier::queryContent( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( nIndex < m_aResults.size() )
 {
@@ -158,8 +164,12 @@ HierarchyResultSetDataSupplier::queryContent( sal_uInt32 
nIndex )
 // virtual
 bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 nIndex )
 {
-osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
+return getResultImpl(aGuard, nIndex);
+}
 
+bool HierarchyResultSetDataSupplier::getResultImpl( 
std::unique_lock& rGuard, sal_uInt32 nIndex )
+{
 if ( m_aResults.size() > nIndex )
 {
 // Result already present.
@@ -201,7 +211,7 @@ bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 
nIndex )
 if ( xResultSet.is() )
 {
 // Callbacks follow!
-aGuard.clear();
+rGuard.unlock();
 
 if ( nOldCount < m_aResults.size() )
 xResultSet->rowCountChanged(
@@ -209,6 +219,8 @@ bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 
nIndex )
 
 if ( m_bCountFinal )
 xResultSet->rowCountFinal();
+
+rGuard.lock();
 }
 
 return bFound;
@@ -218,7 +230,7 @@ bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 
nIndex )
 // virtual
 sal_uInt32 HierarchyResultSetDataSupplier::totalCount()
 {
-osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( m_bCountFinal )
 return m_aResults.size();
@@ -238,7 +250,7 @@ sal_uInt32 HierarchyResultSetDataSupplier::totalCount()
 if ( xResultSet.is() )
 {
 // Callbacks follow!
-aGuard.clear();
+aGuard.unlock();
 
 if ( nOldCount < m_aResults.size() )
 xResultSet->rowCountChanged(
@@ -269,7 +281,7 @@ bool HierarchyResultSetDataSupplier::isCountFinal()
 uno::Reference< sdbc::XRow >
 HierarchyResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex  )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( nIndex < m_aResults.size() )
 {
@@ -282,7 +294,7 @@ HierarchyResultSetDataSupplier::queryPropertyValues( 
sal_uInt32 nIndex  )
 }
 }
 
- 

[Libreoffice-commits] core.git: ucb/source

2022-05-14 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/file/filinl.hxx  |4 ++--
 ucb/source/ucp/file/filtask.hxx |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 27be40762e9e10de05cdc0692eef8a8c6fd5a23c
Author: Noel Grandin 
AuthorDate: Fri May 13 11:11:16 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat May 14 14:44:14 2022 +0200

pass-by-value in TaskManager::MyProperty::setValue

cheaper to move a temporary from some call-sites rather than
copy-construct

Change-Id: Ic1f994d0253c8368548295a08e83dfbbfae0a008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134307
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/file/filinl.hxx b/ucb/source/ucp/file/filinl.hxx
index b29d938def1c..3ea985ebc6cd 100644
--- a/ucb/source/ucp/file/filinl.hxx
+++ b/ucb/source/ucp/file/filinl.hxx
@@ -46,9 +46,9 @@ inline const sal_Int16& 
TaskManager::MyProperty::getAttributes() const
 {
 return Attributes;
 }
-inline void TaskManager::MyProperty::setValue( const css::uno::Any& theValue ) 
const
+inline void TaskManager::MyProperty::setValue( css::uno::Any theValue ) const
 {
-const_cast(this)->Value = theValue;
+const_cast(this)->Value = std::move(theValue);
 }
 inline void TaskManager::MyProperty::setState( const 
css::beans::PropertyState& theState ) const
 {
diff --git a/ucb/source/ucp/file/filtask.hxx b/ucb/source/ucp/file/filtask.hxx
index f8d070a4f36d..3fa4b85752ed 100644
--- a/ucb/source/ucp/file/filtask.hxx
+++ b/ucb/source/ucp/file/filtask.hxx
@@ -182,7 +182,7 @@ namespace fileaccess
 inline const sal_Int16& getAttributes() const;
 
 // The set* functions are declared const, because the key of 
"this" stays intact
-inline void setValue( const css::uno::Any& theValue ) const;
+inline void setValue( css::uno::Any theValue ) const;
 inline void setState( const css::beans::PropertyState& theState ) 
const;
 };
 


[Libreoffice-commits] core.git: ucb/source

2022-05-10 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/file/bc.cxx |  160 ++---
 ucb/source/ucp/file/bc.hxx |   14 +--
 ucb/source/ucp/file/filnot.cxx |2 
 3 files changed, 63 insertions(+), 113 deletions(-)

New commits:
commit 3816184ee779f32d2210c8fcc9f7dd2c77b6f736
Author: Noel Grandin 
AuthorDate: Sun May 8 21:24:32 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 10 19:39:36 2022 +0200

osl::Mutex->std::mutex in ucb::BaseContent

Change-Id: I03c25405b7e4206d6c81bc9c98b6cb07e376cd01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134084
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index e4ed0f180333..03590d3e0173 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -54,63 +54,42 @@ using namespace com::sun::star::ucb;
 
 class fileaccess::PropertyListeners
 {
-typedef 
comphelper::OInterfaceContainerHelper3 
ContainerHelper;
-osl::Mutex& rMutex;
+typedef 
comphelper::OInterfaceContainerHelper4 
ContainerHelper;
 std::unordered_map m_aMap;
+
 public:
-explicit PropertyListeners( ::osl::Mutex& aMutex )
-: rMutex( aMutex )
-{
-}
-void disposeAndClear(const lang::EventObject& rEvt)
+void disposeAndClear(std::unique_lock& rGuard, const 
lang::EventObject& rEvt)
 {
 // create a copy, because do not fire event in a guarded section
-std::unordered_map tempMap;
-{
-::osl::MutexGuard aGuard(rMutex);
-tempMap = std::move(m_aMap);
-}
+std::unordered_map tempMap = 
std::move(m_aMap);
 for (auto& rPair : tempMap)
-rPair.second.disposeAndClear(rEvt);
+rPair.second.disposeAndClear(rGuard, rEvt);
 }
-void addInterface(const OUString& rKey, const 
uno::Reference& rListener)
+void addInterface(std::unique_lock& rGuard, const OUString& 
rKey, const uno::Reference& rListener)
 {
-::osl::MutexGuard aGuard(rMutex);
-auto iter = m_aMap.find(rKey);
-if (iter == m_aMap.end())
-{
-auto ret = m_aMap.emplace(rKey, rMutex);
-ret.first->second.addInterface(rListener);
-}
-else
-iter->second.addInterface(rListener);
+m_aMap[rKey].addInterface(rGuard, rListener);
 }
-void removeInterface(const OUString& rKey, const 
uno::Reference& rListener)
+void removeInterface(std::unique_lock& rGuard, const OUString& 
rKey, const uno::Reference& rListener)
 {
-::osl::MutexGuard aGuard(rMutex);
-
 // search container with id rKey
 auto iter = m_aMap.find(rKey);
 // container found?
 if (iter != m_aMap.end())
-iter->second.removeInterface(rListener);
+iter->second.removeInterface(rGuard, rListener);
 }
-std::vector< OUString > getContainedTypes() const
+std::vector< OUString > getContainedTypes(std::unique_lock& 
rGuard) const
 {
-::osl::MutexGuard aGuard(rMutex);
 std::vector aInterfaceTypes;
 aInterfaceTypes.reserve(m_aMap.size());
 for (const auto& rPair : m_aMap)
 // are interfaces added to this container?
-if (rPair.second.getLength())
+if (rPair.second.getLength(rGuard))
 // yes, put the type in the array
 aInterfaceTypes.push_back(rPair.first);
 return aInterfaceTypes;
 }
-comphelper::OInterfaceContainerHelper3* 
getContainer(const OUString& rKey)
+comphelper::OInterfaceContainerHelper4* 
getContainer(std::unique_lock& , const OUString& rKey)
 {
-::osl::MutexGuard aGuard(rMutex);
-
 auto iter = m_aMap.find(rKey);
 if (iter != m_aMap.end())
 return &iter->second;
@@ -174,23 +153,18 @@ BaseContent::~BaseContent( )
 void SAL_CALL
 BaseContent::addEventListener( const Reference< lang::XEventListener >& 
Listener )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( ! m_pDisposeEventListeners )
-m_pDisposeEventListeners.reset(
-new comphelper::OInterfaceContainerHelper3( 
m_aEventListenerMutex ) );
-
-m_pDisposeEventListeners->addInterface( Listener );
+m_aDisposeEventListeners.addInterface( aGuard, Listener );
 }
 
 
 void SAL_CALL
 BaseContent::removeEventListener( const Reference< lang::XEventListener >& 
Listener )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( m_pDisposeEventListeners )
-m_pDisposeEventListeners->removeInterface( Listener );
+m_aDisposeEventListeners.removeInterface( aGuard, Listener );
 }
 
 
@@ -198,32 +172,19 @@ void SAL_CALL
 BaseContent::dispose()
 {
 lang::EventObject aEvt;
-
std::unique_ptr> 
pDisposeEventListeners;
-
std::unique_ptr> 
pContentEventListeners;
-
std::unique_ptr>
 pPropertySetInfoChangeListeners;
-std::unique

[Libreoffice-commits] core.git: ucb/source

2022-05-10 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/file/filrset.cxx |   98 ++--
 ucb/source/ucp/file/filrset.hxx |   14 ++---
 2 files changed, 43 insertions(+), 69 deletions(-)

New commits:
commit 3b2888fe0971b07d647a29467c317ba42a51b832
Author: Noel Grandin 
AuthorDate: Sun May 8 21:33:51 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 10 19:26:30 2022 +0200

osl::Mutex->std::mutex in ucb::XResultSet_impl

Change-Id: I67f70774c94d953880ebcf9fe9bf24a0492456f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134085
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx
index 5d880cc4a819..5f0d4ec3a25c 100644
--- a/ucb/source/ucp/file/filrset.cxx
+++ b/ucb/source/ucp/file/filrset.cxx
@@ -96,13 +96,9 @@ void SAL_CALL
 XResultSet_impl::addEventListener(
 const uno::Reference< lang::XEventListener >& Listener )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( ! m_pDisposeEventListeners )
-m_pDisposeEventListeners.reset(
-new comphelper::OInterfaceContainerHelper3( 
m_aEventListenerMutex ) );
-
-m_pDisposeEventListeners->addInterface( Listener );
+m_aDisposeEventListeners.addInterface( aGuard, Listener );
 }
 
 
@@ -110,47 +106,32 @@ void SAL_CALL
 XResultSet_impl::removeEventListener(
 const uno::Reference< lang::XEventListener >& Listener )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
-if ( m_pDisposeEventListeners )
-m_pDisposeEventListeners->removeInterface( Listener );
+m_aDisposeEventListeners.removeInterface( aGuard, Listener );
 }
 
 
 void SAL_CALL
 XResultSet_impl::dispose()
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 lang::EventObject aEvt;
 aEvt.Source = static_cast< lang::XComponent * >( this );
 
-if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
-{
-m_pDisposeEventListeners->disposeAndClear( aEvt );
-}
-if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
-{
-m_pRowCountListeners->disposeAndClear( aEvt );
-}
-if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
-{
-m_pIsFinalListeners->disposeAndClear( aEvt );
-}
+m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
+m_aRowCountListeners.disposeAndClear( aGuard, aEvt );
+m_aIsFinalListeners.disposeAndClear( aGuard, aEvt );
 }
 
 
-void XResultSet_impl::rowCountChanged()
+void XResultSet_impl::rowCountChanged(std::unique_lock& rGuard)
 {
 sal_Int32 aOldValue,aNewValue;
-std::vector< uno::Reference< beans::XPropertyChangeListener > > seq;
-{
-osl::MutexGuard aGuard( m_aMutex );
-if( m_pRowCountListeners )
-seq = m_pRowCountListeners->getElements();
-aNewValue = m_aItems.size();
-aOldValue = aNewValue-1;
-}
+std::vector< uno::Reference< beans::XPropertyChangeListener > > seq = 
m_aRowCountListeners.getElements(rGuard);
+aNewValue = m_aItems.size();
+aOldValue = aNewValue-1;
 beans::PropertyChangeEvent aEv;
 aEv.PropertyName = "RowCount";
 aEv.Further = false;
@@ -166,9 +147,8 @@ void XResultSet_impl::isFinalChanged()
 {
 std::vector< uno::Reference< beans::XPropertyChangeListener > > seq;
 {
-osl::MutexGuard aGuard( m_aMutex );
-if( m_pIsFinalListeners )
-seq = m_pIsFinalListeners->getElements();
+std::unique_lock aGuard( m_aMutex );
+seq = m_aIsFinalListeners.getElements(aGuard);
 m_bRowCountFinal = true;
 }
 beans::PropertyChangeEvent aEv;
@@ -217,11 +197,11 @@ XResultSet_impl::OneMore()
 
 if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && IsRegular )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 m_aItems.push_back( aRow );
 m_aIdents.emplace_back( );
 m_aUnqPath.push_back( aUnqPath );
-rowCountChanged();
+rowCountChanged(aGuard);
 return true;
 
 }
@@ -231,11 +211,11 @@ XResultSet_impl::OneMore()
 }
 else if( m_nOpenMode == ucb::OpenMode::FOLDERS && ! IsRegular )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 m_aItems.push_back( aRow );
 m_aIdents.emplace_back( );
 m_aUnqPath.push_back( aUnqPath );
-rowCountChanged();
+rowCountChanged(aGuard);
 return true;
 }
 else if( m_nOpenMode == ucb::OpenMode::FOLDERS && IsRegular )
@@ -244,11 +224,11 @@ XResultSet_impl::OneMore()
 }
 else
 {
-osl::MutexGuard aGuard( m_aMutex );

[Libreoffice-commits] core.git: ucb/source

2022-05-09 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/hierarchy/hierarchydata.cxx |   17 +
 ucb/source/ucp/hierarchy/hierarchydata.hxx |4 ++--
 2 files changed, 7 insertions(+), 14 deletions(-)

New commits:
commit 63a2f314250b05d484747fafc4a814a4553f461e
Author: Noel Grandin 
AuthorDate: Mon May 9 17:55:50 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 10 08:13:40 2022 +0200

osl::Mutex->std::mutex in HierarchyEntry

Several methods actually do not need locking because they are
calling other methods which are already locked, and thereafter
they touch only function-local state.

Change-Id: Ic0c55df65988fcc64899a31586f6a426825cba81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134088
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/hierarchy/hierarchydata.cxx 
b/ucb/source/ucp/hierarchy/hierarchydata.cxx
index bbdde5c2d1ff..3e802a4fd53d 100644
--- a/ucb/source/ucp/hierarchy/hierarchydata.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydata.cxx
@@ -123,7 +123,6 @@ HierarchyEntry::HierarchyEntry(
 
 bool HierarchyEntry::hasData()
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
 uno::Reference< container::XHierarchicalNameAccess > xRootReadAccess
 = getRootReadAccess();
 
@@ -140,8 +139,6 @@ bool HierarchyEntry::getData( HierarchyEntryData& rData )
 {
 try
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
 uno::Reference< container::XHierarchicalNameAccess > xRootReadAccess
 = getRootReadAccess();
 
@@ -242,7 +239,7 @@ bool HierarchyEntry::setData( const HierarchyEntryData& 
rData )
 {
 try
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( !m_xConfigProvider.is() )
 m_xConfigProvider.set(
@@ -454,10 +451,10 @@ bool HierarchyEntry::setData( const HierarchyEntryData& 
rData )
 bool HierarchyEntry::move(
 const OUString& rNewURL, const HierarchyEntryData& rData )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
 OUString aNewPath = createPathFromHierarchyURL( HierarchyUri(rNewURL) );
 
+std::unique_lock aGuard( m_aMutex );
+
 if ( aNewPath == m_aPath )
 return true;
 
@@ -736,7 +733,7 @@ bool HierarchyEntry::remove()
 {
 try
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( !m_xConfigProvider.is() )
 m_xConfigProvider.set(
@@ -844,8 +841,6 @@ bool HierarchyEntry::remove()
 
 bool HierarchyEntry::first( iterator & it )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
 if ( it.pos == -1 )
 {
 // Init...
@@ -912,8 +907,6 @@ bool HierarchyEntry::first( iterator & it )
 
 bool HierarchyEntry::next( iterator& it )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
 if ( it.pos == -1 )
 return first( it );
 
@@ -972,7 +965,7 @@ HierarchyEntry::getRootReadAccess()
 {
 if ( !m_xRootReadAccess.is() )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 if ( !m_xRootReadAccess.is() )
 {
 if ( m_bTriedToGetRootReadAccess )
diff --git a/ucb/source/ucp/hierarchy/hierarchydata.hxx 
b/ucb/source/ucp/hierarchy/hierarchydata.hxx
index 34e24cdb6c35..e81364243d31 100644
--- a/ucb/source/ucp/hierarchy/hierarchydata.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydata.hxx
@@ -20,9 +20,9 @@
 #pragma once
 
 #include 
-#include 
 #include 
 #include 
+#include 
 
 namespace com::sun::star {
 namespace container {
@@ -77,7 +77,7 @@ class HierarchyEntry
 OUString m_aServiceSpecifier;
 OUString m_aName;
 OUString m_aPath;
-::osl::Mutexm_aMutex;
+std::mutex m_aMutex;
 css::uno::Reference< css::uno::XComponentContext > m_xContext;
 css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider;
 css::uno::Reference< css::container::XHierarchicalNameAccess >


[Libreoffice-commits] core.git: ucb/source

2022-05-05 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   80 +
 1 file changed, 48 insertions(+), 32 deletions(-)

New commits:
commit cb64a52afc92891ab853b9bb1294610bb9ca98d0
Author: Michael Stahl 
AuthorDate: Wed May 4 18:04:14 2022 +0200
Commit: Michael Stahl 
CommitDate: Thu May 5 10:50:08 2022 +0200

ucb: webdav-curl: if LOCK fails, display error message

Sharepoint may reject LOCK with HTTP/1.1 403 FORBIDDEN
and then a dialog pops up via UUIInteractionHelper that says
"Server error message: ."

Let's actually put some error message in the dialog, why not the
HTTP status line, plus a little prefix to see which method failed.

Change-Id: Ied895787f813c5cddcb18eb4f693d5bfc8c62076
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133835
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index c3c873072ae1..09f36de25a34 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -752,15 +753,15 @@ struct CurlProcessor
 static auto URIReferenceToURI(CurlSession& rSession, OUString const& 
rURIReference) -> CurlUri;
 
 static auto ProcessRequestImpl(
-CurlSession& rSession, CurlUri const& rURI, curl_slist* 
pRequestHeaderList,
-uno::Reference const* pxOutStream,
+CurlSession& rSession, CurlUri const& rURI, OUString const& rMethod,
+curl_slist* pRequestHeaderList, uno::Reference 
const* pxOutStream,
 uno::Sequence const* pInData,
 ::std::pair<::std::vector const&, DAVResource&> const* 
pRequestedHeaders,
 ResponseHeaders& rHeaders) -> void;
 
 static auto ProcessRequest(
-CurlSession& rSession, CurlUri const& rURI, ::std::vector 
const& rOptions,
-DAVRequestEnvironment const* pEnv,
+CurlSession& rSession, CurlUri const& rURI, OUString const& rMethod,
+::std::vector const& rOptions, DAVRequestEnvironment 
const* pEnv,
 ::std::unique_ptr>
 pRequestHeaderList,
 uno::Reference const* pxOutStream,
@@ -807,7 +808,8 @@ auto CurlProcessor::URIReferenceToURI(CurlSession& 
rSession, OUString const& rUR
 
 /// main function to initiate libcurl requests
 auto CurlProcessor::ProcessRequestImpl(
-CurlSession& rSession, CurlUri const& rURI, curl_slist* const 
pRequestHeaderList,
+CurlSession& rSession, CurlUri const& rURI, OUString const& rMethod,
+curl_slist* const pRequestHeaderList,
 uno::Reference const* const pxOutStream,
 uno::Sequence const* const pInData,
 ::std::pair<::std::vector const&, DAVResource&> const* const 
pRequestedHeaders,
@@ -1007,6 +1009,15 @@ auto CurlProcessor::ProcessRequestImpl(
 }
 else
 {
+// create message containing the HTTP method and response status line
+OUString statusLine("\n" + rMethod + "\n=>\n");
+if (!rHeaders.HeaderFields.empty() && 
!rHeaders.HeaderFields.back().first.empty()
+&& rHeaders.HeaderFields.back().first.front().startsWith("HTTP"))
+{
+statusLine += ::rtl::OStringToOUString(
+::o3tl::trim(rHeaders.HeaderFields.back().first.front()),
+RTL_TEXTENCODING_ASCII_US);
+}
 switch (statusCode)
 {
 case SC_REQUEST_TIMEOUT:
@@ -1041,7 +1052,7 @@ auto CurlProcessor::ProcessRequestImpl(
 [[fallthrough]];
 }
 default:
-throw DAVException(DAVException::DAV_HTTP_ERROR, "", 
statusCode);
+throw DAVException(DAVException::DAV_HTTP_ERROR, statusLine, 
statusCode);
 }
 }
 
@@ -1098,8 +1109,8 @@ static auto TryRemoveExpiredLockToken(CurlSession& 
rSession, CurlUri const& rURI
 }
 
 auto CurlProcessor::ProcessRequest(
-CurlSession& rSession, CurlUri const& rURI, ::std::vector 
const& rOptions,
-DAVRequestEnvironment const* const pEnv,
+CurlSession& rSession, CurlUri const& rURI, OUString const& rMethod,
+::std::vector const& rOptions, DAVRequestEnvironment const* 
const pEnv,
 ::std::unique_ptr>
 pRequestHeaderList,
 uno::Reference const* const pxOutStream,
@@ -1293,7 +1304,7 @@ auto CurlProcessor::ProcessRequest(
 
 try
 {
-ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(), 
&xTempOutStream,
+ProcessRequestImpl(rSession, rURI, rMethod, 
pRequestHeaderList.get(), &xTempOutStream,
pxInStream ? &data : nullptr, 
pRequestedHeaders, headers);
 if (pxOutStream)
 { // only copy to result stream if transfer was successful
@@ -1482,7 +1493,8 @@ auto CurlSession::OPTIONS(OUString const& rURIReference,
 g_NoBody, { CURLOPT_CUSTOMREQUEST, "OPTIONS", "CURLOPT_CUSTOMREQUEST" }
 };
 
-CurlProcessor::P

[Libreoffice-commits] core.git: ucb/source

2022-05-04 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/DAVProperties.cxx|3 +++
 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx |   19 +--
 2 files changed, 16 insertions(+), 6 deletions(-)

New commits:
commit 65362d63b9019e45d1224ed6d78d4e1d443d6b00
Author: Michael Stahl 
AuthorDate: Tue May 3 19:11:31 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed May 4 10:22:06 2022 +0200

ucb: webdav-curl: fix handling of non-standard properties

Sharepoint uses properties like these:

"http://schemas.microsoft.com/repl/resourcetag";
"urn:schemas-microsoft-com:Win32CreationTime"

They aren't standard and don't match our own ucbprops namespace, and it
looks like they should be handled by an encoding to a name like
""

Unfortunately WebDAVResponseParser::endElement() didn't do that when
handling a PROPFIND reply to get the property names.

This causes a crash when all properties are copied in
UniversalContentBroker::globalTransfer(), which is called by
SfxMedium::DoBackup_Impl() when the setting
"/org.openoffice.Office.Common/Save/Document/CreateBackup"
is in effect.

Change-Id: I2d6480bfd2f828b6e7fc431ba4b333d95ec12718
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133769
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/DAVProperties.cxx 
b/ucb/source/ucp/webdav-curl/DAVProperties.cxx
index 746c82ad993d..8b3dce369c5e 100644
--- a/ucb/source/ucp/webdav-curl/DAVProperties.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVProperties.cxx
@@ -76,6 +76,9 @@ void DAVProperties::createSerfPropName( ::std::u16string_view 
const rFullName,
 }
 else
 {
+// this must not be a URI - WebDAVResponseParser must have converted it
+// to the "http://ucb.openoffice.org/dav/props/";;
 rName.name
diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx 
b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
index b2ec174688e4..9a0500d01bff 100644
--- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
@@ -523,6 +523,15 @@ namespace
 }
 }
 
+OUString MakePropertyName(WebDAVContext const& rContext)
+{
+OUString ret;
+OString const name(OUStringToOString(rContext.getName(), 
RTL_TEXTENCODING_UTF8));
+OString const nameSpace(OUStringToOString(rContext.getNamespace(), 
RTL_TEXTENCODING_UTF8));
+DAVProperties::createUCBPropName(nameSpace.getStr(), name.getStr(), 
ret);
+return ret;
+}
+
 void SAL_CALL WebDAVResponseParser::endElement( const OUString& aName )
 {
 const sal_Int32 nLen(aName.getLength());
@@ -532,9 +541,9 @@ namespace
 {
 if(collectThisPropertyAsName())
 {
-// When collecting property names and parent is prop, just 
append the prop name
-// to the collection, no need to parse deeper
-maPropStatNames.push_back(mpContext->getNamespace() + 
mpContext->getName());
+// name must be encoded as expected by createSerfPropName()
+OUString const name(MakePropertyName(*mpContext));
+maPropStatNames.emplace_back(name);
 }
 else
 {
@@ -851,9 +860,7 @@ namespace
 && isCollectingProperties())
 {
 http_dav_ucp::DAVPropertyValue 
aDAVPropertyValue;
-OString const 
name(OUStringToOString(mpContext->getParent()->getName(), 
RTL_TEXTENCODING_UTF8));
-OString const 
nameSpace(OUStringToOString(mpContext->getParent()->getNamespace(), 
RTL_TEXTENCODING_UTF8));
-
DAVProperties::createUCBPropName(nameSpace.getStr(), name.getStr(), 
aDAVPropertyValue.Name);
+aDAVPropertyValue.Name = 
MakePropertyName(*mpContext->getParent());
 if 
(UCBDeadPropertyValue::createFromXML(m_UCBType, m_UCBValue, 
aDAVPropertyValue.Value))
 {
 
maPropStatProperties.push_back(aDAVPropertyValue);


[Libreoffice-commits] core.git: ucb/source

2022-05-03 Thread Stephan Bergmann (via logerrit)
 ucb/source/core/FileAccess.cxx   |2 
 ucb/source/core/ucb.cxx  |6 -
 ucb/source/core/ucbcmds.cxx  |   56 +++-
 ucb/source/core/ucbstore.cxx |   20 ++---
 ucb/source/ucp/cmis/cmis_content.cxx |   34 +-
 ucb/source/ucp/cmis/cmis_repo_content.cxx|2 
 ucb/source/ucp/ext/ucpext_content.cxx|   13 +--
 ucb/source/ucp/file/filglob.cxx  |8 +-
 ucb/source/ucp/file/filtask.cxx  |   24 +++
 ucb/source/ucp/ftp/ftpcontent.cxx|4 -
 ucb/source/ucp/ftp/ftpresultsetI.cxx |2 
 ucb/source/ucp/hierarchy/hierarchycontent.cxx|   38 +--
 ucb/source/ucp/hierarchy/hierarchydata.cxx   |   14 ++--
 ucb/source/ucp/package/pkgcontent.cxx|   52 +++
 ucb/source/ucp/tdoc/tdoc_content.cxx |   70 ++--
 ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx |2 
 ucb/source/ucp/webdav-curl/ContentProperties.cxx |   28 
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   78 +++
 18 files changed, 225 insertions(+), 228 deletions(-)

New commits:
commit 605a34ccca64c86c89e4e8b6e4b049175a994d54
Author: Stephan Bergmann 
AuthorDate: Tue May 3 12:19:50 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Tue May 3 20:04:06 2022 +0200

Just use Any ctor instead of makeAny in ucb

Change-Id: I5e6964b5fa02d27d37ee772c761c72ed5b50492c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133755
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx
index e282d6b10c6d..24674ac07edd 100644
--- a/ucb/source/core/FileAccess.cxx
+++ b/ucb/source/core/FileAccess.cxx
@@ -288,7 +288,7 @@ void OFileAccess::kill( const OUString& FileURL )
 ucbhelper::Content aCnt( aDeleteObj.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), mxEnvironment, 
comphelper::getProcessComponentContext() );
 try
 {
-aCnt.executeCommand( "delete", makeAny( true ) );
+aCnt.executeCommand( "delete", Any( true ) );
 }
 catch ( css::ucb::CommandFailedException const & )
 {
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index 48d02b3dfdae..4e41e8cff567 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -583,7 +583,7 @@ Any SAL_CALL UniversalContentBroker::execute(
 if ( !( aCommand.Argument >>= aArg ) )
 {
 ucbhelper::cancelCommandExecution(
-makeAny( IllegalArgumentException(
+Any( IllegalArgumentException(
 "Wrong argument type!",
 static_cast< cppu::OWeakObject * >( this ),
 -1 ) ),
@@ -607,7 +607,7 @@ Any SAL_CALL UniversalContentBroker::execute(
 if ( !( aCommand.Argument >>= aCheckinArg ) )
 {
 ucbhelper::cancelCommandExecution(
-makeAny( IllegalArgumentException(
+Any( IllegalArgumentException(
 "Wrong argument type!",
 static_cast< cppu::OWeakObject * >( this ),
 -1 ) ),
@@ -623,7 +623,7 @@ Any SAL_CALL UniversalContentBroker::execute(
 
 
 ucbhelper::cancelCommandExecution(
-makeAny( UnsupportedCommandException(
+Any( UnsupportedCommandException(
 OUString(),
 static_cast< cppu::OWeakObject * >( this ) ) ),
 Environment );
diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx
index 88c187199665..f0e45b7cbed5 100644
--- a/ucb/source/core/ucbcmds.cxx
+++ b/ucb/source/core/ucbcmds.cxx
@@ -433,7 +433,7 @@ bool setTitle(
 ucb::Command aSetPropsCommand(
 "setPropertyValues",
 -1,
-uno::makeAny( aPropValues ) );
+uno::Any( aPropValues ) );
 
 uno::Any aResult
 = xCommandProcessor->execute( aSetPropsCommand, 0, xEnv );
@@ -501,7 +501,7 @@ uno::Reference< ucb::XContent > createNew(
 ucb::Command aGetPropsCommand(
 "getPropertyValues",
 -1,
-uno::makeAny( aPropsToObtain ) );
+uno::Any( aPropsToObtain ) );
 
 uno::Reference< sdbc::XRow > xRow;
 xCommandProcessorT->execute( aGetPropsCommand, 0, rContext.xEnv )  >>= 
xRow;
@@ -592,7 +592,7 @@ uno::Reference< ucb::XContent > createNew(
 else
 {
 ucbhelper::cancelCommandExecution(
-uno::makeAny( lang::IllegalArgumentException(
+uno::Any( lang::IllegalArgumentException(
 "Unknown transfer operation!",
 rContext.xProcessor,
 -1 ) ),

[Libreoffice-commits] core.git: ucb/source

2022-05-03 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 5801b887629dbd784116ec6878b61bb99e991647
Author: Michael Stahl 
AuthorDate: Mon May 2 16:44:31 2022 +0200
Commit: Michael Stahl 
CommitDate: Tue May 3 14:42:05 2022 +0200

tdf#148426 ucb: webdav-curl: fall-back to GET if OPTIONS status 500

With the ndr.de server, OPTIONS on an image URL results in a status 500
Internal Server Error and an unexpected closed connection:


16.591:info:ucb.ucp.webdav.curl:1634132:1634170:ucb/source/ucp/webdav-curl/CurlSession.cxx:285:
 debug log: 0x7f9c94004988: transfer closed with 222 bytes remaining to read

Apparently Neon always reported the closed connection problem with a
string:
"Could not read response body: connection was closed by server"

The HTTP status code is extracted in makeStatusCode() and the string
doesn't contain it, so the status is reported as 0 up the stack.

With curl, it can apparently happen that either CURLE_PARTIAL_FILE is
returned, in which case the status is ignored and reported as 0,
or CURLE_OK is returned and the status 500 is reported up the stack.

Adapt the handling in Content::open() to fall back to GET in case of a
500 status.

Change-Id: I5f3dce7f67ce25c87bf3882c89e7ff2d386bcbad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133707
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 995da2c7ba26..30fc16f2de56 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -2254,7 +2254,9 @@ uno::Any Content::open(
 DAVOptions aDAVOptions;
 getResourceOptions( xEnv, aDAVOptions, xResAccess );
 
-if ( aDAVOptions.getHttpResponseStatusCode() != SC_NONE )
+if (aDAVOptions.getHttpResponseStatusCode() != SC_NONE
+// tdf#148426 fall back to GET in case of 500
+&& aDAVOptions.getHttpResponseStatusCode() != 
SC_INTERNAL_SERVER_ERROR)
 {
 // throws exception as if there was a server error, a 
DAV exception
 throw DAVException( DAVException::DAV_HTTP_ERROR,


[Libreoffice-commits] core.git: ucb/source

2022-04-26 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/ftp/ftpurl.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit a8d01742e98d29a57be6d990b7331f789bc3a5ee
Author: Stephan Bergmann 
AuthorDate: Tue Apr 26 14:39:28 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Apr 26 17:08:19 2022 +0200

Improve some signed vs. unsigned comparisons

p2-fwd will always be non-negative

Change-Id: I143d7fd3c5ec192ffaeb56bc2e9f45ac5e83cb6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133439
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx
index 7910a293d570..13b7e839c3e9 100644
--- a/ucb/source/ucp/ftp/ftpurl.cxx
+++ b/ucb/source/ucp/ftp/ftpurl.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ftpurl.hxx"
 #include "ftpcontentprovider.hxx"
@@ -458,8 +459,8 @@ std::vector FTPURL::list(
 OUString viewurl(ident(true,false));
 
 while(true) {
-while(p2-fwd < int(len) && *p2 != '\n') ++p2;
-if(p2-fwd == int(len)) break;
+while(o3tl::make_unsigned(p2-fwd) < len && *p2 != '\n') ++p2;
+if(o3tl::make_unsigned(p2-fwd) == len) break;
 
 *p2 = 0;
 switch(osKind) {


[Libreoffice-commits] core.git: ucb/source

2022-04-20 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 8d9c56e8f42428fd6695942c673bffb985d22ad5
Author: Michael Stahl 
AuthorDate: Wed Apr 20 13:16:31 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed Apr 20 15:48:05 2022 +0200

tdf#146460 tdf#148429 ucb: webdav-curl: censor "curl" in UserAgent

This is now the second bug filed because a server replies with 403 if
the UserAgent contains the string "curl".

Change-Id: I25ca2d255af76a7ff4e64dad900b1bf0b78de59f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133212
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 79574118d210..c3c873072ae1 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -618,9 +618,10 @@ 
CurlSession::CurlSession(uno::Reference const& xContext,
 // en.wikipedia.org:80 forces back 403 "Scripts should use an informative
 // User-Agent string with contact information, or they may be IP-blocked
 // without notice" otherwise:
-OString const useragent(OString::Concat("LibreOffice " LIBO_VERSION_DOTTED 
" curl/")
-+ ::std::string_view(pVersion->version, 
strlen(pVersion->version)) + " "
-+ pVersion->ssl_version);
+OString const useragent(
+OString::Concat("LibreOffice " LIBO_VERSION_DOTTED " 
denylistedbackend/")
++ ::std::string_view(pVersion->version, strlen(pVersion->version)) + " 
"
++ pVersion->ssl_version);
 // looks like an explicit "User-Agent" header in CURLOPT_HTTPHEADER
 // will override CURLOPT_USERAGENT, see Curl_http_useragent(), so no need
 // to check anything here


[Libreoffice-commits] core.git: ucb/source

2022-04-20 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 6d7c3848560883034a4ff12ac1ef52d2d1d28606
Author: Michael Stahl 
AuthorDate: Tue Apr 19 20:08:42 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed Apr 20 11:53:40 2022 +0200

ucb: webdav-curl: check UseUserData before sending user name

Hope this should be acceptable.

Change-Id: I567e0cb358c8693db8f1c674b4fa6f841506f331
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133188
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index a8d7ef233030..995da2c7ba26 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3236,7 +3237,10 @@ void Content::lock(
 }
 
 uno::Any aOwnerAny;
-aOwnerAny <<= OUString("LibreOffice - " + 
::svt::LockFileCommon::GetOOOUserName());
+OUString const 
user(officecfg::Office::Common::Save::Document::UseUserData::get()
+? " - " + ::svt::LockFileCommon::GetOOOUserName()
+: OUString());
+aOwnerAny <<= OUString("LibreOffice" + user);
 
 ucb::Lock aLock(
 ucb::LockScope_EXCLUSIVE,


[Libreoffice-commits] core.git: ucb/source

2022-04-19 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx |   22 ++--
 1 file changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 68f41f4e2dcec65e8885cdfa658c0568a26182a9
Author: Michael Stahl 
AuthorDate: Tue Apr 19 17:34:52 2022 +0200
Commit: Michael Stahl 
CommitDate: Tue Apr 19 19:02:13 2022 +0200

ucb: webdav-curl: fix getting DAV:lockdiscovery property

commit b4576f3da4d90139fc5140962d13cb91dab98797 "tdf#82744: fix WebDAV
lock/unlock behaviour - part 3" added a call to get the
DAV:lockdiscovery property.

But WebDAVResponseParser puts lock related properties into a separate
return value maResult_Lock that is only returned for LOCK requests.

Just add it as a normal property too, then PROPFIND can get it, and
the dialog in SfxMedium::LockOrigFileOnDemand() no longer displays
"Unknown user".

Change-Id: Icee920588ea40b6e203b18287d75484528cfdebb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133185
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx 
b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
index 41f9a8232748..b2ec174688e4 100644
--- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
@@ -22,11 +22,13 @@
 #include "DAVProperties.hxx"
 #include "UCBDeadPropertyValue.hxx"
 
-#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +78,7 @@ namespace
 {
 WebDAVName_unknown = 0,
 WebDAVName_activelock,
+WebDAVName_lockdiscovery,
 WebDAVName_multistatus,
 WebDAVName_response,
 WebDAVName_href,
@@ -115,6 +118,7 @@ namespace
 if(aWebDAVNameMapperList.empty())
 {
 
aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("activelock"), 
WebDAVName_activelock));
+
aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("lockdiscovery"), 
WebDAVName_lockdiscovery));
 
aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("multistatus"), 
WebDAVName_multistatus));
 
aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("response"), 
WebDAVName_response));
 aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("href"), 
WebDAVName_href));
@@ -752,6 +756,20 @@ namespace
 maResult_Lock.push_back(maLock);
 break;
 }
+case WebDAVName_lockdiscovery:
+{
+// lockdiscovery may be requested via PROPFIND,
+// in addition to LOCK! so return it 2 ways
+if (isCollectingProperties())
+{
+http_dav_ucp::DAVPropertyValue 
aDAVPropertyValue;
+
+aDAVPropertyValue.Name = 
"DAV:lockdiscovery";
+aDAVPropertyValue.Value <<= 
::comphelper::containerToSequence(maResult_Lock);
+
maPropStatProperties.push_back(aDAVPropertyValue);
+}
+break;
+}
 case WebDAVName_propstat:
 {
 // propstat end, check status


[Libreoffice-commits] core.git: ucb/source

2022-04-14 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/file/bc.cxx  |2 +-
 ucb/source/ucp/file/filglob.cxx |   14 +++---
 ucb/source/ucp/file/filglob.hxx |4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 9798f8ad50602cf1313a2804b86e79fb80c1ec4d
Author: Noel Grandin 
AuthorDate: Thu Apr 14 13:46:47 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 14 17:45:14 2022 +0200

use more string_view in ucb

Change-Id: I0aa83a1496436d6fb77ad85d24ba088a7ff75f6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133014
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index fe6086160ac6..e4ed0f180333 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -1086,7 +1086,7 @@ void BaseContent::insert( sal_Int32 nMyCommandIdentifier,
 
 XInteractionRequestImpl aRequestImpl(
 rtl::Uri::decode(
-getTitle(m_aUncPath),
+OUString(getTitle(m_aUncPath)),
 rtl_UriDecodeWithCharset,
 RTL_TEXTENCODING_UTF8),
 static_cast(this),
diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx
index 5772934cd161..d93c41b514de 100644
--- a/ucb/source/ucp/file/filglob.cxx
+++ b/ucb/source/ucp/file/filglob.cxx
@@ -183,17 +183,17 @@ namespace fileaccess {
 }
 
 
-OUString getTitle( const OUString& aPath )
+std::u16string_view getTitle( std::u16string_view aPath )
 {
-sal_Int32 lastIndex = aPath.lastIndexOf( '/' );
-return aPath.copy( lastIndex + 1 );
+size_t lastIndex = aPath.rfind( '/' );
+return aPath.substr( lastIndex + 1 );
 }
 
 
-OUString getParentName( const OUString& aFileName )
+OUString getParentName( std::u16string_view aFileName )
 {
-sal_Int32 lastIndex = aFileName.lastIndexOf( '/' );
-OUString aParent = aFileName.copy( 0,lastIndex );
+size_t lastIndex = aFileName.rfind( '/' );
+OUString aParent( aFileName.substr( 0,lastIndex ) );
 
 if( aParent.endsWith(":") && aParent.getLength() == 6 )
 aParent += "/";
@@ -561,7 +561,7 @@ namespace fileaccess {
 prop.Handle = -1;
 OUString aClashingName(
 rtl::Uri::decode(
-getTitle(aUncPath),
+OUString(getTitle(aUncPath)),
 rtl_UriDecodeWithCharset,
 RTL_TEXTENCODING_UTF8));
 prop.Value <<= aClashingName;
diff --git a/ucb/source/ucp/file/filglob.hxx b/ucb/source/ucp/file/filglob.hxx
index 8d3412cdeb7b..b1235056ee18 100644
--- a/ucb/source/ucp/file/filglob.hxx
+++ b/ucb/source/ucp/file/filglob.hxx
@@ -50,12 +50,12 @@ namespace fileaccess {
std::u16string_view old_Name );
 
 // returns the last part of the given url as title
-extern OUString getTitle( const OUString& aPath );
+extern std::u16string_view getTitle( std::u16string_view aPath );
 
 // returns the url without last part as parentname
 // In case aFileName is root ( file:/// ) root is returned
 
-extern OUString getParentName( const OUString& aFileName );
+extern OUString getParentName( std::u16string_view aFileName );
 
 /**
  *  special copy:


[Libreoffice-commits] core.git: ucb/source

2022-04-13 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ab65a74998b498ff49c15db87fc14a9afa89d8bf
Author: Michael Stahl 
AuthorDate: Wed Apr 13 20:18:31 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed Apr 13 21:33:29 2022 +0200

ucb: webdav-curl: oops, increment after checking

Change-Id: I8c51fa88253dbda595eb859d58408ad70ad661e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132982
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index ed0fb60fb2b9..79574118d210 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1374,7 +1374,6 @@ auto CurlProcessor::ProcessRequest(
 }
 else if (pEnv && pEnv->m_xAuthListener)
 {
-++rnAuthRequests;
 ::std::optional const 
oRealm(ExtractRealm(
 headers, statusCode == SC_UNAUTHORIZED ? 
"WWW-Authenticate"
: 
"Proxy-Authenticate"));
@@ -1398,6 +1397,7 @@ auto CurlProcessor::ProcessRequest(
 // will always force its use no matter how hopeless
 bool const isSystemCredSupported((authAvail & 
authSystem) != 0
  && rnAuthRequests 
== 0);
+++rnAuthRequests;
 
 // Ask user via XInteractionHandler.
 // Warning: This likely runs an event loop which 
may


[Libreoffice-commits] core.git: ucb/source

2022-04-13 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 2bc4d1d22fdbd9d97c66bb53762b4b4bf7b61b47
Author: Michael Stahl 
AuthorDate: Wed Apr 13 16:50:30 2022 +0200
Commit: Michael Stahl 
CommitDate: Wed Apr 13 20:09:18 2022 +0200

ucb: webdav-curl: only allow system credentials for auth once

... and in any case abort authentication after 10 failed attempts.

Apparently some PasswordContainer can turn this into an infinite loop.

Change-Id: Ib2333b371a770999e8407ce7e1af21512aadb70d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132974
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 7ad84fb9b217..ed0fb60fb2b9 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1221,6 +1221,8 @@ auto CurlProcessor::ProcessRequest(
 }
 }
 bool isRetry(false);
+int nAuthRequests(0);
+int nAuthRequestsProxy(0);
 
 // libcurl does not have an authentication callback so handle auth
 // related status codes and requesting credentials via this loop
@@ -1363,8 +1365,16 @@ auto CurlProcessor::ProcessRequest(
 case SC_UNAUTHORIZED:
 case SC_PROXY_AUTHENTICATION_REQUIRED:
 {
-if (pEnv && pEnv->m_xAuthListener)
+auto& rnAuthRequests(statusCode == SC_UNAUTHORIZED ? 
nAuthRequests
+   : 
nAuthRequestsProxy);
+if (rnAuthRequests == 10)
 {
+SAL_INFO("ucb.ucp.webdav.curl", "aborting 
authentication after "
+<< 
rnAuthRequests << " attempts");
+}
+else if (pEnv && pEnv->m_xAuthListener)
+{
+++rnAuthRequests;
 ::std::optional const 
oRealm(ExtractRealm(
 headers, statusCode == SC_UNAUTHORIZED ? 
"WWW-Authenticate"
: 
"Proxy-Authenticate"));
@@ -1381,7 +1391,13 @@ auto CurlProcessor::ProcessRequest(
   &authAvail);
 assert(rc == CURLE_OK);
 (void)rc;
-bool const isSystemCredSupported((authAvail & 
authSystem) != 0);
+// only allow SystemCredentials once - the
+// PasswordContainer may have stored it in the
+// Config (TrySystemCredentialsFirst or
+// AuthenticateUsingSystemCredentials) and then it
+// will always force its use no matter how hopeless
+bool const isSystemCredSupported((authAvail & 
authSystem) != 0
+ && rnAuthRequests 
== 0);
 
 // Ask user via XInteractionHandler.
 // Warning: This likely runs an event loop which 
may


[Libreoffice-commits] core.git: ucb/source

2022-02-08 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/SerfLockStore.cxx |   12 ++--
 ucb/source/ucp/webdav-curl/SerfLockStore.hxx |2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 7ac06bdbf8a2b9fed512ae7817131f26f3744898
Author: Michael Stahl 
AuthorDate: Tue Feb 8 11:42:03 2022 +0100
Commit: Michael Stahl 
CommitDate: Tue Feb 8 16:02:30 2022 +0100

ucb: webdav-curl: fix deadlock in SerfLockStore::refreshLocks()

... and removeLock()

(regression from commit 03c7cd9bbe3d46bb13a5cf1ad72ba0eaf702747e)

Change-Id: I4029a7079c7331a7a00c11e2bec5639086bcc928
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129666
Reviewed-by: Noel Grandin 
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
index 000edaaa15ee..005e7c5f10dd 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -191,19 +191,19 @@ void SerfLockStore::removeLock(const OUString& rURI)
 {
 std::unique_lock aGuard( m_aMutex );
 
-removeLockImpl(rURI);
+removeLockImpl(aGuard, rURI);
 }
 
-void SerfLockStore::removeLockImpl(const OUString& rURI)
+void SerfLockStore::removeLockImpl(std::unique_lock & rGuard, 
const OUString& rURI)
 {
 assert(rURI.startsWith("http://";) || rURI.startsWith("https://";));
 
-std::unique_lock aGuard( m_aMutex );
-
 m_aLockInfoMap.erase(rURI);
 
 if ( m_aLockInfoMap.empty() )
-stopTicker(aGuard);
+{
+stopTicker(rGuard);
+}
 }
 
 void SerfLockStore::refreshLocks()
@@ -249,7 +249,7 @@ void SerfLockStore::refreshLocks()
 
 for (auto const& rLock : authFailedLocks)
 {
-removeLockImpl(rLock);
+removeLockImpl(aGuard, rLock);
 }
 }
 
diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
index 8ae9c0786af5..6765c7990b12 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
@@ -81,7 +81,7 @@ public:
 void refreshLocks();
 
 private:
-void removeLockImpl(const OUString& rURI);
+void removeLockImpl(std::unique_lock & rGuard, const OUString& 
rURI);
 void startTicker();
 void stopTicker(std::unique_lock & rGuard);
 };


[Libreoffice-commits] core.git: ucb/source

2022-02-08 Thread Henry Castro (via logerrit)
 ucb/source/ucp/webdav-curl/SerfLockStore.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit abc32f115ffd8df20ed122f6a769027b68da13f2
Author: Henry Castro 
AuthorDate: Thu Feb 3 09:16:10 2022 -0400
Commit: Michael Stahl 
CommitDate: Tue Feb 8 11:26:35 2022 +0100

ucb: webdav: fix "__lll_lock_wait () "

0  0x774bc29c in __lll_lock_wait () at 
../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:103
1  0x774b5714 in __GI___pthread_mutex_lock (mutex=0x7fffbfad04c0 
<(anonymous namespace)::g_Init>)
at ../nptl/pthread_mutex_lock.c:80
2  0x7fffbf996ed2 in __gthread_mutex_lock(__gthread_mutex_t*) 
(__mutex=0x7fffbfad04c0 <(anonymous namespace)::g_Init>)
at /usr/include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:748
3  0x7fffbf9b0b56 in std::mutex::lock() (this=0x7fffbfad04c0 
<(anonymous namespace)::g_Init>)
at /usr/include/c++/8/bits/std_mutex.h:103
4  0x7fffbf9b69dd in std::unique_lock::lock() 
(this=0x7fff97e0)
at /usr/include/c++/8/bits/std_mutex.h:267
5  0x7fffbf9e0878 in 
std::unique_lock::unique_lock(std::mutex&) (this=0x7fff97e0, 
__m=...)
at /usr/include/c++/8/bits/std_mutex.h:197
6  0x7fffbf9f01e7 in http_dav_ucp::SerfLockStore::startTicker() 
(this=0x7fffbfad04c0 <(anonymous namespace)::g_Init>)  at 
/home/hcastro/projects/online/lib/core/sid/ucb/source/ucp/webdav-curl/SerfLockStore.cxx:107
7  0x7fffbf9f0728 in http_dav_ucp::SerfLockStore::addLock(rtl::OUString 
const&, com::sun::star::ucb::Lock const&, rtl::OUString const&, 
rtl::Reference const&, int)

Change-Id: I01d3c1f67281ceab38e0452ba9cc714d4aacdbcb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129447
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
index d39df9a49e58..000edaaa15ee 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -176,11 +176,12 @@ void SerfLockStore::addLock( const OUString& rURI,
  sal_Int32 nLastChanceToSendRefreshRequest )
 {
 assert(rURI.startsWith("http://";) || rURI.startsWith("https://";));
+{
+std::unique_lock aGuard( m_aMutex );
 
-std::unique_lock aGuard( m_aMutex );
-
-m_aLockInfoMap[ rURI ]
-= LockInfo(sToken, rLock, xSession, nLastChanceToSendRefreshRequest);
+m_aLockInfoMap[ rURI ]
+= LockInfo(sToken, rLock, xSession, 
nLastChanceToSendRefreshRequest);
+}
 
 startTicker();
 }


[Libreoffice-commits] core.git: ucb/source

2022-01-31 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 9b5894e67d6ba820443c9f1130231be8c0278f82
Author: Michael Stahl 
AuthorDate: Mon Jan 31 13:47:50 2022 +0100
Commit: Michael Stahl 
CommitDate: Mon Jan 31 16:55:21 2022 +0100

ucb: webdav-curl: suppress libcurl proxy detection

The UCP already reads proxy configuration from configmgr, including a
list of hosts that should ignore proxy: Inet::Settings::ooInetNoProxy

Hence also set an empty string with CURLOPT_PROXY, disabling the
detect_proxy() function.

(The neon library was never built with the libproxy dependency it
needs to detect proxies.)

Change-Id: I279d1b85dbdd2455791d393e634a1fa7c1c17ce0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129220
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 542aba73edcf..90ce91c3cddc 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -679,18 +679,19 @@ 
CurlSession::CurlSession(uno::Reference const& xContext,
 assert(rc == CURLE_OK);
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_HTTPAUTH, CURLAUTH_ANY);
 assert(rc == CURLE_OK); // ANY is always available
+// always set CURLOPT_PROXY to suppress proxy detection in libcurl
+OString const utf8Proxy(OUStringToOString(m_Proxy.aName, 
RTL_TEXTENCODING_UTF8));
+rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_PROXY, utf8Proxy.getStr());
+if (rc != CURLE_OK)
+{
+SAL_WARN("ucb.ucp.webdav.curl", "CURLOPT_PROXY failed: " << 
GetErrorString(rc));
+throw DAVException(DAVException::DAV_SESSION_CREATE,
+   ConnectionEndPointString(m_Proxy.aName, 
m_Proxy.nPort));
+}
 if (!m_Proxy.aName.isEmpty())
 {
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_PROXYPORT, 
static_cast(m_Proxy.nPort));
 assert(rc == CURLE_OK);
-OString const utf8Proxy(OUStringToOString(m_Proxy.aName, 
RTL_TEXTENCODING_UTF8));
-rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_PROXY, 
utf8Proxy.getStr());
-if (rc != CURLE_OK)
-{
-SAL_WARN("ucb.ucp.webdav.curl", "CURLOPT_PROXY failed: " << 
GetErrorString(rc));
-throw DAVException(DAVException::DAV_SESSION_CREATE,
-   ConnectionEndPointString(m_Proxy.aName, 
m_Proxy.nPort));
-}
 // set this initially, may be overwritten during authentication
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_PROXYAUTH, CURLAUTH_ANY);
 assert(rc == CURLE_OK); // ANY is always available


[Libreoffice-commits] core.git: ucb/source

2022-01-20 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   91 +++--
 1 file changed, 50 insertions(+), 41 deletions(-)

New commits:
commit f8ef102a82513233fb794109cecd599304e78407
Author: Michael Stahl 
AuthorDate: Thu Jan 20 12:59:20 2022 +0100
Commit: Michael Stahl 
CommitDate: Thu Jan 20 15:21:46 2022 +0100

ucb: webdav-curl: fix the debug logging more

Unfortunately didn't work in the cases where it needed to work.

Change-Id: Ia132ba38fb6f0be4481dce48da2d713d47fa8bf7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128658
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 9af6c4284355..542aba73edcf 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -161,6 +161,15 @@ struct CurlOption
 }
 };
 
+// NOBODY will prevent logging the response body in ProcessRequest() exception
+// handler, so only use it if logging is disabled
+const CurlOption g_NoBody{ CURLOPT_NOBODY,
+   sal_detail_log_report(SAL_DETAIL_LOG_LEVEL_INFO, 
"ucb.ucp.webdav.curl")
+   == SAL_DETAIL_LOG_ACTION_IGNORE
+   ? 1L
+   : 0L,
+   nullptr };
+
 /// combined guard class to ensure things are released in correct order,
 /// particularly in ProcessRequest() error handling
 class Guard
@@ -332,7 +341,8 @@ static size_t write_callback(char* const ptr, size_t const 
size, size_t const nm
 {
 return 0; // that is an error
 }
-if (200 <= *oResponseCode && *oResponseCode < 300)
+// always write, for exception handler in ProcessRequest()
+//if (200 <= *oResponseCode && *oResponseCode < 300)
 {
 try
 {
@@ -1271,49 +1281,48 @@ auto CurlProcessor::ProcessRequest(
 }
 
 ResponseHeaders headers(rSession.m_pCurl.get());
-uno::Reference xSeqOutStream;
-uno::Reference xDebugOutStream;
-if (!pxOutStream)
-{
-xSeqOutStream = 
io::SequenceOutputStream::create(rSession.m_xContext);
-xDebugOutStream = xSeqOutStream;
-}
+// always pass a stream for debug logging, buffer the result body
+uno::Reference const xSeqOutStream(
+io::SequenceOutputStream::create(rSession.m_xContext));
+uno::Reference const xTempOutStream(xSeqOutStream);
+assert(xTempOutStream.is());
 
 try
 {
-ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(),
-   pxOutStream ? pxOutStream : &xDebugOutStream,
+ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(), 
&xTempOutStream,
pxInStream ? &data : nullptr, 
pRequestedHeaders, headers);
+if (pxOutStream)
+{ // only copy to result stream if transfer was successful
+(*pxOutStream)->writeBytes(xSeqOutStream->getWrittenBytes());
+(*pxOutStream)->closeOutput(); // signal EOF
+}
 }
 catch (DAVException const& rException)
 {
-if (xDebugOutStream.is())
+// log start of request body if there was any
+auto const bytes(xSeqOutStream->getWrittenBytes());
+auto const len(::std::min(bytes.getLength(), 1));
+SAL_INFO("ucb.ucp.webdav.curl",
+ "DAVException; (first) " << len << " bytes of data 
received:");
+if (0 < len)
 {
-auto const bytes(xSeqOutStream->getWrittenBytes());
-auto const len(::std::min(bytes.getLength(), 
1));
-SAL_INFO("ucb.ucp.webdav.curl",
- "DAVException; (first) " << len << " bytes of data 
received:");
-if (0 < len)
+OStringBuffer buf(len);
+for (sal_Int32 i = 0; i < len; ++i)
 {
-OStringBuffer buf(len);
-for (sal_Int32 i = 0; i < len; ++i)
+if (bytes[i] < 0x20) // also if negative
 {
-if (bytes[i] < 0x20) // also if negative
-{
-static char const hexDigit[16]
-= { '0', '1', '2', '3', '4', '5', '6', '7',
-'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-buf.append("\\x");
-
buf.append(hexDigit[static_cast(bytes[i]) >> 4]);
-buf.append(hexDigit[bytes[i] & 0x0F]);
-}
-else
-{
-buf.append(static_cast(bytes[i]));
-}
+static char 

[Libreoffice-commits] core.git: ucb/source

2022-01-18 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   39 -
 1 file changed, 38 insertions(+), 1 deletion(-)

New commits:
commit d32e7ddb6497c3b36b86589765790dbfc3de335e
Author: Michael Stahl 
AuthorDate: Mon Jan 17 19:07:52 2022 +0100
Commit: Michael Stahl 
CommitDate: Tue Jan 18 10:52:07 2022 +0100

ucb: webdav-curl: add even more logging

Some servers like to put error messages in the body if there's a
problem, let's try to to dump that via SAL_INFO, unless it's too big.

Change-Id: I9a29de59ab299f4bfda08ecc3be838972cf0c71d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128513
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 89c60cbac1cc..9af6c4284355 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1271,14 +1271,51 @@ auto CurlProcessor::ProcessRequest(
 }
 
 ResponseHeaders headers(rSession.m_pCurl.get());
+uno::Reference xSeqOutStream;
+uno::Reference xDebugOutStream;
+if (!pxOutStream)
+{
+xSeqOutStream = 
io::SequenceOutputStream::create(rSession.m_xContext);
+xDebugOutStream = xSeqOutStream;
+}
 
 try
 {
-ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(), 
pxOutStream,
+ProcessRequestImpl(rSession, rURI, pRequestHeaderList.get(),
+   pxOutStream ? pxOutStream : &xDebugOutStream,
pxInStream ? &data : nullptr, 
pRequestedHeaders, headers);
 }
 catch (DAVException const& rException)
 {
+if (xDebugOutStream.is())
+{
+auto const bytes(xSeqOutStream->getWrittenBytes());
+auto const len(::std::min(bytes.getLength(), 
1));
+SAL_INFO("ucb.ucp.webdav.curl",
+ "DAVException; (first) " << len << " bytes of data 
received:");
+if (0 < len)
+{
+OStringBuffer buf(len);
+for (sal_Int32 i = 0; i < len; ++i)
+{
+if (bytes[i] < 0x20) // also if negative
+{
+static char const hexDigit[16]
+= { '0', '1', '2', '3', '4', '5', '6', '7',
+'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+buf.append("\\x");
+
buf.append(hexDigit[static_cast(bytes[i]) >> 4]);
+buf.append(hexDigit[bytes[i] & 0x0F]);
+}
+else
+{
+buf.append(static_cast(bytes[i]));
+}
+}
+SAL_INFO("ucb.ucp.webdav.curl", buf.makeStringAndClear());
+}
+}
+
 // error handling part 3: special HTTP status codes
 // that require unlocking m_Mutex to handle
 if (rException.getError() == DAVException::DAV_HTTP_ERROR)


[Libreoffice-commits] core.git: ucb/source

2022-01-14 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 2a506a2e2b747e28e1684e0748fa3d237c65772b
Author: Michael Stahl 
AuthorDate: Thu Jan 13 20:00:03 2022 +0100
Commit: Michael Stahl 
CommitDate: Fri Jan 14 11:12:18 2022 +0100

ucb: webdav-curl: build debug callback also in release builds

And fix the Authorization header redaction, it was assuming there is one
call per header line, but all headers are passed in one call.

Change-Id: Idf86b9e0a4a8f8e9fb39098402a002abc394a589
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128395
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 09fddeb95203..89c60cbac1cc 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -266,7 +266,6 @@ namespace http_dav_ucp
 {
 // libcurl callbacks:
 
-#if OSL_DEBUG_LEVEL > 0
 static int debug_callback(CURL* handle, curl_infotype type, char* data, size_t 
size,
   void* /*userdata*/)
 {
@@ -282,10 +281,17 @@ static int debug_callback(CURL* handle, curl_infotype 
type, char* data, size_t s
 return 0;
 case CURLINFO_HEADER_OUT:
 {
+// unlike IN, this is all headers in one call
 OString tmp(data, size);
-if (tmp.startsWith("Authorization: "))
+sal_Int32 const start(tmp.indexOf("Authorization: "));
+if (start != -1)
 {
-tmp = "Authorization: " + OString::number(tmp.getLength() - 
15) + " bytes redacted";
+sal_Int32 const end(tmp.indexOf("\r\n", start));
+assert(end != -1);
+sal_Int32 const len(SAL_N_ELEMENTS("Authorization: ") - 1);
+tmp = tmp.replaceAt(
+start + len, end - start - len,
+OStringConcatenation(OString::number(end - start - len) + 
" bytes redacted"));
 }
 SAL_INFO("ucb.ucp.webdav.curl", "CURLINFO_HEADER_OUT: " << handle 
<< ": " << tmp);
 return 0;
@@ -309,7 +315,6 @@ static int debug_callback(CURL* handle, curl_infotype type, 
char* data, size_t s
 SAL_INFO("ucb.ucp.webdav.curl", "debug log: " << handle << ": " << pType 
<< " " << size);
 return 0;
 }
-#endif
 
 static size_t write_callback(char* const ptr, size_t const size, size_t const 
nmemb,
  void* const userdata)
@@ -620,7 +625,7 @@ 
CurlSession::CurlSession(uno::Reference const& xContext,
 // this supposedly gives the highest quality error reporting
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_ERRORBUFFER, m_ErrorBuffer);
 assert(rc == CURLE_OK);
-#if OSL_DEBUG_LEVEL > 0
+#if 1
 // just for debugging...
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_DEBUGFUNCTION, 
debug_callback);
 assert(rc == CURLE_OK);


[Libreoffice-commits] core.git: ucb/source

2021-12-27 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/webdav-curl/SerfLockStore.cxx |   28 ---
 ucb/source/ucp/webdav-curl/SerfLockStore.hxx |7 +++---
 2 files changed, 21 insertions(+), 14 deletions(-)

New commits:
commit 03c7cd9bbe3d46bb13a5cf1ad72ba0eaf702747e
Author: Noel Grandin 
AuthorDate: Thu Dec 23 17:27:58 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 17:05:02 2021 +0100

osl::Mutex->std::mutex in SerfLockStore

Change-Id: I931e20b4b604ebd6fac83006deeabaa5939e8c7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127587
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
index 932fb5262411..ec47278b843b 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -89,9 +89,9 @@ SerfLockStore::SerfLockStore()
 
 SerfLockStore::~SerfLockStore()
 {
-osl::ResettableMutexGuard aGuard(m_aMutex);
+std::unique_lock aGuard(m_aMutex);
 stopTicker(aGuard);
-aGuard.reset(); // actually no threads should even try to access members 
now
+aGuard.lock(); // actually no threads should even try to access members now
 m_bFinishing = true;
 
 // release active locks, if any.
@@ -106,7 +106,7 @@ SerfLockStore::~SerfLockStore()
 
 void SerfLockStore::startTicker()
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if ( !m_pTickerThread.is() )
 {
@@ -116,7 +116,7 @@ void SerfLockStore::startTicker()
 }
 
 
-void SerfLockStore::stopTicker(osl::ClearableMutexGuard & rGuard)
+void SerfLockStore::stopTicker(std::unique_lock & rGuard)
 {
 rtl::Reference pTickerThread;
 
@@ -128,7 +128,7 @@ void SerfLockStore::stopTicker(osl::ClearableMutexGuard & 
rGuard)
 m_pTickerThread.clear();
 }
 
-rGuard.clear();
+rGuard.unlock();
 
 if (pTickerThread.is() && pTickerThread->getIdentifier() != 
osl::Thread::getCurrentIdentifier())
 {
@@ -141,7 +141,7 @@ SerfLockStore::getLockTokenForURI(OUString const& rURI, 
css::ucb::Lock const*con
 {
 assert(rURI.startsWith("http://";) || rURI.startsWith("https://";));
 
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 auto const it(m_aLockInfoMap.find(rURI));
 
@@ -179,7 +179,7 @@ void SerfLockStore::addLock( const OUString& rURI,
 {
 assert(rURI.startsWith("http://";) || rURI.startsWith("https://";));
 
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 m_aLockInfoMap[ rURI ]
 = LockInfo(sToken, rLock, xSession, nLastChanceToSendRefreshRequest);
@@ -189,10 +189,17 @@ void SerfLockStore::addLock( const OUString& rURI,
 
 
 void SerfLockStore::removeLock(const OUString& rURI)
+{
+std::unique_lock aGuard( m_aMutex );
+
+removeLockImpl(rURI);
+}
+
+void SerfLockStore::removeLockImpl(const OUString& rURI)
 {
 assert(rURI.startsWith("http://";) || rURI.startsWith("https://";));
 
-osl::ClearableMutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 m_aLockInfoMap.erase(rURI);
 
@@ -200,10 +207,9 @@ void SerfLockStore::removeLock(const OUString& rURI)
 stopTicker(aGuard);
 }
 
-
 void SerfLockStore::refreshLocks()
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 ::std::vector authFailedLocks;
 
@@ -244,7 +250,7 @@ void SerfLockStore::refreshLocks()
 
 for (auto const& rLock : authFailedLocks)
 {
-removeLock(rLock);
+removeLockImpl(rLock);
 }
 }
 
diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
index 7e0757004c41..c3c645b66f2c 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx
@@ -21,7 +21,7 @@
 #pragma once
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -58,7 +58,7 @@ typedef std::map< OUString, LockInfo > LockInfoMap;
 
 class SerfLockStore
 {
-osl::Mutex m_aMutex;
+std::mutex m_aMutex;
 rtl::Reference< TickerThread > m_pTickerThread;
 bool   m_bFinishing;
 LockInfoMapm_aLockInfoMap;
@@ -82,8 +82,9 @@ public:
 void refreshLocks();
 
 private:
+void removeLockImpl(const OUString& rURI);
 void startTicker();
-void stopTicker(osl::ClearableMutexGuard & rGuard);
+void stopTicker(std::unique_lock & rGuard);
 };
 
 } // namespace http_dav_ucp


[Libreoffice-commits] core.git: ucb/source

2021-12-27 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx |  130 +++---
 ucb/source/ucp/webdav-curl/webdavdatasupplier.hxx |   27 +++-
 2 files changed, 67 insertions(+), 90 deletions(-)

New commits:
commit c350c74dbd7783a5efd5ba04e937001670101243
Author: Noel Grandin 
AuthorDate: Thu Dec 23 17:20:32 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 17:04:51 2021 +0100

remove pImpl from DataSupplier

Change-Id: I0fe2d3d83c1d45abc90d22406265a034140bee02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127566
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx 
b/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx
index d97e6ce3e320..c5a008af8409 100644
--- a/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx
@@ -20,7 +20,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -29,7 +28,6 @@
 #include 
 #include "webdavdatasupplier.hxx"
 #include "webdavcontent.hxx"
-#include "ContentProperties.hxx"
 #include "DAVProperties.hxx"
 #include "CurlUri.hxx"
 #include 
@@ -42,22 +40,8 @@ using namespace http_dav_ucp;
 namespace http_dav_ucp
 {
 
-
-// struct ResultListEntry.
-
 namespace {
 
-struct ResultListEntry
-{
-OUString aId;
-uno::Reference< ucb::XContentIdentifier > xId;
-uno::Reference< ucb::XContent >   xContent;
-uno::Reference< sdbc::XRow >  xRow;
-std::unique_ptr pData;
-
-explicit ResultListEntry( std::unique_ptr && pEntry ) : 
pData( std::move(pEntry) ) {}
-};
-
 auto DumpResources(std::vector const& rResources) -> OUString
 {
 OUStringBuffer buf;
@@ -89,33 +73,6 @@ auto DumpResources(std::vector const& 
rResources) -> OUString
 
 }
 
-// ResultList.
-
-
-typedef std::vector> ResultList;
-
-
-// struct DataSupplier_Impl.
-
-
-struct DataSupplier_Impl
-{
-osl::Mutex   m_aMutex;
-ResultList   m_Results;
-rtl::Reference< Content >m_xContent;
-uno::Reference< uno::XComponentContext > m_xContext;
-sal_Int32 const  m_nOpenMode;
-bool m_bCountFinal;
-bool m_bThrowException;
-
-DataSupplier_Impl(
-const uno::Reference< uno::XComponentContext >& rxContext,
-const rtl::Reference< Content >& rContent,
-sal_Int32 nOpenMode )
-: m_xContent( rContent ), m_xContext( rxContext ), m_nOpenMode( nOpenMode 
),
-  m_bCountFinal( false ), m_bThrowException( false ) {}
-};
-
 }
 
 
@@ -126,7 +83,8 @@ DataSupplier::DataSupplier(
 const uno::Reference< uno::XComponentContext >& rxContext,
 const rtl::Reference< Content >& rContent,
 sal_Int32 nOpenMode )
-: m_pImpl(std::make_unique(rxContext, rContent, nOpenMode))
+: m_xContent( rContent ), m_xContext( rxContext ), m_nOpenMode( nOpenMode 
),
+  m_bCountFinal( false ), m_bThrowException( false )
 {
 }
 
@@ -139,11 +97,11 @@ DataSupplier::~DataSupplier()
 // virtual
 OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+osl::Guard< osl::Mutex > aGuard( m_aMutex );
 
-if (nIndex < m_pImpl->m_Results.size())
+if (nIndex < m_Results.size())
 {
-OUString aId = m_pImpl->m_Results[ nIndex ]->aId;
+OUString aId = m_Results[ nIndex ]->aId;
 if ( aId.getLength() )
 {
 // Already cached.
@@ -153,9 +111,9 @@ OUString DataSupplier::queryContentIdentifierString( 
sal_uInt32 nIndex )
 
 if ( getResult( nIndex ) )
 {
-OUString aId = m_pImpl->m_xContent->getResourceAccess().getURL();
+OUString aId = m_xContent->getResourceAccess().getURL();
 
-const ContentProperties& props(*(m_pImpl->m_Results[ nIndex ]->pData));
+const ContentProperties& props(*(m_Results[ nIndex ]->pData));
 
 if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
 aId += "/";
@@ -165,7 +123,7 @@ OUString DataSupplier::queryContentIdentifierString( 
sal_uInt32 nIndex )
 if ( props.isTrailingSlash() )
 aId += "/";
 
-m_pImpl->m_Results[ nIndex ]->aId = aId;
+m_Results[ nIndex ]->aId = aId;
 return aId;
 }
 return OUString();
@@ -176,12 +134,12 @@ OUString DataSupplier::queryContentIdentifierString( 
sal_uInt32 nIndex )
 uno::Reference< ucb::XContentIdentifier >
 DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
 {
-osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+osl::Guard< osl::Mutex > aGuard( m_aMutex );
 
-if (nIndex < m_pImpl->m_Results.size())
+if (nIndex < m_Results.size())
 {
 uno::Reference< ucb::XContentIdentifier > xId
-= m_pImpl->m_Results[ nIndex ]-

[Libreoffice-commits] core.git: ucb/source

2021-12-27 Thread Noel Grandin (via logerrit)
 ucb/source/core/ucbstore.cxx |7 +++
 ucb/source/core/ucbstore.hxx |7 +++
 2 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 42ac3410c0642c5c00023c3d6fb2df093af5fe94
Author: Noel Grandin 
AuthorDate: Mon Dec 27 09:49:15 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 13:28:56 2021 +0100

use comphelper::WeakComponentImplHelper in UcbStore

Change-Id: I0246fe4c93208e87bddcf08ce6423d1e8f7505d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127552
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index a0eece461c7d..fcdc0138ede0 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -128,8 +128,7 @@ public:
 
 
 UcbStore::UcbStore( const Reference< XComponentContext >& xContext )
-: UcbStore_Base(m_aMutex),
-  m_xContext( xContext )
+: m_xContext( xContext )
 {
 }
 
@@ -174,7 +173,7 @@ UcbStore::createPropertySetRegistry( const OUString& )
 
 if ( !m_xTheRegistry.is() )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 if ( !m_xTheRegistry.is() )
 m_xTheRegistry = new PropertySetRegistry( m_xContext, m_aInitArgs 
);
 }
@@ -189,7 +188,7 @@ UcbStore::createPropertySetRegistry( const OUString& )
 // virtual
 void SAL_CALL UcbStore::initialize( const Sequence< Any >& aArguments )
 {
-osl::Guard< osl::Mutex > aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 m_aInitArgs = aArguments;
 }
 
diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx
index de9488b28c05..0042bbafadc2 100644
--- a/ucb/source/core/ucbstore.hxx
+++ b/ucb/source/core/ucbstore.hxx
@@ -35,17 +35,16 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 
 
-using UcbStore_Base = cppu::WeakComponentImplHelper <
+using UcbStore_Base = comphelper::WeakComponentImplHelper <
 css::lang::XServiceInfo,
 css::ucb::XPropertySetRegistryFactory,
 css::lang::XInitialization >;
 
-class UcbStore : public cppu::BaseMutex, public UcbStore_Base
+class UcbStore : public UcbStore_Base
 {
 css::uno::Reference< css::uno::XComponentContext >m_xContext;
 css::uno::Sequence< css::uno::Any >   m_aInitArgs;


[Libreoffice-commits] core.git: ucb/source

2021-12-27 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx |4 ++--
 ucb/source/ucp/webdav-curl/DAVSessionFactory.hxx |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 65dbcbfc58d55d7a7396f3c7c280afefabf34eb4
Author: Noel Grandin 
AuthorDate: Thu Dec 23 17:51:42 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 13:26:40 2021 +0100

osl::Mutex->std::mutex in DAVSessionFactory

Change-Id: I7cca2a76b9285e66f7c54deef8a6e612fd262ab4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127541
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx 
b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
index bbb7a48bcf0a..b89928b5d02b 100644
--- a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
@@ -34,7 +34,7 @@ rtl::Reference< DAVSession > 
DAVSessionFactory::createDAVSession(
 const uno::Sequence< beans::NamedValue >& rFlags,
 const uno::Reference< uno::XComponentContext > & rxContext )
 {
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 
 if (!m_xProxyDecider)
 m_xProxyDecider.reset( new ucbhelper::InternetProxyDecider( rxContext 
) );
@@ -79,7 +79,7 @@ rtl::Reference< DAVSession > 
DAVSessionFactory::createDAVSession(
 void DAVSessionFactory::releaseElement( DAVSession * pElement )
 {
 assert( pElement );
-osl::MutexGuard aGuard( m_aMutex );
+std::unique_lock aGuard( m_aMutex );
 if ( pElement->m_aContainerIt != m_aMap.end() )
 m_aMap.erase( pElement->m_aContainerIt );
 }
diff --git a/ucb/source/ucp/webdav-curl/DAVSessionFactory.hxx 
b/ucb/source/ucp/webdav-curl/DAVSessionFactory.hxx
index b0d426f43bf3..b931e1b4a8ec 100644
--- a/ucb/source/ucp/webdav-curl/DAVSessionFactory.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVSessionFactory.hxx
@@ -24,7 +24,7 @@
 #endif
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -61,7 +61,7 @@ private:
 typedef std::map Map;
 
 Map m_aMap;
-osl::Mutex m_aMutex;
+std::mutex m_aMutex;
 std::unique_ptr m_xProxyDecider;
 
 void releaseElement(DAVSession* pElement);


[Libreoffice-commits] core.git: ucb/source

2021-12-26 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/image/ucpimage.cxx |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit ae80ee2d722ea8a0a0e133488f829b331ca2c195
Author: Noel Grandin 
AuthorDate: Sat Dec 25 18:49:13 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 07:58:58 2021 +0100

use comphelper::WeakComponentImplHelper in Provider

Change-Id: I60e496c823ab36ee5f9775b0b758617815b85151
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127519
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/image/ucpimage.cxx 
b/ucb/source/ucp/image/ucpimage.cxx
index 75bc7404fc0d..478509a716a3 100644
--- a/ucb/source/ucp/image/ucpimage.cxx
+++ b/ucb/source/ucp/image/ucpimage.cxx
@@ -16,7 +16,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -36,14 +36,13 @@
 namespace {
 
 class Provider final:
-private osl::Mutex,
-public cppu::WeakComponentImplHelper<
+public comphelper::WeakComponentImplHelper<
 css::lang::XServiceInfo, css::ucb::XContentProvider>
 {
 public:
 explicit Provider(
 css::uno::Reference const & context):
-WeakComponentImplHelper(*static_cast(this)), context_(context)
+context_(context)
 {}
 
 private:
@@ -65,7 +64,7 @@ private:
 {
 css::uno::Reference context;
 {
-osl::MutexGuard g(*this);
+std::unique_lock g(m_aMutex);
 context = context_;
 }
 if (!context.is()) {
@@ -146,7 +145,7 @@ private:
 Id2->getContentIdentifier());
 }
 
-void SAL_CALL disposing() override {
+void disposing(std::unique_lock&) override {
 context_.clear();
 }
 


[Libreoffice-commits] core.git: ucb/source

2021-12-26 Thread Noel Grandin (via logerrit)
 ucb/source/core/cmdenv.cxx |2 +-
 ucb/source/core/cmdenv.hxx |7 +++
 2 files changed, 4 insertions(+), 5 deletions(-)

New commits:
commit bde743f7455f1b714e3fb495ef45ee00361484cb
Author: Noel Grandin 
AuthorDate: Sat Dec 25 18:53:42 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 07:36:38 2021 +0100

use comphelper::WeakComponentImplHelper in UcbCommandEnvironment

Change-Id: Ic27f2554613e159094be4c180647c2e59f57e00e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127522
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/cmdenv.cxx b/ucb/source/core/cmdenv.cxx
index 0ea51438c920..9189f0e0f0aa 100644
--- a/ucb/source/core/cmdenv.cxx
+++ b/ucb/source/core/cmdenv.cxx
@@ -36,7 +36,7 @@ using namespace ucb_cmdenv;
 // UcbCommandEnvironment Implementation.
 
 
-UcbCommandEnvironment::UcbCommandEnvironment() : 
UcbCommandEnvironment_Base(m_aMutex)
+UcbCommandEnvironment::UcbCommandEnvironment()
 {
 }
 
diff --git a/ucb/source/core/cmdenv.hxx b/ucb/source/core/cmdenv.hxx
index f70e71549429..8896cab85fe1 100644
--- a/ucb/source/core/cmdenv.hxx
+++ b/ucb/source/core/cmdenv.hxx
@@ -19,8 +19,7 @@
 
 #pragma once
 
-#include 
-#include 
+#include 
 
 #include 
 #include 
@@ -30,11 +29,11 @@
 
 namespace ucb_cmdenv {
 
-using UcbCommandEnvironment_Base = cppu::WeakComponentImplHelper< 
css::lang::XInitialization,
+using UcbCommandEnvironment_Base = comphelper::WeakComponentImplHelper< 
css::lang::XInitialization,
   css::lang::XServiceInfo,
   css::ucb::XCommandEnvironment >;
 
-class UcbCommandEnvironment : public cppu::BaseMutex, public 
UcbCommandEnvironment_Base
+class UcbCommandEnvironment : public UcbCommandEnvironment_Base
 {
 css::uno::Reference< css::task::XInteractionHandler > m_xIH;
 css::uno::Reference< css::ucb::XProgressHandler > m_xPH;


[Libreoffice-commits] core.git: ucb/source

2021-12-26 Thread Noel Grandin (via logerrit)
 ucb/source/core/provprox.cxx |2 +-
 ucb/source/core/provprox.hxx |8 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 34cbc302e3899fbacea01e27c66d3fd0bed4ac0d
Author: Noel Grandin 
AuthorDate: Sat Dec 25 18:52:35 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 07:35:38 2021 +0100

use comphelper::WeakComponentImplHelper in UcbContentProviderProxyFactory

Change-Id: I60b68c6589ce34673a2435260cd7b75c17b91a69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127521
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/provprox.cxx b/ucb/source/core/provprox.cxx
index 0489123c8294..7af7ba28add2 100644
--- a/ucb/source/core/provprox.cxx
+++ b/ucb/source/core/provprox.cxx
@@ -37,7 +37,7 @@ using namespace com::sun::star::uno;
 
 UcbContentProviderProxyFactory::UcbContentProviderProxyFactory(
 const Reference< XComponentContext >& rxContext )
-: UcbContentProviderProxyFactory_Base(m_aMutex), m_xContext( rxContext )
+: m_xContext( rxContext )
 {
 }
 
diff --git a/ucb/source/core/provprox.hxx b/ucb/source/core/provprox.hxx
index ccab5781810e..b71fdfe7031c 100644
--- a/ucb/source/core/provprox.hxx
+++ b/ucb/source/core/provprox.hxx
@@ -28,17 +28,15 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
 
 
 
-using UcbContentProviderProxyFactory_Base = cppu::WeakComponentImplHelper <
+using UcbContentProviderProxyFactory_Base = 
comphelper::WeakComponentImplHelper <
 css::lang::XServiceInfo,
 
css::ucb::XContentProviderFactory >;
-class UcbContentProviderProxyFactory : public cppu::BaseMutex, public 
UcbContentProviderProxyFactory_Base
+class UcbContentProviderProxyFactory : public 
UcbContentProviderProxyFactory_Base
 {
 css::uno::Reference< css::uno::XComponentContext > m_xContext;
 


[Libreoffice-commits] core.git: ucb/source

2021-12-06 Thread Noel Grandin (via logerrit)
 ucb/source/sorter/sortresult.cxx |   25 +++--
 ucb/source/sorter/sortresult.hxx |6 +++---
 2 files changed, 10 insertions(+), 21 deletions(-)

New commits:
commit a14b4e1d8a6ae8af24feb0e29b75d0e8996f974e
Author: Noel Grandin 
AuthorDate: Wed Dec 1 20:36:09 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Dec 4 12:00:31 2021 +0100

use OMultiTypeInterfaceContainerHelperVar3 in SortedResultSet

Change-Id: I371dc8d97a4d6cb24c69e97b874bb50384df7526
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126337
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/sorter/sortresult.cxx b/ucb/source/sorter/sortresult.cxx
index af13ca097047..1f28a308dc9b 100644
--- a/ucb/source/sorter/sortresult.cxx
+++ b/ucb/source/sorter/sortresult.cxx
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -94,16 +93,6 @@ public:
 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) 
override;
 };
 
-typedef comphelper::OMultiTypeInterfaceContainerHelperVar2
-PropertyChangeListenerContainer_Impl;
-
-class PropertyChangeListeners_Impl : public 
PropertyChangeListenerContainer_Impl
-{
-public:
-PropertyChangeListeners_Impl()
-: PropertyChangeListenerContainer_Impl( getContainerMutex() ) {}
-};
-
 
 SortedResultSet::SortedResultSet( Reference< XResultSet > const & aResult )
 {
@@ -819,7 +808,7 @@ void SAL_CALL SortedResultSet::addPropertyChangeListener(
 
 if ( !mpPropChangeListeners )
 mpPropChangeListeners.reset(
-new PropertyChangeListeners_Impl() );
+new 
comphelper::OMultiTypeInterfaceContainerHelperVar3(getContainerMutex()) );
 
 mpPropChangeListeners->addInterface( PropertyName, Listener );
 }
@@ -844,7 +833,7 @@ void SAL_CALL SortedResultSet::addVetoableChangeListener(
 
 if ( !mpVetoChangeListeners )
 mpVetoChangeListeners.reset(
-new PropertyChangeListeners_Impl() );
+new 
comphelper::OMultiTypeInterfaceContainerHelperVar3(getContainerMutex()) );
 
 mpVetoChangeListeners->addInterface( PropertyName, Listener );
 }
@@ -1194,14 +1183,14 @@ void SortedResultSet::PropertyChanged( const 
PropertyChangeEvent& rEvt )
 return;
 
 // Notify listeners interested especially in the changed property.
-OInterfaceContainerHelper2* pPropsContainer =
+OInterfaceContainerHelper3* pPropsContainer =
 mpPropChangeListeners->getContainer( rEvt.PropertyName );
 if ( pPropsContainer )
 {
-OInterfaceIteratorHelper2 aIter( *pPropsContainer );
+OInterfaceIteratorHelper3 aIter( *pPropsContainer );
 while ( aIter.hasMoreElements() )
 {
-static_cast< XPropertyChangeListener* >( aIter.next() 
)->propertyChange( rEvt );
+aIter.next()->propertyChange( rEvt );
 }
 }
 
@@ -1209,10 +1198,10 @@ void SortedResultSet::PropertyChanged( const 
PropertyChangeEvent& rEvt )
 pPropsContainer = mpPropChangeListeners->getContainer( OUString() );
 if ( pPropsContainer )
 {
-OInterfaceIteratorHelper2 aIter( *pPropsContainer );
+OInterfaceIteratorHelper3 aIter( *pPropsContainer );
 while ( aIter.hasMoreElements() )
 {
-static_cast< XPropertyChangeListener* >( aIter.next() 
)->propertyChange( rEvt );
+aIter.next()->propertyChange( rEvt );
 }
 }
 }
diff --git a/ucb/source/sorter/sortresult.hxx b/ucb/source/sorter/sortresult.hxx
index bcba14b6d63b..caf3d76e35fc 100644
--- a/ucb/source/sorter/sortresult.hxx
+++ b/ucb/source/sorter/sortresult.hxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -41,7 +42,6 @@
 struct  SortInfo;
 struct  SortListData;
 class   SRSPropertySetInfo;
-class   PropertyChangeListeners_Impl;
 
 
 class SortedEntryList
@@ -94,8 +94,8 @@ class SortedResultSet: public cppu::WeakImplHelper <
 css::beans::XPropertySet >
 {
 comphelper::OInterfaceContainerHelper3 
*mpDisposeEventListeners;
-std::unique_ptrmpPropChangeListeners;
-std::unique_ptrmpVetoChangeListeners;
+
std::unique_ptr>mpPropChangeListeners;
+
std::unique_ptr>mpVetoChangeListeners;
 
 css::uno::Reference < css::sdbc::XResultSet >mxOriginal;
 css::uno::Reference < css::sdbc::XResultSet >mxOther;


[Libreoffice-commits] core.git: ucb/source

2021-12-06 Thread Noel Grandin (via logerrit)
 ucb/source/core/ucbstore.cxx |   15 +++
 ucb/source/core/ucbstore.hxx |4 ++--
 2 files changed, 9 insertions(+), 10 deletions(-)

New commits:
commit a469d1353f4efd2c22d2fd8497a0d456e11760ad
Author: Noel Grandin 
AuthorDate: Wed Dec 1 21:37:24 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Dec 4 12:20:43 2021 +0100

use OMultiTypeInterfaceContainerHelperVar3 in PersistentPropertySet

Change-Id: I4bb884fc76f766d58afec3632c7443e348ea5342
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126340
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index db1cfea7ceab..9d0301e16268 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -1902,29 +1902,28 @@ void PersistentPropertySet::notifyPropertyChangeEvent(
 const PropertyChangeEvent& rEvent ) const
 {
 // Get "normal" listeners for the property.
-OInterfaceContainerHelper2* pContainer =
-m_pPropertyChangeListeners->getContainer(
-rEvent.PropertyName );
+OInterfaceContainerHelper3* pContainer =
+m_pPropertyChangeListeners->getContainer( rEvent.PropertyName );
 if ( pContainer && pContainer->getLength() )
 {
-OInterfaceIteratorHelper2 aIter( *pContainer );
+OInterfaceIteratorHelper3 aIter( *pContainer );
 while ( aIter.hasMoreElements() )
 {
 // Propagate event.
-static_cast< XPropertyChangeListener* >( aIter.next() 
)->propertyChange( rEvent );
+aIter.next()->propertyChange( rEvent );
 }
 }
 
 // Get "normal" listeners for all properties.
-OInterfaceContainerHelper2* pNoNameContainer =
+OInterfaceContainerHelper3* pNoNameContainer =
 m_pPropertyChangeListeners->getContainer( OUString() );
 if ( pNoNameContainer && pNoNameContainer->getLength() )
 {
-OInterfaceIteratorHelper2 aIter( *pNoNameContainer );
+OInterfaceIteratorHelper3 aIter( *pNoNameContainer );
 while ( aIter.hasMoreElements() )
 {
 // Propagate event.
-static_cast< XPropertyChangeListener* >( aIter.next() 
)->propertyChange( rEvent );
+aIter.next()->propertyChange( rEvent );
 }
 }
 }
diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx
index d3c5eb36c0cf..de9488b28c05 100644
--- a/ucb/source/core/ucbstore.hxx
+++ b/ucb/source/core/ucbstore.hxx
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -143,7 +143,7 @@ public:
 
 
 class PropertySetInfo_Impl;
-typedef comphelper::OMultiTypeInterfaceContainerHelperVar2 
PropertyListeners_Impl;
+typedef 
comphelper::OMultiTypeInterfaceContainerHelperVar3 PropertyListeners_Impl;
 
 class PersistentPropertySet : public cppu::WeakImplHelper <
 css::lang::XServiceInfo,


[Libreoffice-commits] core.git: ucb/source

2021-12-06 Thread Noel Grandin (via logerrit)
 ucb/source/cacher/contentresultsetwrapper.cxx |   26 +-
 ucb/source/cacher/contentresultsetwrapper.hxx |8 +---
 2 files changed, 18 insertions(+), 16 deletions(-)

New commits:
commit e782eefb2610af6d412d91d1a94dafaf53806f89
Author: Noel Grandin 
AuthorDate: Wed Dec 1 21:41:57 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Dec 4 12:33:57 2021 +0100

use OMultiTypeInterfaceContainerHelperVar3 in ContentResultSetWrapper

Change-Id: I50d79f400833987b5f5050826c7901c4fc22386e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126341
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx 
b/ucb/source/cacher/contentresultsetwrapper.cxx
index f9e504e2d933..f19353446dde 100644
--- a/ucb/source/cacher/contentresultsetwrapper.cxx
+++ b/ucb/source/cacher/contentresultsetwrapper.cxx
@@ -169,7 +169,7 @@ void 
ContentResultSetWrapper::impl_getVetoableChangeListenerContainer()
 osl::Guard< osl::Mutex > aGuard( m_aMutex );
 if ( !m_pVetoableChangeListeners )
 m_pVetoableChangeListeners.reset(
-new PropertyChangeListenerContainer_Impl( m_aContainerMutex ) );
+new VetoableChangeListenerContainer_Impl( m_aContainerMutex ) );
 }
 
 void ContentResultSetWrapper::impl_notifyPropertyChangeListeners( const 
PropertyChangeEvent& rEvt )
@@ -181,14 +181,14 @@ void 
ContentResultSetWrapper::impl_notifyPropertyChangeListeners( const Property
 }
 
 // Notify listeners interested especially in the changed property.
-OInterfaceContainerHelper2* pContainer =
+OInterfaceContainerHelper3* pContainer =
 m_pPropertyChangeListeners->getContainer( rEvt.PropertyName );
 if( pContainer )
 {
-OInterfaceIteratorHelper2 aIter( *pContainer );
+OInterfaceIteratorHelper3 aIter( *pContainer );
 while( aIter.hasMoreElements() )
 {
-static_cast< XPropertyChangeListener* >( aIter.next() 
)->propertyChange( rEvt );
+aIter.next()->propertyChange( rEvt );
 }
 }
 
@@ -196,10 +196,10 @@ void 
ContentResultSetWrapper::impl_notifyPropertyChangeListeners( const Property
 pContainer = m_pPropertyChangeListeners->getContainer( OUString() );
 if( pContainer )
 {
-OInterfaceIteratorHelper2 aIter( *pContainer );
+OInterfaceIteratorHelper3 aIter( *pContainer );
 while( aIter.hasMoreElements() )
 {
-static_cast< XPropertyChangeListener* >( aIter.next() 
)->propertyChange( rEvt );
+aIter.next()->propertyChange( rEvt );
 }
 }
 }
@@ -213,14 +213,14 @@ void 
ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const Property
 }
 
 // Notify listeners interested especially in the changed property.
-OInterfaceContainerHelper2* pContainer =
+OInterfaceContainerHelper3* pContainer =
 m_pVetoableChangeListeners->getContainer( rEvt.PropertyName );
 if( pContainer )
 {
-OInterfaceIteratorHelper2 aIter( *pContainer );
+OInterfaceIteratorHelper3 aIter( *pContainer );
 while( aIter.hasMoreElements() )
 {
-static_cast< XVetoableChangeListener* >( aIter.next() 
)->vetoableChange( rEvt );
+aIter.next()->vetoableChange( rEvt );
 }
 }
 
@@ -228,10 +228,10 @@ void 
ContentResultSetWrapper::impl_notifyVetoableChangeListeners( const Property
 pContainer = m_pVetoableChangeListeners->getContainer( OUString() );
 if( pContainer )
 {
-OInterfaceIteratorHelper2 aIter( *pContainer );
+OInterfaceIteratorHelper3 aIter( *pContainer );
 while( aIter.hasMoreElements() )
 {
-static_cast< XVetoableChangeListener* >( aIter.next() 
)->vetoableChange( rEvt );
+aIter.next()->vetoableChange( rEvt );
 }
 }
 }
@@ -606,7 +606,7 @@ void SAL_CALL 
ContentResultSetWrapper::removePropertyChangeListener( const OUStr
 if( !m_pPropertyChangeListeners )
 return;
 }
-OInterfaceContainerHelper2* pContainer =
+OInterfaceContainerHelper3* pContainer =
 m_pPropertyChangeListeners->getContainer( rPropertyName );
 
 if( !pContainer )
@@ -659,7 +659,7 @@ void SAL_CALL 
ContentResultSetWrapper::removeVetoableChangeListener( const OUStr
 if( !m_pVetoableChangeListeners )
 return;
 }
-OInterfaceContainerHelper2* pContainer =
+OInterfaceContainerHelper3* pContainer =
 m_pVetoableChangeListeners->getContainer( rPropertyName );
 
 if( !pContainer )
diff --git a/ucb/source/cacher/contentresultsetwrapper.hxx 
b/ucb/source/cacher/contentresultsetwrapper.hxx
index eda5b5e83e9d..ce39650317c0 100644
--- a/ucb/source/cacher/contentresultsetwrapper.hxx
+++ b/ucb/source/cacher/contentresultsetwrapper.hxx
@@ -32,7 +32,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 
@@ -48,8 +48,10 @@ class ContentResultSe

[Libreoffice-commits] core.git: ucb/source

2021-12-01 Thread Jan-Marek Glogowski (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0b35970ffb46075d19f1a65391dde8182f322ef0
Author: Jan-Marek Glogowski 
AuthorDate: Wed Dec 1 09:53:53 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Dec 1 14:32:06 2021 +0100

webdav-curl: just mask CURLE_QUIC_CONNECT_ERROR

... obviously we still need the throw...

Change-Id: Ia7960ce2296e196be600f6b9a8139bc261fd2159
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126170
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 5cde0fc027aa..59f372fa809b 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -948,10 +948,10 @@ auto CurlProcessor::ProcessRequestImpl(
 case CURLE_FAILED_INIT:
 #if CURL_AT_LEAST_VERSION(7, 69, 0)
 case CURLE_QUIC_CONNECT_ERROR:
+#endif
 throw DAVException(
 DAVException::DAV_HTTP_CONNECT,
 ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
-#endif
 case CURLE_REMOTE_ACCESS_DENIED:
 case CURLE_LOGIN_DENIED:
 case CURLE_AUTH_ERROR:


[Libreoffice-commits] core.git: ucb/source

2021-11-30 Thread Jan-Marek Glogowski (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 70a479abe267c0bd4c0c0fd1e945d8e6e4856af2
Author: Jan-Marek Glogowski 
AuthorDate: Tue Nov 30 22:47:02 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Dec 1 08:39:54 2021 +0100

CURLE_QUIC_CONNECT_ERROR requires curl >= 7.69.0

This new error code replaced several CURLE_FAILED_INIT in curl
commit cbb5429001084df4e71ebd95dbf748c3c302c9f7 ("ngtcp2: Add an
error code for QUIC connection errors").

Instead of escalating the curl version further, just mask it with
CURL_AT_LEAST_VERSION; this way my Ubuntu 20.04 schroot can still
use the system CURL for the build...

Change-Id: I24afd32737e2ab74d9e4ce1722012d522ae010bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126158
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index d63d3566bfaa..5cde0fc027aa 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -945,10 +945,13 @@ auto CurlProcessor::ProcessRequestImpl(
 case CURLE_SSL_ISSUER_ERROR:
 case CURLE_SSL_PINNEDPUBKEYNOTMATCH:
 case CURLE_SSL_INVALIDCERTSTATUS:
+case CURLE_FAILED_INIT:
+#if CURL_AT_LEAST_VERSION(7, 69, 0)
 case CURLE_QUIC_CONNECT_ERROR:
 throw DAVException(
 DAVException::DAV_HTTP_CONNECT,
 ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+#endif
 case CURLE_REMOTE_ACCESS_DENIED:
 case CURLE_LOGIN_DENIED:
 case CURLE_AUTH_ERROR:


[Libreoffice-commits] core.git: ucb/source

2021-11-30 Thread Noel Grandin (via logerrit)
 ucb/source/ucp/file/bc.cxx |   65 +
 ucb/source/ucp/file/filnot.cxx |   20 ++--
 ucb/source/ucp/file/filnot.hxx |3 +
 3 files changed, 65 insertions(+), 23 deletions(-)

New commits:
commit 75a1a63108d39eab905058d1bd295b74ecf34663
Author: Noel Grandin 
AuthorDate: Sun Nov 28 21:25:02 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Nov 30 13:11:49 2021 +0100

use more OInterfaceContainerHelper3 in PropertyListeners

Change-Id: I44b06c1ab469e99a9d3b8f4e2b0f3058959fc202
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126063
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index acf68ce65c61..3575ac7f0f85 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -54,16 +54,69 @@ using namespace com::sun::star::ucb;
 #define THROW_WHERE ""
 #endif
 
-typedef comphelper::OMultiTypeInterfaceContainerHelperVar2
-PropertyListeners_impl;
-
 class fileaccess::PropertyListeners
-: public PropertyListeners_impl
 {
+typedef 
comphelper::OInterfaceContainerHelper3 
ContainerHelper;
+osl::Mutex& rMutex;
+std::unordered_map m_aMap;
 public:
 explicit PropertyListeners( ::osl::Mutex& aMutex )
-: PropertyListeners_impl( aMutex )
+: rMutex( aMutex )
+{
+}
+void disposeAndClear(const lang::EventObject& rEvt)
+{
+// create a copy, because do not fire event in a guarded section
+std::unordered_map tempMap;
+{
+::osl::MutexGuard aGuard(rMutex);
+tempMap = std::move(m_aMap);
+}
+for (auto& rPair : tempMap)
+rPair.second.disposeAndClear(rEvt);
+}
+void addInterface(const OUString& rKey, const 
uno::Reference& rListener)
+{
+::osl::MutexGuard aGuard(rMutex);
+auto iter = m_aMap.find(rKey);
+if (iter == m_aMap.end())
+{
+auto ret = m_aMap.emplace(rKey, rMutex);
+ret.first->second.addInterface(rListener);
+}
+else
+iter->second.addInterface(rListener);
+}
+void removeInterface(const OUString& rKey, const 
uno::Reference& rListener)
 {
+::osl::MutexGuard aGuard(rMutex);
+
+// search container with id rKey
+auto iter = m_aMap.find(rKey);
+// container found?
+if (iter != m_aMap.end())
+iter->second.removeInterface(rListener);
+}
+std::vector< OUString > getContainedTypes() const
+{
+::osl::MutexGuard aGuard(rMutex);
+std::vector aInterfaceTypes;
+aInterfaceTypes.reserve(m_aMap.size());
+for (const auto& rPair : m_aMap)
+// are interfaces added to this container?
+if (rPair.second.getLength())
+// yes, put the type in the array
+aInterfaceTypes.push_back(rPair.first);
+return aInterfaceTypes;
+}
+comphelper::OInterfaceContainerHelper3* 
getContainer(const OUString& rKey)
+{
+::osl::MutexGuard aGuard(rMutex);
+
+auto iter = m_aMap.find(rKey);
+if (iter != m_aMap.end())
+return &iter->second;
+return nullptr;
 }
 };
 
@@ -1153,7 +1206,7 @@ BaseContent::cPCL()
 ListenerMap listener;
 for( const auto& rName : seqNames )
 {
-comphelper::OInterfaceContainerHelper2* pContainer = 
m_pPropertyListener->getContainer(rName);
+
comphelper::OInterfaceContainerHelper3* 
pContainer = m_pPropertyListener->getContainer(rName);
 if (!pContainer)
 continue;
 listener[rName] = pContainer->getElements();
diff --git a/ucb/source/ucp/file/filnot.cxx b/ucb/source/ucp/file/filnot.cxx
index 6dce30f03cd8..013311e2d1bc 100644
--- a/ucb/source/ucp/file/filnot.cxx
+++ b/ucb/source/ucp/file/filnot.cxx
@@ -187,15 +187,9 @@ void PropertyChangeNotifier::notifyPropertyChanged(
 auto it = m_aListeners.find( OUString() );
 if (it != m_aListeners.end())
 {
-const std::vector< uno::Reference< uno::XInterface > >& seqList = 
it->second;
+const std::vector< uno::Reference< beans::XPropertiesChangeListener > 
>& seqList = it->second;
 for( const auto& rListener : seqList )
-{
-uno::Reference< beans::XPropertiesChangeListener > aListener( 
rListener,uno::UNO_QUERY );
-if( aListener.is() )
-{
-aListener->propertiesChange( Changes );
-}
-}
+rListener->propertiesChange( Changes );
 }
 
 for( const auto& rChange : std::as_const(Changes) )
@@ -204,15 +198,9 @@ void PropertyChangeNotifier::notifyPropertyChanged(
 it = m_aListeners.find( rChange.PropertyName );
 if (it != m_aListeners.end())
 {
-const std::vector< uno::Reference< uno::XInterface > >& seqList = 
it->second;
+const std::vector< uno::Reference< 
beans::XProper

[Libreoffice-commits] core.git: ucb/source

2021-11-29 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   73 ++---
 1 file changed, 57 insertions(+), 16 deletions(-)

New commits:
commit 2fae5ab2a8cefa758c631d6ae23847089b68800d
Author: Michael Stahl 
AuthorDate: Fri Nov 26 19:20:37 2021 +0100
Commit: Michael Stahl 
CommitDate: Mon Nov 29 15:23:42 2021 +0100

ucb: webdav-curl: don't read from XInputStream during upload

Nextcloud will reply to a PROPFIND request with "100 Continue" and then
after the data is uploaded it will send a "401 Unauthorized" if the
auth header is missing in the headers to which it replied with "100
Continue".

In the next call to ProcessRequestImpl(), reading from the stream
returns no data because it's at EOF, and because of the Content-Length
header the server will hang forever waiting for data.

So copy the stream to a temporary buffer and use that for multiple
calls to ProcessRequestImpl().

Change-Id: If5943a32c4cf50259fe1f84013141765cb5bd891
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125923
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 43bfa6cb85f8..d63d3566bfaa 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -89,12 +91,13 @@ struct DownloadTarget
 
 struct UploadSource
 {
-uno::Reference xInStream;
+uno::Sequence const& rInData;
 ResponseHeaders const& rHeaders;
-UploadSource(uno::Reference const& i_xInStream,
- ResponseHeaders const& i_rHeaders)
-: xInStream(i_xInStream)
+size_t nPosition;
+UploadSource(uno::Sequence const& i_rInData, ResponseHeaders 
const& i_rHeaders)
+: rInData(i_rInData)
 , rHeaders(i_rHeaders)
+, nPosition(0)
 {
 }
 };
@@ -348,15 +351,14 @@ static size_t read_callback(char* const buffer, size_t 
const size, size_t const
 {
 auto* const pSource(static_cast(userdata));
 assert(pSource);
-assert(pSource->xInStream.is());
 size_t const nBytes(size * nitems);
 size_t nRet(0);
 try
 {
-uno::Sequence data;
-data.realloc(nBytes);
-nRet = pSource->xInStream->readSomeBytes(data, nBytes);
-::std::memcpy(buffer, data.getConstArray(), nRet);
+assert(pSource->nPosition <= 
o3tl::make_unsigned(pSource->rInData.getLength()));
+nRet = ::std::min(pSource->rInData.getLength() - 
pSource->nPosition, nBytes);
+::std::memcpy(buffer, pSource->rInData.getConstArray() + 
pSource->nPosition, nRet);
+pSource->nPosition += nRet;
 }
 catch (...)
 {
@@ -737,7 +739,7 @@ struct CurlProcessor
 static auto ProcessRequestImpl(
 CurlSession& rSession, CurlUri const& rURI, curl_slist* 
pRequestHeaderList,
 uno::Reference const* pxOutStream,
-uno::Reference const* pxInStream,
+uno::Sequence const* pInData,
 ::std::pair<::std::vector const&, DAVResource&> const* 
pRequestedHeaders,
 ResponseHeaders& rHeaders) -> void;
 
@@ -792,7 +794,7 @@ auto CurlProcessor::URIReferenceToURI(CurlSession& 
rSession, OUString const& rUR
 auto CurlProcessor::ProcessRequestImpl(
 CurlSession& rSession, CurlUri const& rURI, curl_slist* const 
pRequestHeaderList,
 uno::Reference const* const pxOutStream,
-uno::Reference const* const pxInStream,
+uno::Sequence const* const pInData,
 ::std::pair<::std::vector const&, DAVResource&> const* const 
pRequestedHeaders,
 ResponseHeaders& rHeaders) -> void
 {
@@ -805,7 +807,7 @@ auto CurlProcessor::ProcessRequestImpl(
 rc = curl_easy_setopt(rSession.m_pCurl.get(), CURLOPT_WRITEDATA, 
nullptr);
 assert(rc == CURLE_OK);
 }
-if (pxInStream)
+if (pInData)
 {
 rc = curl_easy_setopt(rSession.m_pCurl.get(), CURLOPT_READDATA, 
nullptr);
 assert(rc == CURLE_OK);
@@ -839,9 +841,9 @@ auto CurlProcessor::ProcessRequestImpl(
 assert(rc == CURLE_OK);
 }
 ::std::optional oUploadSource;
-if (pxInStream)
+if (pInData)
 {
-oUploadSource.emplace(*pxInStream, rHeaders);
+oUploadSource.emplace(*pInData, rHeaders);
 rc = curl_easy_setopt(rSession.m_pCurl.get(), CURLOPT_READDATA, 
&*oUploadSource);
 assert(rc == CURLE_OK);
 // libcurl won't upload without setting this
@@ -1103,6 +1105,45 @@ auto CurlProcessor::ProcessRequest(
 }
 }
 
+uno::Sequence data;
+if (pxInStream)
+{
+uno::Reference const xSeekable(*pxInStream, 
uno::UNO_QUERY);
+if (xSeekable.is())
+{
+auto const len(xSeekable->getLength() - xSeekable->getPosition());
+if ((**pxInStream).readBytes(data, len) != len)
+{
+throw uno::Runtime

[Libreoffice-commits] core.git: ucb/source

2021-11-29 Thread Noel Grandin (via logerrit)
 ucb/source/core/ucbcmds.hxx|6 +++---
 ucb/source/sorter/sortresult.hxx   |2 +-
 ucb/source/ucp/cmis/cmis_content.cxx   |7 ---
 ucb/source/ucp/cmis/cmis_content.hxx   |4 ++--
 ucb/source/ucp/cmis/cmis_repo_content.hxx  |2 +-
 ucb/source/ucp/cmis/cmis_strings.hxx   |   10 +-
 ucb/source/ucp/ftp/ftpcontentprovider.hxx  |4 ++--
 ucb/source/ucp/gio/gio_content.hxx |4 ++--
 ucb/source/ucp/hierarchy/hierarchyprovider.hxx |8 
 ucb/source/ucp/tdoc/tdoc_provider.hxx  |   16 
 ucb/source/ucp/webdav-curl/webdavcontent.hxx   |2 +-
 ucb/source/ucp/webdav-curl/webdavprovider.hxx  |6 +++---
 ucb/source/ucp/webdav-neon/webdavcontent.hxx   |2 +-
 ucb/source/ucp/webdav-neon/webdavprovider.hxx  |   12 ++--
 14 files changed, 43 insertions(+), 42 deletions(-)

New commits:
commit 1d16a2c3aed633bf594675e116327e09fe4d898d
Author: Noel Grandin 
AuthorDate: Fri Nov 26 11:32:46 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Nov 29 12:21:44 2021 +0100

loplugin:stringliteraldefine in ucb

Change-Id: I3b2e01b482f7f4dbceea090b9586cdb4eee4e703
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125869
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/ucb/source/core/ucbcmds.hxx b/ucb/source/core/ucbcmds.hxx
index 1196e1340028..c34a3564d4ae 100644
--- a/ucb/source/core/ucbcmds.hxx
+++ b/ucb/source/core/ucbcmds.hxx
@@ -23,13 +23,13 @@
 // Definitions for the commands supported by the UCB.
 
 
-#define GETCOMMANDINFO_NAME "getCommandInfo"
+inline constexpr OUStringLiteral GETCOMMANDINFO_NAME = u"getCommandInfo";
 #define GETCOMMANDINFO_HANDLE   1024
 
-#define GLOBALTRANSFER_NAME "globalTransfer"
+inline constexpr OUStringLiteral GLOBALTRANSFER_NAME = u"globalTransfer";
 #define GLOBALTRANSFER_HANDLE   1025
 
-#define CHECKIN_NAME"checkin"
+inline constexpr OUStringLiteral CHECKIN_NAME = u"checkin";
 #define CHECKIN_HANDLE  1026
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/sorter/sortresult.hxx b/ucb/source/sorter/sortresult.hxx
index 9593e7699b7c..7db1c97fb61a 100644
--- a/ucb/source/sorter/sortresult.hxx
+++ b/ucb/source/sorter/sortresult.hxx
@@ -83,7 +83,7 @@ public:
 };
 
 
-#define RESULTSET_SERVICE_NAME  "com.sun.star.ucb.SortedResultSet"
+inline constexpr OUStringLiteral RESULTSET_SERVICE_NAME = 
u"com.sun.star.ucb.SortedResultSet";
 
 
 class SortedResultSet: public cppu::WeakImplHelper <
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx 
b/ucb/source/ucp/cmis/cmis_content.cxx
index 7980a1821bba..9cc4e5ca2511 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -1738,9 +1738,10 @@ namespace cmis
 OUString sRet;
 try
 {
-sRet = isFolder( uno::Reference< ucb::XCommandEnvironment >() )
-? std::u16string_view(u"" CMIS_FOLDER_TYPE)
-: std::u16string_view(u"" CMIS_FILE_TYPE);
+if (isFolder( uno::Reference< ucb::XCommandEnvironment >() ))
+sRet = CMIS_FOLDER_TYPE;
+else
+sRet = CMIS_FILE_TYPE;
 }
 catch (const uno::RuntimeException&)
 {
diff --git a/ucb/source/ucp/cmis/cmis_content.hxx 
b/ucb/source/ucp/cmis/cmis_content.hxx
index 54d7b6e41b08..23546ce14a3e 100644
--- a/ucb/source/ucp/cmis/cmis_content.hxx
+++ b/ucb/source/ucp/cmis/cmis_content.hxx
@@ -55,8 +55,8 @@ namespace ucbhelper
 namespace cmis
 {
 
-#define CMIS_FILE_TYPE   "application/vnd.libreoffice.cmis-file"
-#define CMIS_FOLDER_TYPE "application/vnd.libreoffice.cmis-folder"
+inline constexpr OUStringLiteral CMIS_FILE_TYPE = 
u"application/vnd.libreoffice.cmis-file";
+inline constexpr OUStringLiteral CMIS_FOLDER_TYPE = 
u"application/vnd.libreoffice.cmis-folder";
 
 class ContentProvider;
 class Content : public ::ucbhelper::ContentImplHelper,
diff --git a/ucb/source/ucp/cmis/cmis_repo_content.hxx 
b/ucb/source/ucp/cmis/cmis_repo_content.hxx
index efd13d7d8cbf..0b68c4960e93 100644
--- a/ucb/source/ucp/cmis/cmis_repo_content.hxx
+++ b/ucb/source/ucp/cmis/cmis_repo_content.hxx
@@ -41,7 +41,7 @@ namespace ucbhelper
 
 namespace cmis
 {
-#define CMIS_REPO_TYPE   "application/vnd.libreoffice.cmis-repository"
+inline constexpr OUStringLiteral CMIS_REPO_TYPE = 
u"application/vnd.libreoffice.cmis-repository";
 
 class ContentProvider;
 class RepoContent : public ::ucbhelper::ContentImplHelper,
diff --git a/ucb/source/ucp/cmis/cmis_strings.hxx 
b/ucb/source/ucp/cmis/cmis_strings.hxx
index 76a9d469022d..0a7b81d24e70 100644
--- a/ucb/source/ucp/cmis/cmis_strings.hxx
+++ b/ucb/source/ucp/cmis/cmis_strings.hxx
@@ -12,10 +12,10 @@
 
 #pragma once
 
-#define CMIS_TYPE_STRING  "String"
-#define CMIS_TYPE_INTEGER "Integer"
-#define CMIS_TYPE_DECIMAL "Decimal"
-#define CMIS_TYPE_DATETIME"Datetime"
-#define CMIS_TYP

[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   30 -
 1 file changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 78d14ff6ef230ba3433d50ba8ded1a7cd2689b0f
Author: Michael Stahl 
AuthorDate: Fri Nov 26 14:46:16 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 26 18:04:12 2021 +0100

ucb: webdav-curl: don't use chunked encoding for PROPPATCH

Sharepoint 16 has the same problem with this as with PROPFIND.

But this still doesn't work, trying to add dead properties results
in HTTP/1.1 400 BAD REQUEST now.

In fact, it has additional problems: request 3 properties Foo, Bar, Baz
with one PROPFIND and it complains about Foo, FooBar, FooBarBaz...

Change-Id: Ia0ce0f7b9422e0751839151a4c964f0437282c64
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125907
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 5ea645f4d4ee..43bfa6cb85f8 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1588,25 +1588,17 @@ auto CurlSession::PROPPATCH(OUString const& 
rURIReference,
 CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference));
 
 // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked?
-::std::unique_ptr> pList(
-curl_slist_append(nullptr, "Transfer-Encoding: chunked"));
-if (!pList)
-{
-throw uno::RuntimeException("curl_slist_append failed");
-}
+::std::unique_ptr> pList;
 pList.reset(curl_slist_append(pList.release(), "Content-Type: 
application/xml"));
 if (!pList)
 {
 throw uno::RuntimeException("curl_slist_append failed");
 }
 
-::std::vector const options{ { CURLOPT_CUSTOMREQUEST, 
"PROPPATCH",
-   "CURLOPT_CUSTOMREQUEST" } };
-
 // generate XML document for PROPPATCH
-uno::Reference const 
xRequestInStream(io::Pipe::create(m_xContext));
-uno::Reference const 
xRequestOutStream(xRequestInStream, uno::UNO_QUERY);
-assert(xRequestInStream.is());
+uno::Reference const xSeqOutStream(
+io::SequenceOutputStream::create(m_xContext));
+uno::Reference const xRequestOutStream(xSeqOutStream);
 assert(xRequestOutStream.is());
 uno::Reference const 
xWriter(xml::sax::Writer::create(m_xContext));
 xWriter->setOutputStream(xRequestOutStream);
@@ -1657,7 +1649,19 @@ auto CurlSession::PROPPATCH(OUString const& 
rURIReference,
 }
 xWriter->endElement("propertyupdate");
 xWriter->endDocument();
-xRequestOutStream->closeOutput();
+
+uno::Reference const xRequestInStream(
+io::SequenceInputStream::createStreamFromSequence(m_xContext,
+  
xSeqOutStream->getWrittenBytes()));
+assert(xRequestInStream.is());
+
+curl_off_t const len(xSeqOutStream->getWrittenBytes().getLength());
+
+::std::vector const options{
+{ CURLOPT_CUSTOMREQUEST, "PROPPATCH", "CURLOPT_CUSTOMREQUEST" },
+// note: Sharepoint cannot handle "Transfer-Encoding: chunked"
+{ CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
+};
 
 CurlProcessor::ProcessRequest(*this, uri, options, &rEnv, 
::std::move(pList), nullptr,
   &xRequestInStream, nullptr);


[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |3 ---
 1 file changed, 3 deletions(-)

New commits:
commit 91ce3455cfe1c850dd9780c41e6253cb940af1e9
Author: Michael Stahl 
AuthorDate: Fri Nov 26 11:14:10 2021 +0100
Commit: Caolán McNamara 
CommitDate: Fri Nov 26 13:43:01 2021 +0100

cid#1494447 ucb: webdav-curl: Logically dead code

Change-Id: I98a99ddc287fd83ff95e9a1b3851a9888dd6ef5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125864
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index fc478efec7fd..5ea645f4d4ee 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -989,9 +989,6 @@ auto CurlProcessor::ProcessRequestImpl(
 {
 switch (statusCode)
 {
-case SC_NONE:
-assert(false); // ??? should be error returned from perform?
-break;
 case SC_REQUEST_TIMEOUT:
 {
 throw DAVException(


[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/SerfLockStore.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 9f94ea12c7d919441ccbb8ebc99adff11a2e6fd1
Author: Michael Stahl 
AuthorDate: Thu Nov 25 18:40:38 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 26 12:24:56 2021 +0100

ucb: webdav-curl: remove useless assert in getLockTokenForURI()

Change-Id: Ia27acf55bd7baf70c0b57e0922a62b1d9680c5b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125848
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx 
b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
index 0de397986f8f..3601d0c66642 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -168,7 +168,10 @@ SerfLockStore::getLockTokenForURI(OUString const& rURI, 
css::ucb::Lock const*con
 {
 return nullptr;
 }
-assert(it->second.m_Lock.Owner == pLock->Owner); // only own locks expected
+// Only own locks are expected in the lock store, but depending on the
+// server it->second.m_Lock.Owner may contain the string this UCP passed in
+// the LOCK request, or a user identifier generated by the server (happens
+// with Sharepoint), so just ignore it here.
 // ignore Timeout ?
 return &it->second.m_sToken;
 }


[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   35 ++---
 1 file changed, 22 insertions(+), 13 deletions(-)

New commits:
commit f50d0ca0978d8c6b8dff5ce680bce9fe71c0a7dd
Author: Michael Stahl 
AuthorDate: Thu Nov 25 18:24:06 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 26 12:24:33 2021 +0100

ucb: webdav-curl: don't use chunked encoding for LOCK

Sharepoint 16 produces exactly the same error HTML as for PROPFIND.

Change-Id: Idd3862456c4efbb9eb0533298dcd93711b30faae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125847
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index ca5fedd3b280..fc478efec7fd 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1980,8 +1980,19 @@ auto CurlProcessor::Lock(
 uno::Reference const* const pxRequestInStream)
 -> ::std::vector<::std::pair>
 {
-::std::vector const options{ { CURLOPT_CUSTOMREQUEST, "LOCK",
-   "CURLOPT_CUSTOMREQUEST" } };
+curl_off_t len(0);
+if (pxRequestInStream)
+{
+uno::Reference const xSeekable(*pxRequestInStream, 
uno::UNO_QUERY);
+assert(xSeekable.is());
+len = xSeekable->getLength();
+}
+
+::std::vector const options{
+{ CURLOPT_CUSTOMREQUEST, "LOCK", "CURLOPT_CUSTOMREQUEST" },
+// note: Sharepoint cannot handle "Transfer-Encoding: chunked"
+{ CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
+};
 
 // stream for response
 uno::Reference const 
xResponseInStream(io::Pipe::create(rSession.m_xContext));
@@ -2047,9 +2058,9 @@ auto CurlSession::LOCK(OUString const& rURIReference, 
ucb::Lock /*const*/& rLock
 // note: no m_Mutex lock needed here, only in CurlProcessor::Lock()
 
 // generate XML document for acquiring new LOCK
-uno::Reference const 
xRequestInStream(io::Pipe::create(m_xContext));
-uno::Reference const 
xRequestOutStream(xRequestInStream, uno::UNO_QUERY);
-assert(xRequestInStream.is());
+uno::Reference const xSeqOutStream(
+io::SequenceOutputStream::create(m_xContext));
+uno::Reference const xRequestOutStream(xSeqOutStream);
 assert(xRequestOutStream.is());
 uno::Reference const 
xWriter(xml::sax::Writer::create(m_xContext));
 xWriter->setOutputStream(xRequestOutStream);
@@ -2085,15 +2096,13 @@ auto CurlSession::LOCK(OUString const& rURIReference, 
ucb::Lock /*const*/& rLock
 }
 xWriter->endElement("lockinfo");
 xWriter->endDocument();
-xRequestOutStream->closeOutput();
 
-// TODO: either set CURLOPT_INFILESIZE_LARGE or chunked?
-::std::unique_ptr> pList(
-curl_slist_append(nullptr, "Transfer-Encoding: chunked"));
-if (!pList)
-{
-throw uno::RuntimeException("curl_slist_append failed");
-}
+uno::Reference const xRequestInStream(
+io::SequenceInputStream::createStreamFromSequence(m_xContext,
+  
xSeqOutStream->getWrittenBytes()));
+assert(xRequestInStream.is());
+
+::std::unique_ptr> pList;
 pList.reset(curl_slist_append(pList.release(), "Content-Type: 
application/xml"));
 if (!pList)
 {


[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 403d3e057575825f86ff97bf9e277feafa69362e
Author: Michael Stahl 
AuthorDate: Thu Nov 25 17:36:20 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 26 12:24:18 2021 +0100

ucb: webdav-curl: avoid pointless HEAD requests for DAV resources

Content::getPropertyValues() has a funny conditional which was changed
in commit a86bc34ddcff6b04bb9fdb8c960bbf2c49540da1 "Resolves: #i121922#
Fix wrong condition".

But the new condition also appears wrong, there is no need to do any
further requests if all properties have already been retrieved, so the
check for m_bDidGetOrHead could just be omitted.

There is a surprising result in the Remote Files dialog when connecting
to a Sharepoint 16 server: all properties have been retrieved from the
directory given as Root, but because of !m_bDidGetOrHead the branch is
taken anyway.

The HEAD request results in a "HTTP/1.1 302 Redirect" to
$ROOT/Forms/AllItems.aspx, HEAD on this URL gives a "HTTP/1.1 200 OK"
and then subsequently a PROPFIND on that very same URL results in
"HTTP/1.1 404 NOT FOUND".

Physics claims that a single observation should be sufficient to
determine whether an URL exists or not, but Sharepoint is apparently
able to maintain this quantum superposition indefinitely, hence the
Remote Files dialog doesn't display anything as the 404 causes an exception.

Try to fix this by requiring a missing property again before initiating
the HEAD request for DAV resources.

Change-Id: I1239762948b6abd1f8fc097edd4a16cb6b75ca7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125826
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 2467aef835bf..3beb87b9593f 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -1452,9 +1452,12 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 // All properties obtained already?
 std::vector< OUString > aMissingProps;
 if ( !( xProps
-&& xProps->containsAllNames(
-rProperties, aMissingProps ) )
- || !m_bDidGetOrHead )
+&& xProps->containsAllNames(rProperties, aMissingProps))
+// i#121922 for non-DAV, uncacheable properties must be fetched
+// regardless of m_bDidGetOrHead.
+// But SharePoint may do weird things on HEAD so for DAV
+// only do this if required.
+&& (eType != DAV || !m_bDidGetOrHead))
 {
 // Possibly the missing props can be obtained using a HEAD
 // request.


[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   33 -
 1 file changed, 19 insertions(+), 14 deletions(-)

New commits:
commit 8bb183f133202ebb687e0b56cc5a2938354506f7
Author: Michael Stahl 
AuthorDate: Thu Nov 25 17:16:36 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 26 12:22:52 2021 +0100

ucb: webdav-curl: don't use chunked encoding for PROPFIND

Sharepoint 16 responds to PROPFIND with "Transfer-Encoding: chunked"
with "HTTP/1.1 200 OK" and this body:

  Microsoft SharePoint Foundation 
Error.\n\n\nUser: please report details to this Web site's 
Webmaster.\n\n\n\nWebmaster: please see the server's application 
event log for more details.\n

Understandably, WebDAVResponseParser barfs on this:

ucb/source/ucp/webdav-curl/webdavresponseparser.cxx:405: Parser destructed 
with existing content (!)
ucb/source/ucp/webdav-curl/webdavresponseparser.cxx:942: WebDAV Parse error 
(!)

Apparently setting Content-Length works better.

Change-Id: If3eae8c2f8b9f1e1bb4ed4fc67a79a682d7d0050
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125825
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index aacc6bbed48e..ca5fedd3b280 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1431,13 +1431,7 @@ auto CurlProcessor::PropFind(
|| (::std::get<1>(*o_pRequestedProperties) != nullptr)
   != (::std::get<2>(*o_pRequestedProperties) != nullptr));
 
-// TODO: either set CURLOPT_INFILESIZE_LARGE or chunked?
-::std::unique_ptr> pList(
-curl_slist_append(nullptr, "Transfer-Encoding: chunked"));
-if (!pList)
-{
-throw uno::RuntimeException("curl_slist_append failed");
-}
+::std::unique_ptr> pList;
 pList.reset(curl_slist_append(pList.release(), "Content-Type: 
application/xml"));
 if (!pList)
 {
@@ -1464,13 +1458,11 @@ auto CurlProcessor::PropFind(
 throw uno::RuntimeException("curl_slist_append failed");
 }
 
-::std::vector const options{ { CURLOPT_CUSTOMREQUEST, 
"PROPFIND",
-   "CURLOPT_CUSTOMREQUEST" } };
-
-uno::Reference const 
xRequestInStream(io::Pipe::create(rSession.m_xContext));
-uno::Reference const 
xRequestOutStream(xRequestInStream, uno::UNO_QUERY);
-assert(xRequestInStream.is());
+uno::Reference const xSeqOutStream(
+io::SequenceOutputStream::create(rSession.m_xContext));
+uno::Reference const xRequestOutStream(xSeqOutStream);
 assert(xRequestOutStream.is());
+
 uno::Reference const 
xWriter(xml::sax::Writer::create(rSession.m_xContext));
 xWriter->setOutputStream(xRequestOutStream);
 xWriter->startDocument();
@@ -1506,7 +1498,19 @@ auto CurlProcessor::PropFind(
 }
 xWriter->endElement("propfind");
 xWriter->endDocument();
-xRequestOutStream->closeOutput();
+
+uno::Reference const xRequestInStream(
+io::SequenceInputStream::createStreamFromSequence(rSession.m_xContext,
+  
xSeqOutStream->getWrittenBytes()));
+assert(xRequestInStream.is());
+
+curl_off_t const len(xSeqOutStream->getWrittenBytes().getLength());
+
+::std::vector const options{
+{ CURLOPT_CUSTOMREQUEST, "PROPFIND", "CURLOPT_CUSTOMREQUEST" },
+// note: Sharepoint cannot handle "Transfer-Encoding: chunked"
+{ CURLOPT_INFILESIZE_LARGE, len, nullptr, CurlOption::Type::CurlOffT }
+};
 
 // stream for response
 uno::Reference const 
xResponseInStream(io::Pipe::create(rSession.m_xContext));
@@ -1804,6 +1808,7 @@ auto CurlSession::PUT(OUString const& rURIReference,
 
 // lock m_Mutex after accessing global LockStore to avoid deadlock
 
+// note: Nextcloud 20 cannot handle "Transfer-Encoding: chunked"
 ::std::vector const options{ { CURLOPT_INFILESIZE_LARGE, len, 
nullptr,
CurlOption::Type::CurlOffT } };
 


[Libreoffice-commits] core.git: ucb/source

2021-11-26 Thread Caolán McNamara (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f8760d18b274cc7c943921d61c49c99176cd22b8
Author: Caolán McNamara 
AuthorDate: Fri Nov 26 08:58:54 2021 +
Commit: Caolán McNamara 
CommitDate: Fri Nov 26 12:22:08 2021 +0100

cid#1494446 Uninitialized scalar field

Change-Id: Ib8e1d0e691772e822f81afafbd47ba33698b592e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125863
Reviewed-by: Michael Stahl 
Tested-by: Caolán McNamara 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.hxx 
b/ucb/source/ucp/webdav-curl/CurlSession.hxx
index 563f7c3675dd..75ccf682692c 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.hxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.hxx
@@ -39,7 +39,7 @@ private:
 /// read timeout in milliseconds (connection timeout is stored in m_pCurl)
 int m_nReadTimeout = 0;
 /// flag to signal abort to transferring thread
-::std::atomic m_AbortFlag;
+::std::atomic m_AbortFlag = false;
 
 /// libcurl multi handle
 ::std::unique_ptr> 
m_pCurlMulti;


[Libreoffice-commits] core.git: ucb/source

2021-11-25 Thread Andrea Gelmini (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit ddc57169ac8d1de00403dbb09fef5221beaa0f3d
Author: Andrea Gelmini 
AuthorDate: Wed Nov 24 12:23:04 2021 +0100
Commit: Andrea Gelmini 
CommitDate: Fri Nov 26 00:33:59 2021 +0100

Removed break; after return

Change-Id: I14e12fee4b86ba2fadeefddef5de086e85d4bb95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125729
Reviewed-by: Julien Nabet 
Tested-by: Jenkins

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 8bf19a582693..2467aef835bf 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3330,7 +3330,6 @@ void Content::lock(
 // Detailed specification in:
 // 
 return;
-break;
 default:
 //fallthrough
 ;
@@ -3340,7 +3339,6 @@ void Content::lock(
 // we already hold the lock and it is in our internal lockstore
 // just return as if the lock was successful
 return;
-break;
 default:
 //fallthrough
 ;


[Libreoffice-commits] core.git: ucb/source

2021-11-25 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 4e9c1938df3fb13c73910ac4019b66a1924b6d5f
Author: Michael Stahl 
AuthorDate: Wed Nov 24 16:01:04 2021 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 25 18:54:11 2021 +0100

ucb: webdav-curl: NTLM is both system and not-system authentication

Leave it to libcurl collapse the wave function.

Change-Id: Idb51ebaec8b68a7c7fadcae2ae13b3b63ba1db79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125788
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 1c9da506df8e..aacc6bbed48e 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1307,11 +1307,21 @@ auto CurlProcessor::ProcessRequest(
 
 if (ret == 0)
 {
+// NTLM may either use a password requested
+// from the user, or from the system via SSPI
+// so i guess it should not be disabled here
+// regardless of the state of the system auth
+// checkbox, particularly since SSPI is only
+// available on WNT.
+// Additionally, "Negotiate" has a "legacy"
+// mode that is actually just NTLM according to
+// 
https://curl.se/rfc/ntlm.html#ntlmHttpAuthentication
+// so there's nothing in authSystem that can be
+// disabled here.
 roAuth.emplace(userName, passWord,
-   authAvail
-   & ((userName.isEmpty() && 
passWord.isEmpty())
-  ? authSystem
-  : ~authSystem));
+   ((userName.isEmpty() && 
passWord.isEmpty())
+? (authAvail & authSystem)
+: authAvail));
 isRetry = true;
 // Acquire is only necessary in case of 
success.
 guard.Acquire();


[Libreoffice-commits] core.git: ucb/source

2021-11-25 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   12 
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 97af6ccd95b9548723c2baa4b051c049c47bc8ea
Author: Michael Stahl 
AuthorDate: Wed Nov 24 19:52:10 2021 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 25 18:53:05 2021 +0100

ucb: webdav-curl: Sharepoint returns redirect urls that curl can't parse

Encode them just like in WebDAVResponseParser.

Change-Id: I7f0ee1d42df356fdd585d1f6e0f39e4094701a2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125787
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 509c7bc24629..1c9da506df8e 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1012,10 +1012,14 @@ auto CurlProcessor::ProcessRequestImpl(
 assert(rc == CURLE_OK);
 if (pRedirectURL)
 {
-throw DAVException(DAVException::DAV_HTTP_REDIRECT,
-   pRedirectURL ? OUString(pRedirectURL, 
strlen(pRedirectURL),
-   
RTL_TEXTENCODING_UTF8)
-: OUString());
+// Sharepoint 2016 workaround: contains unencoded U+0020
+OUString const redirectURL(::rtl::Uri::encode(
+pRedirectURL
+? OUString(pRedirectURL, strlen(pRedirectURL), 
RTL_TEXTENCODING_UTF8)
+: OUString(),
+rtl_UriCharClassUric, rtl_UriEncodeKeepEscapes, 
RTL_TEXTENCODING_UTF8));
+
+throw DAVException(DAVException::DAV_HTTP_REDIRECT, 
redirectURL);
 }
 [[fallthrough]];
 }


[Libreoffice-commits] core.git: ucb/source

2021-11-24 Thread Andrea Gelmini (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit e6f75af74c7f35feb8a22959a2f876af7f385ca2
Author: Andrea Gelmini 
AuthorDate: Wed Nov 24 12:13:16 2021 +0100
Commit: Julien Nabet 
CommitDate: Wed Nov 24 21:34:30 2021 +0100

Remove break; after return

Change-Id: I0690bcf0740842abde7268d99ab791163262945f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125766
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index f74bf01b5125..8bf19a582693 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3399,7 +3399,6 @@ void Content::unlock(
 // acting as WebDAV and having lock/unlock enabled only
 // for authorized user.
 return;
-break;
 case DAVException::DAV_HTTP_ERROR:
 //grab the error code
 switch( e.getStatus() )
@@ -3411,7 +3410,6 @@ void Content::unlock(
 SAL_WARN( "ucb.ucp.webdav", "unlock() DAVException 
(SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED) - URL: <"
   << m_xIdentifier->getContentIdentifier() << 
">, DAV ExceptionCode: " << e.getError() << ", HTTP error: " << e.getStatus() );
 return;
-break;
 default:
 //fallthrough
 ;


[Libreoffice-commits] core.git: ucb/source

2021-11-24 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   81 +++--
 1 file changed, 21 insertions(+), 60 deletions(-)

New commits:
commit c3db9d7a440f34f3faffee6583da5381a59d5c2a
Author: Michael Stahl 
AuthorDate: Tue Nov 23 21:24:02 2021 +0100
Commit: Michael Stahl 
CommitDate: Wed Nov 24 09:39:14 2021 +0100

ucb: webdav-curl: properly reset CURLOPT_INFILESIZE_LARGE

If the value is set to 0, then the next PROPFIND after PUT will not
append the "Expect: 100-continue" header, and hang without uploading.
See Curl_http_bodysend() which checks for != 0.

Unfortunately with different default values for "long" and "curl_off_t"
CurlOption becomes a little more complicated.

(regression from 8e34fe50412fd58a600ba1b8238b80444aec02e5)

Change-Id: I55ea02659f7a64f373e89a6d02d6865c158fd0c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125742
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index e3c5fdc19191..509c7bc24629 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -124,17 +124,9 @@ struct CurlOption
 Type const Tag;
 union {
 void const* const pValue;
-long const lValue;
-curl_off_t const cValue;
+long /*const*/ lValue;
+curl_off_t /*const*/ cValue;
 };
-#if 0
-::std::variant const Value;
-#endif
 char const* const pExceptionString;
 
 CurlOption(CURLoption const i_Option, void const* const i_Value,
@@ -145,23 +137,27 @@ struct CurlOption
 , pExceptionString(i_pExceptionString)
 {
 }
-CurlOption(CURLoption const i_Option, long const i_Value, char const* 
const i_pExceptionString)
-: Option(i_Option)
-, Tag(Type::Long)
-, lValue(i_Value)
-, pExceptionString(i_pExceptionString)
-{
-}
-#if SAL_TYPES_SIZEOFLONG == 4
+// Depending on platform, curl_off_t may be "long" or a larger type
+// so cannot use overloading to distinguish these cases.
 CurlOption(CURLoption const i_Option, curl_off_t const i_Value,
-   char const* const i_pExceptionString)
+   char const* const i_pExceptionString, Type const type = 
Type::Long)
 : Option(i_Option)
-, Tag(Type::CurlOffT)
-, cValue(i_Value)
+, Tag(type)
 , pExceptionString(i_pExceptionString)
 {
+static_assert(sizeof(long) <= sizeof(curl_off_t));
+switch (type)
+{
+case Type::Long:
+lValue = i_Value;
+break;
+case Type::CurlOffT:
+cValue = i_Value;
+break;
+default:
+assert(false);
+}
 }
-#endif
 };
 
 /// combined guard class to ensure things are released in correct order,
@@ -200,22 +196,6 @@ public:
 for (auto const& it : m_Options)
 {
 CURLcode rc(CURL_LAST); // warning C4701
-#if 0
-if (void const* const* const pp = ::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, *pp);
-}
-else if (long const * const pLong = ::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, *pLong);
-}
-#if SAL_TYPES_SIZEOFLONG == 4
-else if (curl_off_t const* const pOfft = 
::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, *pOfft);
-}
-#endif
-#endif
 if (it.Tag == CurlOption::Type::Pointer)
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, it.pValue);
@@ -224,12 +204,10 @@ public:
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, it.lValue);
 }
-#if SAL_TYPES_SIZEOFLONG == 4
 else if (it.Tag == CurlOption::Type::CurlOffT)
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, it.cValue);
 }
-#endif
 else
 {
 assert(false);
@@ -258,22 +236,6 @@ public:
 for (auto const& it : m_Options)
 {
 CURLcode rc(CURL_LAST); // warning C4701
-#if 0
-if (void const* const* const pp = ::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, nullptr);
-}
-else if (long const * const pLong = ::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, 0L);
-}
-#if SAL_TYPES_SIZEOFLONG == 4
-else if (curl_off_t const* const pOfft = 
::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, curl_off_t(0));
-}
-#endif
-#endif
 if (it.Tag == CurlOption::Type::Pointer)
 {
 

[Libreoffice-commits] core.git: ucb/source

2021-11-23 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   36 +++
 1 file changed, 20 insertions(+), 16 deletions(-)

New commits:
commit fa54bca695f6d17e871e43db75f06a63aec7b739
Author: Michael Stahl 
AuthorDate: Mon Nov 22 16:43:32 2021 +0100
Commit: Michael Stahl 
CommitDate: Tue Nov 23 12:07:35 2021 +0100

tdf#145769 ucb: webdav-curl: stop returning IsDocument=true if it doesn't 
exist

Content::getPropertyValues() has no less than 2 fallbacks that cause it
to return property values IsDocument=true and IsFolder=false in case
there is an authentication failure or server connection failure.

Change-Id: Iddcda6420c517f522d98e58b12a7e19247ff2d1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125667
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index eb19e0265659..f74bf01b5125 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -1339,13 +1339,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 }
 }
 
+bool bNetworkAccessAllowed = true;
+
 if ( !m_bTransient && !bHasAll )
 {
 // Obtain values from server...
 
 
 // First, identify whether resource is DAV or not
-bool bNetworkAccessAllowed = true;
 const ResourceType eType = getResourceType(
 xEnv, xResAccess, &bNetworkAccessAllowed );
 
@@ -1573,7 +1574,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 // For DAV resources we only know the Title, for non-DAV
 // resources we additionally know that it is a document.
 
-if ( eType == DAV )
+else if ( eType == DAV )
 {
 if (!xProps)
 xProps.reset(new ContentProperties(aUnescapedTitle));
@@ -1634,21 +1635,24 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 uno::makeAny( aDate ),
 true );
 }
-// If WebDAV didn't return the resource type, assume default
-// This happens e.g. for lists exported by SharePoint
-else if ( (*it) == "IsFolder" )
-{
-xProps->addProperty(
-(*it),
-uno::makeAny( false ),
-true );
-}
-else if ( (*it) == "IsDocument" )
+else if (bNetworkAccessAllowed) // don't set these if connection 
failed
 {
-xProps->addProperty(
-(*it),
-uno::makeAny( true ),
-true );
+// If WebDAV didn't return the resource type, assume default
+// This happens e.g. for lists exported by SharePoint
+if ((*it) == "IsFolder")
+{
+xProps->addProperty(
+(*it),
+uno::makeAny( false ),
+true );
+}
+else if ((*it) == "IsDocument")
+{
+xProps->addProperty(
+(*it),
+uno::makeAny( true ),
+true );
+}
 }
 }
 }


[Libreoffice-commits] core.git: ucb/source

2021-11-23 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   35 +++
 1 file changed, 30 insertions(+), 5 deletions(-)

New commits:
commit 014336e8d45fc192960b9240d362604577e78553
Author: Michael Stahl 
AuthorDate: Mon Nov 22 16:35:48 2021 +0100
Commit: Michael Stahl 
CommitDate: Tue Nov 23 12:06:27 2021 +0100

ucb: webdav-curl: fix some issues caused by missing authentication

* DAV_HTTP_NOAUTH wasn't actually handled anywhere; treat it the same as
  DAV_HTTP_AUTH for now
* Content::getResourceType() would just determine that the server
  doesn't support DAV if there is any authentication missing
* Content::getResourceOptions() would cache authentication error that is
  caused by executing the command without any XCommandEnvironment and
  therefore no XInteractionHandler

Change-Id: Ie319a505da4b0f6bde01d6611262b8b1dad33d2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125665
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 6d70ff77f8bc..eb19e0265659 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3272,6 +3272,7 @@ void Content::lock(
 false );
 }
 break;
+case DAVException::DAV_HTTP_NOAUTH:
 case DAVException::DAV_HTTP_AUTH:
 {
 SAL_WARN( "ucb.ucp.webdav", "lock(): DAVException 
Authentication error - URL: <"
@@ -3697,6 +3698,7 @@ bool Content::shouldAccessNetworkAfterException( const 
DAVException & e )
  ( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||
  ( e.getError() == DAVException::DAV_HTTP_LOOKUP ) ||
  ( e.getError() == DAVException::DAV_HTTP_CONNECT ) ||
+ ( e.getError() == DAVException::DAV_HTTP_NOAUTH ) ||
  ( e.getError() == DAVException::DAV_HTTP_AUTH ) ||
  ( e.getError() == DAVException::DAV_HTTP_AUTHPROXY ) )
 return false;
@@ -3880,7 +3882,10 @@ Content::ResourceType Content::getResourceType(
 rResAccess->resetUri();
 
 // first check if the cached error can be mapped to 
DAVException::DAV_HTTP_TIMEOUT or mapped to DAVException::DAV_HTTP_CONNECT
-if ( aDAVOptions.getHttpResponseStatusCode() == 
USC_CONNECTION_TIMED_OUT )
+if (aDAVOptions.getHttpResponseStatusCode() == 
USC_CONNECTION_TIMED_OUT
+// can't get any reliable info without auth => cancel request
+|| aDAVOptions.getHttpResponseStatusCode() == USC_AUTH_FAILED
+|| aDAVOptions.getHttpResponseStatusCode() == 
USC_AUTHPROXY_FAILED)
 {
 // behave same as DAVException::DAV_HTTP_TIMEOUT or 
DAVException::DAV_HTTP_CONNECT was thrown
 try
@@ -3889,7 +3894,22 @@ Content::ResourceType Content::getResourceType(
 CurlUri   theUri( rResAccess->getURL() );
 OUString  aHostName  = theUri.GetHost();
 sal_Int32 nPort  = theUri.GetPort();
-throw DAVException( DAVException::DAV_HTTP_TIMEOUT,
+DAVException::ExceptionCode e{};
+switch (aDAVOptions.getHttpResponseStatusCode())
+{
+case USC_CONNECTION_TIMED_OUT:
+e = DAVException::DAV_HTTP_TIMEOUT;
+break;
+case USC_AUTH_FAILED:
+e = DAVException::DAV_HTTP_AUTH;
+break;
+case USC_AUTHPROXY_FAILED:
+e = DAVException::DAV_HTTP_AUTHPROXY;
+break;
+default:
+assert(false);
+}
+throw DAVException( e,
 ConnectionEndPointString(aHostName, 
nPort) );
 }
 catch ( DAVException& exp )
@@ -3907,7 +3927,8 @@ Content::ResourceType Content::getResourceType(
 {
 //resource doesn't exist
 if ( networkAccessAllowed != nullptr )
-*networkAccessAllowed = false;}
+*networkAccessAllowed = false;
+}
 }
 }
 
@@ -4054,6 +4075,7 @@ void Content::getResourceOptions(
 }
 }
 break;
+case DAVException::DAV_HTTP_NOAUTH:
 case DAVException::DAV_HTTP_AUTH:
 {
 SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException: 
DAV_HTTP_AUTH for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
@@ -4064,8 +4086,11 @@ void Content::getResourceOptions(
 //   though possibly DAV enabled
 

[Libreoffice-commits] core.git: ucb/source

2021-11-22 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 8e34fe50412fd58a600ba1b8238b80444aec02e5
Author: Michael Stahl 
AuthorDate: Fri Nov 19 18:22:59 2021 +0100
Commit: Michael Stahl 
CommitDate: Mon Nov 22 11:26:28 2021 +0100

ucb: webdav-curl: don't use chunked encoding for PUT

What happens with Nextcloud:

 CURLINFO_HEADER_OUT: 0xa028408: PUT .../testB.odt HTTP/1.1
User-Agent: LibreOffice 7.3.0.0 curl/7.79.1 NSS/3.71
Accept: */*
Accept-Encoding: deflate, gzip
Transfer-Encoding: chunked
Expect: 100-continue
 debug log: 0xa028408: STATE: DO => DID handle 0xa028408; line 2077 
(connection #0)
 debug log: 0xa028408: STATE: DID => PERFORMING handle 0xa028408; line 2196 
(connection #0)
 debug log: 0xa028408: HTTP 1.1 or later with persistent connection
 CURLINFO_HEADER_IN: 0xa028408: HTTP/1.1 100 Continue
 debug log: 0xa028408: CURLINFO_DATA_OUT 8357
 debug log: 0xa028408: Signaling end of chunked upload via terminating 
chunk.
 debug log: 0xa028408: CURLINFO_DATA_OUT 5
 debug log: 0xa028408: Mark bundle as not supporting multiuse
 debug log: 0xa028408: HTTP 1.1 or later with persistent connection
 CURLINFO_HEADER_IN: 0xa028408: HTTP/1.1 201 Created
 CURLINFO_HEADER_IN: 0xa028408: Date: Fri, 19 Nov 2021 16:27:47 GMT
 CURLINFO_HEADER_IN: 0xa028408: Server: Apache
 CURLINFO_HEADER_IN: 0xa028408: Content-Length: 0

... yes, "201 Created" a 0 byte file.

https://github.com/nextcloud/server/issues/7995

Apparently this doesn't happen with header Content-Length: 8347

Change-Id: I3f38d50530a8b6430b27de2525370e1d95705da6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125579
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 5e5568a44773..e3c5fdc19191 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1800,13 +1800,15 @@ auto CurlSession::PUT(OUString const& rURIReference,
 
 CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference));
 
-// TODO: either set CURLOPT_INFILESIZE_LARGE or chunked?
-::std::unique_ptr> pList(
-curl_slist_append(nullptr, "Transfer-Encoding: chunked"));
-if (!pList)
+// NextCloud silently fails with chunked encoding
+uno::Reference const xSeekable(rxInStream, uno::UNO_QUERY);
+if (!xSeekable.is())
 {
-throw uno::RuntimeException("curl_slist_append failed");
+throw uno::RuntimeException("TODO: not seekable");
 }
+curl_off_t const len(xSeekable->getLength() - xSeekable->getPosition());
+
+::std::unique_ptr> pList;
 OUString const* const 
pToken(g_Init.LockStore.getLockTokenForURI(uri.GetURI(), nullptr));
 if (pToken)
 {
@@ -1828,7 +1830,7 @@ auto CurlSession::PUT(OUString const& rURIReference,
 
 // lock m_Mutex after accessing global LockStore to avoid deadlock
 
-::std::vector const options{};
+::std::vector const options{ { CURLOPT_INFILESIZE_LARGE, len, 
nullptr } };
 
 CurlProcessor::ProcessRequest(*this, uri, options, &rEnv, 
::std::move(pList), nullptr,
   &rxInStream, nullptr);


[Libreoffice-commits] core.git: ucb/source

2021-11-18 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 92dbabbafb25b24bc8c621d4fc516eadb53ff5c9
Author: Michael Stahl 
AuthorDate: Thu Nov 18 17:34:00 2021 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 18 18:34:50 2021 +0100

ucb: webdav-curl: don't assert on valid URL

If you put an URL into the host field of the remote files dialog,
it will gladly create silly urls that start with "https://https://";
- these are syntactically valid because ":" may occur without port
number path segment may be empty, so don't assert.

Change-Id: I29b6317daeb76d8f2fd4a22c0908ad2366c36297
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125484
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 16cd1c0a6081..e1cfd2c3f79f 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -782,7 +782,7 @@ auto CurlProcessor::URIReferenceToURI(CurlSession& 
rSession, OUString const& rUR
 }
 else
 {
-assert(rURIReference.startsWith("/") && 
!rURIReference.startsWith("//"));
+assert(rURIReference.startsWith("/"));
 return rSession.m_URI.CloneWithRelativeRefPathAbsolute(rURIReference);
 }
 }


[Libreoffice-commits] core.git: ucb/source

2021-11-15 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b56ff590a3bd2d09b8f72f0ec1030505e59f9008
Author: Stephan Bergmann 
AuthorDate: Mon Nov 15 17:11:53 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Mon Nov 15 19:32:01 2021 +0100

fix typo in comment

Change-Id: I267390e6d7251ec59c6374ca904ccba16f2a94bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125253
Reviewed-by: Adolfo Jayme Barrientos 
Tested-by: Jenkins

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 8be732e592a6..16cd1c0a6081 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -149,7 +149,7 @@ struct CurlOption
 #if SAL_TYPES_SIZEOFLONG == 4
 // According to mst this might get used "if one of the options to set 
stream size like
 // CURLOPT_INFILESIZE_LARGE were used but it's not the case currently", so 
keep this ctor
-// around as deleted in case it would ever becomes necessary to extend 
Value with a curl_off_t
+// around as deleted in case it would ever become necessary to extend 
Value with a curl_off_t
 // case:
 CurlOption(CURLoption, curl_off_t, char const*) = delete;
 #endif


[Libreoffice-commits] core.git: ucb/source

2021-11-09 Thread Andrea Gelmini (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 41b4053d7a395146a488c4aba0bc17b98b0a9502
Author: Andrea Gelmini 
AuthorDate: Tue Nov 9 23:43:38 2021 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Wed Nov 10 02:25:42 2021 +0100

Fix typo

Change-Id: I1ab712c8bea7083e0f32c647d783d12a770322a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124941
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 4deedeb752a5..8be732e592a6 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -149,7 +149,7 @@ struct CurlOption
 #if SAL_TYPES_SIZEOFLONG == 4
 // According to mst this might get used "if one of the options to set 
stream size like
 // CURLOPT_INFILESIZE_LARGE were used but it's not the case currently", so 
keep this ctor
-// around as deleted in case it would ever becomes necessasy to extend 
Value with a curl_off_t
+// around as deleted in case it would ever becomes necessary to extend 
Value with a curl_off_t
 // case:
 CurlOption(CURLoption, curl_off_t, char const*) = delete;
 #endif


[Libreoffice-commits] core.git: ucb/source

2021-11-09 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   45 +++--
 1 file changed, 6 insertions(+), 39 deletions(-)

New commits:
commit 20168b1f09b4d2aa8643dc7d4a16d8a1dd1008a6
Author: Stephan Bergmann 
AuthorDate: Tue Nov 9 12:10:25 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Nov 9 14:37:59 2021 +0100

The CurlOption curl_off_t case appears to be unused

...at least for my clang-cl Windows x86-64 build (see comments at


"ucb: webdav-curl: rewrite authentication loop for reentrancy")

Change-Id: I4f6b255c6a9acb26844b7ef5c11f0f1fcf06b3df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124907
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index f407ad1e7435..4deedeb752a5 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -118,21 +118,15 @@ struct CurlOption
 enum class Type
 {
 Pointer,
-Long,
-CurlOffT
+Long
 };
 Type const Tag;
 union {
 void const* const pValue;
 long const lValue;
-curl_off_t const cValue;
 };
 #if 0
 ::std::variant const Value;
 #endif
 char const* const pExceptionString;
@@ -153,14 +147,11 @@ struct CurlOption
 {
 }
 #if SAL_TYPES_SIZEOFLONG == 4
-CurlOption(CURLoption const i_Option, curl_off_t const i_Value,
-   char const* const i_pExceptionString)
-: Option(i_Option)
-, Tag(Type::CurlOffT)
-, cValue(i_Value)
-, pExceptionString(i_pExceptionString)
-{
-}
+// According to mst this might get used "if one of the options to set 
stream size like
+// CURLOPT_INFILESIZE_LARGE were used but it's not the case currently", so 
keep this ctor
+// around as deleted in case it would ever becomes necessasy to extend 
Value with a curl_off_t
+// case:
+CurlOption(CURLoption, curl_off_t, char const*) = delete;
 #endif
 };
 
@@ -209,12 +200,6 @@ public:
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, *pLong);
 }
-#if SAL_TYPES_SIZEOFLONG == 4
-else if (curl_off_t const* const pOfft = 
::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, *pOfft);
-}
-#endif
 #endif
 if (it.Tag == CurlOption::Type::Pointer)
 {
@@ -224,12 +209,6 @@ public:
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, it.lValue);
 }
-#if SAL_TYPES_SIZEOFLONG == 4
-else if (it.Tag == CurlOption::Type::CurlOffT)
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, it.cValue);
-}
-#endif
 else
 {
 assert(false);
@@ -267,12 +246,6 @@ public:
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, 0L);
 }
-#if SAL_TYPES_SIZEOFLONG == 4
-else if (curl_off_t const* const pOfft = 
::std::get_if(&it.Value))
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, curl_off_t(0));
-}
-#endif
 #endif
 if (it.Tag == CurlOption::Type::Pointer)
 {
@@ -282,12 +255,6 @@ public:
 {
 rc = curl_easy_setopt(m_pCurl, it.Option, 0L);
 }
-#if SAL_TYPES_SIZEOFLONG == 4
-else if (it.Tag == CurlOption::Type::CurlOffT)
-{
-rc = curl_easy_setopt(m_pCurl, it.Option, curl_off_t(0));
-}
-#endif
 else
 {
 assert(false);


[Libreoffice-commits] core.git: ucb/source

2021-11-09 Thread Stephan Bergmann (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   35 +++--
 ucb/source/ucp/webdav-curl/CurlSession.hxx |4 +--
 ucb/source/ucp/webdav-curl/CurlUri.cxx |3 +-
 ucb/source/ucp/webdav-curl/CurlUri.hxx |9 ---
 4 files changed, 29 insertions(+), 22 deletions(-)

New commits:
commit 0a5388fab08474bade08be838f5749f2cae452d5
Author: Stephan Bergmann 
AuthorDate: Tue Nov 9 08:46:21 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Nov 9 11:33:36 2021 +0100

Address of dllimport function isn't considered constant expression by 
clang-cl

...causing the (mis-)use of std::integral_constant to fail with

> In file included from ucb/source/ucp/webdav-curl/CurlUri.cxx:20:
> In file included from ucb/source/ucp/webdav-curl/CurlUri.hxx:24:
> In file included from 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\memory:11:
> In file included from 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\exception:12:
> In file included from 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\type_traits:12:
> In file included from 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\xstddef:11:
> In file included from 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\cstddef:13:
> 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\xtr1common(22,26):
 error: constexpr variable 'value' must be initialized by a constant expression
> static constexpr _Ty value = _Val;
>  ^   
> 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\xtr1common(28,16):
 note: in instantiation of static data member 'std::integral_constant::value' requested here
> return value;
>^
> 
C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\memory(3195,13):
 note: in instantiation of member function 'std::integral_constant::operator void (*)(void *)' requested here
> _Mypair._Get_first()(_Mypair._Myval2);
> ^
> ucb/source/ucp/webdav-curl/CurlUri.cxx(49,25): note: in instantiation of 
member function 'std::unique_ptr>::~unique_ptr' requested here
> CurlUniquePtr pPart2(pPart);
> ^

etc. as the involved functions like curl_free are defined as

  CURL_EXTERN void curl_free(void *p);

in workdir/UnpackedTarball/curl/include/curl/curl.h, where CURL_EXTERN 
expands
to __declspec(dllimport)

Change-Id: Ib278cd9e97260b588144d81dba344ccbb5309608
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124899
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 7cab4ca763ee..f407ad1e7435 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -776,7 +776,8 @@ struct CurlProcessor
 static auto ProcessRequest(
 CurlSession& rSession, CurlUri const& rURI, ::std::vector 
const& rOptions,
 DAVRequestEnvironment const* pEnv,
-::std::unique_ptr> 
pRequestHeaderList,
+::std::unique_ptr>
+pRequestHeaderList,
 uno::Reference const* pxOutStream,
 uno::Reference const* pxInStream,
 ::std::pair<::std::vector const&, DAVResource&> const* 
pRequestedHeaders) -> void;
@@ -792,10 +793,10 @@ struct CurlProcessor
::std::u16string_view rDestinationURI, 
DAVRequestEnvironment const& rEnv,
bool isOverwrite, char const* pMethod) -> void;
 
-static auto
-Lock(CurlSession& rSession, CurlUri const& rURI, DAVRequestEnvironment 
const* pEnv,
- ::std::unique_ptr> 
pRequestHeaderList,
- uno::Reference const* pxInStream)
+static auto Lock(CurlSession& rSession, CurlUri const& rURI, 
DAVRequestEnvironment const* pEnv,
+ ::std::unique_ptr>
+ pRequestHeaderList,
+ uno::Reference const* pxInStream)
 -> ::std::vector<::std::pair>;
 
 static auto Unlock(CurlSession& rSession, CurlUri const& rURI,
@@ -1110,7 +,8 @@ static auto TryRemoveExpiredLockToken(CurlSession& 
rSession, CurlUri const& rURI
 auto CurlProcessor::ProcessRequest(
 CurlSession& rSession, CurlUri const& rURI, ::std::vector 
const& rOptions,
 DAVRequestEnvironment const* const pEnv,
-::std::unique_ptr> 
pRequestHeaderList,
+::std::unique_ptr>
+pRequestHeaderList,
 uno::Reference const* const pxOutStream,
 uno::Reference const* const pxInStream,
 ::std::pair<::std::vector const&, DAVResource&> const* const 
pRequestedHeaders)
@@ -1448,7 +1450,7 @@ auto CurlProcessor::PropFind(
   != (::std::get<2>(*o_pRequestedProperties) != nullptr));
 
 // TODO: either set CURLOPT_INFILESIZE_

[Libreoffice-commits] core.git: ucb/source

2021-11-05 Thread Mike Kaganski (via logerrit)
 ucb/source/ucp/webdav-curl/webdavcontent.cxx|   87 
 ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx|   34 ---
 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx |4 
 3 files changed, 56 insertions(+), 69 deletions(-)

New commits:
commit 7e33e24181ffaddcee4bc1358650a0bac48f8ebd
Author: Mike Kaganski 
AuthorDate: Fri Nov 5 18:26:01 2021 +0300
Commit: Michael Stahl 
CommitDate: Fri Nov 5 20:56:03 2021 +0100

webdav-curl: there's no non-const Sequence::operator[]

... since commit fb3c04bd1930eedacd406874e1a285d62bbf27d9

Change-Id: Ib56e854206074dd247dcd0f876a8a92b3f9af7ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124763
Tested-by: Julien Nabet 
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 8baa7b95de46..6d70ff77f8bc 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -1376,24 +1376,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 // Only DAV resources support PROPFIND
 std::vector< OUString > aPropNames;
 
-uno::Sequence< beans::Property > aProperties(
-rProperties.getLength() );
-
-if ( !m_aFailedPropNames.empty() )
-{
-sal_Int32 nProps = 0;
-sal_Int32 nCount = rProperties.getLength();
-for ( sal_Int32 n = 0; n < nCount; ++n, ++nProps )
-{
-aProperties[ nProps ] = rProperties[ n ];
-}
-
-aProperties.realloc( nProps );
-}
-else
-{
-aProperties = rProperties;
-}
+uno::Sequence< beans::Property > aProperties(rProperties);
 
 if ( aProperties.getLength() > 0 )
 ContentProperties::UCBNamesToDAVNames(
@@ -1739,6 +1722,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
 }
 
 uno::Sequence< uno::Any > aRet( rValues.getLength() );
+auto aRetRange = asNonConstRange(aRet);
 uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() 
);
 sal_Int32 nChanged = 0;
 
@@ -1776,7 +1760,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
 if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY )
 {
 // Read-only property!
-aRet[ n ] <<= lang::IllegalAccessException(
+aRetRange[ n ] <<= lang::IllegalAccessException(
 "Property is read-only!",
 static_cast< cppu::OWeakObject * >( this ) );
 continue;
@@ -1789,21 +1773,21 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
 if ( rName == "ContentType" )
 {
 // Read-only property!
-aRet[ n ] <<= lang::IllegalAccessException(
+aRetRange[ n ] <<= lang::IllegalAccessException(
 "Property is read-only!",
 static_cast< cppu::OWeakObject * >( this ) );
 }
 else if ( rName == "IsDocument" )
 {
 // Read-only property!
-aRet[ n ] <<= lang::IllegalAccessException(
+aRetRange[ n ] <<= lang::IllegalAccessException(
 "Property is read-only!",
 static_cast< cppu::OWeakObject * >( this ) );
 }
 else if ( rName == "IsFolder" )
 {
 // Read-only property!
-aRet[ n ] <<= lang::IllegalAccessException(
+aRetRange[ n ] <<= lang::IllegalAccessException(
 "Property is read-only!",
 static_cast< cppu::OWeakObject * >( this ) );
 }
@@ -1836,7 +1820,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
 }
 catch ( DAVException const & )
 {
-aRet[ n ] <<= lang::IllegalArgumentException(
+aRetRange[ n ] <<= lang::IllegalArgumentException(
 "Invalid content identifier!",
 static_cast< cppu::OWeakObject * >( this ),
 -1 );
@@ -1844,7 +1828,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
 }
 else
 {
-aRet[ n ] <<= lang::IllegalArgumentException(
+aRetRange[ n ] <<= lang::IllegalArgumentException(
 "Empty title not allowed!",
 static_cast< cppu::OWeakObject * >( this ),
 -1 );
@@ -1852,7 +1836,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
 }
 else
 {
-aRet[ n 

[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 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(-)

New commits:
commit 34f5a5a5e482f47476f1a37684d837c1d21d79b0
Author: Michael Stahl 
AuthorDate: Thu Oct 28 16:56:35 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 19:03:48 2021 +0100

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 

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

[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit a6c21346d4374ea9a0c1e4e1b05e443f48cef65b
Author: Michael Stahl 
AuthorDate: Mon Nov 1 13:27:36 2021 +0100
Commit: Michael Stahl 
CommitDate: Mon Nov 1 19:03:14 2021 +0100

ucb: webdav-curl: fix MOVE/COPY/DELETE crash

These need "nobody"; some errors like 401 will return a body that should
be ignored.

Change-Id: If2f726aa34d4d3fae1bd61bc87b62e2d55a7ff26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124561
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index a3426f7ddd89..d7a0f62ce606 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1915,8 +1915,9 @@ auto CurlSession::MKCOL(OUString const& rURIReference, 
DAVRequestEnvironment con
 
 CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference));
 
-::std::vector const options{ { CURLOPT_CUSTOMREQUEST, "MKCOL",
-   "CURLOPT_CUSTOMREQUEST" } };
+::std::vector const options{
+{ CURLOPT_NOBODY, 1L, nullptr }, { CURLOPT_CUSTOMREQUEST, "MKCOL", 
"CURLOPT_CUSTOMREQUEST" }
+};
 
 CurlProcessor::ProcessRequest(*this, uri, options, &rEnv, nullptr, 
nullptr, nullptr, nullptr);
 }
@@ -1943,8 +1944,9 @@ auto CurlProcessor::MoveOrCopy(CurlSession& rSession, 
OUString const& rSourceURI
 throw uno::RuntimeException("curl_slist_append failed");
 }
 
-::std::vector const options{ { CURLOPT_CUSTOMREQUEST, pMethod,
-   "CURLOPT_CUSTOMREQUEST" } };
+::std::vector const options{
+{ CURLOPT_NOBODY, 1L, nullptr }, { CURLOPT_CUSTOMREQUEST, pMethod, 
"CURLOPT_CUSTOMREQUEST" }
+};
 
 CurlProcessor::ProcessRequest(rSession, uriSource, options, &rEnv, 
::std::move(pList), nullptr,
   nullptr, nullptr);
@@ -1974,7 +1976,8 @@ auto CurlSession::DESTROY(OUString const& rURIReference, 
DAVRequestEnvironment c
 
 CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference));
 
-::std::vector const options{ { CURLOPT_CUSTOMREQUEST, "DELETE",
+::std::vector const options{ { CURLOPT_NOBODY, 1L, nullptr },
+ { CURLOPT_CUSTOMREQUEST, "DELETE",
"CURLOPT_CUSTOMREQUEST" } };
 
 CurlProcessor::ProcessRequest(*this, uri, options, &rEnv, nullptr, 
nullptr, nullptr, nullptr);


[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx | 1197 ++---
 1 file changed, 616 insertions(+), 581 deletions(-)

New commits:
commit d4acfea2fed8f999347e49ed76c3f5115952df5c
Author: Michael Stahl 
AuthorDate: Fri Oct 29 21:53:31 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 19:02:16 2021 +0100

ucb: webdav-curl: rewrite authentication loop for reentrancy

Surprisingly calling authenticate() can lead to a reentrant call
via event loop, which fortunately deadlocks with non-recusive mutex,
or we'd have a much more difficult to debug problem:

 5  std::unique_lock::unique_lock()
 7  http_dav_ucp::CurlProcessor::PropFind()
 8  http_dav_ucp::CurlSession::PROPFIND() (this=0x391fe80, 
rURIReference="/testL.odt", depth=http_dav_ucp::DAVZERO, 
o_rResourceInfos=std::__debug::vector of length 0, capacity 0, rEnv=...)
 9  http_dav_ucp::DAVResourceAccess::PROPFIND() (this=0xab3bb00, 
nDepth=http_dav_ucp::DAVZERO, rResInfo=std::__debug::vector of length 0, 
capacity 0, xEnv=uno::Reference to (class ucbhelper::CommandEnvironment *) 
0x390b578)
 10 http_dav_ucp::Content::getProperties() (this=0xa8ba9a0, 
xEnv=uno::Reference to (class ucbhelper::CommandEnvironment *) 0x390b578)
 15 SfxBaseModel::isVersionable() (this=0x7159c90)
 19 SfxBindings::Update_Impl(SfxStateCache&)
 24 Timer::Invoke() (this=0x7394708)
 30 g_main_loop_run ()
 35 (anonymous namespace)::executeMasterPasswordDialog()
 40 (anonymous namespace)::UUIInteractionHandler::handle()
 41 PasswordContainer::RequestPasswordFromUser()
 42 PasswordContainer::GetMasterPassword()
 47 PasswordContainer::find()
 48 uui::PasswordContainerHelper::handleAuthenticationRequest()
 57 ucbhelper::InterceptedInteraction::handle()
 58 http_dav_ucp::DAVAuthListener_Impl::authenticate()
 59 http_dav_ucp::CurlProcessor::ProcessRequestImpl()
 60 http_dav_ucp::CurlProcessor::ProcessRequest()
 61 http_dav_ucp::CurlProcessor::PropFind()
 62 http_dav_ucp::CurlSession::PROPFIND() (this=0x391fe80, 
rURIReference="/testL.odt", depth=http_dav_ucp::DAVZERO, 
o_rResourceInfos=std::__debug::vector of length 0, capacity 0, rEnv=...)
 63 http_dav_ucp::DAVResourceAccess::PROPFIND() (this=0xab8c060, 
nDepth=http_dav_ucp::DAVZERO, rResInfo=std::__debug::vector of length 0, 
capacity 0, xEnv=uno::Reference to (class ucbhelper::CommandEnvironment *) 
0x390b578)
 64 http_dav_ucp::Content::getProperties() (this=0xa8ba9a0, 
xEnv=uno::Reference to (class ucbhelper::CommandEnvironment *) 0x390b578)
 67 ucbhelper::PropertySetInfo::hasPropertyByName() (this=0xa8d7a20, 
Name="TitleOnServer")
 68 SfxBaseModel::getTitle()
 74 framework::TitleHelper::impl_updateTitle()
 75 framework::TitleHelper::documentEventOccured()
 78 SfxBaseModel::postEvent_Impl() (this=0x7159c90, aName="OnModeChanged", 
xController=empty uno::Reference)
 79 SfxBaseModel::Notify()
 80 SfxBroadcaster::Broadcast()
 81 SfxObjectShell::SetModalMode_Impl()
 82 SfxViewFrame::SetModalMode(bool)
 83 SfxFrameWindow_Impl::ModalHierarchyHdl()
 86 SalFrame::NotifyModalHierarchy()
 88 SalGtkFilePicker::execute()
 92 ModelData_Impl::OutputFileDialog()
 93 SfxStoringHelper::GUIStoreModel()

Need to move authentication loop to the outer function, so that all the
option guards in ProcessRequestImpl() are reset/set again, and also
delay setting the option guards from the various callers so they can be
reset in ProcessRequest() before authenticate().

Change-Id: Id697b1459f94f80fc58cee7768c2bd388369b29c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124452
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 6fb54998c531..a3426f7ddd89 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -99,6 +99,72 @@ struct UploadSource
 }
 };
 
+auto GetErrorString(CURLcode const rc, char const* const pErrorBuffer = 
nullptr) -> OString
+{
+char const* const pMessage( // static fallback
+(pErrorBuffer && pErrorBuffer[0] != '\0') ? pErrorBuffer : 
curl_easy_strerror(rc));
+return OString::Concat("(") + OString::number(sal_Int32(rc)) + ") " + 
pMessage;
+}
+
+auto GetErrorStringMulti(CURLMcode const mc) -> OString
+{
+return OString::Concat("(") + OString::number(sal_Int32(mc)) + ") " + 
curl_multi_strerror(mc);
+}
+
+/// represent an option to be passed to curl_easy_setopt()
+struct CurlOption
+{
+CURLoption const Option;
+enum class Type
+{
+Pointer,
+Long,
+CurlOffT
+};
+Type const Tag;
+union {
+void const* const pValue;
+decltype(0L) const lValue;
+curl_off_t const cValue;
+};
+#if 0
+::std::variant const Value;
+#endif
+char const* const pExceptionString;

[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx   |   25 +--
 ucb/source/ucp/webdav-curl/CurlSession.hxx   |3 ++
 ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx |   14 +---
 ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx |2 -
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |2 -
 5 files changed, 34 insertions(+), 12 deletions(-)

New commits:
commit 5d845fd02700c43352740cc9e675c91a6876e7d9
Author: Michael Stahl 
AuthorDate: Tue Oct 26 13:52:29 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 19:01:33 2021 +0100

ucb: webdav-curl: implement CurlSession::abort()

It looks like libcurl has an API to wake up a transfer in another
thread, but have to use curl_multi_poll() instead of curl_multi_wait()
to enable that.

Change-Id: I728416eba45eb6665b0041955cdce8bee07e845e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124220
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 76fdbce1bac5..6fb54998c531 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -589,11 +589,16 @@ auto CurlSession::UsesProxy() -> bool
 
 auto CurlSession::abort() -> void
 {
-// this is using synchronous libcurl apis - no way to abort?
-// might be possible with more complexity and CURLOPT_CONNECT_ONLY
-// or curl_multi API, but is it worth the complexity?
-// ... it looks like CURLOPT_CONNECT_ONLY would disable all HTTP handling.
-// abort() was a no-op since OOo 3.2 and before that it crashed.
+// note: abort() was a no-op since OOo 3.2 and before that it crashed.
+bool expected(false);
+// it would be pointless to lock m_Mutex here as the other thread holds it
+if (m_AbortFlag.compare_exchange_strong(expected, true))
+{
+// This function looks safe to call without m_Mutex as long as the
+// m_pCurlMulti handle is not destroyed, and the caller must own a ref
+// to this object which keeps it alive; it should cause poll to return.
+curl_multi_wakeup(m_pCurlMulti.get());
+}
 }
 
 /// this is just a bunch of static member functions called from CurlSession
@@ -663,6 +668,10 @@ auto CurlProcessor::ProcessRequestImpl(
 ::std::pair<::std::vector const&, DAVResource&> const* const 
pRequestedHeaders)
 -> void
 {
+// Clear flag before transfer starts; only a transfer started before
+// calling abort() will be aborted, not one started later.
+rSession.m_AbortFlag.store(false);
+
 if (pEnv)
 { // add custom request headers passed by caller
 for (auto const& rHeader : pEnv->m_aRequestHeaders)
@@ -887,7 +896,7 @@ auto CurlProcessor::ProcessRequestImpl(
 break;
 }
 int nFDs;
-mc = curl_multi_wait(rSession.m_pCurlMulti.get(), nullptr, 0, 
rSession.m_nReadTimeout,
+mc = curl_multi_poll(rSession.m_pCurlMulti.get(), nullptr, 0, 
rSession.m_nReadTimeout,
  &nFDs);
 if (mc != CURLM_OK)
 {
@@ -897,6 +906,10 @@ auto CurlProcessor::ProcessRequestImpl(
 DAVException::DAV_HTTP_CONNECT,
 ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
 }
+if (rSession.m_AbortFlag.load())
+{ // flag was set by abort() -> not sure what exception to throw?
+throw DAVException(DAVException::DAV_HTTP_ERROR, "abort() was 
called", 0);
+}
 } while (nRunning != 0);
 // there should be exactly 1 CURLMsg now, but the interface is
 // extensible so future libcurl versions could yield additional things
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.hxx 
b/ucb/source/ucp/webdav-curl/CurlSession.hxx
index 67e4e3616aab..73b32096f6ea 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.hxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.hxx
@@ -14,6 +14,7 @@
 
 #include 
 
+#include 
 #include 
 
 namespace http_dav_ucp
@@ -37,6 +38,8 @@ private:
 bool m_isAuthenticatedProxy = false;
 /// read timeout in milliseconds (connection timeout is stored in m_pCurl)
 int m_nReadTimeout = 0;
+/// flag to signal abort to transferring thread
+::std::atomic m_AbortFlag;
 
 /// libcurl multi handle
 ::std::unique_ptr> m_pCurlMulti;
diff --git a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx 
b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx
index a6bfd7d79642..248d65b8c60c 100644
--- a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx
@@ -570,10 +570,16 @@ void DAVResourceAccess::GET(
 
 void DAVResourceAccess::abort()
 {
-// 17.11.09 (tkr): abort currently disabled caused by issue i106766
-// initialize();
-// m_xSession->abort();
-SAL_INFO("ucb.ucp.w

[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit eb7fecd8ef3c0507ac6f9f60cc25161d84349e93
Author: Michael Stahl 
AuthorDate: Mon Oct 25 17:49:40 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 19:01:02 2021 +0100

ucb: webdav-curl: escape broken SharePoint 2016 URIs

[ reimplement commit 069aa870aadb9f9069e8715c8be30394410f0288 ]

Change-Id: I01a93e3a448e6dc921d1e0471ae01c8ac8feea11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124218
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx 
b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
index 478e9090990e..9595d42a03b2 100644
--- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace com::sun::star;
@@ -551,7 +552,13 @@ namespace
 // href end, save it if we have whitespace
 if(whitespaceIsAvailable())
 {
-maHref = mpContext->getWhiteSpace();
+// Sharepoint 2016 workaround: apparently
+// the result is an IRI (RFC 3987 
possibly?)
+// so try to encode the non-ASCII chars
+// without changing anything else
+maHref = 
::rtl::Uri::encode(mpContext->getWhiteSpace(),
+rtl_UriCharClassUric, 
rtl_UriEncodeKeepEscapes,
+RTL_TEXTENCODING_UTF8);
 }
 break;
 }


[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit a1ce00dad942b459dc145d4ac5ab1d02893fff0b
Author: Michael Stahl 
AuthorDate: Mon Oct 25 17:45:41 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 19:00:44 2021 +0100

ucb: webdav-curl: tdf#82744: fix WebDAV lock/unlock behaviour - part 4

[ reimplement Sharepoint 2013 workaround from commit
  fed2984281a85a5a2f308841ec810f218c75f2ab ]

Change-Id: Ib7f5a66e32d630e900f5f77c882ba791a9ab7aac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124217
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 35e70b6d4908..76fdbce1bac5 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -1689,8 +1689,15 @@ auto CurlSession::PUT(OUString const& rURIReference,
 OUString const token(g_Init.LockStore.getLockToken(uri.GetURI()));
 if (!token.isEmpty())
 {
-OString const utf8If("If: <" + OUStringToOString(rURIReference, 
RTL_TEXTENCODING_ASCII_US)
- + "> (<" + OUStringToOString(token, 
RTL_TEXTENCODING_ASCII_US) + ">)");
+OString const utf8If("If: "
+// disabled as Sharepoint 2013 workaround, it accepts only
+// "No-Tag-List", see fed2984281a85a5a2f308841ec810f218c75f2ab
+#if 0
+"<" + OUStringToOString(rURIReference, 
RTL_TEXTENCODING_ASCII_US)
+ + "> "
+#endif
+ "(<"
+ + OUStringToOString(token, 
RTL_TEXTENCODING_ASCII_US) + ">)");
 pList.reset(curl_slist_append(pList.release(), utf8If.getStr()));
 if (!pList)
 {


[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx |   84 +++--
 ucb/source/ucp/webdav-curl/CurlSession.hxx |4 +
 2 files changed, 84 insertions(+), 4 deletions(-)

New commits:
commit ebe2050da7f04e0e4b3c7d27ec25379604fc86da
Author: Michael Stahl 
AuthorDate: Tue Oct 26 12:18:11 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 18:59:48 2021 +0100

ucb: webdav-curl: use curl_multi API to support read timeout

This enables passing timeout to the curl_multi_wait() function.

Change-Id: Ic0ab9afe955b3625be0a44304c69882eb896abf0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124219
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 4c42985190ff..35e70b6d4908 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -137,6 +137,11 @@ static auto GetErrorString(CURLcode const rc, char const* 
const pErrorBuffer = n
 return OString::Concat("(") + OString::number(sal_Int32(rc)) + ") " + 
pMessage;
 }
 
+static auto GetErrorStringMulti(CURLMcode const mc) -> OString
+{
+return OString::Concat("(") + OString::number(sal_Int32(mc)) + ") " + 
curl_multi_strerror(mc);
+}
+
 // libcurl callbacks:
 
 #if OSL_DEBUG_LEVEL > 0
@@ -445,6 +450,13 @@ 
CurlSession::CurlSession(uno::Reference const& xContext,
 , m_Proxy(rProxyDecider.getProxy(m_URI.GetScheme(), m_URI.GetHost(), 
m_URI.GetPort()))
 {
 assert(m_URI.GetScheme() == "http" || m_URI.GetScheme() == "https");
+m_pCurlMulti.reset(curl_multi_init());
+if (!m_pCurlMulti)
+{
+SAL_WARN("ucb.ucp.webdav.curl", "curl_multi_init failed");
+throw DAVException(DAVException::DAV_SESSION_CREATE,
+   ConnectionEndPointString(m_URI.GetHost(), 
m_URI.GetPort()));
+}
 m_pCurl.reset(curl_easy_init());
 if (!m_pCurl)
 {
@@ -504,10 +516,8 @@ 
CurlSession::CurlSession(uno::Reference const& xContext,
 throw DAVException(DAVException::DAV_SESSION_CREATE,
ConnectionEndPointString(m_URI.GetHost(), 
m_URI.GetPort()));
 }
-#if 0
 auto const 
readTimeout(officecfg::Inet::Settings::ReadTimeout::get(m_xContext));
-// TODO: read timeout??? does not map to this value?
-#endif
+m_nReadTimeout = ::std::max(20, ::std::min(readTimeout, 180)) * 
1000;
 // default is infinite
 rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_TIMEOUT, 300L);
 if (rc != CURLE_OK)
@@ -837,8 +847,74 @@ auto CurlProcessor::ProcessRequestImpl(
 assert(rc == CURLE_OK);
 }
 rSession.m_ErrorBuffer[0] = '\0';
+
+// note: easy handle must be added for *every* transfer!
+// otherwise it gets stuck in MSTATE_MSGSENT forever after 1st transfer
+auto mc = curl_multi_add_handle(rSession.m_pCurlMulti.get(), 
rSession.m_pCurl.get());
+if (mc != CURLM_OK)
+{
+SAL_WARN("ucb.ucp.webdav.curl",
+ "curl_multi_add_handle failed: " << 
GetErrorStringMulti(mc));
+throw DAVException(
+DAVException::DAV_SESSION_CREATE,
+ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+}
+::comphelper::ScopeGuard const gg([&]() {
+mc = curl_multi_remove_handle(rSession.m_pCurlMulti.get(), 
rSession.m_pCurl.get());
+if (mc != CURLM_OK)
+{
+SAL_WARN("ucb.ucp.webdav.curl",
+ "curl_multi_remove_handle failed: " << 
GetErrorStringMulti(mc));
+}
+});
+
 // this is where libcurl actually does something
-rc = curl_easy_perform(rSession.m_pCurl.get());
+rc = CURL_LAST; // clear current value
+int nRunning;
+do
+{
+mc = curl_multi_perform(rSession.m_pCurlMulti.get(), &nRunning);
+if (mc != CURLM_OK)
+{
+SAL_WARN("ucb.ucp.webdav.curl",
+ "curl_multi_perform failed: " << 
GetErrorStringMulti(mc));
+throw DAVException(
+DAVException::DAV_HTTP_CONNECT,
+ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+}
+if (nRunning == 0)
+{ // short request like HEAD on loopback could be done in first 
call
+break;
+}
+int nFDs;
+mc = curl_multi_wait(rSession.m_pCurlMulti.get(), nullptr, 0, 
rSession.m_nReadTimeout,
+ &nFDs);
+if (mc != CURLM_OK)
+{
+SAL_WARN("ucb.ucp.webdav.curl",
+ "curl_multi_poll failed: " << 
GetErrorStringMulti(mc));
+throw DAVException(
+DAVException::DAV_HTTP_CONNECT,
+Co

[Libreoffice-commits] core.git: ucb/source

2021-11-01 Thread Michael Stahl (via logerrit)
 ucb/source/ucp/webdav-curl/CurlSession.cxx   |   17 -
 ucb/source/ucp/webdav-curl/CurlSession.hxx   |4 ++--
 ucb/source/ucp/webdav-curl/SerfLockStore.cxx |   19 +--
 3 files changed, 35 insertions(+), 5 deletions(-)

New commits:
commit 791f94a967560fb36cce06e673b115f3ffc707ae
Author: Michael Stahl 
AuthorDate: Mon Oct 25 15:26:55 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Nov 1 18:59:12 2021 +0100

ucb: webdav-curl: remove locks from LockStore after AUTH error

[ reimplement commit 94e4695bcfcb9356d37942c47359b94531ef7b95 ]

Change-Id: I15d1a95074dcad3f2c642bb0819741a2b0f734c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124216
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 3fe73b57f873..4c42985190ff 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -2064,7 +2064,8 @@ auto CurlSession::UNLOCK(OUString const& rURIReference, 
DAVRequestEnvironment co
 }
 
 auto CurlSession::NonInteractive_LOCK(OUString const& rURI,
-  sal_Int32& 
o_rLastChanceToSendRefreshRequest) -> bool
+  sal_Int32& 
o_rLastChanceToSendRefreshRequest,
+  bool& o_rIsAuthFailed) -> bool
 {
 SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK: " << rURI);
 
@@ -2097,6 +2098,20 @@ auto CurlSession::NonInteractive_LOCK(OUString const& 
rURI,
 SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK succeeded on " << 
rURI);
 return true;
 }
+catch (DAVException const& rException)
+{
+SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK failed on " << 
rURI);
+switch (rException.getError())
+{
+case DAVException::DAV_HTTP_AUTH:
+case DAVException::DAV_HTTP_NOAUTH:
+o_rIsAuthFailed = true;
+break;
+default:
+break;
+}
+return false;
+}
 catch (...)
 {
 SAL_INFO("ucb.ucp.webdav.curl", "NonInteractive_LOCK failed on " << 
rURI);
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.hxx 
b/ucb/source/ucp/webdav-curl/CurlSession.hxx
index 88496308a947..33288b312051 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.hxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.hxx
@@ -127,8 +127,8 @@ public:
 
 virtual auto abort() -> void override;
 
-auto NonInteractive_LOCK(OUString const& rURI, sal_Int32& 
o_rLastChanceToSendRefreshRequest)
--> bool;
+auto NonInteractive_LOCK(OUString const& rURI, 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 93cca865eb1b..ef9534dbe58f 100644
--- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx
@@ -135,8 +135,10 @@ void SerfLockStore::stopTicker(osl::ClearableMutexGuard & 
rGuard)
 
 rGuard.clear();
 
-if (pTickerThread.is())
+if (pTickerThread.is() && pTickerThread->getIdentifier() != 
osl::Thread::getCurrentIdentifier())
+{
 pTickerThread->join(); // without m_aMutex locked (to prevent deadlock)
+}
 }
 
 OUString SerfLockStore::getLockToken(const OUString& rURI)
@@ -238,6 +240,8 @@ void SerfLockStore::refreshLocks()
 {
 osl::MutexGuard aGuard( m_aMutex );
 
+::std::vector authFailedLocks;
+
 for ( auto& rLockInfo : m_aLockInfoMap )
 {
 LockInfo & rInfo = rLockInfo.second;
@@ -251,20 +255,31 @@ void SerfLockStore::refreshLocks()
 {
 // refresh the lock.
 sal_Int32 nlastChanceToSendRefreshRequest = -1;
+bool isAuthFailed(false);
 if (rInfo.m_xSession->NonInteractive_LOCK(
- rLockInfo.first, nlastChanceToSendRefreshRequest))
+ rLockInfo.first, nlastChanceToSendRefreshRequest,
+ isAuthFailed))
 {
 rInfo.m_nLastChanceToSendRefreshRequest
 = nlastChanceToSendRefreshRequest;
 }
 else
 {
+if (isAuthFailed)
+{
+authFailedLocks.push_back(rLockInfo.first);
+}
 // refresh failed. stop auto-refresh.
 rInfo.m_nLastChanceToSendRefreshRequest = -1;
 }
 }
 }
 }
+
+for (auto const& rLock : authFailedLocks)
+{
+removeLock(rLock);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


  1   2   3   4   5   6   >