[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 3 commits - comphelper/inc comphelper/source framework/source offapi/com sal/inc sal/osl sfx2/inc sfx2/source ucbhelper/inc ucbhelper/source ucb/source vcl/source

Andrea Pescetti pescetti at apache.org
Thu Sep 24 17:12:37 PDT 2015


 comphelper/inc/comphelper/mediadescriptor.hxx                 |    1 
 comphelper/inc/comphelper/stillreadwriteinteraction.hxx       |    7 
 comphelper/source/misc/mediadescriptor.cxx                    |   35 
 comphelper/source/misc/stillreadwriteinteraction.cxx          |   24 
 framework/source/loadenv/loadenv.cxx                          |    1 
 offapi/com/sun/star/ucb/InteractiveLockingException.idl       |    6 
 offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl |    7 
 offapi/com/sun/star/ucb/makefile.mk                           |    1 
 sal/inc/osl/file.h                                            |    1 
 sal/inc/osl/file.hxx                                          |    1 
 sal/osl/w32/file_error.c                                      |    4 
 sfx2/inc/sfx2/docfile.hxx                                     |    5 
 sfx2/source/dialog/filedlghelper.cxx                          |    2 
 sfx2/source/doc/docfile.cxx                                   |  317 +++++++
 sfx2/source/view/viewfrm.cxx                                  |   99 +-
 ucb/source/ucp/file/filglob.cxx                               |    4 
 ucb/source/ucp/webdav/DAVException.hxx                        |   25 
 ucb/source/ucp/webdav/DAVResourceAccess.hxx                   |    2 
 ucb/source/ucp/webdav/DAVTypes.hxx                            |    2 
 ucb/source/ucp/webdav/SerfCallbacks.cxx                       |    6 
 ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx                 |    8 
 ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx                 |    4 
 ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx               |    9 
 ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx               |    5 
 ucb/source/ucp/webdav/SerfLockStore.cxx                       |  108 +-
 ucb/source/ucp/webdav/SerfLockStore.hxx                       |    8 
 ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx                |    4 
 ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx                |    5 
 ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx                 |    8 
 ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx                 |    6 
 ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx                 |    8 
 ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx                 |    3 
 ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx            |    8 
 ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx            |    4 
 ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx                  |    7 
 ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx                  |    2 
 ucb/source/ucp/webdav/SerfRequestProcessor.cxx                |  185 ++++
 ucb/source/ucp/webdav/SerfRequestProcessor.hxx                |   30 
 ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx         |   82 +-
 ucb/source/ucp/webdav/SerfRequestProcessorImplFac.hxx         |   37 
 ucb/source/ucp/webdav/SerfSession.cxx                         |  408 +++++-----
 ucb/source/ucp/webdav/SerfSession.hxx                         |   16 
 ucb/source/ucp/webdav/SerfTypes.hxx                           |   33 
 ucb/source/ucp/webdav/makefile.mk                             |    5 
 ucb/source/ucp/webdav/webdavcontent.cxx                       |  180 +++-
 ucb/source/ucp/webdav/webdavcontent.hxx                       |   34 
 ucb/source/ucp/webdav/webdavprovider.cxx                      |    1 
 ucb/source/ucp/webdav/webdavresponseparser.cxx                |  225 +++++
 ucb/source/ucp/webdav/webdavresponseparser.hxx                |    1 
 ucbhelper/inc/ucbhelper/content.hxx                           |   21 
 ucbhelper/source/client/content.cxx                           |   35 
 vcl/source/gdi/jobset.cxx                                     |    4 
 52 files changed, 1673 insertions(+), 371 deletions(-)

New commits:
commit 31fda9c8517d1c10048a3e800847fdbad691c6ef
Author: Andrea Pescetti <pescetti at apache.org>
Date:   Thu Sep 24 23:49:58 2015 +0000

    #i126305# Add support for WebDAV locking.
    
    Patch by: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>

diff --git a/comphelper/inc/comphelper/mediadescriptor.hxx b/comphelper/inc/comphelper/mediadescriptor.hxx
index 8797252..51ba921 100644
--- a/comphelper/inc/comphelper/mediadescriptor.hxx
+++ b/comphelper/inc/comphelper/mediadescriptor.hxx
@@ -85,6 +85,7 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
         static const ::rtl::OUString& PROP_HIDDEN();
         static const ::rtl::OUString& PROP_INPUTSTREAM();
         static const ::rtl::OUString& PROP_INTERACTIONHANDLER();
+        static const ::rtl::OUString& PROP_AUTHENTICATIONHANDLER();
         static const ::rtl::OUString& PROP_JUMPMARK();
         static const ::rtl::OUString& PROP_MACROEXECUTIONMODE();
         static const ::rtl::OUString& PROP_MEDIATYPE();
diff --git a/comphelper/inc/comphelper/stillreadwriteinteraction.hxx b/comphelper/inc/comphelper/stillreadwriteinteraction.hxx
index 9787b18..3fcced2 100644
--- a/comphelper/inc/comphelper/stillreadwriteinteraction.hxx
+++ b/comphelper/inc/comphelper/stillreadwriteinteraction.hxx
@@ -44,18 +44,23 @@ class COMPHELPER_DLLPUBLIC StillReadWriteInteraction : public ::ucbhelper::Inter
 private:
     static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION       = 0;
     static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
+    static const sal_Int32 HANDLE_AUTHENTICATIONREQUESTEXCEPTION = 2;
 
     sal_Bool m_bUsed;
     sal_Bool m_bHandledByMySelf;
     sal_Bool m_bHandledByInternalHandler;
 
 public:
-    StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler);
+    StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler,
+                              const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xAuthenticationHandler);
 
     void resetInterceptions();
     void resetErrorStates();
     sal_Bool wasWriteError();
 
+protected:
+    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xAuthenticationHandler;
+
 private:
     virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest&                         aRequest,
         const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest);
diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index 9b13f76..5529edf 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -175,6 +175,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_INTERACTIONHANDLER()
     return sProp;
 }
 
+const ::rtl::OUString& MediaDescriptor::PROP_AUTHENTICATIONHANDLER()
+{
+    static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("AuthenticationHandler"));
+    return sProp;
+}
+
 const ::rtl::OUString& MediaDescriptor::PROP_JUMPMARK()
 {
     static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("JumpMark"));
@@ -706,8 +712,11 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s
     css::uno::Reference< css::task::XInteractionHandler > xOrgInteraction = getUnpackedValueOrDefault(
         MediaDescriptor::PROP_INTERACTIONHANDLER(),
         css::uno::Reference< css::task::XInteractionHandler >());
+    css::uno::Reference< css::task::XInteractionHandler > xAuthenticationInteraction = getUnpackedValueOrDefault(
+        MediaDescriptor::PROP_AUTHENTICATIONHANDLER(),
+        css::uno::Reference< css::task::XInteractionHandler >());
 
-    StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction);
+    StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction, xAuthenticationInteraction);
     css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
 
     css::uno::Reference< css::ucb::XProgressHandler > xProgress;
@@ -738,11 +747,17 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s
     css::uno::Reference< css::io::XInputStream > xInputStream;
 
     sal_Bool bReadOnly = sal_False;
+    //bModeRequestedExplicitly means 'read/write mode requested explicitly'
     sal_Bool bModeRequestedExplicitly = sal_False;
+    // MediaDescriptor::PROP_READONLY is present only if the mediadescriptor was used at least one time
+    // that is, it exists if the file was changed from readonly mode to read/write using the GUI interface
     const_iterator pIt = find(MediaDescriptor::PROP_READONLY());
     if (pIt != end())
     {
         pIt->second >>= bReadOnly;
+        // TODO: thinking a different way: we enable the switch to r/o even though the file
+        // was requested r/w explicitly (consider the case were we want to open a file in r/w mode (e.g. switching from r/o mode to r/w mode
+        // according to GUI request) instead of returning an error
         bModeRequestedExplicitly = sal_True;
     }
 
@@ -762,10 +777,24 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s
                 // ignore exception, if reason was problem reasoned on
                 // open it in WRITEABLE mode! Then we try it READONLY
                 // later a second time.
-                // All other errors must be handled as real error an
+                // All other errors must be handled as real error and
                 // break this method.
                 if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
-                    return sal_False;
+                {
+                    //-> i126305
+                    // If the protocol is webdav, then we need to treat the stream as readonly, even if the
+                    // operation was requested as read/write explicitly (the WebDAV UCB implementation is monodirectional
+                    // read or write not both at the same time).
+                    rtl::OUString aScheme;
+                    css::uno::Reference< css::ucb::XContentIdentifier > xContId(
+                        aContent.get().is() ? aContent.get()->getIdentifier() : 0 );
+                    if ( xContId.is() )
+                        aScheme = xContId->getContentProviderScheme();
+                    if(!aScheme.equalsIgnoreAsciiCaseAscii( "http" ) && !aScheme.equalsIgnoreAsciiCaseAscii( "https" ))
+                        return sal_False;
+                    //<- i126305
+                }
+
                 xStream.clear();
                 xInputStream.clear();
             }
diff --git a/comphelper/source/misc/stillreadwriteinteraction.cxx b/comphelper/source/misc/stillreadwriteinteraction.cxx
index 6479f5e..72a24e0 100644
--- a/comphelper/source/misc/stillreadwriteinteraction.cxx
+++ b/comphelper/source/misc/stillreadwriteinteraction.cxx
@@ -37,14 +37,18 @@
 #include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
 #endif
 
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
+
 namespace comphelper{
 
     namespace css = ::com::sun::star;
 
-StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler)
+    StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
+                                                         const css::uno::Reference< css::task::XInteractionHandler >& xAuthenticationHandler)
              : m_bUsed                    (sal_False)
              , m_bHandledByMySelf         (sal_False)
              , m_bHandledByInternalHandler(sal_False)
+             , m_xAuthenticationHandler(xAuthenticationHandler)
 {
     ::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
     ::ucbhelper::InterceptedInteraction::InterceptedRequest                  aInterceptedRequest;
@@ -61,6 +65,12 @@ StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference<
     aInterceptedRequest.MatchExact = sal_False;
     lInterceptions.push_back(aInterceptedRequest);
 
+    aInterceptedRequest.Handle = HANDLE_AUTHENTICATIONREQUESTEXCEPTION;
+    aInterceptedRequest.Request <<= css::ucb::AuthenticationRequest();
+    aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
+    aInterceptedRequest.MatchExact = sal_False;
+    lInterceptions.push_back(aInterceptedRequest);
+
     setInterceptedHandler(xHandler);
     setInterceptions(lInterceptions);
 }
@@ -114,6 +124,18 @@ ucbhelper::InterceptedInteraction::EInterceptionState StillReadWriteInteraction:
             bAbort = sal_True;
         }
         break;
+    case HANDLE_AUTHENTICATIONREQUESTEXCEPTION:
+        {
+//use internal authentication dedicated handler and return
+            if (m_xAuthenticationHandler.is())
+            {
+                m_xAuthenticationHandler->handle(xRequest);
+                return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
+            }
+            else //simply abort
+                bAbort = sal_True;;
+        }
+        break;
     }
 
     // handle interaction by ourself
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index 530621d..8a6caaf 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -376,6 +376,7 @@ void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::lang::XMulti
        )
     {
         io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
+        io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= xInteractionHandler;
     }
 
     if (io_lMediaDescriptor.find(::comphelper::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
diff --git a/offapi/com/sun/star/ucb/InteractiveLockingException.idl b/offapi/com/sun/star/ucb/InteractiveLockingException.idl
index 81f428a..fe91e13 100644
--- a/offapi/com/sun/star/ucb/InteractiveLockingException.idl
+++ b/offapi/com/sun/star/ucb/InteractiveLockingException.idl
@@ -45,6 +45,12 @@ module com { module sun { module star { module ucb {
     /** The Url of the resource this exception is related to.
     */
     string Url;
+
+    //->i126305 ---------------------------------------------------------------
+    /** Extended information, some Internet Server send this to the client
+    */
+    string ExtendedInfo;
+    //<-i126305
 };
 
 //=============================================================================
diff --git a/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl b/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl
index 8f6786f..bf23e5c 100644
--- a/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl
+++ b/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl
@@ -46,6 +46,13 @@ module com { module sun { module star { module ucb {
         <false/> the lock has been obtained by another principal.
     */
     boolean SelfOwned;
+    //->i126305 -------------------------------------------------------------------------
+    /** The owner of the lock.
+     *
+     *  Used for WevDAV interface
+    */
+    string Owner;
+    //<-i126305
 };
 
 //=============================================================================
diff --git a/offapi/com/sun/star/ucb/makefile.mk b/offapi/com/sun/star/ucb/makefile.mk
index 26c67d2..b0c6116 100644
--- a/offapi/com/sun/star/ucb/makefile.mk
+++ b/offapi/com/sun/star/ucb/makefile.mk
@@ -117,6 +117,7 @@ IDLFILES=\
     InteractiveFileIOException.idl\
     InteractiveIOException.idl\
     InteractiveLockingException.idl\
+    InteractiveLockingLockNotAvailableException.idl\
     InteractiveLockingLockExpiredException.idl\
     InteractiveLockingLockedException.idl\
     InteractiveLockingNotLockedException.idl\
diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx
index aee3e45..5ba285c 100644
--- a/sfx2/inc/sfx2/docfile.hxx
+++ b/sfx2/inc/sfx2/docfile.hxx
@@ -140,6 +140,8 @@ public:
     void                UseInteractionHandler( sal_Bool );
     ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
                         GetInteractionHandler();
+    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
+                        GetAuthenticationInteractionHandler();
 
     void setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,sal_Bool bIsReadOnly )
     { m_xInputStreamToLoadFrom = xInputStream; m_bIsReadOnly = bIsReadOnly; }
@@ -211,6 +213,9 @@ public:
     sal_Bool            Commit();
     sal_Bool            IsStorage();
 
+    //->i126305
+    sal_Int8            ShowLockedWebDAVDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading );
+    //<-i126305
     sal_Int8            ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
     sal_Bool            LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
     void                UnlockFile( sal_Bool bReleaseLockStream );
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 9350316..f246f17 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2710,7 +2710,7 @@ static int impl_isFolder( const OUString& rPath )
     {
     }
 
-    ::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler );
+    ::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler , uno::Reference< task::XInteractionHandler >());
 
     try
     {
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index c15dc4b..6149311 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -50,6 +50,10 @@
 #include <com/sun/star/ucb/XContentProvider.hpp>
 #include <com/sun/star/ucb/XProgressHandler.hpp>
 #include <com/sun/star/ucb/XCommandInfo.hpp>
+#include <com/sun/star/ucb/Lock.hpp>
+#include <com/sun/star/ucb/InteractiveLockingLockNotAvailableException.hpp>
+#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
 #include <com/sun/star/util/XArchiver.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
@@ -309,6 +313,8 @@ public:
 
     ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xInteraction;
 
+    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xCredentialInteraction;
+
     sal_Bool        m_bRemoveBackup;
     ::rtl::OUString m_aBackupURL;
 
@@ -486,7 +492,11 @@ void SfxMedium::CheckFileDate( const util::DateTime& aInitDate )
 //------------------------------------------------------------------
 sal_Bool SfxMedium::DocNeedsFileDateCheck()
 {
-    return ( !IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
+    ::rtl::OUString aScheme =  INetURLObject::GetScheme( GetURLObject().GetProtocol() );
+    sal_Bool bIsWebDAV = ( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+                                  aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) );
+    return ( !IsReadOnly() &&
+             ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) || bIsWebDAV ) );
 }
 
 //------------------------------------------------------------------
@@ -910,6 +920,86 @@ void SfxMedium::SetEncryptionDataToStorage_Impl()
     }
 }
 
+//->i126305 -----------------------------------------------------------------
+//for the time being the aData holds a single OUString, the owner of the lock
+sal_Int8 SfxMedium::ShowLockedWebDAVDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading )
+{
+    sal_Int8 nResult = LOCK_UI_NOLOCK;
+
+    // show the interaction regarding the document opening
+    uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
+
+    if ( ::svt::DocumentLockFile::IsInteractionAllowed() && xHandler.is() && bIsLoading )
+    {
+        ::rtl::OUString aDocumentURL = GetURLObject().GetLastName();
+        ::rtl::OUString aInfo;
+        ::rtl::Reference< ::ucbhelper::InteractionRequest > xInteractionRequestImpl;
+
+        aInfo = aData[0];
+        if(aData.getLength() > 1 && aData[1].getLength() > 0)
+        {
+            aInfo += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\n" ) );
+            aInfo += aData[1];
+        }
+
+        if ( bIsLoading )
+        {
+            xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
+                uno::makeAny( document::LockedDocumentRequest( ::rtl::OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
+        }
+        else
+        {
+            xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
+                uno::makeAny( document::LockedOnSavingRequest( ::rtl::OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
+        }
+
+        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
+        aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() );
+        aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() );
+        aContinuations[2] = new ::ucbhelper::InteractionDisapprove( xInteractionRequestImpl.get() );
+        xInteractionRequestImpl->setContinuations( aContinuations );
+
+        xHandler->handle( xInteractionRequestImpl.get() );
+
+        ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xInteractionRequestImpl->getSelection();
+        if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() )
+        {
+            SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+        }
+        else if ( uno::Reference< task::XInteractionDisapprove >( xSelected.get(), uno::UNO_QUERY ).is() )
+        {
+            // alien lock on loading, user has selected to edit a copy of document
+            // TODO/LATER: alien lock on saving, user has selected to do SaveAs to different location
+            // means that a copy of the document should be opened
+            GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
+        }
+        else // if ( XSelected == aContinuations[1] )
+        {
+            // alien lock on loading, user has selected to retry saving
+            // TODO/LATER: alien lock on saving, user has selected to retry saving
+            if ( bIsLoading )
+                GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+            else
+                nResult = LOCK_UI_TRY;
+        }
+    }
+    else
+    {
+        if ( bIsLoading )
+        {
+            // if no interaction handler is provided the default answer is open readonly
+            // that usually happens in case the document is loaded per API
+            // so the document must be opened readonly for backward compatibility
+            GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+        }
+        else
+            SetError( ERRCODE_IO_ACCESSDENIED, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+    }
+
+    return nResult;
+}
+//<-i126305
+
 //------------------------------------------------------------------
 sal_Int8 SfxMedium::ShowLockedDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock )
 {
@@ -1216,8 +1306,112 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
             }
             else
             {
-                // this is no file URL, check whether the file is readonly
-                bResult = !bContentReadonly;
+                //->i126305
+                // check if path scheme is http:// or https://
+                ::rtl::OUString aScheme =  INetURLObject::GetScheme(GetURLObject().GetProtocol());
+                if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+                    aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
+                {
+                    //so, this is webdav stuff...
+                    Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler();
+                    if ( !bResult )
+                    {
+                        // no read-write access is necessary on loading if the document is explicitly opened as copy
+                        SFX_ITEMSET_ARG( GetItemSet(), pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False);
+                        bResult = ( bLoading && pTemplateItem && pTemplateItem->GetValue() );
+                    }
+
+                    if ( !bResult && !IsReadOnly() )
+                    {
+
+                        // in case of storing the document should request the output before locking
+                        if ( bLoading )
+                        {
+                            // let the stream be opened to check the system file locking
+                            GetMedium_Impl();
+                        }
+
+                        sal_Int8 bUIStatus = LOCK_UI_NOLOCK;
+                        do
+                        {
+                            if( !bResult )
+                            {
+                                Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
+                                uno::Reference< task::XInteractionHandler > xCHandler = GetAuthenticationInteractionHandler();
+                                xComEnv = new ::ucbhelper::CommandEnvironment( xCHandler,
+                                                                               Reference< ::com::sun::star::ucb::XProgressHandler >() );
+                                ::ucbhelper::Content aContentToLock( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv);
+                                rtl::OUString   aOwner;
+                                try {
+                                    aContentToLock.lock();
+                                    bResult = sal_True;
+                                }
+                                catch( ucb::InteractiveLockingLockNotAvailableException )
+                                {
+                                    // signalled when the lock can not be done because the method is known but not allowed on the resource
+                                    // the resource is still available, can be worked upon, at your risk
+                                    // so ask user whether he wants to open the document without any locking
+                                    uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
+
+                                    if ( xHandler.is() )
+                                    {
+                                        ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl
+                                            = new ::ucbhelper::InteractionRequest( uno::makeAny( document::LockFileIgnoreRequest() ) );
+
+                                        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
+                                        aContinuations[0] = new ::ucbhelper::InteractionAbort( xIgnoreRequestImpl.get() );
+                                        aContinuations[1] = new ::ucbhelper::InteractionApprove( xIgnoreRequestImpl.get() );
+                                        xIgnoreRequestImpl->setContinuations( aContinuations );
+
+                                        xHandler->handle( xIgnoreRequestImpl.get() );
+
+                                        ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
+                                        bResult = (  uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is() );
+                                    }
+                                }
+                                catch( ucb::InteractiveLockingLockedException& e )
+                                {
+                                    // here get the lock owner currently active
+                                    aOwner = e.Owner;
+                                    rtl::OUString aExtendedError;
+
+                                    if ( !bResult && !bNoUI )
+                                    {
+                                        uno::Sequence< ::rtl::OUString > aData( 2 );
+
+                                        aData[0] = aOwner;
+                                        aData[1] = aExtendedError;
+                                        bUIStatus = ShowLockedWebDAVDocumentDialog( aData, bLoading );
+                                        if ( bUIStatus == LOCK_UI_SUCCEEDED )
+                                        {
+                                            // take the ownership over the lock file, accept the current lock (already there)
+                                            bResult = sal_True;
+                                        }
+                                    }
+                                }
+                            }
+                        } while( !bResult && bUIStatus == LOCK_UI_TRY );
+                    }
+
+                    if ( !bResult && GetError() == ERRCODE_NONE )
+                    {
+                        // the error should be set in case it is storing process
+                        // or the document has been opened for editing explicitly
+                        SFX_ITEMSET_ARG( pSet, pReadOnlyItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
+                        if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) )
+                            SetError( ERRCODE_IO_ACCESSDENIED, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+                        else
+                            GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+                    }
+
+                    pImp->m_bLocked = bResult;
+                }
+                else
+                {
+                    // this is neither file URL nor WebDAV, check whether the file is readonly
+                    bResult = !bContentReadonly;
+                }
+                //<-i126305
             }
         }
     }
@@ -2309,7 +2503,17 @@ void SfxMedium::GetMedium_Impl()
                         aMedium.addInputStreamOwnLock();
                     }
                     else
+                    {
+                        //add acheck for protocol, to see if it's http or https then add
+                        //the interecation handler to be used by the authentication dialog
+                        ::rtl::OUString aScheme =  INetURLObject::GetScheme(GetURLObject().GetProtocol());
+                        if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+                            aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
+                        {
+                            aMedium[comphelper::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= GetAuthenticationInteractionHandler();
+                        }
                         aMedium.addInputStream();
+                    }
 
                     // the ReadOnly property set in aMedium is ignored
                     // the check is done in LockOrigFileOnDemand() for file and non-file URLs
@@ -2531,6 +2735,36 @@ void SfxMedium::UseInteractionHandler( sal_Bool bUse )
 //------------------------------------------------------------------
 
 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
+SfxMedium::GetAuthenticationInteractionHandler()
+{
+    // search a possible existing handler inside cached item set
+    if ( pSet )
+    {
+        ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xHandler;
+        SFX_ITEMSET_ARG( pSet, pHandler, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False);
+        if ( pHandler && (pHandler->GetValue() >>= xHandler) && xHandler.is() )
+            return xHandler;
+    }
+
+    // otherwhise return cached default handler ... if it exist.
+    if ( pImp->xCredentialInteraction.is() )
+        return pImp->xCredentialInteraction;
+
+    // create default handler and cache it!
+    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+    if ( xFactory.is() )
+    {
+        pImp->xCredentialInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >(
+            xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
+        return pImp->xCredentialInteraction;
+    }
+
+    return ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >();
+}
+
+//------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
 SfxMedium::GetInteractionHandler()
 {
     // if interaction isn't allowed explicitly ... return empty reference!
@@ -2558,7 +2792,8 @@ SfxMedium::GetInteractionHandler()
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
     if ( xFactory.is() )
     {
-        pImp->xInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >( xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
+        pImp->xInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >(
+            xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
         return pImp->xInteraction;
     }
 
@@ -2708,38 +2943,74 @@ void SfxMedium::CloseAndRelease()
 
 void SfxMedium::UnlockFile( sal_Bool bReleaseLockStream )
 {
-    if ( pImp->m_xLockingStream.is() )
+    //->i126305
+    //check if the file is local
+    if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
     {
-        if ( bReleaseLockStream )
+    //<-i126305
+        if ( pImp->m_xLockingStream.is() )
+        {
+            if ( bReleaseLockStream )
+            {
+                try
+                {
+                    uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
+                    uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
+                    if ( xInStream.is() )
+                        xInStream->closeInput();
+                    if ( xOutStream.is() )
+                        xOutStream->closeOutput();
+                }
+                catch( uno::Exception& )
+                {}
+            }
+
+            pImp->m_xLockingStream = uno::Reference< io::XStream >();
+        }
+
+        if ( pImp->m_bLocked )
         {
             try
             {
-                uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
-                uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
-                if ( xInStream.is() )
-                    xInStream->closeInput();
-                if ( xOutStream.is() )
-                    xOutStream->closeOutput();
+                pImp->m_bLocked = sal_False;
+                ::svt::DocumentLockFile aLockFile( aLogicName );
+                // TODO/LATER: A warning could be shown in case the file is not the own one
+                aLockFile.RemoveFile();
             }
             catch( uno::Exception& )
             {}
         }
-
-        pImp->m_xLockingStream = uno::Reference< io::XStream >();
+    //->i126305
     }
-
-    if ( pImp->m_bLocked )
+    else
     {
-        try
+        //not local, check if webdav
+        ::rtl::OUString aScheme =  INetURLObject::GetScheme(GetURLObject().GetProtocol());
+        if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+            aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
         {
-            pImp->m_bLocked = sal_False;
-            ::svt::DocumentLockFile aLockFile( aLogicName );
-            // TODO/LATER: A warning could be shown in case the file is not the own one
-            aLockFile.RemoveFile();
+            if ( pImp->m_bLocked )
+            {
+                // an interaction handler should be used for authentication
+                try {
+                    Reference< ::com::sun::star::task::XInteractionHandler > xHandler = GetAuthenticationInteractionHandler();
+                    Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
+                    xComEnv = new ::ucbhelper::CommandEnvironment( xHandler,
+                                                                   Reference< ::com::sun::star::ucb::XProgressHandler >() );
+                    ::ucbhelper::Content aContentToUnlock( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv);
+                    pImp->m_bLocked = sal_False;
+                    aContentToUnlock.unlock();
+                }
+                catch (ucb::InteractiveNetworkReadException& e)
+                {
+                    //signalled when this resource can not be unlocked, for whatever reason
+                }
+                catch( uno::Exception& )
+                {}
+            }
         }
-        catch( uno::Exception& )
-        {}
     }
+    //<-i126305
 }
 
 void SfxMedium::CloseAndReleaseStreams_Impl()
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 1bce20a..a615337 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -303,7 +303,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
     SfxFrame *pParent = GetFrame().GetParentFrame();
     if ( rReq.GetSlot() == SID_RELOAD )
     {
-        // Bei CTRL-Reload den aktiven Frame reloaden
+        // With CTRL-Reload reload the active frame
         SfxViewFrame* pActFrame = this;
         while ( pActFrame )
             pActFrame = pActFrame->GetActiveChildFrame_Impl();
@@ -318,8 +318,8 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
             }
         }
 
-        // Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames
-        // gemacht werden soll
+        // If only reloading of the graphs or more child frames
+        // is needed
         SfxFrame& rFrame = GetFrame();
         if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
         {
@@ -338,16 +338,16 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                 pChild = pNext;
             }
 
-            // Der TopLevel-Frame selbst het keine Graphiken!
+            // The TopLevel frame itself had no graphics
             if ( bReloadAvailable )
                 return;
         }
     }
     else
     {
-        // Bei CTRL-Edit den TopFrame bearbeiten
+        // With CTRL-Edit edit the top frame
         sal_uInt16 nModifier = rReq.GetModifier();
-
+        //KEY_MOD1 is the Ctrl modifier key
         if ( ( nModifier & KEY_MOD1 ) && pParent )
         {
             SfxViewFrame *pTop = GetTopViewFrame();
@@ -364,9 +364,8 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
             if ( GetFrame().HasComponent() )
                 break;
 
-            // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
-            // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
-            // trotzdem nicht geht!
+            // Because of double functioning of the toolbox button (with/without Ctrl)
+            // it's possible that the slot is enabled, but Ctrl-click is not.
             if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ))
                 break;
 
@@ -446,11 +445,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                     return;
             }
 
-            // Parameter auswerten
+            // Evaluate parameters
             // sal_Bool bReload = sal_True;
             if ( rReq.IsAPI() )
             {
-                // per API steuern ob r/w oder r/o
+                // Control through API if r/w or r/o
                 SFX_REQUEST_ARG(rReq, pEditItem, SfxBoolItem, SID_EDITDOC, sal_False);
                 if ( pEditItem )
                     nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
@@ -466,13 +465,27 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
 
             INetURLObject aMedObj( pMed->GetName() );
 
-            // the logic below is following, if the document seems not to need to be reloaded and the physical name is different
-            // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required
-            if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE &&
-                    aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
-                    !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) ))
-                  || pMed->IsRemote() ) )
-               || pVersionItem )
+            // -> i126305
+            // the logic below is following:
+            // if the document seems not to need to be reloaded
+            //     and the physical name is different to the logical one,
+            // then on file system it can be checked that the copy is still newer than the original and no document reload is required.
+            // some semplification to enhance readability of the 'if' expression
+            //
+            // on the 'http/https' protocol case, the bool bPhysObjIsYounger relies upon the getlastmodified Property of a WebDAV resource.
+            // Said property should be implemented, but sometimes it's not. This happens on some small webdav servers, where it's not
+            // implemented. On this case the reload will not work properly.
+            // Details at this link: http://tools.ietf.org/html/rfc4918#section-15, section 15.7
+            // TODO: add an indication to the user? Difficult to implement I think.
+            sal_Bool bPhysObjIsYounger = ::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) );
+            sal_Bool bIsHttpOrHttps = (aMedObj.GetProtocol() == INET_PROT_HTTP || aMedObj.GetProtocol() == INET_PROT_HTTPS);
+            if ( ( !bNeedsReload && ( ( aMedObj.GetProtocol() == INET_PROT_FILE &&
+                                        aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
+                                        !bPhysObjIsYounger )
+                                      || ( bIsHttpOrHttps && !bPhysObjIsYounger )
+                                      || ( pMed->IsRemote() && !bIsHttpOrHttps ) ) )
+                 || pVersionItem )
+            // <- i126305
             {
                 sal_Bool bOK = sal_False;
                 if ( !pVersionItem )
@@ -514,13 +527,15 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                         pSh->DoSaveCompleted( pMed );
                     }
 
-                    // r/o-Doc kann nicht in Editmode geschaltet werden?
+                    // r/o-Doc can not be switched to edit mode?
                     rReq.Done( sal_False );
 
                     if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
                     {
-                        // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen
+                        // ::com::sun::star::sdbcx::User ask to open as template (a copy of the document)
                         QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
+                        // this is the querybox that is opened when the file is asked to move from r/o to edit using the button
+                        // on the toolbar
                         if ( RET_YES == aBox.Execute() )
                         {
                             SfxApplication* pApp = SFX_APP();
@@ -572,9 +587,8 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
 
         case SID_RELOAD:
         {
-            // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
-            // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
-            // trotzdem nicht geht!
+            // Because of double functioning of the toolbox button (with/without Ctrl)
+            // it's possible that the slot is enabled, but Ctrl-click is not.
             if ( !pSh || !pSh->CanReload_Impl() )
                 break;
             SfxApplication* pApp = SFX_APP();
@@ -596,12 +610,12 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
             pImp->bReloading = sal_True;
             SFX_REQUEST_ARG(rReq, pURLItem, SfxStringItem,
                             SID_FILE_NAME, sal_False);
-            // editierbar "offnen?
+            // open to edit?
             sal_Bool bForEdit = !pSh->IsReadOnly();
             if ( rReq.GetSlot() == SID_EDITDOC )
                 bForEdit = !bForEdit;
 
-            // ggf. beim User nachfragen
+            // if necessary ask the user
             sal_Bool bDo = ( GetViewShell()->PrepareClose() != sal_False );
             SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
             if ( bDo && GetFrame().DocIsModified_Impl() &&
@@ -615,15 +629,15 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
             {
                 SfxMedium *pMedium = xOldObj->GetMedium();
 
-                // Frameset abziehen, bevor FramesetView evtl. verschwindet
+                //Pull frameset before FramesetView possibly disappear
                 String aURL = pURLItem ? pURLItem->GetValue() :
                                 pMedium->GetName();
 
                 sal_Bool bHandsOff =
                     ( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
 
-                // bestehende SfxMDIFrames f"ur dieses Doc leeren
-                // eigenes Format oder R/O jetzt editierbar "offnen?
+                // empty existing SfxMDIFrames of this Doc
+                // own format or R/O is now open editable?
                 SfxObjectShellLock xNewObj;
 
                 // collect the views of the document
@@ -704,7 +718,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
 
                 xOldObj->CancelTransfers();
 
-                // eigentliches Reload
+                //actual reload
                 //pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) );
 
                 if ( pSilentItem && pSilentItem->GetValue() )
@@ -727,8 +741,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                     pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
 
                 xOldObj->SetModified( sal_False );
-                // Altes Dok nicht cachen! Gilt nicht, wenn anderes
-                // Doc geladen wird.
+                // Old Doc not cached! Does not apply if another Doc is loaded.
 
                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
@@ -760,6 +773,26 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                 }
                 catch ( uno::Exception& )
                 {
+                    //->i126305 OBSERVATION
+                    // When this exception is thrown the r/o refresh of a file locked by another user
+                    // is not completed.
+                    // Code flow arrives here with a 'com.sun.star.task.ErrorCodeIOException'.
+                    // It's thrown at around line 1970 of main/sfx2/source/doc/sfxbasemodel.cxx,
+                    // in method 'SfxBaseModel::load'.
+                    // Because of this exception, the document is not reloaded when it should be.
+                    // The error generating the exception is 1287, or ERRCODE_IO_ACCESSDENIED.
+                    // It seems that the reason for this is the way the property PROP_READONLY seems used
+                    // in MediaDescriptor: both as property of the media and a request from GUI.
+                    // See main/comphelper/source/misc/mediadescriptor.cxx around line 755, where the behavior
+                    // leading to the error originates in the code flow.
+                    // This problem doesn't arise in WebDAV, since the stream is monodirectional (read or write) in UCB implementation.
+                    //<-i126305
+                    //->i126305 WORKAROUND
+                    // Code flow needs to reset the reloading, since it will no longer take part in the following code.
+                    // This specific flag, if not reset, will break the code flow on the next call of this method,
+                    // when it appears that the toolbar button stops functioning.
+                    pImp->bReloading = sal_False;
+                    //<-i126305
                     xNewObj->DoClose();
                     xNewObj = 0;
                 }
@@ -857,14 +890,14 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                     SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
                 }
 
-                // als erledigt recorden
+                // register as done
                 rReq.Done( sal_True );
                 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
                 return;
             }
             else
             {
-                // als nicht erledigt recorden
+                // register as not done
                 rReq.Done();
                 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_False));
                 pImp->bReloading = sal_False;
diff --git a/ucb/source/ucp/webdav/DAVException.hxx b/ucb/source/ucp/webdav/DAVException.hxx
index 63f7e76..d7481cd 100644
--- a/ucb/source/ucp/webdav/DAVException.hxx
+++ b/ucb/source/ucp/webdav/DAVException.hxx
@@ -138,18 +138,27 @@ class DAVException
     private:
         ExceptionCode   mExceptionCode;
         rtl::OUString   mData;
+    //owner of the lock in case of DAV_LOCKED
+        rtl::OUString   mOwner;
+    //extendend error information, if the server has a specific header
+    //see in SerfRequestProcessor::handleSerfResponse for detail on how this is obtained
+        rtl::OUString   mExtendedError;
         sal_uInt16      mStatusCode;
 
     public:
          DAVException( ExceptionCode inExceptionCode )
              : mExceptionCode( inExceptionCode )
              , mData()
+             , mOwner()
+             , mExtendedError()
              , mStatusCode( SC_NONE )
          {};
          DAVException( ExceptionCode inExceptionCode,
                        const rtl::OUString & rData )
              : mExceptionCode( inExceptionCode )
              , mData( rData )
+             , mOwner()
+             , mExtendedError()
              , mStatusCode( SC_NONE )
          {};
          DAVException( ExceptionCode inExceptionCode,
@@ -157,13 +166,29 @@ class DAVException
                        sal_uInt16 nStatusCode )
             : mExceptionCode( inExceptionCode )
             , mData( rData )
+            , mOwner()
+            , mExtendedError()
+            , mStatusCode( nStatusCode )
+         {};
+         DAVException( ExceptionCode inExceptionCode,
+                       const rtl::OUString & rData,
+                       const rtl::OUString & rExtendedError,
+                       sal_uInt16 nStatusCode = SC_NONE )
+            : mExceptionCode( inExceptionCode )
+            , mData( rData )
+            , mOwner()
+            , mExtendedError( rExtendedError )
             , mStatusCode( nStatusCode )
          {};
         ~DAVException( ) {};
 
     const ExceptionCode & getError() const { return mExceptionCode; }
     const rtl::OUString & getData() const  { return mData; }
+    const rtl::OUString & getExtendedError() const { return  mExtendedError; }
     sal_uInt16 getStatus() const { return mStatusCode; }
+    const rtl::OUString & getOwner() const { return mOwner; }
+    void setOwner(const rtl::OUString & rOwner) { mOwner = rOwner; }
+
 };
 
 } // namespace http_dav_ucp
diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.hxx b/ucb/source/ucp/webdav/DAVResourceAccess.hxx
index 11b2207..e1078f7 100644
--- a/ucb/source/ucp/webdav/DAVResourceAccess.hxx
+++ b/ucb/source/ucp/webdav/DAVResourceAccess.hxx
@@ -203,7 +203,7 @@ public:
     void
     LOCK( com::sun::star::ucb::Lock & inLock,
           const com::sun::star::uno::Reference<
-              com::sun::star::ucb::XCommandEnvironment > & xEnv )
+          com::sun::star::ucb::XCommandEnvironment > & xEnv )
         throw( DAVException );
 
 #if 0 // currently not used, but please don't remove code
diff --git a/ucb/source/ucp/webdav/DAVTypes.hxx b/ucb/source/ucp/webdav/DAVTypes.hxx
index 611861c..2af5fd5 100644
--- a/ucb/source/ucp/webdav/DAVTypes.hxx
+++ b/ucb/source/ucp/webdav/DAVTypes.hxx
@@ -76,6 +76,8 @@ struct ProppatchValue
     : operation( o ), name( n ), value( v ) {}
 };
 
+enum LockScope { EXCLUSIVE = 0, SHARED = 1 };
+
 } // namespace http_dav_ucp
 
 #endif // _DAVTYPES_HXX_
diff --git a/ucb/source/ucp/webdav/SerfCallbacks.cxx b/ucb/source/ucp/webdav/SerfCallbacks.cxx
index 680bf81..e32d2c7 100644
--- a/ucb/source/ucp/webdav/SerfCallbacks.cxx
+++ b/ucb/source/ucp/webdav/SerfCallbacks.cxx
@@ -36,6 +36,7 @@ extern "C" apr_status_t Serf_ConnectSetup( apr_socket_t *skt,
                                            apr_pool_t *pool )
 {
     SerfSession* pSerfSession = static_cast< SerfSession* >( setup_baton );
+    OSL_TRACE("Serf_ConnectSetup");
     return pSerfSession->setupSerfConnection( skt,
                                               read_bkt,
                                               write_bkt,
@@ -52,6 +53,7 @@ extern "C" apr_status_t Serf_Credentials( char **username,
                                           apr_pool_t *pool )
 {
     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( baton );
+    OSL_TRACE("Serf_Credential");
     return pReqProc->provideSerfCredentials( username,
                                              password,
                                              request,
@@ -68,6 +70,7 @@ extern "C" apr_status_t Serf_CertificateChainValidation(
     const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded,
     apr_size_t nCertificateChainLength)
 {
+    OSL_TRACE("Serf_CertificateChainValidation");
     return static_cast<SerfSession*>(pSerfSession)
         ->verifySerfCertificateChain(nFailures, pCertificateChainBase64Encoded, nCertificateChainLength);
 }
@@ -82,6 +85,7 @@ extern "C" apr_status_t Serf_SetupRequest( serf_request_t *request,
                                            apr_pool_t * pool )
 {
     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( setup_baton );
+    OSL_TRACE("Serf_SetupRequest");
     return pReqProc->setupSerfRequest( request,
                                        req_bkt,
                                        acceptor,
@@ -97,6 +101,7 @@ extern "C" serf_bucket_t* Serf_AcceptResponse( serf_request_t *request,
                                                apr_pool_t *pool )
 {
     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( acceptor_baton );
+    OSL_TRACE("Serf_AcceptResponse");
     return pReqProc->acceptSerfResponse( request,
                                          stream,
                                          pool );
@@ -108,6 +113,7 @@ extern "C" apr_status_t Serf_HandleResponse( serf_request_t *request,
                                              apr_pool_t *pool )
 {
     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( handler_baton );
+    OSL_TRACE("Serf_HandleResponse");
     return pReqProc->handleSerfResponse( request,
                                          response,
                                          pool );
diff --git a/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx
index 4cb0796..098e459 100644
--- a/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx
@@ -32,10 +32,12 @@ namespace http_dav_ucp
 SerfCopyReqProcImpl::SerfCopyReqProcImpl( const char* inSourcePath,
                                           const DAVRequestHeaders& inRequestHeaders,
                                           const char* inDestinationPath,
-                                          const bool inOverwrite )
+                                          const bool inOverwrite,
+                                          const char* inLockToken )
     : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
     , mDestPathStr( inDestinationPath )
     , mbOverwrite( inOverwrite )
+    , mpLockToken( inLockToken )
 {
 }
 
@@ -67,6 +69,10 @@ serf_bucket_t * SerfCopyReqProcImpl::createSerfRequestBucket( serf_request_t * i
     {
         serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
     }
+    if(mpLockToken)
+    {
+        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+    }
 
     return req_bkt;
 }
diff --git a/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx
index 7ba4c79..ee97a55 100644
--- a/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx
@@ -33,7 +33,8 @@ public:
     SerfCopyReqProcImpl( const char* inSourcePath,
                          const DAVRequestHeaders& inRequestHeaders,
                          const char* inDestinationPath,
-                         const bool inOverwrite );
+                         const bool inOverwrite,
+                         const char*  inLockToken );
 
     virtual ~SerfCopyReqProcImpl();
 
@@ -50,6 +51,7 @@ protected:
 private:
     const char* mDestPathStr;
     const bool mbOverwrite;
+    const char* mpLockToken;
 };
 
 } // namespace http_dav_ucp
diff --git a/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx
index 54b7190..359b60e 100644
--- a/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx
@@ -30,8 +30,10 @@ namespace http_dav_ucp
 {
 
 SerfDeleteReqProcImpl::SerfDeleteReqProcImpl( const char* inPath,
-                                              const DAVRequestHeaders& inRequestHeaders )
+                                              const DAVRequestHeaders& inRequestHeaders,
+                                              const char* inLockToken )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
+    , mpLockToken( inLockToken )
 {
 }
 
@@ -52,6 +54,11 @@ serf_bucket_t * SerfDeleteReqProcImpl::createSerfRequestBucket( serf_request_t *
     serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
     // general header fields provided by caller
     setRequestHeaders( hdrs_bkt );
+    // specific header field
+    if(mpLockToken)
+    {
+        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+    }
 
     return req_bkt;
 }
diff --git a/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx
index ca6fcf8..ec97b8a 100644
--- a/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx
@@ -29,9 +29,12 @@ namespace http_dav_ucp
 
 class SerfDeleteReqProcImpl : public SerfRequestProcessorImpl
 {
+private:
+    const char* mpLockToken;
 public:
     SerfDeleteReqProcImpl( const char* inPath,
-                           const DAVRequestHeaders& inRequestHeaders );
+                           const DAVRequestHeaders& inRequestHeaders,
+                           const char* inLockRToken );
 
     virtual ~SerfDeleteReqProcImpl();
 
diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index cf66417..9f18943 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -24,11 +24,10 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_ucb.hxx"
 
-#include <ne_locks.h>
-#include <ne_uri.h>
 #include <rtl/ustring.hxx>
 #include <osl/time.h>
 #include <osl/thread.hxx>
+#include "SerfTypes.hxx"
 #include "SerfSession.hxx"
 #include "SerfLockStore.hxx"
 
@@ -58,7 +57,7 @@ protected:
 // -------------------------------------------------------------------
 void TickerThread::run()
 {
-    OSL_TRACE( "TickerThread: start." );
+    OSL_TRACE( "TickerThread::run: start." );
 
     // we have to go through the loop more often to be able to finish ~quickly
     const int nNth = 25;
@@ -83,10 +82,8 @@ void TickerThread::run()
 
 // -------------------------------------------------------------------
 SerfLockStore::SerfLockStore()
-    : m_pSerfLockStore( ne_lockstore_create() ),
-      m_pTickerThread( 0 )
+    : m_pTickerThread( 0 )
 {
-    OSL_ENSURE( m_pSerfLockStore, "Unable to create neon lock store!" );
 }
 
 // -------------------------------------------------------------------
@@ -103,15 +100,15 @@ SerfLockStore::~SerfLockStore()
     while ( it != end )
     {
         SerfLock * pLock = (*it).first;
-        (*it).second.xSession->UNLOCK( pLock );
-
-        ne_lockstore_remove( m_pSerfLockStore, pLock );
-        ne_lock_destroy( pLock );
-
+        try
+        {
+            (*it).second.xSession->UNLOCK( pLock );
+            (*it).second.xSession->release();
+        }
+        catch (DAVException & )
+        {}
         ++it;
     }
-
-    ne_lockstore_destroy( m_pSerfLockStore );
 }
 
 // -------------------------------------------------------------------
@@ -140,23 +137,34 @@ void SerfLockStore::stopTicker()
     }
 }
 
+#if 0       //not currently used
 // -------------------------------------------------------------------
-void SerfLockStore::registerSession( HttpSession * pHttpSession )
+void SerfLockStore::registerSession( SerfSession /* aSession */ )
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    ne_lockstore_register( m_pSerfLockStore, pHttpSession );
 }
+#endif
 
 // -------------------------------------------------------------------
-SerfLock * SerfLockStore::findByUri( rtl::OUString const & rUri )
+SerfLock * SerfLockStore::findByUri( rtl::OUString const & rUri)
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    ne_uri aUri;
-    ne_uri_parse( rtl::OUStringToOString(
-        rUri, RTL_TEXTENCODING_UTF8 ).getStr(), &aUri );
-    return ne_lockstore_findbyuri( m_pSerfLockStore, &aUri );
+    LockInfoMap::const_iterator it( m_aLockInfoMap.begin() );
+    const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
+
+    while ( it != end )
+    {
+        SerfLock * pLock = (*it).first;
+        if( pLock->getResourceUri().equals( rUri ) )
+        {
+            return pLock;
+        }
+        ++it;
+    }
+
+    return static_cast<SerfLock*>(0);
 }
 
 // -------------------------------------------------------------------
@@ -166,13 +174,24 @@ void SerfLockStore::addLock( SerfLock * pLock,
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    ne_lockstore_add( m_pSerfLockStore, pLock );
     m_aLockInfoMap[ pLock ]
         = LockInfo( xSession, nLastChanceToSendRefreshRequest );
-
+    //acquire this session, needed to manage the lock refresh
+    xSession->acquire();
+
+#if OSL_DEBUG_LEVEL > 0
+    rtl::OUString   aOwner;
+    pLock->getLock().Owner >>= aOwner;
+    rtl::OUString   aToken;
+    aToken = pLock->getLock().LockTokens[0];
+    OSL_TRACE("SerfLockStore::addLock: new lock added aOwner '%s', token '%s'",
+              rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr(),
+              rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
+#endif
     startTicker();
 }
 
+#if 0       //not currently used
 // -------------------------------------------------------------------
 void SerfLockStore::updateLock( SerfLock * pLock,
                                 sal_Int32 nLastChanceToSendRefreshRequest )
@@ -189,17 +208,23 @@ void SerfLockStore::updateLock( SerfLock * pLock,
             = nLastChanceToSendRefreshRequest;
     }
 }
+#endif
 
 // -------------------------------------------------------------------
 void SerfLockStore::removeLock( SerfLock * pLock )
 {
     osl::MutexGuard aGuard( m_aMutex );
 
-    m_aLockInfoMap.erase( pLock );
-    ne_lockstore_remove( m_pSerfLockStore, pLock );
-
-    if ( m_aLockInfoMap.size() == 0 )
-        stopTicker();
+    LockInfoMap::iterator it( m_aLockInfoMap.find( pLock ) );
+    if(it != m_aLockInfoMap.end())
+    {
+        LockInfo & rInfo = (*it).second;
+        rInfo.xSession->release();
+        m_aLockInfoMap.erase( pLock );
+        //the caller should deallocate SerfLock class after the call!
+        if ( m_aLockInfoMap.size() == 0 )
+            stopTicker();
+    }
 }
 
 // -------------------------------------------------------------------
@@ -221,18 +246,39 @@ void SerfLockStore::refreshLocks()
                      <= sal_Int32( t1.Seconds ) )
             {
                 // refresh the lock.
+#if OSL_DEBUG_LEVEL > 0
+                ucb::Lock aLock = (*it).first->getLock();
+                rtl::OUString   aOwner;
+                aLock.Owner >>= aOwner;
+                rtl::OUString   aToken;
+                aToken = aLock.LockTokens[0];
+                OSL_TRACE( "SerfLockStore::refreshLocks: refresh started for lock: aOwner '%s', token '%s'",
+                    rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr(),
+                    rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
+#endif
                 sal_Int32 nlastChanceToSendRefreshRequest = -1;
-                if ( rInfo.xSession->LOCK(
-                         (*it).first,
-                         /* out param */ nlastChanceToSendRefreshRequest ) )
+                try
                 {
+                    rInfo.xSession->LOCK( (*it).first,
+                                          /* out param */ nlastChanceToSendRefreshRequest );
                     rInfo.nLastChanceToSendRefreshRequest
                         = nlastChanceToSendRefreshRequest;
+#if OSL_DEBUG_LEVEL > 0
+                    OSL_TRACE( "Lock '%s' successfully refreshed." ,
+                        rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
+#endif
                 }
-                else
+                catch ( DAVException & e )
                 {
                     // refresh failed. stop auto-refresh.
+                    // TODO i126305 discuss:
+                    // probably not a good idea to stop the refresh?
+                    // may be just ignore and go on, it's possible the net is temporary down?
                     rInfo.nLastChanceToSendRefreshRequest = -1;
+#if OSL_DEBUG_LEVEL > 0
+                    OSL_TRACE( "SerfLockStore::refreshLocks: Lock '%s' not refreshed! (error: DAVException.mStatusCode %d)",
+                         rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr(), e.getStatus()  );
+#endif
                 }
             }
         }
diff --git a/ucb/source/ucp/webdav/SerfLockStore.hxx b/ucb/source/ucp/webdav/SerfLockStore.hxx
index 0b39b42..64862f7 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.hxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.hxx
@@ -27,6 +27,7 @@
 #include <osl/mutex.hxx>
 #include <rtl/ref.hxx>
 #include "SerfTypes.hxx"
+#include "SerfSession.hxx"
 
 namespace http_dav_ucp
 {
@@ -52,8 +53,8 @@ typedef struct _LockInfo
 
     _LockInfo( rtl::Reference< SerfSession > const & _xSession,
               sal_Int32 _nLastChanceToSendRefreshRequest )
-    : xSession( _xSession ),
-      nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
+        : xSession( _xSession )
+        , nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
 
 } LockInfo;
 
@@ -62,7 +63,6 @@ typedef std::map< SerfLock *, LockInfo, ltptr > LockInfoMap;
 class SerfLockStore
 {
     osl::Mutex         m_aMutex;
-//    ne_lock_store    * m_pSerfLockStore;
     TickerThread     * m_pTickerThread;
     LockInfoMap        m_aLockInfoMap;
 
@@ -70,7 +70,7 @@ public:
     SerfLockStore();
     ~SerfLockStore();
 
-    void registerSession( HttpSession * pHttpSession );
+    void registerSession( SerfSession aSession );
 
     SerfLock * findByUri( rtl::OUString const & rUri );
 
diff --git a/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx
index 14692e1..8ba26d8 100644
--- a/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx
@@ -30,8 +30,10 @@ namespace http_dav_ucp
 {
 
 SerfMkColReqProcImpl::SerfMkColReqProcImpl( const char* inPath,
-                                            const DAVRequestHeaders& inRequestHeaders )
+                                            const DAVRequestHeaders& inRequestHeaders,
+                                            const char* inLockToken )
     : SerfRequestProcessorImpl( inPath,inRequestHeaders )
+    , mpLockToken( inLockToken )
 {
 }
 
diff --git a/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx
index bda085b..9748bd3 100644
--- a/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx
@@ -29,9 +29,12 @@ namespace http_dav_ucp
 
 class SerfMkColReqProcImpl : public SerfRequestProcessorImpl
 {
+private:
+    const char* mpLockToken;
 public:
     SerfMkColReqProcImpl( const char* inPath,
-                          const DAVRequestHeaders& inRequestHeaders );
+                          const DAVRequestHeaders& inRequestHeaders,
+                          const char* inLockToken );
 
     virtual ~SerfMkColReqProcImpl();
 
diff --git a/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx
index 391313f..b57d3bf 100644
--- a/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx
@@ -32,10 +32,12 @@ namespace http_dav_ucp
 SerfMoveReqProcImpl::SerfMoveReqProcImpl( const char* inSourcePath,
                                           const DAVRequestHeaders& inRequestHeaders,
                                           const char* inDestinationPath,
-                                          const bool inOverwrite )
+                                          const bool inOverwrite,
+                                          const char* inLockToken)
     : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
     , mDestPathStr( inDestinationPath )
     , mbOverwrite( inOverwrite )
+    , mpLockToken( inLockToken )
 {
 }
 
@@ -67,6 +69,10 @@ serf_bucket_t * SerfMoveReqProcImpl::createSerfRequestBucket( serf_request_t * i
     {
         serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
     }
+    if(mpLockToken)
+    {
+        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+    }
 
     return req_bkt;
 }
diff --git a/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx
index 4e1ba5b..258a61b 100644
--- a/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx
@@ -33,7 +33,8 @@ public:
     SerfMoveReqProcImpl( const char* inSourcePath,
                          const DAVRequestHeaders& inRequestHeaders,
                          const char* inDestinationPath,
-                         const bool inOverwrite );
+                         const bool inOverwrite,
+                         const char* inLockToken );
 
     virtual ~SerfMoveReqProcImpl();
 
@@ -49,7 +50,8 @@ protected:
 
 private:
     const char* mDestPathStr;
-    const bool mbOverwrite;
+    const bool  mbOverwrite;
+    const char* mpLockToken;
 };
 
 } // namespace http_dav_ucp
diff --git a/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx
index e9a55d0..4d59240 100644
--- a/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx
@@ -35,12 +35,14 @@ SerfPostReqProcImpl::SerfPostReqProcImpl( const char* inPath,
                                           const DAVRequestHeaders& inRequestHeaders,
                                           const char* inData,
                                           apr_size_t inDataLen,
+                                          const char* inLockToken,
                                           const char* inContentType,
                                           const char* inReferer,
                                           const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
     , mpPostData( inData )
     , mnPostDataLen( inDataLen )
+    , mpLockToken( inLockToken )
     , mpContentType( inContentType )
     , mpReferer( inReferer )
     , xInputStream( xioInStrm )
@@ -52,12 +54,14 @@ SerfPostReqProcImpl::SerfPostReqProcImpl( const char* inPath,
                                           const DAVRequestHeaders& inRequestHeaders,
                                           const char* inData,
                                           apr_size_t inDataLen,
+                                          const char* inLockToken,
                                           const char* inContentType,
                                           const char* inReferer,
                                           const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
     , mpPostData( inData )
     , mnPostDataLen( inDataLen )
+    , mpLockToken( inLockToken )
     , mpContentType( inContentType )
     , mpReferer( inReferer )
     , xInputStream()
@@ -102,6 +106,10 @@ serf_bucket_t * SerfPostReqProcImpl::createSerfRequestBucket( serf_request_t * i
     {
         serf_bucket_headers_set( hdrs_bkt, "Referer", mpReferer );
     }
+    if(mpLockToken)
+    {
+        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+    }
 
     return req_bkt;
 }
diff --git a/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx
index 87edb35..6a0d867 100644
--- a/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx
@@ -37,6 +37,7 @@ public:
                          const DAVRequestHeaders& inRequestHeaders,
                          const char* inData,
                          apr_size_t inDataLen,
+                         const char* inLockToken,
                          const char* inContentType,
                          const char* inReferer,
                          const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm );
@@ -45,6 +46,7 @@ public:
                          const DAVRequestHeaders& inRequestHeaders,
                          const char* inData,
                          apr_size_t inDataLen,
+                         const char* inLockToken,
                          const char* inContentType,
                          const char* inReferer,
                          const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm );
@@ -64,6 +66,7 @@ protected:
 private:
     const char* mpPostData;
     apr_size_t mnPostDataLen;
+    const char* mpLockToken;
     const char* mpContentType;
     const char* mpReferer;
     com::sun::star::uno::Reference< SerfInputStream > xInputStream;
diff --git a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
index 7a8ca48..40c9a2e 100644
--- a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
@@ -35,9 +35,11 @@ namespace http_dav_ucp
 
 SerfPropPatchReqProcImpl::SerfPropPatchReqProcImpl( const char* inPath,
                                                     const DAVRequestHeaders& inRequestHeaders,
-                                                    const std::vector< ProppatchValue > & inProperties )
+                                                    const std::vector< ProppatchValue > & inProperties,
+                                                    const char* inLockToken )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
     , mpProperties( &inProperties )
+    , mpLockToken( inLockToken )
 {
 }
 
@@ -167,6 +169,10 @@ serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_
         setRequestHeaders( hdrs_bkt );
 
         // request specific header fields
+        if(mpLockToken)
+        {
+            serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+        }
         if ( body_bkt != 0 && aBodyText.getLength() > 0 )
         {
             serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
diff --git a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx
index 98e74c9..0265901 100644
--- a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx
@@ -35,7 +35,8 @@ class SerfPropPatchReqProcImpl : public SerfRequestProcessorImpl
 public:
     SerfPropPatchReqProcImpl( const char* inPath,
                               const DAVRequestHeaders& inRequestHeaders,
-                              const std::vector< ProppatchValue > & inProperties );
+                              const std::vector< ProppatchValue > & inProperties,
+                              const char* inLockToken );
 
     virtual ~SerfPropPatchReqProcImpl();
 
@@ -51,6 +52,7 @@ protected:
 
 private:
     const std::vector< ProppatchValue > * mpProperties;
+    const  char *mpLockToken;
 };
 
 } // namespace http_dav_ucp
diff --git a/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx
index f24f68d..a2253b2 100644
--- a/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx
@@ -34,9 +34,11 @@ namespace http_dav_ucp
 SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath,
                                         const DAVRequestHeaders& inRequestHeaders,
                                         const char* inData,
+                                        const char* inLockToken,
                                         apr_size_t inDataLen )
     : SerfRequestProcessorImpl( inPath, inRequestHeaders )
     , mpData( inData )
+    , mpLockToken( inLockToken)
     , mnDataLen( inDataLen )
 {
 }
@@ -68,6 +70,11 @@ serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in
     serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
     // general header fields provided by caller
     setRequestHeaders( hdrs_bkt );
+    if(mpLockToken)
+    {
+    // request specific header field
+        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+    }
 
     return req_bkt;
 }
diff --git a/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx
index fd851ab..94e2098 100644
--- a/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx
+++ b/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx
@@ -33,6 +33,7 @@ public:
     SerfPutReqProcImpl( const char* inPath,
                         const DAVRequestHeaders& inRequestHeaders,
                         const char* inData,
+                        const char* inLockToken,
                         apr_size_t inDataLen );
 
 
@@ -50,6 +51,7 @@ protected:
 
 private:
     const char* mpData;
+    const char* mpLockToken;
     apr_size_t mnDataLen;
 
 };
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
index aa96890..7db219c 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
@@ -30,6 +30,9 @@
 
 #include <apr_strings.h>
 
+//to examine returned http code
+#include "DAVException.hxx"
+
 namespace http_dav_ucp
 {
 
@@ -111,11 +114,19 @@ bool SerfRequestProcessor::processPropFind( const Depth inDepth,
 
 // PROPPATCH
 bool SerfRequestProcessor::processPropPatch( const std::vector< ProppatchValue > & inProperties,
+                                             const com::sun::star::ucb::Lock  inLock,
                                              apr_status_t& outSerfStatus )
 {
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createPropPatchReqProcImpl( mPathStr,
                                              mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
-                                             inProperties );
+                                             inProperties,
+                                             inLockToken );
     outSerfStatus = runProcessor();
 
     return outSerfStatus == APR_SUCCESS;
@@ -194,11 +205,19 @@ bool SerfRequestProcessor::processHead( const std::vector< ::rtl::OUString > & i
 // PUT
 bool SerfRequestProcessor::processPut( const char* inData,
                                        apr_size_t inDataLen,
+                                       const com::sun::star::ucb::Lock inLock,
                                        apr_status_t& outSerfStatus )
 {
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createPutReqProcImpl( mPathStr,
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                        inData,
+                                       inLockToken,
                                        inDataLen );
     outSerfStatus = runProcessor();
 
@@ -210,6 +229,7 @@ bool SerfRequestProcessor::processPost( const char* inData,
                                         apr_size_t inDataLen,
                                         const rtl::OUString & inContentType,
                                         const rtl::OUString & inReferer,
+                                        const com::sun::star::ucb::Lock inLock,
                                         const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
                                         apr_status_t& outSerfStatus )
 {
@@ -217,10 +237,17 @@ bool SerfRequestProcessor::processPost( const char* inData,
                                 rtl::OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
     mReferer = apr_pstrdup( mrSerfSession.getAprPool(),
                                 rtl::OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createPostReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         inData,
                                         inDataLen,
+                                        inLockToken,
                                         mContentType,
                                         mReferer,
                                         xioInStrm );
@@ -234,6 +261,7 @@ bool SerfRequestProcessor::processPost( const char* inData,
                                         apr_size_t inDataLen,
                                         const rtl::OUString & inContentType,
                                         const rtl::OUString & inReferer,
+                                        const com::sun::star::ucb::Lock inLock,
                                         const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
                                         apr_status_t& outSerfStatus )
 {
@@ -241,10 +269,17 @@ bool SerfRequestProcessor::processPost( const char* inData,
                                 rtl::OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
     mReferer = apr_pstrdup( mrSerfSession.getAprPool(),
                             rtl::OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createPostReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         inData,
                                         inDataLen,
+                                        inLockToken,
                                         mContentType,
                                         mReferer,
                                         xioOutStrm );
@@ -254,20 +289,36 @@ bool SerfRequestProcessor::processPost( const char* inData,
 }
 
 // DELETE
-bool SerfRequestProcessor::processDelete( apr_status_t& outSerfStatus )
+bool SerfRequestProcessor::processDelete( const com::sun::star::ucb::Lock inLock,
+                                          apr_status_t& outSerfStatus )
 {
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createDeleteReqProcImpl( mPathStr,
-                                          mrSerfSession.getRequestEnvironment().m_aRequestHeaders );
+                                          mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                          inLockToken );
     outSerfStatus = runProcessor();
 
     return outSerfStatus == APR_SUCCESS;
 }
 
 // MKCOL
-bool SerfRequestProcessor::processMkCol( apr_status_t& outSerfStatus )
+bool SerfRequestProcessor::processMkCol( const com::sun::star::ucb::Lock inLock,
+                                         apr_status_t& outSerfStatus )
 {
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createMkColReqProcImpl( mPathStr,
-                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders );
+                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                         inLockToken );
     outSerfStatus = runProcessor();
 
     return outSerfStatus == APR_SUCCESS;
@@ -276,14 +327,22 @@ bool SerfRequestProcessor::processMkCol( apr_status_t& outSerfStatus )
 // COPY
 bool SerfRequestProcessor::processCopy( const rtl::OUString & inDestinationPath,
                                         const bool inOverwrite,
+                                        const com::sun::star::ucb::Lock inLock,
                                         apr_status_t& outSerfStatus )
 {
     mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
                                 rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createCopyReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         mDestPathStr,
-                                        inOverwrite );
+                                        inOverwrite,
+                                        inLockToken );
     outSerfStatus = runProcessor();
 
     return outSerfStatus == APR_SUCCESS;
@@ -292,14 +351,95 @@ bool SerfRequestProcessor::processCopy( const rtl::OUString & inDestinationPath,
 // MOVE
 bool SerfRequestProcessor::processMove( const rtl::OUString & inDestinationPath,
                                         const bool inOverwrite,
+                                        const com::sun::star::ucb::Lock  inLock,
                                         apr_status_t& outSerfStatus )
 {
     mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
                                 rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
+    char * inLockToken = static_cast<char*>(0);
+    if(inLock.LockTokens.getLength() > 0)
+    {
+        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
     mpProcImpl = createMoveReqProcImpl( mPathStr,
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
                                         mDestPathStr,
-                                        inOverwrite );
+                                        inOverwrite,
+                                        inLockToken );
+    outSerfStatus = runProcessor();
+
+    return outSerfStatus == APR_SUCCESS;
+}
+
+//LOCK creating a new lock
+bool SerfRequestProcessor::processLock( const rtl::OUString & inDestinationPath,
+                                        const com::sun::star::ucb::Lock& inLock,
+                                        DAVPropertyValue & outLock,
+                                        apr_status_t& outSerfStatus )
+{
+    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
+                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
+    char * Timeout;
+    if(inLock.Timeout == -1)
+        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Infinite" );
+    else
+        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Second-%ld", inLock.Timeout );
+
+    mpProcImpl = createLockReqProcImpl( mPathStr,
+                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                        inLock,
+                                        Timeout,
+                                        outLock);
+    outSerfStatus = runProcessor();
+
+    return outSerfStatus == APR_SUCCESS;
+}
+
+//LOCK refresh an existing lock
+bool SerfRequestProcessor::processLockRefresh( const rtl::OUString & inDestinationPath,
+                                        const com::sun::star::ucb::Lock& inLock,
+                                        DAVPropertyValue & outLock,
+                                        apr_status_t& outSerfStatus )
+{
+    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
+                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
+    char * Timeout;
+    if(inLock.Timeout == -1)
+        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Infinite" );
+    else
+        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Second-%ld", inLock.Timeout );
+
+    char * inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
+                                 rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+
+    mpProcImpl = createLockRefreshProcImpl( mPathStr,
+                                            mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                            inLock,
+                                            inLockToken,
+                                            Timeout,
+                                            outLock);
+    outSerfStatus = runProcessor();
+
+    return outSerfStatus == APR_SUCCESS;
+}
+
+//ULOCK unlock an existing lock
+bool SerfRequestProcessor::processUnlock( const rtl::OUString & inDestinationPath,
+                                        const com::sun::star::ucb::Lock& inLock,
+                                        apr_status_t& outSerfStatus )
+{
+    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
+                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+    char * aToken = apr_psprintf( mrSerfSession.getAprPool(), "<%s>",
+                                 rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
+
+    mpProcImpl = createUnlockProcImpl( mPathStr,
+                                       mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
+                                       inLock,
+                                       aToken );
+
     outSerfStatus = runProcessor();
 
     return outSerfStatus == APR_SUCCESS;
@@ -316,6 +456,7 @@ apr_status_t SerfRequestProcessor::runProcessor()
     }
 
     // create serf request
+    OSL_ASSERT(mrSerfSession.getSerfConnection() != NULL);
     serf_connection_request_create( mrSerfSession.getSerfConnection(),
                                     Serf_SetupRequest,
                                     this );
@@ -336,6 +477,10 @@ apr_status_t SerfRequestProcessor::runProcessor()
         }
         if ( status != APR_SUCCESS )
         {
+#if OSL_DEBUG_LEVEL > 0
+            char buff[512];
+            OSL_TRACE("SerfRequestProcessor::runProcessor, status != APR_SUCCESS: %d (%s)",status, apr_strerror(status, buff, 512));
+#endif
             break;
         }
         if ( mbProcessingDone )
@@ -356,6 +501,7 @@ void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus )
         return;
     }
 
+    OSL_TRACE("SerfRequestProcessor::postprocessProcessor:%d",__LINE__);
     switch ( inStatus )
     {
     case APR_EGENERAL:
@@ -391,6 +537,11 @@ void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus )
                 mpDAVException = new DAVException( DAVException::DAV_HTTP_REDIRECT,
                                                    mRedirectLocation );
                 break;
+            case SC_LOCKED:
+                mpDAVException = new DAVException( DAVException::DAV_LOCKED,
+                                                   mHTTPStatusCodeText,
+                                                   mnHTTPStatusCode );
+                break;
             default:
                 mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR,
                                                    mHTTPStatusCodeText,
@@ -404,7 +555,6 @@ void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus )
         mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR );
         break;
     }
-
 }
 
 apr_status_t SerfRequestProcessor::provideSerfCredentials( char ** outUsername,
@@ -500,6 +650,24 @@ apr_status_t SerfRequestProcessor::handleSerfResponse( serf_request_t * inSerfRe
             mbProcessingDone = false; // allow another try in order to get a response
             return status;
         }
+        serf_bucket_t *headers = serf_bucket_response_get_headers( inSerfResponseBucket );
+
+        // check header according:
+        // http://tools.ietf.org/html/rfc7231#section-7.4.2
+        // need to do this so we can adjust the protocol accordingly
+        // serf_bucket_headers_get is case independent
+        const char* server = serf_bucket_headers_get( headers, "server" );
+        if( server )
+        {
+            //update the server type on session
+            mrSerfSession.setServerHeaderField( ::rtl::OUString::createFromAscii( server ) );
+        }
+        //the following extension is MS IIS specific,
+        //see https://msdn.microsoft.com/en-us/library/cc250064.aspx
+        //site last checked on 2015-03-02
+        //TODO i126305 need to be added when serf is updated to a version supporting Windows authentication
+        //const char* msDavExtErr = serf_bucket_headers_get( headers, "X-MSDAVEXT_ERROR" );
+
         // TODO - check, if response status code handling is correct
         mnHTTPStatusCode = ( sl.version != 0 && sl.code >= 0 )
                            ? static_cast< sal_uInt16 >( sl.code )
@@ -517,7 +685,6 @@ apr_status_t SerfRequestProcessor::handleSerfResponse( serf_request_t * inSerfRe
                  mnHTTPStatusCode == 307 )
             {
                 // new location for certain redirections
-                serf_bucket_t *headers = serf_bucket_response_get_headers( inSerfResponseBucket );
                 const char* location = serf_bucket_headers_get( headers, "Location" );
                 if ( location )
                 {
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
index 673eb39..36ba52f 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
@@ -32,6 +32,7 @@
 #include "DAVResource.hxx"
 #include "DAVException.hxx"
 
+#include "SerfTypes.hxx"
 #include "SerfInputStream.hxx"
 #include <com/sun/star/io/XOutputStream.hpp>
 
@@ -62,6 +63,7 @@ public:
 
     // PROPPATCH
     bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
+                           const com::sun::star::ucb::Lock  inLock,
                            apr_status_t& outSerfStatus );
 
     // GET
@@ -92,6 +94,7 @@ public:
     // PUT
     bool processPut( const char* inData,
                      apr_size_t inDataLen,
+                     const com::sun::star::ucb::Lock  inLock,
                      apr_status_t& outSerfStatus );
 
     // POST
@@ -99,6 +102,7 @@ public:
                       apr_size_t inDataLen,
                       const rtl::OUString & inContentType,
                       const rtl::OUString & inReferer,
+                      const com::sun::star::ucb::Lock  inLock,
                       const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
                       apr_status_t& outSerfStatus );
 
@@ -107,25 +111,47 @@ public:
                       apr_size_t inDataLen,
                       const rtl::OUString & inContentType,
                       const rtl::OUString & inReferer,
+                      const com::sun::star::ucb::Lock  inLock,
                       const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
                       apr_status_t& outSerfStatus );
 
     // DELETE
-    bool processDelete( apr_status_t& outSerfStatus );
+    bool processDelete( const com::sun::star::ucb::Lock inLock,
+                        apr_status_t& outSerfStatus );
 
     // MKCOL
-    bool processMkCol( apr_status_t& outSerfStatus );
+    bool processMkCol( const com::sun::star::ucb::Lock inLock,
+                       apr_status_t& outSerfStatus );
 
     // COPY
     bool processCopy( const rtl::OUString & inDestinationPath,
                       const bool inOverwrite,
+                      const com::sun::star::ucb::Lock inLock,
                       apr_status_t& outSerfStatus );
 
     // MOVE
     bool processMove( const rtl::OUString & inDestinationPath,
                       const bool inOverwrite,
+                      const com::sun::star::ucb::Lock inLock,
                       apr_status_t& outSerfStatus );
 
+    // LOCK
+    bool processLock( const rtl::OUString & inDestinationPath,
+                      const com::sun::star::ucb::Lock& inLock,
+                      DAVPropertyValue & outLock,
+                      apr_status_t& outSerfStatus );
+
+    // LOCK refresh
+    bool processLockRefresh( const rtl::OUString & inDestinationPath,
+                      const com::sun::star::ucb::Lock& inLock,
+                      DAVPropertyValue & outLock,
+                      apr_status_t& outSerfStatus );
+
+    //UNLOCK
+    bool processUnlock( const rtl::OUString & inDestinationPath,
+                        const com::sun::star::ucb::Lock& inLock,
+                        apr_status_t& outSerfStatus );
+
     apr_status_t provideSerfCredentials( char ** outUsername,
                                          char ** outPassword,
                                          serf_request_t * inRequest,
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx b/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx
index 460e54a..de4a41e 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx
@@ -22,6 +22,7 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_ucb.hxx"
 
+#include "SerfTypes.hxx"
 #include "SerfRequestProcessorImplFac.hxx"
 #include "SerfPropFindReqProcImpl.hxx"
 #include "SerfPropPatchReqProcImpl.hxx"
@@ -33,6 +34,9 @@
 #include "SerfMkColReqProcImpl.hxx"
 #include "SerfCopyReqProcImpl.hxx"
 #include "SerfMoveReqProcImpl.hxx"
+#include "SerfLockReqProcImpl.hxx"
+#include "SerfLockRefreshProcImpl.hxx"
+#include "SerfUnlockProcImpl.hxx"
 
 namespace http_dav_ucp
 {
@@ -64,11 +68,13 @@ namespace http_dav_ucp
 
     SerfRequestProcessorImpl* createPropPatchReqProcImpl( const char* inPath,
                                                           const DAVRequestHeaders& inRequestHeaders,
-                                                          const std::vector< ProppatchValue > & inProperties )
+                                                          const std::vector< ProppatchValue > & inProperties,
+                                                          const char* inLockToken )
     {
         SerfRequestProcessorImpl* pReqProcImpl = new SerfPropPatchReqProcImpl( inPath,
                                                                                inRequestHeaders,

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list