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

Matúš Kukan matus.kukan at collabora.com
Wed Mar 26 08:40:38 PDT 2014


 ucb/Library_ucpdav1.mk                                |    5 
 ucb/source/ucp/webdav/AprEnv.cxx                      |    9 
 ucb/source/ucp/webdav/AprEnv.hxx                      |    6 
 ucb/source/ucp/webdav/DAVProperties.hxx               |    3 
 ucb/source/ucp/webdav/DAVSessionFactory.cxx           |    2 
 ucb/source/ucp/webdav/DAVSessionFactory.hxx           |    3 
 ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx         |  202 ++++++++++++++++
 ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx         |   67 +++++
 ucb/source/ucp/webdav/SerfLockStore.cxx               |   73 ++---
 ucb/source/ucp/webdav/SerfLockStore.hxx               |   54 +---
 ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx     |    1 
 ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx    |    1 
 ucb/source/ucp/webdav/SerfRequestProcessor.cxx        |   74 ++++--
 ucb/source/ucp/webdav/SerfRequestProcessor.hxx        |    7 
 ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx |  221 ------------------
 ucb/source/ucp/webdav/SerfRequestProcessorImplFac.hxx |  115 ---------
 ucb/source/ucp/webdav/SerfSession.cxx                 |  180 +++-----------
 ucb/source/ucp/webdav/SerfSession.hxx                 |   21 -
 ucb/source/ucp/webdav/SerfTypes.hxx                   |   37 ---
 ucb/source/ucp/webdav/SerfUnlockReqProcImpl.cxx       |   68 +++++
 ucb/source/ucp/webdav/SerfUnlockReqProcImpl.hxx       |   54 ++++
 ucb/source/ucp/webdav/webdavcontent.cxx               |    5 
 ucb/source/ucp/webdav/webdavprovider.cxx              |    3 
 ucb/source/ucp/webdav/webdavprovider.hxx              |    4 
 ucb/source/ucp/webdav/webdavresponseparser.cxx        |   92 +++++--
 ucb/source/ucp/webdav/webdavresponseparser.hxx        |   11 
 26 files changed, 660 insertions(+), 658 deletions(-)

New commits:
commit 2d832c264801a8b1e155d33d1506af55dc6e207f
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Mar 26 16:17:21 2014 +0100

    webdav: Workaround failing unlocking by ignoring certificates when closing.
    
    In neon version, we use xml::crypto::SEInitializer in
    NeonSession_CertificationNotify which I see called only once.
    For some reason in serf, Serf_ConnectSetup is called every time
    we send a command to the server. But that leads to not working
    verifySerfCertificateChain in __run_exit_handlers because
    xml::crypto::SEInitializer is not available anymore.
    
    Change-Id: I15685256790375dd86eb1b7614da25838d5ce244

diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index 183d393..2053598 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -75,6 +75,7 @@ void TickerThread::run()
 
 SerfLockStore::SerfLockStore()
     : m_pTickerThread( 0 )
+    , m_bFinishing( false )
 {
 }
 
@@ -82,6 +83,7 @@ SerfLockStore::SerfLockStore()
 SerfLockStore::~SerfLockStore()
 {
     stopTicker();
+    m_bFinishing = true;
 
     // release active locks, if any.
     SAL_WARN_IF( !m_aLockInfoMap.empty(), "ucb.ucp.webdav",
@@ -96,6 +98,10 @@ SerfLockStore::~SerfLockStore()
     }
 }
 
+bool SerfLockStore::finishing() const
+{
+    return m_bFinishing;
+}
 
 void SerfLockStore::startTicker()
 {
diff --git a/ucb/source/ucp/webdav/SerfLockStore.hxx b/ucb/source/ucp/webdav/SerfLockStore.hxx
index 8205a20..a995ced 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.hxx
@@ -55,12 +55,14 @@ class SerfLockStore
 {
     osl::Mutex         m_aMutex;
     TickerThread     * m_pTickerThread;
+    bool               m_bFinishing;
     LockInfoMap        m_aLockInfoMap;
 
 public:
     SerfLockStore();
     ~SerfLockStore();
 
+    bool finishing() const;
     OUString getLockToken( const OUString& rLock );
 
     void addLock( const OUString& rLock,
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index cff90be..eea9644 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -352,6 +352,13 @@ apr_status_t SerfSession::verifySerfCertificateChain (
         return SERF_SSL_CERT_UNKNOWN_FAILURE;
     }
 
+    // When called from SerfLockStore::~SerfLockStore(),
+    // css::xml::crypto::SEInitializer::create() will fail
+    // but we want to send unlock commands anyway,
+    // so just ignore certificates and return here.
+    if (apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->finishing())
+        return APR_SUCCESS;
+
     // Create some crypto objects to decode and handle the base64
     // encoded certificate chain.
     uno::Reference< security::XCertificateContainer > xCertificateContainer;
commit 06072a9707ecebf97758a50255863ee7d3383162
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Mar 25 22:38:27 2014 +0100

    remove SerfTypes.hxx
    
    Change-Id: I189e7168562db2ca03fd64745eb1f826b6c9adc2

diff --git a/ucb/source/ucp/webdav/DAVProperties.hxx b/ucb/source/ucp/webdav/DAVProperties.hxx
index 8bf3ca3..f7c2911 100644
--- a/ucb/source/ucp/webdav/DAVProperties.hxx
+++ b/ucb/source/ucp/webdav/DAVProperties.hxx
@@ -22,11 +22,12 @@
 #define _DAVPROPERTIES_HXX_
 
 #include <rtl/ustring.hxx>
-#include "SerfTypes.hxx"
 
 namespace http_dav_ucp
 {
 
+typedef struct { const char *nspace, *name; } SerfPropName;
+
 struct DAVProperties
 {
     static const OUString CREATIONDATE;
diff --git a/ucb/source/ucp/webdav/SerfLockStore.hxx b/ucb/source/ucp/webdav/SerfLockStore.hxx
index eefd7b8..8205a20 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.hxx
@@ -25,7 +25,6 @@
 #include <osl/mutex.hxx>
 #include <rtl/ref.hxx>
 #include <rtl/ustring.hxx>
-#include <SerfTypes.hxx>
 #include <SerfSession.hxx>
 
 namespace http_dav_ucp
diff --git a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
index 2661e10..8117b1b 100644
--- a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
@@ -18,7 +18,6 @@
  */
 
 #include "SerfPropFindReqProcImpl.hxx"
-#include "SerfTypes.hxx"
 #include "DAVProperties.hxx"
 
 #include "webdavresponseparser.hxx"
diff --git a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
index 950eb16..06e539d 100644
--- a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
@@ -23,7 +23,6 @@
 #include "UCBDeadPropertyValue.hxx"
 
 #include "SerfPropPatchReqProcImpl.hxx"
-#include "SerfTypes.hxx"
 
 namespace http_dav_ucp
 {
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index 017b978..cff90be 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -28,7 +28,6 @@
 #include <apr_strings.h>
 
 #include "DAVAuthListener.hxx"
-#include "SerfTypes.hxx"
 #include "SerfSession.hxx"
 #include "SerfUri.hxx"
 #include "SerfRequestProcessor.hxx"
@@ -193,7 +192,7 @@ serf_context_t* SerfSession::getSerfContext()
     return m_pSerfContext;
 }
 
-SerfConnection* SerfSession::getSerfConnection()
+serf_connection_t* SerfSession::getSerfConnection()
 {
     return m_pSerfConnection;
 }
diff --git a/ucb/source/ucp/webdav/SerfSession.hxx b/ucb/source/ucp/webdav/SerfSession.hxx
index f580a47..92cecf7 100644
--- a/ucb/source/ucp/webdav/SerfSession.hxx
+++ b/ucb/source/ucp/webdav/SerfSession.hxx
@@ -26,9 +26,10 @@
 #include <boost/shared_ptr.hpp>
 #include <osl/mutex.hxx>
 #include "DAVSession.hxx"
-#include "SerfTypes.hxx"
 #include "SerfUri.hxx"
 
+#include <serf.h>
+
 namespace ucbhelper { class ProxyDecider; }
 
 namespace http_dav_ucp
@@ -51,7 +52,7 @@ private:
     OUString           m_aProxyName;
     sal_Int32               m_nProxyPort;
 
-    SerfConnection*         m_pSerfConnection;
+    serf_connection_t*      m_pSerfConnection;
     serf_context_t*         m_pSerfContext;
     serf_bucket_alloc_t*    m_pSerfBucket_Alloc;
     bool                    m_bIsHeadRequestInProgress;
@@ -104,7 +105,7 @@ public:
     apr_pool_t* getAprPool();
     serf_bucket_alloc_t* getSerfBktAlloc();
     serf_context_t* getSerfContext();
-    SerfConnection* getSerfConnection();
+    serf_connection_t* getSerfConnection();
 
     // DAVSession methods
     virtual sal_Bool CanUse( const OUString & inUri );
@@ -274,7 +275,7 @@ private:
 
     /*
     // low level GET implementation, used by public GET implementations
-    static int GET( SerfConnection * sess,
+    static int GET( serf_connection_t * sess,
                     const char * uri,
                     //ne_block_reader reader,
                     bool getheaders,
@@ -282,14 +283,14 @@ private:
 
     // Buffer-based PUT implementation. Serf only has file descriptor-
     // based API.
-    static int PUT( SerfConnection * sess,
+    static int PUT( serf_connection_t * sess,
                     const char * uri,
                     const char * buffer,
                     size_t size );
 
     // Buffer-based POST implementation. Serf only has file descriptor-
     // based API.
-    int POST( SerfConnection * sess,
+    int POST( serf_connection_t * sess,
               const char * uri,
               const char * buffer,
               //ne_block_reader reader,
diff --git a/ucb/source/ucp/webdav/SerfTypes.hxx b/ucb/source/ucp/webdav/SerfTypes.hxx
deleted file mode 100644
index 2393458..0000000
--- a/ucb/source/ucp/webdav/SerfTypes.hxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-
-#ifndef INCLUDED_SERFTYPES_HXX
-#define INCLUDED_SERFTYPES_HXX
-
-#include <serf.h>
-
-typedef serf_connection_t SerfConnection;
-
-// TODO, check if we need it later on
-typedef struct { const char *nspace, *name; } SerfPropName;
-
-#endif // INCLUDED_SERFTYPES_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 05671c1f01c73bd3f4773c9653d95e3188657eb3
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Mar 25 22:17:59 2014 +0100

    unused variables and simplify
    
    Change-Id: Ib2412d5bd3e3db42b972783bb8d17bc6559c9c21

diff --git a/ucb/source/ucp/webdav/DAVSessionFactory.cxx b/ucb/source/ucp/webdav/DAVSessionFactory.cxx
index c2f1dd2..43a2a85 100644
--- a/ucb/source/ucp/webdav/DAVSessionFactory.cxx
+++ b/ucb/source/ucp/webdav/DAVSessionFactory.cxx
@@ -34,8 +34,6 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
                 const uno::Reference< uno::XComponentContext > & rxContext )
     throw( DAVException )
 {
-    m_xMSF = rxContext;
-
     osl::MutexGuard aGuard( m_aMutex );
 
     if ( !m_xProxyDecider.get() )
diff --git a/ucb/source/ucp/webdav/DAVSessionFactory.hxx b/ucb/source/ucp/webdav/DAVSessionFactory.hxx
index 6617e8c..9f9f5c5 100644
--- a/ucb/source/ucp/webdav/DAVSessionFactory.hxx
+++ b/ucb/source/ucp/webdav/DAVSessionFactory.hxx
@@ -56,7 +56,6 @@ public:
                                 rxContext )
             throw( DAVException );
 
-    ::uno::Reference< ::uno::XComponentContext > getServiceFactory() {  return m_xMSF; }
 private:
     typedef std::map< OUString, DAVSession * > Map;
 
@@ -64,8 +63,6 @@ private:
     osl::Mutex m_aMutex;
     std::auto_ptr< ucbhelper::InternetProxyDecider > m_xProxyDecider;
 
-    ::uno::Reference< ::uno::XComponentContext > m_xMSF;
-
     void releaseElement( DAVSession * pElement ) SAL_THROW(());
 
     friend class DAVSession;
diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index a9696b3..183d393 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -91,8 +91,7 @@ SerfLockStore::~SerfLockStore()
     const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
     while ( it != end )
     {
-        const OUString& rLock = (*it).first;
-        (*it).second.m_xSession->UNLOCK( rLock );
+        (*it).second.m_xSession->UNLOCK( (*it).first );
         ++it;
     }
 }
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index 65fd5dc..017b978 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -36,6 +36,7 @@
 #include "SerfInputStream.hxx"
 #include "UCBDeadPropertyValue.hxx"
 
+#include <com/sun/star/xml/crypto/SEInitializer.hpp>
 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
 #include <com/sun/star/security/XCertificate.hpp>
 #include <com/sun/star/security/CertificateValidity.hpp>
@@ -354,7 +355,6 @@ apr_status_t SerfSession::verifySerfCertificateChain (
 
     // Create some crypto objects to decode and handle the base64
     // encoded certificate chain.
-    uno::Reference< xml::crypto::XSEInitializer > xSEInitializer;
     uno::Reference< security::XCertificateContainer > xCertificateContainer;
     uno::Reference< xml::crypto::XXMLSecurityContext > xSecurityContext;
     uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnv;
@@ -365,10 +365,8 @@ apr_status_t SerfSession::verifySerfCertificateChain (
         // Create a certificate container.
         xCertificateContainer = security::CertificateContainer::create( xContext );
 
-        xSEInitializer = uno::Reference< xml::crypto::XSEInitializer >(
-            xContext->getServiceManager()->createInstanceWithContext(
-                OUString( "com.sun.star.xml.crypto.SEInitializer" ), xContext ),
-            uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::xml::crypto::XSEInitializer > xSEInitializer =
+            css::xml::crypto::SEInitializer::create( xContext );
 
         xSecurityContext = xSEInitializer->createSecurityContext( OUString() );
         if (xSecurityContext.is())
diff --git a/ucb/source/ucp/webdav/webdavprovider.cxx b/ucb/source/ucp/webdav/webdavprovider.cxx
index 16684d8..0cf92da 100644
--- a/ucb/source/ucp/webdav/webdavprovider.cxx
+++ b/ucb/source/ucp/webdav/webdavprovider.cxx
@@ -39,7 +39,6 @@ using namespace http_dav_ucp;
 ContentProvider::ContentProvider(
                 const uno::Reference< uno::XComponentContext >& rContext )
 : ::ucbhelper::ContentProviderImplHelper( rContext ),
-  m_xDAVSessionFactory( new DAVSessionFactory() ),
   m_pProps( 0 )
 {
 }
@@ -196,7 +195,7 @@ ContentProvider::queryContent(
     try
     {
         xContent = new ::http_dav_ucp::Content(
-                        m_xContext, this, xCanonicId, m_xDAVSessionFactory );
+                        m_xContext, this, xCanonicId, new DAVSessionFactory() );
         registerNewContent( xContent );
     }
     catch ( ucb::ContentCreationException const & )
diff --git a/ucb/source/ucp/webdav/webdavprovider.hxx b/ucb/source/ucp/webdav/webdavprovider.hxx
index 6947650..caf95600 100644
--- a/ucb/source/ucp/webdav/webdavprovider.hxx
+++ b/ucb/source/ucp/webdav/webdavprovider.hxx
@@ -68,7 +68,6 @@ namespace http_dav_ucp {
 
 class ContentProvider : public ::ucbhelper::ContentProviderImplHelper
 {
-    rtl::Reference< DAVSessionFactory > m_xDAVSessionFactory;
     PropertyMap * m_pProps;
 
 public:
@@ -121,9 +120,6 @@ public:
     // Non-interface methods.
 
 
-    rtl::Reference< DAVSessionFactory > getDAVSessionFactory()
-    { return m_xDAVSessionFactory; }
-
     bool getProperty( const OUString & rPropName,
                       ::com::sun::star::beans::Property & rProp,
                       bool bStrict = false );
commit 166a934cdf6b3adc89bca8ce6b2489d225c75309
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Mar 25 12:19:35 2014 +0100

    webdav: Implement refreshing of locks.
    
    Change-Id: Ia4a1c7b929dac473dfb5a5fa233c7f0c662a95c6

diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
index 9e16212..ff766ef 100644
--- a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
@@ -32,10 +32,12 @@ namespace http_dav_ucp
 SerfLockReqProcImpl::SerfLockReqProcImpl( const char* inPath,
                                           const DAVRequestHeaders& inRequestHeaders,
                                           SerfSession& rSession,
-                                          const css::ucb::Lock & rLock )
+                                          const css::ucb::Lock& rLock,
+                                          sal_Int32* plastChanceToSendRefreshRequest )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
     , m_rSession( rSession )
     , m_aLock( rLock )
+    , m_plastChanceToSendRefreshRequest( plastChanceToSendRefreshRequest )
     , m_xInputStream( new SerfInputStream() )
 {
 }
@@ -76,9 +78,12 @@ serf_bucket_t * SerfLockReqProcImpl::createSerfRequestBucket( serf_request_t * i
     aBody.append("</lockinfo>\n");
 
     const OString aBodyText(aBody.makeStringAndClear());
-    serf_bucket_t* body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(),
-                                                              aBodyText.getLength(),
-                                                              pSerfBucketAlloc );
+    serf_bucket_t* body_bkt = 0;
+
+    if (!m_plastChanceToSendRefreshRequest)
+        body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(),
+                                                   aBodyText.getLength(),
+                                                   pSerfBucketAlloc );
 
     // create serf request
     serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
@@ -86,7 +91,8 @@ serf_bucket_t * SerfLockReqProcImpl::createSerfRequestBucket( serf_request_t * i
                                                                  getPathStr(),
                                                                  body_bkt,
                                                                  pSerfBucketAlloc );
-    handleChunkedEncoding(req_bkt, aBodyText.getLength());
+    if (!m_plastChanceToSendRefreshRequest)
+        handleChunkedEncoding(req_bkt, aBodyText.getLength());
 
     // set request header fields
     serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
@@ -110,8 +116,18 @@ serf_bucket_t * SerfLockReqProcImpl::createSerfRequestBucket( serf_request_t * i
         default:
             throw DAVException( DAVException::DAV_INVALID_ARG );
     }
-    serf_bucket_headers_set( hdrs_bkt, "Depth", depth );
-    serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
+    if (!m_plastChanceToSendRefreshRequest)
+    {
+        serf_bucket_headers_set( hdrs_bkt, "Depth", depth );
+        serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
+    }
+    else
+    {
+        const OString sToken( "(<" + OUStringToOString( apr_environment::AprEnv::getAprEnv()->
+                    getSerfLockStore()->getLockToken( OUString::createFromAscii(getPathStr())),
+                    RTL_TEXTENCODING_UTF8 ) + ">)" );
+        serf_bucket_headers_set( hdrs_bkt, "If", sToken.getStr() );
+    }
 
     // Set the lock timeout
     if (m_aLock.Timeout == -1)
@@ -121,6 +137,8 @@ serf_bucket_t * SerfLockReqProcImpl::createSerfRequestBucket( serf_request_t * i
         const OString aTimeValue("Second-" + OString::number(m_aLock.Timeout));
         serf_bucket_headers_set( hdrs_bkt, "Timeout", aTimeValue.getStr() );
     }
+    else
+        serf_bucket_headers_set( hdrs_bkt, "Timeout", "Second-180" );
 
     osl_getSystemTime( &m_aStartCall );
 
@@ -158,6 +176,13 @@ void SerfLockReqProcImpl::handleEndOfResponseData( serf_bucket_t * )
                 else
                     SAL_WARN("ucb.ucp.webdav", "No chance to refresh lock before timeout!" );
             }
+            if (m_plastChanceToSendRefreshRequest)
+            {
+                *m_plastChanceToSendRefreshRequest = lastChanceToSendRefreshRequest;
+                assert(aLocks.size() == 1);
+                // We are just refreshing lock, do not add it into SerfLockStore
+                break;
+            }
             apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->addLock(
                     OUString::createFromAscii(getPathStr()),
                     aLocks[i].LockTokens[0],
diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
index 766bc2b..9341a40 100644
--- a/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
@@ -37,7 +37,8 @@ public:
     SerfLockReqProcImpl( const char* inPath,
                          const DAVRequestHeaders& inRequestHeaders,
                          SerfSession& rSession,
-                         const css::ucb::Lock & rLock );
+                         const css::ucb::Lock& rLock,
+                         sal_Int32* plastChanceToSendRefreshRequest = 0 );
 
     virtual ~SerfLockReqProcImpl() SAL_OVERRIDE;
 
@@ -53,6 +54,8 @@ private:
 
     SerfSession& m_rSession;
     css::ucb::Lock m_aLock;
+    // if m_plastChanceToSendRefreshRequest is not 0 we are sending just refresh request
+    sal_Int32* m_plastChanceToSendRefreshRequest;
     TimeValue m_aStartCall;
     css::uno::Reference< SerfInputStream > m_xInputStream;
 };
diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index 6c0a29e..a9696b3 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -197,8 +197,7 @@ void SerfLockStore::refreshLocks()
                 // refresh the lock.
                 sal_Int32 nlastChanceToSendRefreshRequest = -1;
                 if ( rInfo.m_xSession->LOCK(
-                         (*it).first,
-                         /* out param */ nlastChanceToSendRefreshRequest ) )
+                         (*it).first, &nlastChanceToSendRefreshRequest ) )
                 {
                     rInfo.m_nLastChanceToSendRefreshRequest
                         = nlastChanceToSendRefreshRequest;
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
index ced9d5b..ddeecca 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
@@ -313,12 +313,13 @@ bool SerfRequestProcessor::processMove( const OUString & inDestinationPath,
 }
 
 
-bool SerfRequestProcessor::processLock( const css::ucb::Lock & rLock )
+bool SerfRequestProcessor::processLock( const css::ucb::Lock & rLock, sal_Int32 *plastChanceToSendRefreshRequest )
 {
     mpProcImpl = new SerfLockReqProcImpl( mPathStr,
                                           mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                           mrSerfSession,
-                                          rLock );
+                                          rLock,
+                                          plastChanceToSendRefreshRequest );
 
     return runProcessor() == APR_SUCCESS;
 }
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
index 7e4573f..ef0987f 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
@@ -126,7 +126,7 @@ public:
                       apr_status_t& outSerfStatus );
 
     //LOCK
-    bool processLock( const css::ucb::Lock & rLock );
+    bool processLock( const css::ucb::Lock & rLock, sal_Int32 *plastChanceToSendRefreshRequest = 0 );
 
     //UNLOCK
     bool processUnlock();
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index f8222b9..65fd5dc 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -1060,32 +1060,25 @@ sal_Int64 SerfSession::LOCK( const OUString & /*inPath*/,
 
 // LOCK (refresh existing lock)
 
-bool SerfSession::LOCK( const OUString& /*rLock*/,
-                        sal_Int32 & /*rlastChanceToSendRefreshRequest*/ )
+bool SerfSession::LOCK( const OUString& rLock,
+                        sal_Int32 *plastChanceToSendRefreshRequest )
 {
     osl::Guard< osl::Mutex > theGuard( m_aMutex );
 
-    return true;
-    /*
-    // refresh existing lock.
-
-    TimeValue startCall;
-    osl_getSystemTime( &startCall );
+    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( rLock ) );
+    aReqProc->processLock( ucb::Lock(), plastChanceToSendRefreshRequest );
 
-    if ( ne_lock_refresh( m_pHttpSession, pLock ) == NE_OK )
+    try
     {
-        rlastChanceToSendRefreshRequest
-            = lastChanceToSendRefreshRequest( startCall, pLock->timeout );
-
-        SAL_INFO("ucb.ucp.webdav",  "Lock successfully refreshed." );
+        HandleError( aReqProc );
+        SAL_INFO("ucb.ucp.webdav",  "Refreshing LOCK of " << rLock << " succeeded." );
         return true;
     }
-    else
+    catch(...)
     {
-        SAL_INFO("ucb.ucp.webdav",  "Lock not refreshed!" );
+        SAL_INFO("ucb.ucp.webdav",  "Refreshing LOCK of " << rLock << " failed!" );
         return false;
     }
-    */
 }
 
 
diff --git a/ucb/source/ucp/webdav/SerfSession.hxx b/ucb/source/ucp/webdav/SerfSession.hxx
index 0c2288b..f580a47 100644
--- a/ucb/source/ucp/webdav/SerfSession.hxx
+++ b/ucb/source/ucp/webdav/SerfSession.hxx
@@ -267,8 +267,7 @@ private:
                                  const DAVRequestEnvironment & rEnv );
 
     // refresh lock, called by SerfLockStore::refreshLocks
-    bool LOCK( const OUString& rLock,
-               sal_Int32 & rlastChanceToSendRefreshRequest );
+    bool LOCK( const OUString& rLock, sal_Int32 *plastChanceToSendRefreshRequest );
 
     // unlock, called by SerfLockStore::~SerfLockStore
     void UNLOCK( const OUString& rLock );
commit 53e9b3393aaeb00687eae096944531747976cef3
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Fri Mar 21 12:42:51 2014 +0100

    webdav: Implement unlocking of documents.
    
    Change-Id: I12c092fa7034702273182ef07431ed00f38df8ef

diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk
index 9ada038..51225d2 100644
--- a/ucb/Library_ucpdav1.mk
+++ b/ucb/Library_ucpdav1.mk
@@ -95,6 +95,7 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
 	ucb/source/ucp/webdav/SerfRequestProcessor \
 	ucb/source/ucp/webdav/SerfRequestProcessorImpl \
 	ucb/source/ucp/webdav/SerfSession \
+	ucb/source/ucp/webdav/SerfUnlockReqProcImpl \
 	ucb/source/ucp/webdav/SerfUri \
 	ucb/source/ucp/webdav/UCBDeadPropertyValue \
 	ucb/source/ucp/webdav/webdavcontent \
diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index 15aae7e..6c0a29e 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -123,6 +123,17 @@ void SerfLockStore::stopTicker()
     }
 }
 
+OUString SerfLockStore::getLockToken( const OUString& rLock )
+{
+    osl::MutexGuard aGuard( m_aMutex );
+
+    LockInfoMap::const_iterator it( m_aLockInfoMap.find( rLock ) );
+    if ( it != m_aLockInfoMap.end() )
+        return (*it).second.m_sToken;
+
+    SAL_WARN("ucb.ucp.webdav", "SerfLockStore::getLockToken: lock not found!" );
+    return OUString();
+}
 
 void SerfLockStore::addLock( const OUString& rLock,
                              const OUString& sToken,
diff --git a/ucb/source/ucp/webdav/SerfLockStore.hxx b/ucb/source/ucp/webdav/SerfLockStore.hxx
index 92ab190..eefd7b8 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.hxx
@@ -62,6 +62,8 @@ public:
     SerfLockStore();
     ~SerfLockStore();
 
+    OUString getLockToken( const OUString& rLock );
+
     void addLock( const OUString& rLock,
                   const OUString& sToken,
                   rtl::Reference< SerfSession > const & xSession,
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
index a557781..ced9d5b 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
@@ -18,6 +18,8 @@
  */
 
 #include "SerfRequestProcessor.hxx"
+
+#include "AprEnv.hxx"
 #include "SerfCallbacks.hxx"
 #include "SerfSession.hxx"
 #include "SerfPropFindReqProcImpl.hxx"
@@ -31,6 +33,7 @@
 #include "SerfCopyReqProcImpl.hxx"
 #include "SerfMoveReqProcImpl.hxx"
 #include "SerfLockReqProcImpl.hxx"
+#include "SerfUnlockReqProcImpl.hxx"
 
 #include <apr_strings.h>
 
@@ -320,6 +323,22 @@ bool SerfRequestProcessor::processLock( const css::ucb::Lock & rLock )
     return runProcessor() == APR_SUCCESS;
 }
 
+bool SerfRequestProcessor::processUnlock()
+{
+    // get the lock from lock store
+    const OUString sToken(
+            apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->getLockToken(
+                OUString::createFromAscii(mPathStr)) );
+    if ( sToken.isEmpty() )
+        throw DAVException( DAVException::DAV_NOT_LOCKED );
+
+    mpProcImpl = new SerfUnlockReqProcImpl( mPathStr,
+                                            mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                            sToken );
+
+    return runProcessor() == APR_SUCCESS;
+}
+
 apr_status_t SerfRequestProcessor::runProcessor()
 {
     prepareProcessor();
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
index f941a49..7e4573f 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
@@ -128,6 +128,9 @@ public:
     //LOCK
     bool processLock( const css::ucb::Lock & rLock );
 
+    //UNLOCK
+    bool processUnlock();
+
     apr_status_t provideSerfCredentials( char ** outUsername,
                                          char ** outPassword,
                                          serf_request_t * inRequest,
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index 7b21f8f..f8222b9 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -1091,58 +1091,47 @@ bool SerfSession::LOCK( const OUString& /*rLock*/,
 
 // UNLOCK
 
-void SerfSession::UNLOCK( const OUString & /*inPath*/,
-                          const DAVRequestEnvironment & /*rEnv*/ )
+void SerfSession::UNLOCK( const OUString & inPath,
+                          const DAVRequestEnvironment & rEnv )
     throw ( DAVException )
 {
     osl::Guard< osl::Mutex > theGuard( m_aMutex );
 
-    /*
-    // get the neon lock from lock store
-    SerfLock * theLock
-        = m_aSerfLockStore.findByUri( makeAbsoluteURL( inPath ) );
-    if ( !theLock )
-        throw DAVException( DAVException::DAV_NOT_LOCKED );
-
     Init( rEnv );
 
-    int theRetVal = ne_unlock( m_pHttpSession, theLock );
+    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
+    aReqProc->processUnlock();
 
-    if ( theRetVal == NE_OK )
+    try
     {
-        m_aSerfLockStore.removeLock( theLock );
-        ne_lock_destroy( theLock );
+        HandleError( aReqProc );
+        SAL_INFO("ucb.ucp.webdav",  "UNLOCK of " << inPath << " succeeded." );
     }
-    else
+    catch(...)
     {
-        SAL_INFO("ucb.ucp.webdav",  "SerfSession::UNLOCK: unlocking of "
-                    << makeAbsoluteURL( inPath ) << " failed.");
+        SAL_INFO("ucb.ucp.webdav",  "UNLOCK of " << inPath << " failed!" );
     }
-
-    HandleError( theRetVal, inPath, rEnv );
-    */
 }
 
 
 // UNLOCK
 
-bool SerfSession::UNLOCK( const OUString& /*rLock*/ )
+void SerfSession::UNLOCK( const OUString& rLock )
 {
     osl::Guard< osl::Mutex > theGuard( m_aMutex );
 
-    return true;
-    /*
-    if ( ne_unlock( m_pHttpSession, pLock ) == NE_OK )
+    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( rLock ) );
+    aReqProc->processUnlock();
+
+    try
     {
-        SAL_INFO("ucb.ucp.webdav",  "UNLOCK succeeded." );
-        return true;
+        HandleError( aReqProc );
+        SAL_INFO("ucb.ucp.webdav",  "UNLOCK of " << rLock << " succeeded." );
     }
-    else
+    catch(...)
     {
-        SAL_INFO("ucb.ucp.webdav",  "UNLOCK failed!" );
-        return false;
+        SAL_INFO("ucb.ucp.webdav",  "UNLOCK of " << rLock << " failed!" );
     }
-    */
 }
 
 
diff --git a/ucb/source/ucp/webdav/SerfSession.hxx b/ucb/source/ucp/webdav/SerfSession.hxx
index b3dfab7..0c2288b 100644
--- a/ucb/source/ucp/webdav/SerfSession.hxx
+++ b/ucb/source/ucp/webdav/SerfSession.hxx
@@ -271,7 +271,7 @@ private:
                sal_Int32 & rlastChanceToSendRefreshRequest );
 
     // unlock, called by SerfLockStore::~SerfLockStore
-    bool UNLOCK( const OUString& rLock );
+    void UNLOCK( const OUString& rLock );
 
     /*
     // low level GET implementation, used by public GET implementations
diff --git a/ucb/source/ucp/webdav/SerfUnlockReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfUnlockReqProcImpl.cxx
new file mode 100644
index 0000000..59c8994
--- /dev/null
+++ b/ucb/source/ucp/webdav/SerfUnlockReqProcImpl.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "SerfUnlockReqProcImpl.hxx"
+
+namespace http_dav_ucp
+{
+
+SerfUnlockReqProcImpl::SerfUnlockReqProcImpl( const char* inPath,
+                                              const DAVRequestHeaders& inRequestHeaders,
+                                              const OUString& sToken)
+    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
+    , m_sToken( sToken )
+{
+}
+
+SerfUnlockReqProcImpl::~SerfUnlockReqProcImpl()
+{
+}
+
+serf_bucket_t * SerfUnlockReqProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
+{
+    // create serf request
+    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
+                                                                 "UNLOCK",
+                                                                 getPathStr(),
+                                                                 0,
+                                                                 serf_request_get_alloc( inSerfRequest ) );
+    // set request header fields
+    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
+
+    // general header fields provided by caller
+    setRequestHeaders( hdrs_bkt );
+
+    // token header field
+    serf_bucket_headers_set( hdrs_bkt, "Lock-Token",
+            OUStringToOString(m_sToken, RTL_TEXTENCODING_UTF8).getStr() );
+
+    return req_bkt;
+}
+
+void SerfUnlockReqProcImpl::processChunkOfResponseData( const char* , apr_size_t )
+{
+}
+
+void SerfUnlockReqProcImpl::handleEndOfResponseData( serf_bucket_t * )
+{
+}
+
+} // namespace http_dav_ucp
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav/SerfUnlockReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfUnlockReqProcImpl.hxx
new file mode 100644
index 0000000..dc2e6d1
--- /dev/null
+++ b/ucb/source/ucp/webdav/SerfUnlockReqProcImpl.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SERFUNLOCKREQPROCIMPL_HXX
+#define INCLUDED_SERFUNLOCKREQPROCIMPL_HXX
+
+#include "SerfRequestProcessorImpl.hxx"
+
+namespace http_dav_ucp
+{
+
+class SerfUnlockReqProcImpl : public SerfRequestProcessorImpl
+{
+public:
+    SerfUnlockReqProcImpl( const char* inPath,
+                           const DAVRequestHeaders& inRequestHeaders,
+                           const OUString& sToken);
+
+    virtual ~SerfUnlockReqProcImpl() SAL_OVERRIDE;
+
+    virtual serf_bucket_t *createSerfRequestBucket(
+            serf_request_t * inSerfRequest ) SAL_OVERRIDE;
+
+private:
+    virtual void processChunkOfResponseData(
+            const char* data, apr_size_t len ) SAL_OVERRIDE;
+
+    virtual void handleEndOfResponseData(
+            serf_bucket_t * inSerfResponseBucket ) SAL_OVERRIDE;
+
+    OUString m_sToken;
+};
+
+} // namespace http_dav_ucp
+
+#endif // INCLUDED_SERFUNLOCKREQPROCIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3648ba0db379b3ca2cc6bb84a4b6c14f16217fa9
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Mar 20 12:27:21 2014 +0100

    webdav: Store locks in SerfLockStore, so we could unlock later.
    
    Change-Id: If2667e9374917dd1e4c4361378783729761e7dda

diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk
index ad0fe79..9ada038 100644
--- a/ucb/Library_ucpdav1.mk
+++ b/ucb/Library_ucpdav1.mk
@@ -85,6 +85,7 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
 	ucb/source/ucp/webdav/SerfHeadReqProcImpl \
 	ucb/source/ucp/webdav/SerfInputStream \
 	ucb/source/ucp/webdav/SerfLockReqProcImpl \
+	ucb/source/ucp/webdav/SerfLockStore \
 	ucb/source/ucp/webdav/SerfMkColReqProcImpl \
 	ucb/source/ucp/webdav/SerfMoveReqProcImpl \
 	ucb/source/ucp/webdav/SerfPostReqProcImpl \
@@ -104,7 +105,6 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
 	ucb/source/ucp/webdav/webdavresultset \
 	ucb/source/ucp/webdav/webdavservices \
  ))
-	#ucb/source/ucp/webdav/SerfLockStore
 
 endif # WITH_WEBDAV
 
diff --git a/ucb/source/ucp/webdav/AprEnv.cxx b/ucb/source/ucp/webdav/AprEnv.cxx
index 327b7dd..e9e650f 100644
--- a/ucb/source/ucp/webdav/AprEnv.cxx
+++ b/ucb/source/ucp/webdav/AprEnv.cxx
@@ -28,10 +28,14 @@ AprEnv::AprEnv()
     apr_initialize();
 
     apr_pool_create(&mpAprPool, NULL);
+
+    mpSerfLockStore = new http_dav_ucp::SerfLockStore();
 }
 
 AprEnv::~AprEnv()
 {
+    delete mpSerfLockStore;
+
     apr_pool_destroy(mpAprPool);
 
     apr_terminate();
@@ -50,6 +54,11 @@ apr_pool_t* AprEnv::getAprPool()
     return mpAprPool;
 }
 
+http_dav_ucp::SerfLockStore* AprEnv::getSerfLockStore()
+{
+    return mpSerfLockStore;
+}
+
 } // namespace apr_environment
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav/AprEnv.hxx b/ucb/source/ucp/webdav/AprEnv.hxx
index 9b7c59b..4f360aa 100644
--- a/ucb/source/ucp/webdav/AprEnv.hxx
+++ b/ucb/source/ucp/webdav/AprEnv.hxx
@@ -22,6 +22,7 @@
 #define INCLUDED_APRENV_HXX
 
 #include <apr_pools.h>
+#include <SerfLockStore.hxx>
 
 namespace apr_environment
 {
@@ -36,8 +37,13 @@ class AprEnv
 
         apr_pool_t* getAprPool();
 
+        http_dav_ucp::SerfLockStore* getSerfLockStore();
+
     private:
         apr_pool_t* mpAprPool;
+        // SerfLockStore is a static object and has to be destroyed
+        // before AprEnv, so store it here.
+        http_dav_ucp::SerfLockStore* mpSerfLockStore;
 
         AprEnv();
 
diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
index 667583d..9e16212 100644
--- a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
@@ -18,6 +18,9 @@
  */
 
 #include "SerfLockReqProcImpl.hxx"
+
+#include "AprEnv.hxx"
+#include "SerfSession.hxx"
 #include "DAVException.hxx"
 
 #include "webdavresponseparser.hxx"
@@ -28,8 +31,10 @@ namespace http_dav_ucp
 
 SerfLockReqProcImpl::SerfLockReqProcImpl( const char* inPath,
                                           const DAVRequestHeaders& inRequestHeaders,
+                                          SerfSession& rSession,
                                           const css::ucb::Lock & rLock )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
+    , m_rSession( rSession )
     , m_aLock( rLock )
     , m_xInputStream( new SerfInputStream() )
 {
@@ -139,7 +144,24 @@ void SerfLockReqProcImpl::handleEndOfResponseData( serf_bucket_t * )
     {
         for (size_t i = 0; i < aLocks.size(); ++i)
         {
-           // m_pSerfLockStore->addLock( aLocks[i], m_pSerfSession, m_aStartCall );
+            sal_Int64 timeout = aLocks[i].Timeout;
+            TimeValue aEnd;
+            osl_getSystemTime( &aEnd );
+            // Try to estimate a safe absolute time for sending the
+            // lock refresh request.
+            sal_Int32 lastChanceToSendRefreshRequest = -1;
+            if ( timeout != -1 )
+            {
+                sal_Int32 calltime = aEnd.Seconds - m_aStartCall.Seconds;
+                if ( calltime <= timeout )
+                    lastChanceToSendRefreshRequest = aEnd.Seconds + timeout - calltime;
+                else
+                    SAL_WARN("ucb.ucp.webdav", "No chance to refresh lock before timeout!" );
+            }
+            apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->addLock(
+                    OUString::createFromAscii(getPathStr()),
+                    aLocks[i].LockTokens[0],
+                    &m_rSession, lastChanceToSendRefreshRequest );
             SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: created lock for "
                     << getPathStr() << ". token: " << aLocks[i].LockTokens[0]);
         }
diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
index cb746a3..766bc2b 100644
--- a/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
@@ -29,11 +29,14 @@
 namespace http_dav_ucp
 {
 
+class SerfSession;
+
 class SerfLockReqProcImpl : public SerfRequestProcessorImpl
 {
 public:
     SerfLockReqProcImpl( const char* inPath,
                          const DAVRequestHeaders& inRequestHeaders,
+                         SerfSession& rSession,
                          const css::ucb::Lock & rLock );
 
     virtual ~SerfLockReqProcImpl() SAL_OVERRIDE;
@@ -48,6 +51,7 @@ private:
     virtual
     void handleEndOfResponseData( serf_bucket_t * inSerfResponseBucket ) SAL_OVERRIDE;
 
+    SerfSession& m_rSession;
     css::ucb::Lock m_aLock;
     TimeValue m_aStartCall;
     css::uno::Reference< SerfInputStream > m_xInputStream;
diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index 82468ec..15aae7e 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -17,8 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <ne_locks.h>
-#include <ne_uri.h>
 #include <rtl/ustring.hxx>
 #include <osl/time.h>
 #include <osl/thread.hxx>
@@ -76,10 +74,8 @@ void TickerThread::run()
 
 
 SerfLockStore::SerfLockStore()
-    : m_pSerfLockStore( ne_lockstore_create() ),
-      m_pTickerThread( 0 )
+    : m_pTickerThread( 0 )
 {
-    SAL_WARN_IF( !m_pSerfLockStore, "ucb.ucp.webdav", "Unable to create neon lock store!" );
 }
 
 
@@ -95,16 +91,10 @@ SerfLockStore::~SerfLockStore()
     const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
     while ( it != end )
     {
-        SerfLock * pLock = (*it).first;
-        (*it).second.xSession->UNLOCK( pLock );
-
-        ne_lockstore_remove( m_pSerfLockStore, pLock );
-        ne_lock_destroy( pLock );
-
+        const OUString& rLock = (*it).first;
+        (*it).second.m_xSession->UNLOCK( rLock );
         ++it;
     }
-
-    ne_lockstore_destroy( m_pSerfLockStore );
 }
 
 
@@ -134,62 +124,42 @@ void SerfLockStore::stopTicker()
 }
 
 
-void SerfLockStore::registerSession( HttpSession * pHttpSession )
-{
-    osl::MutexGuard aGuard( m_aMutex );
-
-    ne_lockstore_register( m_pSerfLockStore, pHttpSession );
-}
-
-
-SerfLock * SerfLockStore::findByUri( OUString const & rUri )
-{
-    osl::MutexGuard aGuard( m_aMutex );
-
-    ne_uri aUri;
-    ne_uri_parse( OUStringToOString(
-        rUri, RTL_TEXTENCODING_UTF8 ).getStr(), &aUri );
-    return ne_lockstore_findbyuri( m_pSerfLockStore, &aUri );
-}
-
-
-void SerfLockStore::addLock( SerfLock * pLock,
+void SerfLockStore::addLock( const OUString& rLock,
+                             const OUString& sToken,
                              rtl::Reference< SerfSession > const & xSession,
                              sal_Int32 nLastChanceToSendRefreshRequest )
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    ne_lockstore_add( m_pSerfLockStore, pLock );
-    m_aLockInfoMap[ pLock ]
-        = LockInfo( xSession, nLastChanceToSendRefreshRequest );
+    m_aLockInfoMap[ rLock ]
+        = LockInfo( sToken, xSession, nLastChanceToSendRefreshRequest );
 
     startTicker();
 }
 
 
-void SerfLockStore::updateLock( SerfLock * pLock,
+void SerfLockStore::updateLock( const OUString& rLock,
                                 sal_Int32 nLastChanceToSendRefreshRequest )
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    LockInfoMap::iterator it( m_aLockInfoMap.find( pLock ) );
+    LockInfoMap::iterator it( m_aLockInfoMap.find( rLock ) );
     SAL_WARN_IF( it == m_aLockInfoMap.end(), "ucb.ucp.webdav",
                 "SerfLockStore::updateLock: lock not found!" );
 
     if ( it != m_aLockInfoMap.end() )
     {
-        (*it).second.nLastChanceToSendRefreshRequest
+        (*it).second.m_nLastChanceToSendRefreshRequest
             = nLastChanceToSendRefreshRequest;
     }
 }
 
 
-void SerfLockStore::removeLock( SerfLock * pLock )
+void SerfLockStore::removeLock( const OUString& rLock )
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    m_aLockInfoMap.erase( pLock );
-    ne_lockstore_remove( m_pSerfLockStore, pLock );
+    m_aLockInfoMap.erase( rLock );
 
     if ( m_aLockInfoMap.empty() )
         stopTicker();
@@ -205,27 +175,27 @@ void SerfLockStore::refreshLocks()
     while ( it != end )
     {
         LockInfo & rInfo = (*it).second;
-        if ( rInfo.nLastChanceToSendRefreshRequest != -1 )
+        if ( rInfo.m_nLastChanceToSendRefreshRequest != -1 )
         {
             // 30 seconds or less remaining until lock expires?
             TimeValue t1;
             osl_getSystemTime( &t1 );
-            if ( rInfo.nLastChanceToSendRefreshRequest - 30
+            if ( rInfo.m_nLastChanceToSendRefreshRequest - 30
                      <= sal_Int32( t1.Seconds ) )
             {
                 // refresh the lock.
                 sal_Int32 nlastChanceToSendRefreshRequest = -1;
-                if ( rInfo.xSession->LOCK(
+                if ( rInfo.m_xSession->LOCK(
                          (*it).first,
                          /* out param */ nlastChanceToSendRefreshRequest ) )
                 {
-                    rInfo.nLastChanceToSendRefreshRequest
+                    rInfo.m_nLastChanceToSendRefreshRequest
                         = nlastChanceToSendRefreshRequest;
                 }
                 else
                 {
                     // refresh failed. stop auto-refresh.
-                    rInfo.nLastChanceToSendRefreshRequest = -1;
+                    rInfo.m_nLastChanceToSendRefreshRequest = -1;
                 }
             }
         }
diff --git a/ucb/source/ucp/webdav/SerfLockStore.hxx b/ucb/source/ucp/webdav/SerfLockStore.hxx
index 4fff5f6..92ab190 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.hxx
@@ -24,43 +24,37 @@
 #include <map>
 #include <osl/mutex.hxx>
 #include <rtl/ref.hxx>
-#include "SerfTypes.hxx"
+#include <rtl/ustring.hxx>
+#include <SerfTypes.hxx>
+#include <SerfSession.hxx>
 
 namespace http_dav_ucp
 {
 
 class TickerThread;
-class SerfSession;
 
-struct ltptr
+struct LockInfo
 {
-    bool operator()( const SerfLock * p1, const SerfLock * p2 ) const
-    {
-        return p1 < p2;
-    }
+    OUString m_sToken;
+    rtl::Reference< SerfSession > m_xSession;
+    sal_Int32 m_nLastChanceToSendRefreshRequest;
+
+    LockInfo()
+        : m_nLastChanceToSendRefreshRequest( -1 ) {}
+
+    LockInfo( const OUString& sToken,
+              rtl::Reference< SerfSession > const & xSession,
+              sal_Int32 nLastChanceToSendRefreshRequest )
+    : m_sToken( sToken ),
+      m_xSession( xSession ),
+      m_nLastChanceToSendRefreshRequest( nLastChanceToSendRefreshRequest ) {}
 };
 
-typedef struct _LockInfo
-{
-    rtl::Reference< SerfSession > xSession;
-    sal_Int32 nLastChanceToSendRefreshRequest;
-
-    _LockInfo()
-        : nLastChanceToSendRefreshRequest( -1 ) {}
-
-    _LockInfo( rtl::Reference< SerfSession > const & _xSession,
-              sal_Int32 _nLastChanceToSendRefreshRequest )
-    : xSession( _xSession ),
-      nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
-
-} LockInfo;
-
-typedef std::map< SerfLock *, LockInfo, ltptr > LockInfoMap;
+typedef std::map< OUString, LockInfo > LockInfoMap;
 
 class SerfLockStore
 {
     osl::Mutex         m_aMutex;
-//    ne_lock_store    * m_pSerfLockStore;
     TickerThread     * m_pTickerThread;
     LockInfoMap        m_aLockInfoMap;
 
@@ -68,20 +62,17 @@ public:
     SerfLockStore();
     ~SerfLockStore();
 
-    void registerSession( HttpSession * pHttpSession );
-
-    SerfLock * findByUri( OUString const & rUri );
-
-    void addLock( SerfLock * pLock,
+    void addLock( const OUString& rLock,
+                  const OUString& sToken,
                   rtl::Reference< SerfSession > const & xSession,
                   // time in seconds since Jan 1 1970
                   // -1: infinite lock, no refresh
                   sal_Int32 nLastChanceToSendRefreshRequest );
 
-    void updateLock( SerfLock * pLock,
+    void updateLock( const OUString& rLock,
                      sal_Int32 nLastChanceToSendRefreshRequest );
 
-    void removeLock( SerfLock * pLock );
+    void removeLock( const OUString& rLock );
 
     void refreshLocks();
 
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
index 8a1663b..a557781 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
@@ -314,6 +314,7 @@ bool SerfRequestProcessor::processLock( const css::ucb::Lock & rLock )
 {
     mpProcImpl = new SerfLockReqProcImpl( mPathStr,
                                           mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                          mrSerfSession,
                                           rLock );
 
     return runProcessor() == APR_SUCCESS;
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index 1c7189f..7b21f8f 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -52,12 +52,6 @@
 using namespace com::sun::star;
 using namespace http_dav_ucp;
 
-
-
-// static members!
-//SerfLockStore SerfSession::m_aSerfLockStore;
-
-
 // Constructor
 
 SerfSession::SerfSession(
@@ -1066,7 +1060,7 @@ sal_Int64 SerfSession::LOCK( const OUString & /*inPath*/,
 
 // LOCK (refresh existing lock)
 
-bool SerfSession::LOCK( SerfLock * /*pLock*/,
+bool SerfSession::LOCK( const OUString& /*rLock*/,
                         sal_Int32 & /*rlastChanceToSendRefreshRequest*/ )
 {
     osl::Guard< osl::Mutex > theGuard( m_aMutex );
@@ -1132,7 +1126,7 @@ void SerfSession::UNLOCK( const OUString & /*inPath*/,
 
 // UNLOCK
 
-bool SerfSession::UNLOCK( SerfLock * /*pLock*/ )
+bool SerfSession::UNLOCK( const OUString& /*rLock*/ )
 {
     osl::Guard< osl::Mutex > theGuard( m_aMutex );
 
diff --git a/ucb/source/ucp/webdav/SerfSession.hxx b/ucb/source/ucp/webdav/SerfSession.hxx
index b2642b1..b3dfab7 100644
--- a/ucb/source/ucp/webdav/SerfSession.hxx
+++ b/ucb/source/ucp/webdav/SerfSession.hxx
@@ -27,7 +27,6 @@
 #include <osl/mutex.hxx>
 #include "DAVSession.hxx"
 #include "SerfTypes.hxx"
-//#include "SerfLockStore.hxx"
 #include "SerfUri.hxx"
 
 namespace ucbhelper { class ProxyDecider; }
@@ -63,8 +62,6 @@ private:
 
     DAVRequestEnvironment m_aEnv;
 
-//    static SerfLockStore m_aSerfLockStore;
-
     char* getHostinfo();
     bool isSSLNeeded();
 
@@ -270,11 +267,11 @@ private:
                                  const DAVRequestEnvironment & rEnv );
 
     // refresh lock, called by SerfLockStore::refreshLocks
-    bool LOCK( SerfLock * pLock,
+    bool LOCK( const OUString& rLock,
                sal_Int32 & rlastChanceToSendRefreshRequest );
 
     // unlock, called by SerfLockStore::~SerfLockStore
-    bool UNLOCK( SerfLock * pLock );
+    bool UNLOCK( const OUString& rLock );
 
     /*
     // low level GET implementation, used by public GET implementations
diff --git a/ucb/source/ucp/webdav/SerfTypes.hxx b/ucb/source/ucp/webdav/SerfTypes.hxx
index b396697..2393458 100644
--- a/ucb/source/ucp/webdav/SerfTypes.hxx
+++ b/ucb/source/ucp/webdav/SerfTypes.hxx
@@ -26,9 +26,6 @@
 
 typedef serf_connection_t SerfConnection;
 
-// TODO, figure out type of <SerfLock>
-typedef int SerfLock;
-
 // TODO, check if we need it later on
 typedef struct { const char *nspace, *name; } SerfPropName;
 
commit c1496e67616c3ec94d500bb632cca6b844f37a2f
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Mar 20 20:59:46 2014 +0100

    webdav: Parse response of LOCK request.
    
    Change-Id: Ib17de602e2c51eb29b0495ce7411836ceeccf9d4

diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
index f5aa35c..667583d 100644
--- a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
@@ -20,7 +20,7 @@
 #include "SerfLockReqProcImpl.hxx"
 #include "DAVException.hxx"
 
-//#include "webdavresponseparser.hxx"
+#include "webdavresponseparser.hxx"
 #include <rtl/strbuf.hxx>
 
 namespace http_dav_ucp
@@ -131,33 +131,23 @@ void SerfLockReqProcImpl::processChunkOfResponseData( const char* data,
     }
 }
 
-void SerfLockReqProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ )
+void SerfLockReqProcImpl::handleEndOfResponseData( serf_bucket_t * )
 {
-    //const std::vector< DAVResourceInfo > rResInfo( parseWebDAVPropNameResponse( m_xInputStream.get() ) );
+    const std::vector< css::ucb::Lock > aLocks( parseWebDAVLockResponse( m_xInputStream.get() ) );
 
-    /*
-    if ( theRetVal == NE_OK )
+    if (!aLocks.empty())
     {
-        m_aSerfLockStore.addLock( theLock,
-                                  this,
-                                  lastChanceToSendRefreshRequest(
-                                      startCall, theLock->timeout ) );
-
-        uno::Sequence< OUString > aTokens( 1 );
-        aTokens[ 0 ] = OUString::createFromAscii( theLock->token );
-        m_xLock.LockTokens = aTokens;
-
-        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: created lock for "
-                    << makeAbsoluteURL( inPath ) << ". token: " << theLock->token );
+        for (size_t i = 0; i < aLocks.size(); ++i)
+        {
+           // m_pSerfLockStore->addLock( aLocks[i], m_pSerfSession, m_aStartCall );
+            SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: created lock for "
+                    << getPathStr() << ". token: " << aLocks[i].LockTokens[0]);
+        }
     }
     else
     {
-        ne_lock_destroy( theLock );
-
-        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: obtaining lock for "
-                    << makeAbsoluteURL( inPath ) << " failed!");
+        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: obtaining lock failed!");
     }
-    */
 }
 
 } // namespace http_dav_ucp
diff --git a/ucb/source/ucp/webdav/webdavresponseparser.cxx b/ucb/source/ucp/webdav/webdavresponseparser.cxx
index 1c251f8..8b7c928 100644
--- a/ucb/source/ucp/webdav/webdavresponseparser.cxx
+++ b/ucb/source/ucp/webdav/webdavresponseparser.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/ucb/LockEntry.hpp>
 #include <com/sun/star/ucb/LockScope.hpp>
 #include <com/sun/star/ucb/LockType.hpp>
+#include <com/sun/star/ucb/Lock.hpp>
 #include <map>
 #include <boost/unordered_map.hpp>
 
@@ -69,6 +70,7 @@ namespace
     enum WebDAVName
     {
         WebDAVName_unknown = 0,
+        WebDAVName_activelock,
         WebDAVName_multistatus,
         WebDAVName_response,
         WebDAVName_href,
@@ -80,8 +82,11 @@ namespace
         WebDAVName_supportedlock,
         WebDAVName_lockentry,
         WebDAVName_lockscope,
+        WebDAVName_locktoken,
         WebDAVName_exclusive,
         WebDAVName_locktype,
+        WebDAVName_owner,
+        WebDAVName_timeout,
         WebDAVName_write,
         WebDAVName_shared,
         WebDAVName_status,
@@ -100,6 +105,7 @@ namespace
 
         if(aWebDAVNameMapperList.empty())
         {
+            aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("activelock"), WebDAVName_activelock));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("multistatus"), WebDAVName_multistatus));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("response"), WebDAVName_response));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("href"), WebDAVName_href));
@@ -111,8 +117,11 @@ namespace
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("supportedlock"), WebDAVName_supportedlock));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("lockentry"), WebDAVName_lockentry));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("lockscope"), WebDAVName_lockscope));
+            aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("locktoken"), WebDAVName_locktoken));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("exclusive"), WebDAVName_exclusive));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("locktype"), WebDAVName_locktype));
+            aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("owner"), WebDAVName_owner));
+            aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("timeout"), WebDAVName_timeout));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("write"), WebDAVName_write));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("shared"), WebDAVName_shared));
             aWebDAVNameMapperList.insert(WebDAVNameValueType(OUString("status"), WebDAVName_status));
@@ -277,12 +286,14 @@ namespace
     enum WebDAVResponseParserMode
     {
         WebDAVResponseParserMode_PropFind = 0,
-        WebDAVResponseParserMode_PropName
+        WebDAVResponseParserMode_PropName,
+        WebDAVResponseParserMode_Lock
     };
 
     class WebDAVResponseParser : public cppu::WeakImplHelper1< com::sun::star::xml::sax::XDocumentHandler >
     {
     private:
+        std::vector< ucb::Lock >                      maResult_Lock;
         std::vector< http_dav_ucp::DAVResource >      maResult_PropFind;
         std::vector< http_dav_ucp::DAVResourceInfo >  maResult_PropName;
 
@@ -296,6 +307,7 @@ namespace
         uno::Sequence< ucb::LockEntry >             maLockEntries;
         ucb::LockScope                              maLockScope;
         ucb::LockType                               maLockType;
+        ucb::Lock                                   maLock;
         WebDAVResponseParserMode                    meWebDAVResponseParserMode;
 
         // bitfield
@@ -356,6 +368,7 @@ namespace
         virtual void SAL_CALL processingInstruction( const OUString& aTarget, const OUString& aData ) throw (xml::sax::SAXException, uno::RuntimeException);
         virtual void SAL_CALL setDocumentLocator( const uno::Reference< xml::sax::XLocator >& xLocator ) throw (xml::sax::SAXException, uno::RuntimeException);
 
+        const std::vector< ucb::Lock >& getResult_Lock() const { return maResult_Lock; }
         const std::vector< http_dav_ucp::DAVResource >& getResult_PropFind() const { return maResult_PropFind; }
         const std::vector< http_dav_ucp::DAVResourceInfo >& getResult_PropName() const { return maResult_PropName; }
     };
@@ -480,6 +493,11 @@ namespace
                                 mbLockTypeSet = false;
                                 break;
                             }
+                            case WebDAVName_activelock:
+                            {
+                                maLock = ucb::Lock();
+                                break;
+                            }
                         }
                         break;
                     }
@@ -641,6 +659,30 @@ namespace
                                 }
                                 break;
                             }
+                            case WebDAVName_owner:
+                            {
+                                maLock.Owner <<= mpContext->getWhiteSpace();
+                                break;
+                            }
+                            case WebDAVName_timeout:
+                            {
+                                const OUString sTimeout(mpContext->getWhiteSpace());
+                                if (sTimeout == "Infinite")
+                                    maLock.Timeout = -1;
+                                else if (sTimeout.startsWith("Second-"))
+                                    maLock.Timeout = sTimeout.copy(7).toInt64();
+                                break;
+                            }
+                            case WebDAVName_locktoken:
+                            {
+                                const OUString sLockToken(maHref);
+                                SAL_WARN_IF(!sLockToken.startsWith("opaquelocktoken:"), "ucb.ucp.webdav",
+                                        "Parser error: wrong 'locktoken' value.");
+                                const sal_Int32 nLength(maLock.LockTokens.getLength());
+                                maLock.LockTokens.realloc(nLength+1);
+                                maLock.LockTokens[nLength] = sLockToken;
+                                break;
+                            }
                             case WebDAVName_exclusive:
                             {
                                 // exclusive lockscope end
@@ -671,6 +713,12 @@ namespace
                                 }
                                 break;
                             }
+                            case WebDAVName_activelock:
+                            {
+                                maLock.Type = maLockType;
+                                maLock.Scope = maLockScope;
+                                maResult_Lock.push_back(maLock);
+                            }
                             case WebDAVName_propstat:
                             {
                                 // propstat end, check status
@@ -789,10 +837,10 @@ namespace
 
 namespace
 {
-    void parseWebDAVPropNameResponse(
+    template<typename T>
+    void parseWebDAVResponse(
         const uno::Reference< io::XInputStream >& xInputStream,
-        std::vector< http_dav_ucp::DAVResource >& rPropFind,
-        std::vector< http_dav_ucp::DAVResourceInfo >& rPropName,
+        std::vector< T >& rResult,
         WebDAVResponseParserMode eWebDAVResponseParserMode)
     {
         if(xInputStream.is())
@@ -818,16 +866,17 @@ namespace
                 // get result
                 switch(eWebDAVResponseParserMode)
                 {
+                    // *(std::vector<T>*) & is a horrible hack but hopefully works,
+                    // I was not able to come up with something sane :-/
                     case WebDAVResponseParserMode_PropFind:
-                    {
-                        rPropFind = pWebDAVResponseParser->getResult_PropFind();
+                        rResult = *(std::vector<T>*) &pWebDAVResponseParser->getResult_PropFind();
                         break;
-                    }
                     case WebDAVResponseParserMode_PropName:
-                    {
-                        rPropName = pWebDAVResponseParser->getResult_PropName();
+                        rResult = *(std::vector<T>*) &pWebDAVResponseParser->getResult_PropName();
+                        break;
+                    case WebDAVResponseParserMode_Lock:
+                        rResult = *(std::vector<T>*) &pWebDAVResponseParser->getResult_Lock();
                         break;
-                    }
                 }
             }
             catch(uno::Exception&)
@@ -843,22 +892,25 @@ namespace
 
 namespace http_dav_ucp
 {
-    std::vector< DAVResource > parseWebDAVPropFindResponse(const uno::Reference< io::XInputStream >& xInputStream)
+    std::vector< ucb::Lock > parseWebDAVLockResponse(const uno::Reference< io::XInputStream >& xInputStream)
     {
-        std::vector< DAVResource > aRetval;
-        std::vector< DAVResourceInfo > aFoo;
+        std::vector< ucb::Lock > aResult;
+        parseWebDAVResponse< ucb::Lock >(xInputStream, aResult, WebDAVResponseParserMode_Lock);
+        return aResult;
+    }
 
-        parseWebDAVPropNameResponse(xInputStream, aRetval, aFoo, WebDAVResponseParserMode_PropFind);
-        return aRetval;
+    std::vector< DAVResource > parseWebDAVPropFindResponse(const uno::Reference< io::XInputStream >& xInputStream)
+    {
+        std::vector< DAVResource > aResult;
+        parseWebDAVResponse< DAVResource >(xInputStream, aResult, WebDAVResponseParserMode_PropFind);
+        return aResult;
     }
 
     std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const uno::Reference< io::XInputStream >& xInputStream)
     {
-        std::vector< DAVResource > aFoo;
-        std::vector< DAVResourceInfo > aRetval;
-
-        parseWebDAVPropNameResponse(xInputStream, aFoo, aRetval, WebDAVResponseParserMode_PropName);
-        return aRetval;
+        std::vector< DAVResourceInfo > aResult;
+        parseWebDAVResponse< DAVResourceInfo >(xInputStream, aResult, WebDAVResponseParserMode_PropName);
+        return aResult;
     }
 } // namespace http_dav_ucp
 
diff --git a/ucb/source/ucp/webdav/webdavresponseparser.hxx b/ucb/source/ucp/webdav/webdavresponseparser.hxx
index ceadd8a..17ffb30 100644
--- a/ucb/source/ucp/webdav/webdavresponseparser.hxx
+++ b/ucb/source/ucp/webdav/webdavresponseparser.hxx
@@ -22,22 +22,19 @@
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/ucb/Lock.hpp>
 #include "DAVResource.hxx"
 #include <vector>
 
 
-
 namespace http_dav_ucp
 {
-    std::vector< DAVResource > parseWebDAVPropFindResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
-    std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
+    std::vector< css::ucb::Lock > parseWebDAVLockResponse(const css::uno::Reference< css::io::XInputStream >& xInputStream);
+    std::vector< DAVResource > parseWebDAVPropFindResponse(const css::uno::Reference< css::io::XInputStream >& xInputStream);
+    std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const css::uno::Reference< css::io::XInputStream >& xInputStream);
 } // namespace http_dav_ucp
 
 
-
 #endif // _WEBDAVRESPONSEPARSER_HXX_
 
-
-// eof
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6e0cc0cd40fcceef601c9b680f44b95f6286ffa0
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Mar 20 09:40:06 2014 +0100

    webdav: Lock files when opening them.
    
    The implementation is not perfect but good enough as a start.
    
    Change-Id: I6f006ae7a16ee73de20448e1228d9acfd69becb4

diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk
index 2e23ba8..ad0fe79 100644
--- a/ucb/Library_ucpdav1.mk
+++ b/ucb/Library_ucpdav1.mk
@@ -84,6 +84,7 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
 	ucb/source/ucp/webdav/SerfGetReqProcImpl \
 	ucb/source/ucp/webdav/SerfHeadReqProcImpl \
 	ucb/source/ucp/webdav/SerfInputStream \
+	ucb/source/ucp/webdav/SerfLockReqProcImpl \
 	ucb/source/ucp/webdav/SerfMkColReqProcImpl \
 	ucb/source/ucp/webdav/SerfMoveReqProcImpl \
 	ucb/source/ucp/webdav/SerfPostReqProcImpl \
diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
new file mode 100644
index 0000000..f5aa35c
--- /dev/null
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "SerfLockReqProcImpl.hxx"
+#include "DAVException.hxx"
+
+//#include "webdavresponseparser.hxx"
+#include <rtl/strbuf.hxx>
+
+namespace http_dav_ucp
+{
+
+SerfLockReqProcImpl::SerfLockReqProcImpl( const char* inPath,
+                                          const DAVRequestHeaders& inRequestHeaders,
+                                          const css::ucb::Lock & rLock )
+    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
+    , m_aLock( rLock )
+    , m_xInputStream( new SerfInputStream() )
+{
+}
+
+SerfLockReqProcImpl::~SerfLockReqProcImpl()
+{
+}
+
+serf_bucket_t * SerfLockReqProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
+{
+    serf_bucket_alloc_t* pSerfBucketAlloc = serf_request_get_alloc( inSerfRequest );
+
+    OStringBuffer aBody("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+                        "<lockinfo xmlns='DAV:'>\n <lockscope>");
+
+    // Set the lock scope
+    switch ( m_aLock.Scope )
+    {
+        case css::ucb::LockScope_EXCLUSIVE:
+            aBody.append("<exclusive/>");
+            break;
+        case css::ucb::LockScope_SHARED:
+            aBody.append("<shared/>");
+            break;
+        default:
+            throw DAVException( DAVException::DAV_INVALID_ARG );
+    }
+    aBody.append("</lockscope>\n <locktype><write/></locktype>\n");
+
+    // Set the lock owner
+    OUString aValue;
+    if ((m_aLock.Owner >>= aValue) && !aValue.isEmpty())
+    {
+        aBody.append(" <owner>");
+        aBody.append(OUStringToOString(aValue, RTL_TEXTENCODING_UTF8));
+        aBody.append("</owner>\n");
+    }
+    aBody.append("</lockinfo>\n");
+
+    const OString aBodyText(aBody.makeStringAndClear());
+    serf_bucket_t* body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(),
+                                                              aBodyText.getLength(),
+                                                              pSerfBucketAlloc );
+
+    // create serf request
+    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
+                                                                 "LOCK",
+                                                                 getPathStr(),
+                                                                 body_bkt,
+                                                                 pSerfBucketAlloc );
+    handleChunkedEncoding(req_bkt, aBodyText.getLength());
+
+    // set request header fields
+    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
+
+    // general header fields provided by caller
+    setRequestHeaders( hdrs_bkt );
+
+    // request specific header fields
+    const char * depth = 0;
+    switch( m_aLock.Depth )
+    {
+        case css::ucb::LockDepth_ZERO:
+            depth = "0";
+            break;
+        case css::ucb::LockDepth_ONE:
+            depth = "1";
+            break;
+        case css::ucb::LockDepth_INFINITY:
+            depth = "infinity";
+            break;
+        default:
+            throw DAVException( DAVException::DAV_INVALID_ARG );
+    }
+    serf_bucket_headers_set( hdrs_bkt, "Depth", depth );
+    serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
+
+    // Set the lock timeout
+    if (m_aLock.Timeout == -1)
+        serf_bucket_headers_set( hdrs_bkt, "Timeout", "Infinite" );
+    else if (m_aLock.Timeout > 0)
+    {
+        const OString aTimeValue("Second-" + OString::number(m_aLock.Timeout));
+        serf_bucket_headers_set( hdrs_bkt, "Timeout", aTimeValue.getStr() );
+    }
+
+    osl_getSystemTime( &m_aStartCall );
+
+    return req_bkt;
+}
+
+void SerfLockReqProcImpl::processChunkOfResponseData( const char* data,
+                                                          apr_size_t len )
+{
+    if ( m_xInputStream.is() )
+    {
+        m_xInputStream->AddToStream( data, len );
+    }
+}
+
+void SerfLockReqProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ )
+{
+    //const std::vector< DAVResourceInfo > rResInfo( parseWebDAVPropNameResponse( m_xInputStream.get() ) );
+
+    /*
+    if ( theRetVal == NE_OK )
+    {
+        m_aSerfLockStore.addLock( theLock,
+                                  this,
+                                  lastChanceToSendRefreshRequest(
+                                      startCall, theLock->timeout ) );
+
+        uno::Sequence< OUString > aTokens( 1 );
+        aTokens[ 0 ] = OUString::createFromAscii( theLock->token );
+        m_xLock.LockTokens = aTokens;
+
+        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: created lock for "
+                    << makeAbsoluteURL( inPath ) << ". token: " << theLock->token );
+    }
+    else
+    {
+        ne_lock_destroy( theLock );
+
+        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: obtaining lock for "
+                    << makeAbsoluteURL( inPath ) << " failed!");
+    }
+    */
+}
+
+} // namespace http_dav_ucp
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
new file mode 100644
index 0000000..cb746a3
--- /dev/null
+++ b/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SERFLOCKREQPROCIMPL_HXX
+#define INCLUDED_SERFLOCKREQPROCIMPL_HXX
+
+#include "SerfRequestProcessorImpl.hxx"
+#include "SerfInputStream.hxx"
+
+#include <com/sun/star/ucb/Lock.hpp>
+#include <osl/time.h>
+
+namespace http_dav_ucp
+{
+
+class SerfLockReqProcImpl : public SerfRequestProcessorImpl
+{
+public:
+    SerfLockReqProcImpl( const char* inPath,
+                         const DAVRequestHeaders& inRequestHeaders,
+                         const css::ucb::Lock & rLock );
+
+    virtual ~SerfLockReqProcImpl() SAL_OVERRIDE;
+
+    virtual
+    serf_bucket_t * createSerfRequestBucket( serf_request_t * inSerfRequest ) SAL_OVERRIDE;
+
+private:
+    virtual
+    void processChunkOfResponseData( const char* data, apr_size_t len ) SAL_OVERRIDE;
+
+    virtual
+    void handleEndOfResponseData( serf_bucket_t * inSerfResponseBucket ) SAL_OVERRIDE;
+
+    css::ucb::Lock m_aLock;
+    TimeValue m_aStartCall;
+    css::uno::Reference< SerfInputStream > m_xInputStream;
+};
+
+} // namespace http_dav_ucp
+
+#endif // INCLUDED_SERFLOCKREQPROCIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
index 70d5575..8a1663b 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
@@ -30,6 +30,7 @@
 #include "SerfMkColReqProcImpl.hxx"
 #include "SerfCopyReqProcImpl.hxx"
 #include "SerfMoveReqProcImpl.hxx"
+#include "SerfLockReqProcImpl.hxx"
 
 #include <apr_strings.h>
 
@@ -308,6 +309,16 @@ bool SerfRequestProcessor::processMove( const OUString & inDestinationPath,
     return outSerfStatus == APR_SUCCESS;
 }
 
+
+bool SerfRequestProcessor::processLock( const css::ucb::Lock & rLock )
+{
+    mpProcImpl = new SerfLockReqProcImpl( mPathStr,
+                                          mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                          rLock );
+
+    return runProcessor() == APR_SUCCESS;
+}
+
 apr_status_t SerfRequestProcessor::runProcessor()
 {
     prepareProcessor();
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
index 9addb34..f941a49 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
@@ -32,6 +32,7 @@
 
 #include "SerfInputStream.hxx"
 #include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/ucb/Lock.hpp>
 
 namespace http_dav_ucp
 {
@@ -124,6 +125,9 @@ public:
                       const bool inOverwrite,
                       apr_status_t& outSerfStatus );
 
+    //LOCK
+    bool processLock( const css::ucb::Lock & rLock );
+
     apr_status_t provideSerfCredentials( char ** outUsername,
                                          char ** outPassword,
                                          serf_request_t * inRequest,
diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx
index e4c600f..1c7189f 100644
--- a/ucb/source/ucp/webdav/SerfSession.cxx
+++ b/ucb/source/ucp/webdav/SerfSession.cxx
@@ -1008,7 +1008,7 @@ namespace
 // LOCK (set new lock)
 
 void SerfSession::LOCK( const OUString & inPath,
-                        ucb::Lock & /*rLock*/,
+                        ucb::Lock & rLock,
                         const DAVRequestEnvironment & rEnv )
     throw ( DAVException )
 {
@@ -1017,87 +1017,9 @@ void SerfSession::LOCK( const OUString & inPath,
     Init( rEnv );
 
     boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
-    HandleError( aReqProc );
-    /* Create a depth zero, exclusive write lock, with default timeout
-     * (allowing a server to pick a default).  token, owner and uri are
-     * unset. */
-    /*
-    SerfLock * theLock = ne_lock_create();
-
-    // Set the lock uri
-    ne_uri aUri;
-    ne_uri_parse( OUStringToOString( makeAbsoluteURL( inPath ),
-                                          RTL_TEXTENCODING_UTF8 ).getStr(),
-                  &aUri );
-    theLock->uri = aUri;
-
-    // Set the lock depth
-    switch( rLock.Depth )
-    {
-    case ucb::LockDepth_ZERO:
-        theLock->depth = NE_DEPTH_ZERO;
-        break;
-    case ucb::LockDepth_ONE:
-        theLock->depth = NE_DEPTH_ONE;
-        break;
-    case ucb::LockDepth_INFINITY:
-        theLock->depth = NE_DEPTH_INFINITE;
-        break;
-    default:
-        throw DAVException( DAVException::DAV_INVALID_ARG );
-    }
-
-    // Set the lock scope
-    switch ( rLock.Scope )
-    {
-    case ucb::LockScope_EXCLUSIVE:
-        theLock->scope = ne_lockscope_exclusive;
-        break;
-    case ucb::LockScope_SHARED:
-        theLock->scope = ne_lockscope_shared;
-        break;
-    default:
-        throw DAVException( DAVException::DAV_INVALID_ARG );
-    }
-
-    // Set the lock timeout
-    theLock->timeout = (long)rLock.Timeout;
-
-    // Set the lock owner
-    OUString aValue;
-    rLock.Owner >>= aValue;
-    theLock->owner =
-        ne_strdup( OUStringToOString( aValue,
-                                           RTL_TEXTENCODING_UTF8 ).getStr() );
-    TimeValue startCall;
-    osl_getSystemTime( &startCall );
+    aReqProc->processLock( rLock );
 
-    int theRetVal = ne_lock( m_pHttpSession, theLock );
-
-    if ( theRetVal == NE_OK )
-    {
-        m_aSerfLockStore.addLock( theLock,
-                                  this,
-                                  lastChanceToSendRefreshRequest(
-                                      startCall, theLock->timeout ) );
-
-        uno::Sequence< OUString > aTokens( 1 );
-        aTokens[ 0 ] = OUString::createFromAscii( theLock->token );
-        rLock.LockTokens = aTokens;
-
-        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: created lock for "
-                    << makeAbsoluteURL( inPath ) << ". token: " << theLock->token );
-    }
-    else
-    {
-        ne_lock_destroy( theLock );
-
-        SAL_INFO("ucb.ucp.webdav",  "SerfSession::LOCK: obtaining lock for "
-                    << makeAbsoluteURL( inPath ) << " failed!");
-    }
-
-    HandleError( theRetVal, inPath, rEnv );
-    */
+    HandleError( aReqProc );
 }
 
 
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index b705822..f22a306 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -590,6 +590,11 @@ uno::Any SAL_CALL Content::execute(
         }
 
         aRet = open( aOpenCommand, Environment );
+
+        if ( (aOpenCommand.Mode == ucb::OpenMode::DOCUMENT ||
+              aOpenCommand.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE) &&
+                supportsExclusiveWriteLock( Environment ) )
+            lock( Environment );
     }
     else if ( aCommand.Name == "insert" )
     {
commit 9f586e2fbe41ec4d808369fac9501e3e9aea08f5
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Mar 20 09:20:30 2014 +0100

    Remove pointless SerfRequestProcessorImplFac indirection.
    
    Change-Id: If8549893a686c7a665adde0436d377d6d695e5bf

diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk
index 4f6f4c2..2e23ba8 100644
--- a/ucb/Library_ucpdav1.mk
+++ b/ucb/Library_ucpdav1.mk
@@ -92,7 +92,6 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\
 	ucb/source/ucp/webdav/SerfPutReqProcImpl \
 	ucb/source/ucp/webdav/SerfRequestProcessor \
 	ucb/source/ucp/webdav/SerfRequestProcessorImpl \
-	ucb/source/ucp/webdav/SerfRequestProcessorImplFac \
 	ucb/source/ucp/webdav/SerfSession \
 	ucb/source/ucp/webdav/SerfUri \
 	ucb/source/ucp/webdav/UCBDeadPropertyValue \
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
index 5e2b67e..70d5575 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
@@ -18,10 +18,18 @@
  */
 
 #include "SerfRequestProcessor.hxx"
-#include "SerfRequestProcessorImpl.hxx"
-#include "SerfRequestProcessorImplFac.hxx"
 #include "SerfCallbacks.hxx"
 #include "SerfSession.hxx"
+#include "SerfPropFindReqProcImpl.hxx"
+#include "SerfPropPatchReqProcImpl.hxx"
+#include "SerfGetReqProcImpl.hxx"
+#include "SerfHeadReqProcImpl.hxx"
+#include "SerfPutReqProcImpl.hxx"
+#include "SerfPostReqProcImpl.hxx"
+#include "SerfDeleteReqProcImpl.hxx"
+#include "SerfMkColReqProcImpl.hxx"
+#include "SerfCopyReqProcImpl.hxx"
+#include "SerfMoveReqProcImpl.hxx"
 
 #include <apr_strings.h>
 
@@ -80,7 +88,7 @@ bool SerfRequestProcessor::processPropFind( const Depth inDepth,
                                             std::vector< DAVResource > & ioResources,
                                             apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createPropFindReqProcImpl( mPathStr,
+    mpProcImpl = new SerfPropFindReqProcImpl( mPathStr,
                                             mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                             inDepth,
                                             inPropNames,
@@ -95,7 +103,7 @@ bool SerfRequestProcessor::processPropFind( const Depth inDepth,
                                             std::vector< DAVResourceInfo > & ioResInfo,
                                             apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createPropFindReqProcImpl( mPathStr,
+    mpProcImpl = new SerfPropFindReqProcImpl( mPathStr,
                                             mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                             inDepth,
                                             ioResInfo );
@@ -108,7 +116,7 @@ bool SerfRequestProcessor::processPropFind( const Depth inDepth,
 bool SerfRequestProcessor::processPropPatch( const std::vector< ProppatchValue > & inProperties,
                                              apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createPropPatchReqProcImpl( mPathStr,
+    mpProcImpl = new SerfPropPatchReqProcImpl( mPathStr,
                                              mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                              inProperties );
     outSerfStatus = runProcessor();
@@ -120,7 +128,7 @@ bool SerfRequestProcessor::processPropPatch( const std::vector< ProppatchValue >
 bool SerfRequestProcessor::processGet( const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
                                        apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createGetReqProcImpl( mPathStr,
+    mpProcImpl = new SerfGetReqProcImpl( mPathStr,
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                        xioInStrm );
     outSerfStatus = runProcessor();
@@ -134,7 +142,7 @@ bool SerfRequestProcessor::processGet( const com::sun::star::uno::Reference< Ser
                                        DAVResource & ioResource,
                                        apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createGetReqProcImpl( mPathStr,
+    mpProcImpl = new SerfGetReqProcImpl( mPathStr,
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                        xioInStrm,
                                        inHeaderNames,
@@ -148,7 +156,7 @@ bool SerfRequestProcessor::processGet( const com::sun::star::uno::Reference< Ser
 bool SerfRequestProcessor::processGet( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
                                        apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createGetReqProcImpl( mPathStr,
+    mpProcImpl = new SerfGetReqProcImpl( mPathStr,
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                        xioOutStrm );
     outSerfStatus = runProcessor();
@@ -162,7 +170,7 @@ bool SerfRequestProcessor::processGet( const com::sun::star::uno::Reference< com
                                        DAVResource & ioResource,
                                        apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createGetReqProcImpl( mPathStr,
+    mpProcImpl = new SerfGetReqProcImpl( mPathStr,
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                        xioOutStrm,
                                        inHeaderNames,
@@ -177,7 +185,7 @@ bool SerfRequestProcessor::processHead( const std::vector< OUString > & inHeader
                                         DAVResource & ioResource,
                                         apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createHeadReqProcImpl( mPathStr,
+    mpProcImpl = new SerfHeadReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         inHeaderNames,
                                         ioResource );
@@ -191,7 +199,7 @@ bool SerfRequestProcessor::processPut( const char* inData,
                                        apr_size_t inDataLen,
                                        apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createPutReqProcImpl( mPathStr,
+    mpProcImpl = new SerfPutReqProcImpl( mPathStr,
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                        inData,
                                        inDataLen );
@@ -212,7 +220,7 @@ bool SerfRequestProcessor::processPost( const char* inData,
                                 OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
     mReferer = apr_pstrdup( mrSerfSession.getAprPool(),
                                 OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
-    mpProcImpl = createPostReqProcImpl( mPathStr,
+    mpProcImpl = new SerfPostReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         inData,
                                         inDataLen,
@@ -236,7 +244,7 @@ bool SerfRequestProcessor::processPost( const char* inData,
                                 OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
     mReferer = apr_pstrdup( mrSerfSession.getAprPool(),
                             OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
-    mpProcImpl = createPostReqProcImpl( mPathStr,
+    mpProcImpl = new SerfPostReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         inData,
                                         inDataLen,
@@ -251,7 +259,7 @@ bool SerfRequestProcessor::processPost( const char* inData,
 // DELETE
 bool SerfRequestProcessor::processDelete( apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createDeleteReqProcImpl( mPathStr,
+    mpProcImpl = new SerfDeleteReqProcImpl( mPathStr,
                                           mrSerfSession.getRequestEnvironment().m_aRequestHeaders );
     outSerfStatus = runProcessor();
 
@@ -261,7 +269,7 @@ bool SerfRequestProcessor::processDelete( apr_status_t& outSerfStatus )
 // MKCOL
 bool SerfRequestProcessor::processMkCol( apr_status_t& outSerfStatus )
 {
-    mpProcImpl = createMkColReqProcImpl( mPathStr,
+    mpProcImpl = new SerfMkColReqProcImpl( mPathStr,
                                          mrSerfSession.getRequestEnvironment().m_aRequestHeaders );
     outSerfStatus = runProcessor();
 
@@ -275,7 +283,7 @@ bool SerfRequestProcessor::processCopy( const OUString & inDestinationPath,
 {
     mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
                                 OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
-    mpProcImpl = createCopyReqProcImpl( mPathStr,
+    mpProcImpl = new SerfCopyReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         mDestPathStr,
                                         inOverwrite );
@@ -291,7 +299,7 @@ bool SerfRequestProcessor::processMove( const OUString & inDestinationPath,
 {
     mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
                                 OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
-    mpProcImpl = createMoveReqProcImpl( mPathStr,
+    mpProcImpl = new SerfMoveReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         mDestPathStr,
                                         inOverwrite );
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx b/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx
deleted file mode 100644
index cbd45a1..0000000
--- a/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx
+++ /dev/null
@@ -1,221 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "SerfRequestProcessorImplFac.hxx"
-#include "SerfPropFindReqProcImpl.hxx"
-#include "SerfPropPatchReqProcImpl.hxx"
-#include "SerfGetReqProcImpl.hxx"
-#include "SerfHeadReqProcImpl.hxx"
-#include "SerfPutReqProcImpl.hxx"
-#include "SerfPostReqProcImpl.hxx"
-#include "SerfDeleteReqProcImpl.hxx"
-#include "SerfMkColReqProcImpl.hxx"
-#include "SerfCopyReqProcImpl.hxx"
-#include "SerfMoveReqProcImpl.hxx"
-
-namespace http_dav_ucp
-{
-    SerfRequestProcessorImpl* createPropFindReqProcImpl( const char* inPath,
-                                                         const DAVRequestHeaders& inRequestHeaders,
-                                                         const Depth inDepth,
-                                                         const std::vector< OUString > & inPropNames,
-                                                         std::vector< DAVResource > & ioResources )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfPropFindReqProcImpl( inPath,
-                                                                              inRequestHeaders,
-                                                                              inDepth,
-                                                                              inPropNames,
-                                                                              ioResources );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createPropFindReqProcImpl( const char* inPath,
-                                                         const DAVRequestHeaders& inRequestHeaders,
-                                                         const Depth inDepth,
-                                                         std::vector< DAVResourceInfo > & ioResInfo )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfPropFindReqProcImpl( inPath,
-                                                                              inRequestHeaders,
-                                                                              inDepth,
-                                                                              ioResInfo );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createPropPatchReqProcImpl( const char* inPath,
-                                                          const DAVRequestHeaders& inRequestHeaders,
-                                                          const std::vector< ProppatchValue > & inProperties )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfPropPatchReqProcImpl( inPath,
-                                                                               inRequestHeaders,
-                                                                               inProperties );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createGetReqProcImpl( const char* inPath,
-                                                    const DAVRequestHeaders& inRequestHeaders,
-                                                    const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfGetReqProcImpl( inPath,
-                                                                         inRequestHeaders,
-                                                                         xioInStrm );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createGetReqProcImpl( const char* inPath,
-                                                    const DAVRequestHeaders& inRequestHeaders,
-                                                    const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
-                                                    const std::vector< OUString > & inHeaderNames,
-                                                    DAVResource& ioResource )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfGetReqProcImpl( inPath,
-                                                                         inRequestHeaders,
-                                                                         xioInStrm,
-                                                                         inHeaderNames,
-                                                                         ioResource );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createGetReqProcImpl( const char* inPath,
-                                                    const DAVRequestHeaders& inRequestHeaders,
-                                                    const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfGetReqProcImpl( inPath,
-                                                                         inRequestHeaders,
-                                                                         xioOutStrm );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createGetReqProcImpl( const char* inPath,
-                                                    const DAVRequestHeaders& inRequestHeaders,
-                                                    const com::sun::star::uno::Reference<com::sun::star::io::XOutputStream >& xioOutStrm,
-                                                    const std::vector< OUString > & inHeaderNames,
-                                                    DAVResource& ioResource )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfGetReqProcImpl( inPath,
-                                                                         inRequestHeaders,
-                                                                         xioOutStrm,
-                                                                         inHeaderNames,
-                                                                         ioResource );
-        return pReqProcImpl;
-    }
-
-    SerfRequestProcessorImpl* createHeadReqProcImpl( const char* inPath,
-                                                     const DAVRequestHeaders& inRequestHeaders,
-                                                     const std::vector< OUString > & inHeaderNames,
-                                                     DAVResource& ioResource )
-    {
-        SerfRequestProcessorImpl* pReqProcImpl = new SerfHeadReqProcImpl( inPath,
-                                                                          inRequestHeaders,
-                                                                          inHeaderNames,

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list