View | Details | Raw Unified | Return to issue 126305
Collapse All | Expand All

(-)a/main/comphelper/inc/comphelper/mediadescriptor.hxx (+1 lines)
Lines 85-90 class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap Link Here
85
        static const ::rtl::OUString& PROP_HIDDEN();
85
        static const ::rtl::OUString& PROP_HIDDEN();
86
        static const ::rtl::OUString& PROP_INPUTSTREAM();
86
        static const ::rtl::OUString& PROP_INPUTSTREAM();
87
        static const ::rtl::OUString& PROP_INTERACTIONHANDLER();
87
        static const ::rtl::OUString& PROP_INTERACTIONHANDLER();
88
        static const ::rtl::OUString& PROP_AUTHENTICATIONHANDLER();
88
        static const ::rtl::OUString& PROP_JUMPMARK();
89
        static const ::rtl::OUString& PROP_JUMPMARK();
89
        static const ::rtl::OUString& PROP_MACROEXECUTIONMODE();
90
        static const ::rtl::OUString& PROP_MACROEXECUTIONMODE();
90
        static const ::rtl::OUString& PROP_MEDIATYPE();
91
        static const ::rtl::OUString& PROP_MEDIATYPE();
(-)a/main/comphelper/inc/comphelper/stillreadwriteinteraction.hxx (-1 / +6 lines)
Lines 44-61 class COMPHELPER_DLLPUBLIC StillReadWriteInteraction : public ::ucbhelper::Inter Link Here
44
private:
44
private:
45
	static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION       = 0;
45
	static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION       = 0;
46
	static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
46
	static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
47
    static const sal_Int32 HANDLE_AUTHENTICATIONREQUESTEXCEPTION = 2;
47
48
48
	sal_Bool m_bUsed;
49
	sal_Bool m_bUsed;
49
	sal_Bool m_bHandledByMySelf;
50
	sal_Bool m_bHandledByMySelf;
50
	sal_Bool m_bHandledByInternalHandler;
51
	sal_Bool m_bHandledByInternalHandler;
51
52
52
public:
53
public:
53
	StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler);
54
	StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler,
55
                              const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xAuthenticationHandler);
54
56
55
	void resetInterceptions();
57
	void resetInterceptions();
56
	void resetErrorStates();
58
	void resetErrorStates();
57
	sal_Bool wasWriteError();
59
	sal_Bool wasWriteError();
58
60
61
protected:
62
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xAuthenticationHandler;
63
59
private:
64
private:
60
	virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest&                         aRequest,
65
	virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest&                         aRequest,
61
		const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest);
66
		const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest);
(-)a/main/comphelper/source/misc/mediadescriptor.cxx (-3 / +32 lines)
Lines 175-180 const ::rtl::OUString& MediaDescriptor::PROP_INTERACTIONHANDLER() Link Here
175
    return sProp;
175
    return sProp;
176
}
176
}
177
177
178
const ::rtl::OUString& MediaDescriptor::PROP_AUTHENTICATIONHANDLER()
179
{
180
    static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("AuthenticationHandler"));
181
    return sProp;
182
}
183
178
const ::rtl::OUString& MediaDescriptor::PROP_JUMPMARK()
184
const ::rtl::OUString& MediaDescriptor::PROP_JUMPMARK()
179
{
185
{
180
    static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("JumpMark"));
186
    static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("JumpMark"));
Lines 706-713 sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s Link Here
706
	css::uno::Reference< css::task::XInteractionHandler > xOrgInteraction = getUnpackedValueOrDefault(
712
	css::uno::Reference< css::task::XInteractionHandler > xOrgInteraction = getUnpackedValueOrDefault(
707
		MediaDescriptor::PROP_INTERACTIONHANDLER(),
713
		MediaDescriptor::PROP_INTERACTIONHANDLER(),
708
		css::uno::Reference< css::task::XInteractionHandler >());
714
		css::uno::Reference< css::task::XInteractionHandler >());
715
	css::uno::Reference< css::task::XInteractionHandler > xAuthenticationInteraction = getUnpackedValueOrDefault(
716
		MediaDescriptor::PROP_AUTHENTICATIONHANDLER(),
717
		css::uno::Reference< css::task::XInteractionHandler >());
709
718
710
    StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction);
719
    StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction, xAuthenticationInteraction);
711
	css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
720
	css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
712
721
713
	css::uno::Reference< css::ucb::XProgressHandler > xProgress;
722
	css::uno::Reference< css::ucb::XProgressHandler > xProgress;
Lines 738-748 sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s Link Here
738
    css::uno::Reference< css::io::XInputStream > xInputStream;
747
    css::uno::Reference< css::io::XInputStream > xInputStream;
739
748
740
    sal_Bool bReadOnly = sal_False;
749
    sal_Bool bReadOnly = sal_False;
750
    //bModeRequestedExplicitly means 'read/write mode requested explicitly'
741
	sal_Bool bModeRequestedExplicitly = sal_False;
751
	sal_Bool bModeRequestedExplicitly = sal_False;
752
    // MediaDescriptor::PROP_READONLY is present only if the mediadescriptor was used at least one time
753
    // that is, it exists if the file was changed from readonly mode to read/write using the GUI interface
742
    const_iterator pIt = find(MediaDescriptor::PROP_READONLY());
754
    const_iterator pIt = find(MediaDescriptor::PROP_READONLY());
743
    if (pIt != end())
755
    if (pIt != end())
744
	{
756
	{
745
		pIt->second >>= bReadOnly;
757
		pIt->second >>= bReadOnly;
758
        // TODO: thinking a different way: we enable the switch to r/o even though the file
759
        // 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
760
        // according to GUI request) instead of returning an error
746
		bModeRequestedExplicitly = sal_True;
761
		bModeRequestedExplicitly = sal_True;
747
	}
762
	}
748
763
Lines 762-771 sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s Link Here
762
                // ignore exception, if reason was problem reasoned on
777
                // ignore exception, if reason was problem reasoned on
763
                // open it in WRITEABLE mode! Then we try it READONLY
778
                // open it in WRITEABLE mode! Then we try it READONLY
764
                // later a second time.
779
                // later a second time.
765
                // All other errors must be handled as real error an
780
                // All other errors must be handled as real error and
766
                // break this method.
781
                // break this method.
767
                if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
782
                if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
768
                    return sal_False;
783
                {
784
                    //-> i126305
785
                    // If the protocol is webdav, then we need to treat the stream as readonly, even if the
786
                    // operation was requested as read/write explicitly (the WebDAV UCB implementation is monodirectional
787
                    // read or write not both at the same time).
788
                    rtl::OUString aScheme;
789
                    css::uno::Reference< css::ucb::XContentIdentifier > xContId(
790
                        aContent.get().is() ? aContent.get()->getIdentifier() : 0 );
791
                    if ( xContId.is() )
792
                        aScheme = xContId->getContentProviderScheme();
793
                    if(!aScheme.equalsIgnoreAsciiCaseAscii( "http" ) && !aScheme.equalsIgnoreAsciiCaseAscii( "https" ))
794
                        return sal_False;
795
                    //<- i126305
796
                }
797
769
                xStream.clear();
798
                xStream.clear();
770
                xInputStream.clear();
799
                xInputStream.clear();
771
            }
800
            }
(-)a/main/comphelper/source/misc/stillreadwriteinteraction.cxx (-2 / +24 lines)
Lines 37-50 Link Here
37
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
37
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
38
#endif
38
#endif
39
39
40
#include <com/sun/star/ucb/AuthenticationRequest.hpp>
41
40
namespace comphelper{
42
namespace comphelper{
41
43
42
	namespace css = ::com::sun::star;
44
	namespace css = ::com::sun::star;
43
45
44
StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler)
46
    StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
47
                                                         const css::uno::Reference< css::task::XInteractionHandler >& xAuthenticationHandler)
45
 			: m_bUsed                    (sal_False)
48
 			: m_bUsed                    (sal_False)
46
 			, m_bHandledByMySelf         (sal_False)
49
 			, m_bHandledByMySelf         (sal_False)
47
 			, m_bHandledByInternalHandler(sal_False)
50
 			, m_bHandledByInternalHandler(sal_False)
51
 			, m_xAuthenticationHandler(xAuthenticationHandler)
48
{
52
{
49
	::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
53
	::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
50
	::ucbhelper::InterceptedInteraction::InterceptedRequest                  aInterceptedRequest;
54
	::ucbhelper::InterceptedInteraction::InterceptedRequest                  aInterceptedRequest;
Lines 60-66 StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< Link Here
60
	aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
64
	aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
61
	aInterceptedRequest.MatchExact = sal_False;
65
	aInterceptedRequest.MatchExact = sal_False;
62
	lInterceptions.push_back(aInterceptedRequest);
66
	lInterceptions.push_back(aInterceptedRequest);
63
	 
67
68
	aInterceptedRequest.Handle = HANDLE_AUTHENTICATIONREQUESTEXCEPTION;
69
	aInterceptedRequest.Request <<= css::ucb::AuthenticationRequest();
70
	aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
71
	aInterceptedRequest.MatchExact = sal_False;
72
	lInterceptions.push_back(aInterceptedRequest);
73
64
	setInterceptedHandler(xHandler);
74
	setInterceptedHandler(xHandler);
65
	setInterceptions(lInterceptions);
75
	setInterceptions(lInterceptions);
66
}
76
}
Lines 114-119 ucbhelper::InterceptedInteraction::EInterceptionState StillReadWriteInteraction: Link Here
114
			bAbort = sal_True;
124
			bAbort = sal_True;
115
		}
125
		}
116
		break;
126
		break;
127
    case HANDLE_AUTHENTICATIONREQUESTEXCEPTION:
128
		{
129
//use internal authentication dedicated handler and return
130
            if (m_xAuthenticationHandler.is())
131
            {
132
                m_xAuthenticationHandler->handle(xRequest);
133
                return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
134
            }
135
            else //simply abort
136
                bAbort = sal_True;;
137
		}
138
		break;
117
	}
139
	}
118
140
119
	// handle interaction by ourself
141
	// handle interaction by ourself
(-)a/main/framework/source/loadenv/loadenv.cxx (+1 lines)
Lines 376-381 void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::lang::XMulti Link Here
376
       )
376
       )
377
    {
377
    {
378
        io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
378
        io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
379
        io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= xInteractionHandler;
379
    }
380
    }
380
381
381
    if (io_lMediaDescriptor.find(::comphelper::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
382
    if (io_lMediaDescriptor.find(::comphelper::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
(-)a/main/offapi/com/sun/star/ucb/InteractiveLockingException.idl (+6 lines)
Lines 45-50 module com { module sun { module star { module ucb { Link Here
45
    /** The Url of the resource this exception is related to.
45
    /** The Url of the resource this exception is related to.
46
    */
46
    */
47
    string Url;
47
    string Url;
48
49
    //->i126305 ---------------------------------------------------------------
50
    /** Extended information, some Internet Server send this to the client
51
    */
52
    string ExtendedInfo;
53
    //<-i126305
48
};
54
};
49
55
50
//=============================================================================
56
//=============================================================================
(-)a/main/offapi/com/sun/star/ucb/InteractiveLockingLockNotAvailableException.idl (+48 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
23
#ifndef __com_sun_star_ucb_InteractiveLockingLockNotAvailableException_idl__
24
#define __com_sun_star_ucb_InteractiveLockingLockNotAvailableException_idl__
25
26
#ifndef __com_sun_star_ucb_InteractiveLockingException_idl__
27
#include <com/sun/star/ucb/InteractiveLockingException.idl>
28
#endif
29
30
31
//=============================================================================
32
33
module com { module sun { module star { module ucb {
34
35
//=============================================================================
36
/** An error indicating that the resource can not be locked because the lock capabiliy is not available
37
38
    @since OpenOffice 4.2
39
*/
40
/*published*/ exception InteractiveLockingLockNotAvailableException : com::sun::star::ucb::InteractiveLockingException
41
{
42
};
43
44
//=============================================================================
45
46
}; }; }; };
47
48
#endif
(-)a/main/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl (+7 lines)
Lines 46-51 module com { module sun { module star { module ucb { Link Here
46
        <false/> the lock has been obtained by another principal.
46
        <false/> the lock has been obtained by another principal.
47
    */
47
    */
48
    boolean SelfOwned;
48
    boolean SelfOwned;
49
    //->i126305 -------------------------------------------------------------------------
50
    /** The owner of the lock.
51
     *
52
     *  Used for WevDAV interface
53
    */
54
    string Owner;
55
    //<-i126305
49
};
56
};
50
57
51
//=============================================================================
58
//=============================================================================
(-)a/main/offapi/com/sun/star/ucb/makefile.mk (+1 lines)
Lines 117-122 IDLFILES=\ Link Here
117
	InteractiveFileIOException.idl\
117
	InteractiveFileIOException.idl\
118
	InteractiveIOException.idl\
118
	InteractiveIOException.idl\
119
	InteractiveLockingException.idl\
119
	InteractiveLockingException.idl\
120
	InteractiveLockingLockNotAvailableException.idl\
120
	InteractiveLockingLockExpiredException.idl\
121
	InteractiveLockingLockExpiredException.idl\
121
	InteractiveLockingLockedException.idl\
122
	InteractiveLockingLockedException.idl\
122
	InteractiveLockingNotLockedException.idl\
123
	InteractiveLockingNotLockedException.idl\
(-)a/main/sfx2/inc/sfx2/docfile.hxx (+5 lines)
Lines 140-145 public: Link Here
140
    void                UseInteractionHandler( sal_Bool );
140
    void                UseInteractionHandler( sal_Bool );
141
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
141
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
142
						GetInteractionHandler();
142
						GetInteractionHandler();
143
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
144
                        GetAuthenticationInteractionHandler();
143
145
144
    void setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,sal_Bool bIsReadOnly )
146
    void setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,sal_Bool bIsReadOnly )
145
    { m_xInputStreamToLoadFrom = xInputStream; m_bIsReadOnly = bIsReadOnly; }
147
    { m_xInputStreamToLoadFrom = xInputStream; m_bIsReadOnly = bIsReadOnly; }
Lines 211-216 public: Link Here
211
	sal_Bool            Commit();
213
	sal_Bool            Commit();
212
    sal_Bool            IsStorage();
214
    sal_Bool            IsStorage();
213
215
216
    //->i126305
217
    sal_Int8            ShowLockedWebDAVDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading );
218
    //<-i126305
214
    sal_Int8            ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
219
    sal_Int8            ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
215
    sal_Bool            LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
220
    sal_Bool            LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
216
    void                UnlockFile( sal_Bool bReleaseLockStream );
221
    void                UnlockFile( sal_Bool bReleaseLockStream );
(-)a/main/sfx2/source/dialog/filedlghelper.cxx (-1 / +1 lines)
Lines 2710-2716 static int impl_isFolder( const OUString& rPath ) Link Here
2710
	{
2710
	{
2711
	}
2711
	}
2712
2712
2713
	::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler );
2713
	::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler , uno::Reference< task::XInteractionHandler >());
2714
2714
2715
	try
2715
	try
2716
	{
2716
	{
(-)a/main/sfx2/source/doc/docfile.cxx (-24 / +295 lines)
Lines 50-55 Link Here
50
#include <com/sun/star/ucb/XContentProvider.hpp>
50
#include <com/sun/star/ucb/XContentProvider.hpp>
51
#include <com/sun/star/ucb/XProgressHandler.hpp>
51
#include <com/sun/star/ucb/XProgressHandler.hpp>
52
#include <com/sun/star/ucb/XCommandInfo.hpp>
52
#include <com/sun/star/ucb/XCommandInfo.hpp>
53
#include <com/sun/star/ucb/Lock.hpp>
54
#include <com/sun/star/ucb/InteractiveLockingLockNotAvailableException.hpp>
55
#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
56
#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
53
#include <com/sun/star/util/XArchiver.hpp>
57
#include <com/sun/star/util/XArchiver.hpp>
54
#include <com/sun/star/io/XOutputStream.hpp>
58
#include <com/sun/star/io/XOutputStream.hpp>
55
#include <com/sun/star/io/XInputStream.hpp>
59
#include <com/sun/star/io/XInputStream.hpp>
Lines 309-314 public: Link Here
309
313
310
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xInteraction;
314
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xInteraction;
311
315
316
    ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xCredentialInteraction;
317
312
	sal_Bool 		m_bRemoveBackup;
318
	sal_Bool 		m_bRemoveBackup;
313
	::rtl::OUString m_aBackupURL;
319
	::rtl::OUString m_aBackupURL;
314
320
Lines 486-492 void SfxMedium::CheckFileDate( const util::DateTime& aInitDate ) Link Here
486
//------------------------------------------------------------------
492
//------------------------------------------------------------------
487
sal_Bool SfxMedium::DocNeedsFileDateCheck()
493
sal_Bool SfxMedium::DocNeedsFileDateCheck()
488
{
494
{
489
    return ( !IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
495
    ::rtl::OUString aScheme =  INetURLObject::GetScheme( GetURLObject().GetProtocol() );
496
    sal_Bool bIsWebDAV = ( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
497
                                  aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) );
498
    return ( !IsReadOnly() &&
499
             ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) || bIsWebDAV ) );
490
}
500
}
491
501
492
//------------------------------------------------------------------
502
//------------------------------------------------------------------
Lines 910-915 void SfxMedium::SetEncryptionDataToStorage_Impl() Link Here
910
	}
920
	}
911
}
921
}
912
922
923
//->i126305 -----------------------------------------------------------------
924
//for the time being the aData holds a single OUString, the owner of the lock
925
sal_Int8 SfxMedium::ShowLockedWebDAVDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading )
926
{
927
    sal_Int8 nResult = LOCK_UI_NOLOCK;
928
929
    // show the interaction regarding the document opening
930
    uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
931
932
    if ( ::svt::DocumentLockFile::IsInteractionAllowed() && xHandler.is() && bIsLoading )
933
    {
934
        ::rtl::OUString aDocumentURL = GetURLObject().GetLastName();
935
        ::rtl::OUString aInfo;
936
        ::rtl::Reference< ::ucbhelper::InteractionRequest > xInteractionRequestImpl;
937
938
        aInfo = aData[0];
939
        if(aData.getLength() > 1 && aData[1].getLength() > 0)
940
        {
941
            aInfo += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\n" ) );
942
            aInfo += aData[1];
943
        }
944
945
        if ( bIsLoading )
946
        {
947
            xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
948
                uno::makeAny( document::LockedDocumentRequest( ::rtl::OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
949
        }
950
        else
951
        {
952
            xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
953
                uno::makeAny( document::LockedOnSavingRequest( ::rtl::OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
954
        }
955
956
        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
957
        aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() );
958
        aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() );
959
        aContinuations[2] = new ::ucbhelper::InteractionDisapprove( xInteractionRequestImpl.get() );
960
        xInteractionRequestImpl->setContinuations( aContinuations );
961
962
        xHandler->handle( xInteractionRequestImpl.get() );
963
964
        ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xInteractionRequestImpl->getSelection();
965
        if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() )
966
        {
967
            SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
968
        }
969
        else if ( uno::Reference< task::XInteractionDisapprove >( xSelected.get(), uno::UNO_QUERY ).is() )
970
        {
971
            // alien lock on loading, user has selected to edit a copy of document
972
            // TODO/LATER: alien lock on saving, user has selected to do SaveAs to different location
973
            // means that a copy of the document should be opened
974
            GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
975
        }
976
        else // if ( XSelected == aContinuations[1] )
977
        {
978
            // alien lock on loading, user has selected to retry saving
979
            // TODO/LATER: alien lock on saving, user has selected to retry saving
980
            if ( bIsLoading )
981
                GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
982
            else
983
                nResult = LOCK_UI_TRY;
984
        }
985
    }
986
    else
987
    {
988
        if ( bIsLoading )
989
        {
990
            // if no interaction handler is provided the default answer is open readonly
991
            // that usually happens in case the document is loaded per API
992
            // so the document must be opened readonly for backward compatibility
993
            GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
994
        }
995
        else
996
            SetError( ERRCODE_IO_ACCESSDENIED, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
997
    }
998
999
    return nResult;
1000
}
1001
//<-i126305
1002
913
//------------------------------------------------------------------
1003
//------------------------------------------------------------------
914
sal_Int8 SfxMedium::ShowLockedDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock )
1004
sal_Int8 SfxMedium::ShowLockedDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock )
915
{
1005
{
Lines 1216-1223 sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) Link Here
1216
            }
1306
            }
1217
            else
1307
            else
1218
            {
1308
            {
1219
                // this is no file URL, check whether the file is readonly
1309
                //->i126305
1220
                bResult = !bContentReadonly;
1310
                // check if path scheme is http:// or https://
1311
                ::rtl::OUString aScheme =  INetURLObject::GetScheme(GetURLObject().GetProtocol());
1312
                if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
1313
                    aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
1314
                {
1315
                    //so, this is webdav stuff...
1316
                    Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler();
1317
                    if ( !bResult )
1318
                    {
1319
                        // no read-write access is necessary on loading if the document is explicitly opened as copy
1320
                        SFX_ITEMSET_ARG( GetItemSet(), pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False);
1321
                        bResult = ( bLoading && pTemplateItem && pTemplateItem->GetValue() );
1322
                    }
1323
1324
                    if ( !bResult && !IsReadOnly() )
1325
                    {
1326
1327
                        // in case of storing the document should request the output before locking
1328
                        if ( bLoading )
1329
                        {
1330
                            // let the stream be opened to check the system file locking
1331
                            GetMedium_Impl();
1332
                        }
1333
1334
                        sal_Int8 bUIStatus = LOCK_UI_NOLOCK;
1335
                        do
1336
                        {
1337
                            if( !bResult )
1338
                            {
1339
                                Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
1340
                                uno::Reference< task::XInteractionHandler > xCHandler = GetAuthenticationInteractionHandler();
1341
                                xComEnv = new ::ucbhelper::CommandEnvironment( xCHandler,
1342
                                                                               Reference< ::com::sun::star::ucb::XProgressHandler >() );
1343
                                ::ucbhelper::Content aContentToLock( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv);
1344
                                rtl::OUString   aOwner;
1345
                                try {
1346
                                    aContentToLock.lock();
1347
                                    bResult = sal_True;
1348
                                }
1349
                                catch( ucb::InteractiveLockingLockNotAvailableException )
1350
                                {
1351
                                    // signalled when the lock can not be done because the method is known but not allowed on the resource
1352
                                    // the resource is still available, can be worked upon, at your risk
1353
                                    // so ask user whether he wants to open the document without any locking
1354
                                    uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
1355
1356
                                    if ( xHandler.is() )
1357
                                    {
1358
                                        ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl
1359
                                            = new ::ucbhelper::InteractionRequest( uno::makeAny( document::LockFileIgnoreRequest() ) );
1360
1361
                                        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
1362
                                        aContinuations[0] = new ::ucbhelper::InteractionAbort( xIgnoreRequestImpl.get() );
1363
                                        aContinuations[1] = new ::ucbhelper::InteractionApprove( xIgnoreRequestImpl.get() );
1364
                                        xIgnoreRequestImpl->setContinuations( aContinuations );
1365
1366
                                        xHandler->handle( xIgnoreRequestImpl.get() );
1367
1368
                                        ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
1369
                                        bResult = (  uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is() );
1370
                                    }
1371
                                }
1372
                                catch( ucb::InteractiveLockingLockedException& e )
1373
                                {
1374
                                    // here get the lock owner currently active
1375
                                    aOwner = e.Owner;
1376
                                    rtl::OUString aExtendedError;
1377
1378
                                    if ( !bResult && !bNoUI )
1379
                                    {
1380
                                        uno::Sequence< ::rtl::OUString > aData( 2 );
1381
1382
                                        aData[0] = aOwner;
1383
                                        aData[1] = aExtendedError;
1384
                                        bUIStatus = ShowLockedWebDAVDocumentDialog( aData, bLoading );
1385
                                        if ( bUIStatus == LOCK_UI_SUCCEEDED )
1386
                                        {
1387
                                            // take the ownership over the lock file, accept the current lock (already there)
1388
                                            bResult = sal_True;
1389
                                        }
1390
                                    }
1391
                                }
1392
                            }
1393
                        } while( !bResult && bUIStatus == LOCK_UI_TRY );
1394
                    }
1395
1396
                    if ( !bResult && GetError() == ERRCODE_NONE )
1397
                    {
1398
                        // the error should be set in case it is storing process
1399
                        // or the document has been opened for editing explicitly
1400
                        SFX_ITEMSET_ARG( pSet, pReadOnlyItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
1401
                        if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) )
1402
                            SetError( ERRCODE_IO_ACCESSDENIED, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
1403
                        else
1404
                            GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
1405
                    }
1406
1407
                    pImp->m_bLocked = bResult;
1408
                }
1409
                else
1410
                {
1411
                    // this is neither file URL nor WebDAV, check whether the file is readonly
1412
                    bResult = !bContentReadonly;
1413
                }
1414
                //<-i126305
1221
            }
1415
            }
1222
        }
1416
        }
1223
    }
1417
    }
Lines 2194-2200 void SfxMedium::GetLockingStream_Impl() Link Here
2194
        SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False);
2388
        SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False);
2195
        if ( pWriteStreamItem )
2389
        if ( pWriteStreamItem )
2196
            pWriteStreamItem->GetValue() >>= pImp->m_xLockingStream;
2390
            pWriteStreamItem->GetValue() >>= pImp->m_xLockingStream;
2197
   
2391
2198
        if ( !pImp->m_xLockingStream.is() )
2392
        if ( !pImp->m_xLockingStream.is() )
2199
        {
2393
        {
2200
            // open the original document
2394
            // open the original document
Lines 2309-2315 void SfxMedium::GetMedium_Impl() Link Here
2309
                        aMedium.addInputStreamOwnLock();
2503
                        aMedium.addInputStreamOwnLock();
2310
                    }
2504
                    }
2311
                    else
2505
                    else
2506
                    {
2507
                        //add acheck for protocol, to see if it's http or https then add
2508
                        //the interecation handler to be used by the authentication dialog
2509
                        ::rtl::OUString aScheme =  INetURLObject::GetScheme(GetURLObject().GetProtocol());
2510
                        if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
2511
                            aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
2512
                        {
2513
                            aMedium[comphelper::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= GetAuthenticationInteractionHandler();
2514
                        }
2312
                        aMedium.addInputStream();
2515
                        aMedium.addInputStream();
2516
                    }
2313
2517
2314
                    // the ReadOnly property set in aMedium is ignored
2518
                    // the ReadOnly property set in aMedium is ignored
2315
                    // the check is done in LockOrigFileOnDemand() for file and non-file URLs
2519
                    // the check is done in LockOrigFileOnDemand() for file and non-file URLs
Lines 2531-2536 void SfxMedium::UseInteractionHandler( sal_Bool bUse ) Link Here
2531
//------------------------------------------------------------------
2735
//------------------------------------------------------------------
2532
2736
2533
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
2737
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
2738
SfxMedium::GetAuthenticationInteractionHandler()
2739
{
2740
    // search a possible existing handler inside cached item set
2741
    if ( pSet )
2742
    {
2743
        ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xHandler;
2744
        SFX_ITEMSET_ARG( pSet, pHandler, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False);
2745
        if ( pHandler && (pHandler->GetValue() >>= xHandler) && xHandler.is() )
2746
            return xHandler;
2747
    }
2748
2749
    // otherwhise return cached default handler ... if it exist.
2750
    if ( pImp->xCredentialInteraction.is() )
2751
        return pImp->xCredentialInteraction;
2752
2753
    // create default handler and cache it!
2754
    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
2755
    if ( xFactory.is() )
2756
    {
2757
        pImp->xCredentialInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >(
2758
            xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
2759
        return pImp->xCredentialInteraction;
2760
    }
2761
2762
	return ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >();
2763
}
2764
2765
//------------------------------------------------------------------
2766
2767
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
2534
SfxMedium::GetInteractionHandler()
2768
SfxMedium::GetInteractionHandler()
2535
{
2769
{
2536
    // if interaction isn't allowed explicitly ... return empty reference!
2770
    // if interaction isn't allowed explicitly ... return empty reference!
Lines 2558-2564 SfxMedium::GetInteractionHandler() Link Here
2558
    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
2792
    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
2559
    if ( xFactory.is() )
2793
    if ( xFactory.is() )
2560
    {
2794
    {
2561
        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 );
2795
        pImp->xInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >(
2796
            xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
2562
        return pImp->xInteraction;
2797
        return pImp->xInteraction;
2563
    }
2798
    }
2564
2799
Lines 2708-2745 void SfxMedium::CloseAndRelease() Link Here
2708
2943
2709
void SfxMedium::UnlockFile( sal_Bool bReleaseLockStream )
2944
void SfxMedium::UnlockFile( sal_Bool bReleaseLockStream )
2710
{
2945
{
2711
    if ( pImp->m_xLockingStream.is() )
2946
    //->i126305
2947
    //check if the file is local
2948
    if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
2712
    {
2949
    {
2713
        if ( bReleaseLockStream )
2950
    //<-i126305
2951
        if ( pImp->m_xLockingStream.is() )
2952
        {
2953
            if ( bReleaseLockStream )
2954
            {
2955
                try
2956
                {
2957
                    uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
2958
                    uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
2959
                    if ( xInStream.is() )
2960
                        xInStream->closeInput();
2961
                    if ( xOutStream.is() )
2962
                        xOutStream->closeOutput();
2963
                }
2964
                catch( uno::Exception& )
2965
                {}
2966
            }
2967
2968
            pImp->m_xLockingStream = uno::Reference< io::XStream >();
2969
        }
2970
2971
        if ( pImp->m_bLocked )
2714
        {
2972
        {
2715
            try
2973
            try
2716
            {
2974
            {
2717
                uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
2975
                pImp->m_bLocked = sal_False;
2718
                uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
2976
                ::svt::DocumentLockFile aLockFile( aLogicName );
2719
                if ( xInStream.is() )
2977
                // TODO/LATER: A warning could be shown in case the file is not the own one
2720
                    xInStream->closeInput();
2978
                aLockFile.RemoveFile();
2721
                if ( xOutStream.is() )
2722
                    xOutStream->closeOutput();
2723
            }
2979
            }
2724
            catch( uno::Exception& )
2980
            catch( uno::Exception& )
2725
            {}
2981
            {}
2726
        }
2982
        }
2727
2983
    //->i126305
2728
        pImp->m_xLockingStream = uno::Reference< io::XStream >();
2729
    }
2984
    }
2730
2985
    else
2731
    if ( pImp->m_bLocked )
2732
    {
2986
    {
2733
        try
2987
        //not local, check if webdav
2988
        ::rtl::OUString aScheme =  INetURLObject::GetScheme(GetURLObject().GetProtocol());
2989
        if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
2990
            aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
2734
        {
2991
        {
2735
            pImp->m_bLocked = sal_False;
2992
            if ( pImp->m_bLocked )
2736
            ::svt::DocumentLockFile aLockFile( aLogicName );
2993
            {
2737
            // TODO/LATER: A warning could be shown in case the file is not the own one
2994
                // an interaction handler should be used for authentication
2738
            aLockFile.RemoveFile();
2995
                try {
2996
                    Reference< ::com::sun::star::task::XInteractionHandler > xHandler = GetAuthenticationInteractionHandler();
2997
                    Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
2998
                    xComEnv = new ::ucbhelper::CommandEnvironment( xHandler,
2999
                                                                   Reference< ::com::sun::star::ucb::XProgressHandler >() );
3000
                    ::ucbhelper::Content aContentToUnlock( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv);
3001
                    pImp->m_bLocked = sal_False;
3002
                    aContentToUnlock.unlock();
3003
                }
3004
                catch (ucb::InteractiveNetworkReadException& e)
3005
                {
3006
                    //signalled when this resource can not be unlocked, for whatever reason
3007
                }
3008
                catch( uno::Exception& )
3009
                {}
3010
            }
2739
        }
3011
        }
2740
        catch( uno::Exception& )
2741
        {}
2742
    }
3012
    }
3013
    //<-i126305
2743
}
3014
}
2744
3015
2745
void SfxMedium::CloseAndReleaseStreams_Impl()
3016
void SfxMedium::CloseAndReleaseStreams_Impl()
(-)a/main/sfx2/source/view/viewfrm.cxx (-33 / +66 lines)
Lines 303-309 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
303
    SfxFrame *pParent = GetFrame().GetParentFrame();
303
    SfxFrame *pParent = GetFrame().GetParentFrame();
304
	if ( rReq.GetSlot() == SID_RELOAD )
304
	if ( rReq.GetSlot() == SID_RELOAD )
305
	{
305
	{
306
        // Bei CTRL-Reload den aktiven Frame reloaden
306
        // With CTRL-Reload reload the active frame
307
        SfxViewFrame* pActFrame = this;
307
        SfxViewFrame* pActFrame = this;
308
        while ( pActFrame )
308
        while ( pActFrame )
309
            pActFrame = pActFrame->GetActiveChildFrame_Impl();
309
            pActFrame = pActFrame->GetActiveChildFrame_Impl();
Lines 318-325 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
318
            }
318
            }
319
        }
319
        }
320
320
321
		// Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames
321
        // If only reloading of the graphs or more child frames
322
		// gemacht werden soll
322
        // is needed
323
		SfxFrame& rFrame = GetFrame();
323
		SfxFrame& rFrame = GetFrame();
324
		if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
324
		if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
325
		{
325
		{
Lines 338-353 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
338
				pChild = pNext;
338
				pChild = pNext;
339
			}
339
			}
340
340
341
			// Der TopLevel-Frame selbst het keine Graphiken!
341
			// The TopLevel frame itself had no graphics
342
			if ( bReloadAvailable )
342
			if ( bReloadAvailable )
343
				return;
343
				return;
344
		}
344
		}
345
    }
345
    }
346
    else
346
    else
347
    {
347
    {
348
        // Bei CTRL-Edit den TopFrame bearbeiten
348
        // With CTRL-Edit edit the top frame
349
        sal_uInt16 nModifier = rReq.GetModifier();
349
        sal_uInt16 nModifier = rReq.GetModifier();
350
350
        //KEY_MOD1 is the Ctrl modifier key
351
        if ( ( nModifier & KEY_MOD1 ) && pParent )
351
        if ( ( nModifier & KEY_MOD1 ) && pParent )
352
        {
352
        {
353
            SfxViewFrame *pTop = GetTopViewFrame();
353
            SfxViewFrame *pTop = GetTopViewFrame();
Lines 364-372 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
364
			if ( GetFrame().HasComponent() )
364
			if ( GetFrame().HasComponent() )
365
				break;
365
				break;
366
366
367
            // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
367
            // Because of double functioning of the toolbox button (with/without Ctrl)
368
            // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
368
            // it's possible that the slot is enabled, but Ctrl-click is not.
369
            // trotzdem nicht geht!
370
            if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ))
369
            if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ))
371
                break;
370
                break;
372
371
Lines 446-456 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
446
                    return;
445
                    return;
447
			}
446
			}
448
447
449
			// Parameter auswerten
448
			// Evaluate parameters
450
            // sal_Bool bReload = sal_True;
449
            // sal_Bool bReload = sal_True;
451
			if ( rReq.IsAPI() )
450
			if ( rReq.IsAPI() )
452
			{
451
			{
453
				// per API steuern ob r/w oder r/o
452
				// Control through API if r/w or r/o
454
            	SFX_REQUEST_ARG(rReq, pEditItem, SfxBoolItem, SID_EDITDOC, sal_False);
453
            	SFX_REQUEST_ARG(rReq, pEditItem, SfxBoolItem, SID_EDITDOC, sal_False);
455
				if ( pEditItem )
454
				if ( pEditItem )
456
					nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
455
					nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
Lines 466-478 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
466
465
467
            INetURLObject aMedObj( pMed->GetName() );
466
            INetURLObject aMedObj( pMed->GetName() );
468
467
469
            // the logic below is following, if the document seems not to need to be reloaded and the physical name is different
468
            // -> i126305
470
            // 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
469
            // the logic below is following:
471
            if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE &&
470
            // if the document seems not to need to be reloaded
472
                    aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
471
            //     and the physical name is different to the logical one,
473
                    !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) ))
472
            // then on file system it can be checked that the copy is still newer than the original and no document reload is required.
474
                  || pMed->IsRemote() ) )
473
            // some semplification to enhance readability of the 'if' expression
475
               || pVersionItem )
474
            // 
475
            // on the 'http/https' protocol case, the bool bPhysObjIsYounger relies upon the getlastmodified Property of a WebDAV resource.
476
            // Said property should be implemented, but sometimes it's not. This happens on some small webdav servers, where it's not
477
            // implemented. On this case the reload will not work properly.
478
            // Details at this link: http://tools.ietf.org/html/rfc4918#section-15, section 15.7
479
            // TODO: add an indication to the user? Difficult to implement I think.
480
            sal_Bool bPhysObjIsYounger = ::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) );
481
            sal_Bool bIsHttpOrHttps = (aMedObj.GetProtocol() == INET_PROT_HTTP || aMedObj.GetProtocol() == INET_PROT_HTTPS);
482
            if ( ( !bNeedsReload && ( ( aMedObj.GetProtocol() == INET_PROT_FILE &&
483
                                        aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
484
                                        !bPhysObjIsYounger )
485
                                      || ( bIsHttpOrHttps && !bPhysObjIsYounger )
486
                                      || ( pMed->IsRemote() && !bIsHttpOrHttps ) ) )
487
                 || pVersionItem )
488
            // <- i126305
476
            {
489
            {
477
                sal_Bool bOK = sal_False;
490
                sal_Bool bOK = sal_False;
478
                if ( !pVersionItem )
491
                if ( !pVersionItem )
Lines 514-526 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
514
                        pSh->DoSaveCompleted( pMed );
527
                        pSh->DoSaveCompleted( pMed );
515
                    }
528
                    }
516
529
517
                    // r/o-Doc kann nicht in Editmode geschaltet werden?
530
                    // r/o-Doc can not be switched to edit mode?
518
                    rReq.Done( sal_False );
531
                    rReq.Done( sal_False );
519
532
520
                    if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
533
                    if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
521
                    {
534
                    {
522
                        // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen
535
                        // ::com::sun::star::sdbcx::User ask to open as template (a copy of the document)
523
                        QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
536
                        QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
537
                        // this is the querybox that is opened when the file is asked to move from r/o to edit using the button
538
                        // on the toolbar
524
                        if ( RET_YES == aBox.Execute() )
539
                        if ( RET_YES == aBox.Execute() )
525
                        {
540
                        {
526
                            SfxApplication* pApp = SFX_APP();
541
                            SfxApplication* pApp = SFX_APP();
Lines 572-580 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
572
587
573
        case SID_RELOAD:
588
        case SID_RELOAD:
574
        {
589
        {
575
            // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
590
            // Because of double functioning of the toolbox button (with/without Ctrl)
576
            // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
591
            // it's possible that the slot is enabled, but Ctrl-click is not.
577
            // trotzdem nicht geht!
578
            if ( !pSh || !pSh->CanReload_Impl() )
592
            if ( !pSh || !pSh->CanReload_Impl() )
579
                break;
593
                break;
580
            SfxApplication* pApp = SFX_APP();
594
            SfxApplication* pApp = SFX_APP();
Lines 596-607 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
596
            pImp->bReloading = sal_True;
610
            pImp->bReloading = sal_True;
597
            SFX_REQUEST_ARG(rReq, pURLItem, SfxStringItem,
611
            SFX_REQUEST_ARG(rReq, pURLItem, SfxStringItem,
598
                            SID_FILE_NAME, sal_False);
612
                            SID_FILE_NAME, sal_False);
599
            // editierbar "offnen?
613
            // open to edit?
600
            sal_Bool bForEdit = !pSh->IsReadOnly();
614
            sal_Bool bForEdit = !pSh->IsReadOnly();
601
            if ( rReq.GetSlot() == SID_EDITDOC )
615
            if ( rReq.GetSlot() == SID_EDITDOC )
602
                bForEdit = !bForEdit;
616
                bForEdit = !bForEdit;
603
617
604
            // ggf. beim User nachfragen
618
            // if necessary ask the user
605
            sal_Bool bDo = ( GetViewShell()->PrepareClose() != sal_False );
619
            sal_Bool bDo = ( GetViewShell()->PrepareClose() != sal_False );
606
            SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
620
            SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
607
            if ( bDo && GetFrame().DocIsModified_Impl() &&
621
            if ( bDo && GetFrame().DocIsModified_Impl() &&
Lines 615-629 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
615
            {
629
            {
616
                SfxMedium *pMedium = xOldObj->GetMedium();
630
                SfxMedium *pMedium = xOldObj->GetMedium();
617
631
618
				// Frameset abziehen, bevor FramesetView evtl. verschwindet
632
				//Pull frameset before FramesetView possibly disappear
619
				String aURL = pURLItem ? pURLItem->GetValue() :
633
				String aURL = pURLItem ? pURLItem->GetValue() :
620
								pMedium->GetName();
634
								pMedium->GetName();
621
635
622
                sal_Bool bHandsOff =
636
                sal_Bool bHandsOff =
623
                    ( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
637
                    ( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
624
638
625
                // bestehende SfxMDIFrames f"ur dieses Doc leeren
639
                // empty existing SfxMDIFrames of this Doc
626
                // eigenes Format oder R/O jetzt editierbar "offnen?
640
                // own format or R/O is now open editable?
627
                SfxObjectShellLock xNewObj;
641
                SfxObjectShellLock xNewObj;
628
642
629
                // collect the views of the document
643
                // collect the views of the document
Lines 704-710 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
704
718
705
                xOldObj->CancelTransfers();
719
                xOldObj->CancelTransfers();
706
720
707
                // eigentliches Reload
721
                //actual reload
708
                //pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) );
722
                //pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) );
709
723
710
                if ( pSilentItem && pSilentItem->GetValue() )
724
                if ( pSilentItem && pSilentItem->GetValue() )
Lines 727-734 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
727
		            pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
741
		            pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
728
742
729
				xOldObj->SetModified( sal_False );
743
				xOldObj->SetModified( sal_False );
730
                // Altes Dok nicht cachen! Gilt nicht, wenn anderes
744
                // Old Doc not cached! Does not apply if another Doc is loaded.
731
				// Doc geladen wird.
732
745
733
                SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
746
                SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
734
                SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
747
                SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
Lines 760-765 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
760
                }
773
                }
761
                catch ( uno::Exception& )
774
                catch ( uno::Exception& )
762
                {
775
                {
776
                    //->i126305 OBSERVATION
777
                    // When this exception is thrown the r/o refresh of a file locked by another user
778
                    // is not completed.
779
                    // Code flow arrives here with a 'com.sun.star.task.ErrorCodeIOException'.
780
                    // It's thrown at around line 1970 of main/sfx2/source/doc/sfxbasemodel.cxx,
781
                    // in method 'SfxBaseModel::load'.
782
                    // Because of this exception, the document is not reloaded when it should be.
783
                    // The error generating the exception is 1287, or ERRCODE_IO_ACCESSDENIED.
784
                    // It seems that the reason for this is the way the property PROP_READONLY seems used
785
                    // in MediaDescriptor: both as property of the media and a request from GUI.
786
                    // See main/comphelper/source/misc/mediadescriptor.cxx around line 755, where the behavior
787
                    // leading to the error originates in the code flow.
788
                    // This problem doesn't arise in WebDAV, since the stream is monodirectional (read or write) in UCB implementation.
789
                    //<-i126305
790
                    //->i126305 WORKAROUND
791
                    // Code flow needs to reset the reloading, since it will no longer take part in the following code.
792
                    // This specific flag, if not reset, will break the code flow on the next call of this method,
793
                    // when it appears that the toolbar button stops functioning.
794
                    pImp->bReloading = sal_False;
795
                    //<-i126305
763
                    xNewObj->DoClose();
796
                    xNewObj->DoClose();
764
                    xNewObj = 0;
797
                    xNewObj = 0;
765
                }
798
                }
Lines 857-870 void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) Link Here
857
                    SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
890
                    SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
858
                }
891
                }
859
892
860
                // als erledigt recorden
893
                // register as done
861
                rReq.Done( sal_True );
894
                rReq.Done( sal_True );
862
                rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
895
                rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
863
                return;
896
                return;
864
            }
897
            }
865
            else
898
            else
866
            {
899
            {
867
                // als nicht erledigt recorden
900
                // register as not done
868
                rReq.Done();
901
                rReq.Done();
869
                rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_False));
902
                rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_False));
870
                pImp->bReloading = sal_False;
903
                pImp->bReloading = sal_False;
(-)a/main/ucb/source/ucp/webdav/DAVException.hxx (+25 lines)
Lines 138-155 class DAVException Link Here
138
    private:
138
    private:
139
        ExceptionCode   mExceptionCode;
139
        ExceptionCode   mExceptionCode;
140
        rtl::OUString   mData;
140
        rtl::OUString   mData;
141
    //owner of the lock in case of DAV_LOCKED
142
        rtl::OUString   mOwner;
143
    //extendend error information, if the server has a specific header
144
    //see in SerfRequestProcessor::handleSerfResponse for detail on how this is obtained
145
        rtl::OUString   mExtendedError;
141
        sal_uInt16      mStatusCode;
146
        sal_uInt16      mStatusCode;
142
147
143
    public:
148
    public:
144
         DAVException( ExceptionCode inExceptionCode ) 
149
         DAVException( ExceptionCode inExceptionCode ) 
145
             : mExceptionCode( inExceptionCode )
150
             : mExceptionCode( inExceptionCode )
146
             , mData()
151
             , mData()
152
             , mOwner()
153
             , mExtendedError()
147
             , mStatusCode( SC_NONE )
154
             , mStatusCode( SC_NONE )
148
         {};
155
         {};
149
         DAVException( ExceptionCode inExceptionCode,
156
         DAVException( ExceptionCode inExceptionCode,
150
                       const rtl::OUString & rData ) 
157
                       const rtl::OUString & rData ) 
151
             : mExceptionCode( inExceptionCode )
158
             : mExceptionCode( inExceptionCode )
152
             , mData( rData )
159
             , mData( rData )
160
             , mOwner()
161
             , mExtendedError()
153
             , mStatusCode( SC_NONE )
162
             , mStatusCode( SC_NONE )
154
         {};
163
         {};
155
         DAVException( ExceptionCode inExceptionCode,
164
         DAVException( ExceptionCode inExceptionCode,
Lines 157-169 class DAVException Link Here
157
                       sal_uInt16 nStatusCode )
166
                       sal_uInt16 nStatusCode )
158
            : mExceptionCode( inExceptionCode )
167
            : mExceptionCode( inExceptionCode )
159
            , mData( rData )
168
            , mData( rData )
169
            , mOwner()
170
            , mExtendedError()
171
            , mStatusCode( nStatusCode )
172
         {};
173
         DAVException( ExceptionCode inExceptionCode,
174
                       const rtl::OUString & rData,
175
                       const rtl::OUString & rExtendedError,
176
                       sal_uInt16 nStatusCode = SC_NONE )
177
            : mExceptionCode( inExceptionCode )
178
            , mData( rData )
179
            , mOwner()
180
            , mExtendedError( rExtendedError )
160
            , mStatusCode( nStatusCode )
181
            , mStatusCode( nStatusCode )
161
         {};
182
         {};
162
        ~DAVException( ) {};
183
        ~DAVException( ) {};
163
184
164
    const ExceptionCode & getError() const { return mExceptionCode; }
185
    const ExceptionCode & getError() const { return mExceptionCode; }
165
    const rtl::OUString & getData() const  { return mData; }
186
    const rtl::OUString & getData() const  { return mData; }
187
    const rtl::OUString & getExtendedError() const { return  mExtendedError; }
166
    sal_uInt16 getStatus() const { return mStatusCode; }
188
    sal_uInt16 getStatus() const { return mStatusCode; }
189
    const rtl::OUString & getOwner() const { return mOwner; }
190
    void setOwner(const rtl::OUString & rOwner) { mOwner = rOwner; }
191
167
};
192
};
168
193
169
} // namespace http_dav_ucp
194
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx (-1 / +1 lines)
Lines 203-209 public: Link Here
203
    void
203
    void
204
    LOCK( com::sun::star::ucb::Lock & inLock,
204
    LOCK( com::sun::star::ucb::Lock & inLock,
205
          const com::sun::star::uno::Reference<
205
          const com::sun::star::uno::Reference<
206
              com::sun::star::ucb::XCommandEnvironment > & xEnv )
206
          com::sun::star::ucb::XCommandEnvironment > & xEnv )
207
        throw( DAVException );
207
        throw( DAVException );
208
208
209
#if 0 // currently not used, but please don't remove code
209
#if 0 // currently not used, but please don't remove code
(-)a/main/ucb/source/ucp/webdav/DAVTypes.hxx (+2 lines)
Lines 76-81 struct ProppatchValue Link Here
76
	: operation( o ), name( n ), value( v ) {}
76
	: operation( o ), name( n ), value( v ) {}
77
};
77
};
78
78
79
enum LockScope { EXCLUSIVE = 0, SHARED = 1 };
80
79
} // namespace http_dav_ucp
81
} // namespace http_dav_ucp
80
82
81
#endif // _DAVTYPES_HXX_
83
#endif // _DAVTYPES_HXX_
(-)a/main/ucb/source/ucp/webdav/SerfCallbacks.cxx (+6 lines)
Lines 36-41 extern "C" apr_status_t Serf_ConnectSetup( apr_socket_t *skt, Link Here
36
                                           apr_pool_t *pool )
36
                                           apr_pool_t *pool )
37
{
37
{
38
    SerfSession* pSerfSession = static_cast< SerfSession* >( setup_baton );
38
    SerfSession* pSerfSession = static_cast< SerfSession* >( setup_baton );
39
    OSL_TRACE("Serf_ConnectSetup");
39
    return pSerfSession->setupSerfConnection( skt,
40
    return pSerfSession->setupSerfConnection( skt,
40
                                              read_bkt,
41
                                              read_bkt,
41
                                              write_bkt,
42
                                              write_bkt,
Lines 52-57 extern "C" apr_status_t Serf_Credentials( char **username, Link Here
52
                                          apr_pool_t *pool )
53
                                          apr_pool_t *pool )
53
{
54
{
54
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( baton );
55
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( baton );
56
    OSL_TRACE("Serf_Credential");
55
    return pReqProc->provideSerfCredentials( username, 
57
    return pReqProc->provideSerfCredentials( username, 
56
                                             password,
58
                                             password,
57
                                             request,
59
                                             request,
Lines 68-73 extern "C" apr_status_t Serf_CertificateChainValidation( Link Here
68
    const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded,
70
    const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded,
69
    apr_size_t nCertificateChainLength)
71
    apr_size_t nCertificateChainLength)
70
{
72
{
73
    OSL_TRACE("Serf_CertificateChainValidation");
71
    return static_cast<SerfSession*>(pSerfSession)
74
    return static_cast<SerfSession*>(pSerfSession)
72
        ->verifySerfCertificateChain(nFailures, pCertificateChainBase64Encoded, nCertificateChainLength);
75
        ->verifySerfCertificateChain(nFailures, pCertificateChainBase64Encoded, nCertificateChainLength);
73
}
76
}
Lines 82-87 extern "C" apr_status_t Serf_SetupRequest( serf_request_t *request, Link Here
82
                                           apr_pool_t * pool )
85
                                           apr_pool_t * pool )
83
{
86
{
84
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( setup_baton );
87
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( setup_baton );
88
    OSL_TRACE("Serf_SetupRequest");
85
    return pReqProc->setupSerfRequest( request, 
89
    return pReqProc->setupSerfRequest( request, 
86
                                       req_bkt,
90
                                       req_bkt,
87
                                       acceptor,
91
                                       acceptor,
Lines 97-102 extern "C" serf_bucket_t* Serf_AcceptResponse( serf_request_t *request, Link Here
97
                                               apr_pool_t *pool )
101
                                               apr_pool_t *pool )
98
{
102
{
99
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( acceptor_baton );
103
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( acceptor_baton );
104
    OSL_TRACE("Serf_AcceptResponse");
100
    return pReqProc->acceptSerfResponse( request,
105
    return pReqProc->acceptSerfResponse( request,
101
                                         stream,
106
                                         stream,
102
                                         pool );
107
                                         pool );
Lines 108-113 extern "C" apr_status_t Serf_HandleResponse( serf_request_t *request, Link Here
108
                                             apr_pool_t *pool )
113
                                             apr_pool_t *pool )
109
{
114
{
110
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( handler_baton );
115
    SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( handler_baton );
116
    OSL_TRACE("Serf_HandleResponse");
111
    return pReqProc->handleSerfResponse( request,
117
    return pReqProc->handleSerfResponse( request,
112
                                         response,
118
                                         response,
113
                                         pool );
119
                                         pool );
(-)a/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx (-1 / +7 lines)
Lines 32-41 namespace http_dav_ucp Link Here
32
SerfCopyReqProcImpl::SerfCopyReqProcImpl( const char* inSourcePath,
32
SerfCopyReqProcImpl::SerfCopyReqProcImpl( const char* inSourcePath,
33
                                          const DAVRequestHeaders& inRequestHeaders,
33
                                          const DAVRequestHeaders& inRequestHeaders,
34
                                          const char* inDestinationPath,
34
                                          const char* inDestinationPath,
35
                                          const bool inOverwrite )
35
                                          const bool inOverwrite,
36
                                          const char* inLockToken )
36
    : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
37
    : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
37
    , mDestPathStr( inDestinationPath )
38
    , mDestPathStr( inDestinationPath )
38
    , mbOverwrite( inOverwrite )
39
    , mbOverwrite( inOverwrite )
40
    , mpLockToken( inLockToken )
39
{
41
{
40
}
42
}
41
43
Lines 67-72 serf_bucket_t * SerfCopyReqProcImpl::createSerfRequestBucket( serf_request_t * i Link Here
67
    {
69
    {
68
        serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
70
        serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
69
    }
71
    }
72
    if(mpLockToken)
73
    {
74
        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
75
    }
70
76
71
    return req_bkt;
77
    return req_bkt;
72
}
78
}
(-)a/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx (-1 / +3 lines)
Lines 33-39 public: Link Here
33
    SerfCopyReqProcImpl( const char* inSourcePath,
33
    SerfCopyReqProcImpl( const char* inSourcePath,
34
                         const DAVRequestHeaders& inRequestHeaders,
34
                         const DAVRequestHeaders& inRequestHeaders,
35
                         const char* inDestinationPath,
35
                         const char* inDestinationPath,
36
                         const bool inOverwrite );
36
                         const bool inOverwrite,
37
                         const char*  inLockToken );
37
38
38
    virtual ~SerfCopyReqProcImpl();
39
    virtual ~SerfCopyReqProcImpl();
39
40
Lines 50-55 protected: Link Here
50
private:
51
private:
51
    const char* mDestPathStr;
52
    const char* mDestPathStr;
52
    const bool mbOverwrite;
53
    const bool mbOverwrite;
54
    const char* mpLockToken;
53
};
55
};
54
56
55
} // namespace http_dav_ucp
57
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx (-1 / +8 lines)
Lines 30-37 namespace http_dav_ucp Link Here
30
{
30
{
31
31
32
SerfDeleteReqProcImpl::SerfDeleteReqProcImpl( const char* inPath,
32
SerfDeleteReqProcImpl::SerfDeleteReqProcImpl( const char* inPath,
33
                                              const DAVRequestHeaders& inRequestHeaders )
33
                                              const DAVRequestHeaders& inRequestHeaders,
34
                                              const char* inLockToken )
34
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
35
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
36
    , mpLockToken( inLockToken )
35
{
37
{
36
}
38
}
37
39
Lines 52-57 serf_bucket_t * SerfDeleteReqProcImpl::createSerfRequestBucket( serf_request_t * Link Here
52
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
54
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
53
    // general header fields provided by caller
55
    // general header fields provided by caller
54
    setRequestHeaders( hdrs_bkt );
56
    setRequestHeaders( hdrs_bkt );
57
    // specific header field
58
    if(mpLockToken)
59
    {
60
        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
61
    }
55
62
56
    return req_bkt;
63
    return req_bkt;
57
}
64
}
(-)a/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx (-1 / +4 lines)
Lines 29-37 namespace http_dav_ucp Link Here
29
29
30
class SerfDeleteReqProcImpl : public SerfRequestProcessorImpl
30
class SerfDeleteReqProcImpl : public SerfRequestProcessorImpl
31
{
31
{
32
private:
33
    const char* mpLockToken;
32
public:
34
public:
33
    SerfDeleteReqProcImpl( const char* inPath,
35
    SerfDeleteReqProcImpl( const char* inPath,
34
                           const DAVRequestHeaders& inRequestHeaders );
36
                           const DAVRequestHeaders& inRequestHeaders,
37
                           const char* inLockRToken );
35
38
36
    virtual ~SerfDeleteReqProcImpl();
39
    virtual ~SerfDeleteReqProcImpl();
37
40
(-)a/main/ucb/source/ucp/webdav/SerfLockRefreshProcImpl.cxx (+80 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
// MARKER(update_precomp.py): autogen include statement, do not remove
23
#include "precompiled_ucb.hxx"
24
25
#include "SerfTypes.hxx"
26
#include "SerfLockRefreshProcImpl.hxx"
27
#include "DAVProperties.hxx"
28
29
#include "webdavresponseparser.hxx"
30
#include <serf/serf.h>
31
#include <rtl/ustrbuf.hxx>
32
#include <apr/apr_strings.h>
33
34
namespace http_dav_ucp
35
{
36
37
SerfLockRefreshProcImpl::SerfLockRefreshProcImpl( const char* inSourcePath,
38
                                                  const DAVRequestHeaders& inRequestHeaders, // on debug the header look empty
39
                                                  const ucb::Lock& inLock,
40
                                                  const char* inLockToken,
41
                                                  const char* inTimeout,
42
                                          DAVPropertyValue & outLock)
43
    : SerfLockReqProcImpl( inSourcePath, inRequestHeaders, inLock, inTimeout, outLock )
44
    , mpLockToken( inLockToken )
45
{
46
}
47
48
SerfLockRefreshProcImpl::~SerfLockRefreshProcImpl()
49
{
50
}
51
52
serf_bucket_t * SerfLockRefreshProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
53
{
54
    // create serf request
55
    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
56
                                                                 "LOCK",
57
                                                                 getPathStr(),
58
                                                                 0,
59
                                                                 serf_request_get_alloc( inSerfRequest ) );
60
    // set request header fields
61
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
62
    if (hdrs_bkt != NULL)
63
    {
64
        // general header fields provided by caller
65
        setRequestHeaders( hdrs_bkt );
66
67
        // request specific header fields
68
        if(mTimeout != 0)
69
        {
70
            serf_bucket_headers_set( hdrs_bkt, "Timeout", mTimeout );
71
        }
72
        if(mpLockToken != 0)
73
        {
74
            serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
75
        }
76
    }
77
    return req_bkt;
78
}
79
80
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/SerfLockRefreshProcImpl.hxx (+51 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
#ifndef INCLUDED_SERFLOCKREFRESHPROCIMPL_HXX
23
#define INCLUDED_SERFLOCKREFRESHPROCIMPL_HXX
24
25
#include "SerfLockReqProcImpl.hxx"
26
27
namespace http_dav_ucp
28
{
29
30
    class SerfLockRefreshProcImpl : public SerfLockReqProcImpl
31
    {
32
    protected:
33
        const char*         mpLockToken;
34
35
    public:
36
        SerfLockRefreshProcImpl( const char* inSourcePath,
37
                                 const DAVRequestHeaders& inRequestHeaders,
38
                                 const ucb::Lock& inLock,
39
                                 const char* inLockToken,
40
                                 const char* inTimeout,
41
                                 DAVPropertyValue & outLock);
42
43
        virtual ~SerfLockRefreshProcImpl();
44
45
        virtual
46
        serf_bucket_t * createSerfRequestBucket( serf_request_t * inSerfRequest );
47
    };
48
49
} // namespace http_dav_ucp
50
51
#endif // INCLUDED_SERFLOCKREFRESHPROCIMPL_HXX
(-)a/main/ucb/source/ucp/webdav/SerfLockReqProcImpl.cxx (+155 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
// MARKER(update_precomp.py): autogen include statement, do not remove
23
#include "precompiled_ucb.hxx"
24
25
#include "SerfTypes.hxx"
26
#include "SerfLockReqProcImpl.hxx"
27
#include "DAVProperties.hxx"
28
29
#include "webdavresponseparser.hxx"
30
#include <serf/serf.h>
31
#include <rtl/ustrbuf.hxx>
32
#include <apr/apr_strings.h>
33
34
namespace http_dav_ucp
35
{
36
37
SerfLockReqProcImpl::SerfLockReqProcImpl( const char* inSourcePath,
38
                                          const DAVRequestHeaders& inRequestHeaders, // on debug the header look empty
39
                                          const ucb::Lock& inLock,
40
                                          const char* inTimeout,
41
                                          DAVPropertyValue & outLock)
42
    : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
43
    , mLock( inLock )
44
    , mTimeout(inTimeout)
45
    , mLockObtained( &outLock )
46
    , xInputStream( new SerfInputStream() )
47
{
48
    switch ( inLock.Depth )
49
    {
50
        //i126305 TODO investigate on this case...
51
    case ucb::LockDepth_MAKE_FIXED_SIZE:
52
53
    case ucb::LockDepth_ZERO:
54
        mDepthStr = "0";
55
        break;
56
    case ucb::LockDepth_ONE:
57
            mDepthStr = "1";
58
            break;
59
    case ucb::LockDepth_INFINITY:
60
            mDepthStr = "infinity";
61
            break;
62
    }
63
64
    switch ( inLock.Scope )
65
    {
66
        //i126305 TODO investigate on this case...
67
    case ucb::LockScope_MAKE_FIXED_SIZE:
68
69
    case ucb::LockScope_EXCLUSIVE:
70
        mLockScope = "<lockscope><exclusive/></lockscope>";
71
        break;
72
    case ucb::LockScope_SHARED:
73
        mLockScope = "<lockscope><shared/></lockscope>";
74
        break;
75
    }
76
}
77
78
SerfLockReqProcImpl::~SerfLockReqProcImpl()
79
{
80
}
81
82
#define LOCK_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?><lockinfo xmlns=\"DAV:\">"
83
#define LOCK_TYPE "<locktype><write/></locktype>"
84
#define LOCK_TRAILER "</lockinfo>"
85
86
serf_bucket_t * SerfLockReqProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
87
{
88
  //prepare body of request:
89
    serf_bucket_alloc_t* pSerfBucketAlloc = serf_request_get_alloc( inSerfRequest );
90
    serf_bucket_t* body_bkt = 0;
91
    rtl::OString aBodyText;
92
    {
93
       rtl::OUStringBuffer aBuffer;
94
        aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_HEADER ));
95
        aBuffer.appendAscii( mLockScope );
96
        aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_TYPE ));
97
        aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<owner>" ));
98
        rtl::OUString aStr;
99
        mLock.Owner >>= aStr;
100
        aBuffer.appendAscii( rtl::OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 ).getStr() );
101
        aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</owner>" ));
102
        aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_TRAILER ));
103
        aBodyText = rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
104
        body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(),
105
                                                   aBodyText.getLength(),
106
                                                   pSerfBucketAlloc );
107
    }
108
109
    // create serf request
110
    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
111
                                                                 "LOCK",
112
                                                                 getPathStr(),
113
                                                                 body_bkt,
114
                                                                 pSerfBucketAlloc );
115
    handleChunkedEncoding(req_bkt, aBodyText.getLength());
116
117
    // set request header fields
118
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
119
    if (hdrs_bkt != NULL)
120
    {
121
        // general header fields provided by caller
122
        setRequestHeaders( hdrs_bkt );
123
124
        // request specific header fields
125
        serf_bucket_headers_set( hdrs_bkt, "Timeout", mTimeout );
126
        serf_bucket_headers_set( hdrs_bkt, "Depth", mDepthStr );
127
        if (hdrs_bkt!=NULL && body_bkt != 0 && aBodyText.getLength() > 0 )
128
        {
129
            serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
130
        }
131
    }
132
    else
133
    {
134
        OSL_ASSERT("Headers Bucket missing");
135
    }
136
137
    return req_bkt;
138
}
139
140
void SerfLockReqProcImpl::processChunkOfResponseData( const char* data,
141
                                                      apr_size_t len )
142
{
143
    if ( xInputStream.is() )
144
    {
145
        xInputStream->AddToStream( data, len );
146
    }
147
}
148
149
void SerfLockReqProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ )
150
{
151
    const DAVPropertyValue rLocksValue( parseWebDAVLockResponse( xInputStream.get() ) );
152
    *mLockObtained = rLocksValue;
153
}
154
155
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/SerfLockReqProcImpl.hxx (+74 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
#ifndef INCLUDED_SERFLOCKREQPROCIMPL_HXX
23
#define INCLUDED_SERFLOCKREQPROCIMPL_HXX
24
25
#include "SerfTypes.hxx"
26
#include "SerfRequestProcessorImpl.hxx"
27
28
#include "SerfInputStream.hxx"
29
30
#include <vector>
31
#include <rtl/ustring.hxx>
32
#include "SerfTypes.hxx"
33
#include "DAVTypes.hxx"
34
#include "DAVResource.hxx"
35
36
namespace http_dav_ucp
37
{
38
39
    class SerfLockReqProcImpl : public SerfRequestProcessorImpl
40
    {
41
42
    protected:
43
        std::vector< DAVResource > mpResources;
44
        const ucb::Lock     mLock;
45
        const char*         mDepthStr;
46
        const char*         mLockScope;
47
        const char*         mTimeout;
48
        DAVPropertyValue*   mLockObtained;
49
        com::sun::star::uno::Reference< SerfInputStream > xInputStream;
50
51
    public:
52
        SerfLockReqProcImpl( const char* inSourcePath,
53
                             const DAVRequestHeaders& inRequestHeaders,
54
                             const ucb::Lock& inLock,
55
                             const char* inTimeout,
56
                             DAVPropertyValue & outLock);
57
58
        virtual ~SerfLockReqProcImpl();
59
60
        virtual
61
        serf_bucket_t * createSerfRequestBucket( serf_request_t * inSerfRequest );
62
63
    protected:
64
        virtual
65
        void processChunkOfResponseData( const char* data, apr_size_t len );
66
67
        virtual
68
        void handleEndOfResponseData( serf_bucket_t * inSerfResponseBucket );
69
70
    };
71
72
} // namespace http_dav_ucp
73
74
#endif // INCLUDED_SERFLOCKREQPROCIMPL_HXX
(-)a/main/ucb/source/ucp/webdav/SerfLockStore.cxx (-31 / +77 lines)
Lines 24-34 Link Here
24
// MARKER(update_precomp.py): autogen include statement, do not remove
24
// MARKER(update_precomp.py): autogen include statement, do not remove
25
#include "precompiled_ucb.hxx"
25
#include "precompiled_ucb.hxx"
26
26
27
#include <ne_locks.h>
28
#include <ne_uri.h>
29
#include <rtl/ustring.hxx>
27
#include <rtl/ustring.hxx>
30
#include <osl/time.h>
28
#include <osl/time.h>
31
#include <osl/thread.hxx>
29
#include <osl/thread.hxx>
30
#include "SerfTypes.hxx"
32
#include "SerfSession.hxx"
31
#include "SerfSession.hxx"
33
#include "SerfLockStore.hxx"
32
#include "SerfLockStore.hxx"
34
33
Lines 58-64 protected: Link Here
58
// -------------------------------------------------------------------
57
// -------------------------------------------------------------------
59
void TickerThread::run()
58
void TickerThread::run()
60
{
59
{
61
    OSL_TRACE( "TickerThread: start." );
60
    OSL_TRACE( "TickerThread::run: start." );
62
61
63
    // we have to go through the loop more often to be able to finish ~quickly
62
    // we have to go through the loop more often to be able to finish ~quickly
64
    const int nNth = 25;
63
    const int nNth = 25;
Lines 83-92 void TickerThread::run() Link Here
83
82
84
// -------------------------------------------------------------------
83
// -------------------------------------------------------------------
85
SerfLockStore::SerfLockStore()
84
SerfLockStore::SerfLockStore()
86
    : m_pSerfLockStore( ne_lockstore_create() ),
85
    : m_pTickerThread( 0 )
87
      m_pTickerThread( 0 )
88
{
86
{
89
    OSL_ENSURE( m_pSerfLockStore, "Unable to create neon lock store!" );
90
}
87
}
91
88
92
// -------------------------------------------------------------------
89
// -------------------------------------------------------------------
Lines 103-117 SerfLockStore::~SerfLockStore() Link Here
103
    while ( it != end )
100
    while ( it != end )
104
    {
101
    {
105
        SerfLock * pLock = (*it).first;
102
        SerfLock * pLock = (*it).first;
106
        (*it).second.xSession->UNLOCK( pLock );
103
        try
107
104
        {
108
        ne_lockstore_remove( m_pSerfLockStore, pLock );
105
            (*it).second.xSession->UNLOCK( pLock );
109
        ne_lock_destroy( pLock );
106
            (*it).second.xSession->release();
110
107
        }
108
        catch (DAVException & )
109
        {}
111
        ++it;
110
        ++it;
112
    }
111
    }
113
114
    ne_lockstore_destroy( m_pSerfLockStore );
115
}
112
}
116
113
117
// -------------------------------------------------------------------
114
// -------------------------------------------------------------------
Lines 140-162 void SerfLockStore::stopTicker() Link Here
140
    }
137
    }
141
}
138
}
142
139
140
#if 0       //not currently used
143
// -------------------------------------------------------------------
141
// -------------------------------------------------------------------
144
void SerfLockStore::registerSession( HttpSession * pHttpSession )
142
void SerfLockStore::registerSession( SerfSession /* aSession */ )
145
{
143
{
146
    osl::MutexGuard aGuard( m_aMutex );
144
    osl::MutexGuard aGuard( m_aMutex );
147
145
148
    ne_lockstore_register( m_pSerfLockStore, pHttpSession );
149
}
146
}
147
#endif
150
148
151
// -------------------------------------------------------------------
149
// -------------------------------------------------------------------
152
SerfLock * SerfLockStore::findByUri( rtl::OUString const & rUri )
150
SerfLock * SerfLockStore::findByUri( rtl::OUString const & rUri)
153
{
151
{
154
    osl::MutexGuard aGuard( m_aMutex );
152
    osl::MutexGuard aGuard( m_aMutex );
155
153
156
    ne_uri aUri;
154
    LockInfoMap::const_iterator it( m_aLockInfoMap.begin() );
157
    ne_uri_parse( rtl::OUStringToOString(
155
    const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
158
        rUri, RTL_TEXTENCODING_UTF8 ).getStr(), &aUri );
156
159
    return ne_lockstore_findbyuri( m_pSerfLockStore, &aUri );
157
    while ( it != end )
158
    {
159
        SerfLock * pLock = (*it).first;
160
        if( pLock->getResourceUri().equals( rUri ) )
161
        {
162
            return pLock;
163
        }
164
        ++it;
165
    }
166
167
    return static_cast<SerfLock*>(0);
160
}
168
}
161
169
162
// -------------------------------------------------------------------
170
// -------------------------------------------------------------------
Lines 166-178 void SerfLockStore::addLock( SerfLock * pLock, Link Here
166
{
174
{
167
    osl::MutexGuard aGuard( m_aMutex );
175
    osl::MutexGuard aGuard( m_aMutex );
168
176
169
    ne_lockstore_add( m_pSerfLockStore, pLock );
170
    m_aLockInfoMap[ pLock ]
177
    m_aLockInfoMap[ pLock ]
171
        = LockInfo( xSession, nLastChanceToSendRefreshRequest );
178
        = LockInfo( xSession, nLastChanceToSendRefreshRequest );
172
179
    //acquire this session, needed to manage the lock refresh
180
    xSession->acquire();
181
182
#if OSL_DEBUG_LEVEL > 0
183
    rtl::OUString   aOwner;
184
    pLock->getLock().Owner >>= aOwner;
185
    rtl::OUString   aToken;
186
    aToken = pLock->getLock().LockTokens[0];
187
    OSL_TRACE("SerfLockStore::addLock: new lock added aOwner '%s', token '%s'",
188
              rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr(),
189
              rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
190
#endif
173
    startTicker();
191
    startTicker();
174
}
192
}
175
193
194
#if 0       //not currently used
176
// -------------------------------------------------------------------
195
// -------------------------------------------------------------------
177
void SerfLockStore::updateLock( SerfLock * pLock,
196
void SerfLockStore::updateLock( SerfLock * pLock,
178
                                sal_Int32 nLastChanceToSendRefreshRequest )
197
                                sal_Int32 nLastChanceToSendRefreshRequest )
Lines 189-205 void SerfLockStore::updateLock( SerfLock * pLock, Link Here
189
            = nLastChanceToSendRefreshRequest;
208
            = nLastChanceToSendRefreshRequest;
190
    }
209
    }
191
}
210
}
211
#endif
192
212
193
// -------------------------------------------------------------------
213
// -------------------------------------------------------------------
194
void SerfLockStore::removeLock( SerfLock * pLock )
214
void SerfLockStore::removeLock( SerfLock * pLock )
195
{
215
{
196
    osl::MutexGuard aGuard( m_aMutex );
216
    osl::MutexGuard aGuard( m_aMutex );
197
217
198
    m_aLockInfoMap.erase( pLock );
218
    LockInfoMap::iterator it( m_aLockInfoMap.find( pLock ) );
199
    ne_lockstore_remove( m_pSerfLockStore, pLock );
219
    if(it != m_aLockInfoMap.end())
200
220
    {
201
    if ( m_aLockInfoMap.size() == 0 )
221
        LockInfo & rInfo = (*it).second;
202
        stopTicker();
222
        rInfo.xSession->release();
223
        m_aLockInfoMap.erase( pLock );
224
        //the caller should deallocate SerfLock class after the call!
225
        if ( m_aLockInfoMap.size() == 0 )
226
            stopTicker();
227
    }
203
}
228
}
204
229
205
// -------------------------------------------------------------------
230
// -------------------------------------------------------------------
Lines 221-238 void SerfLockStore::refreshLocks() Link Here
221
                     <= sal_Int32( t1.Seconds ) )
246
                     <= sal_Int32( t1.Seconds ) )
222
            {
247
            {
223
                // refresh the lock.
248
                // refresh the lock.
249
#if OSL_DEBUG_LEVEL > 0
250
                ucb::Lock aLock = (*it).first->getLock();
251
                rtl::OUString   aOwner;
252
                aLock.Owner >>= aOwner;
253
                rtl::OUString   aToken;
254
                aToken = aLock.LockTokens[0];
255
                OSL_TRACE( "SerfLockStore::refreshLocks: refresh started for lock: aOwner '%s', token '%s'",
256
                    rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr(),
257
                    rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
258
#endif
224
                sal_Int32 nlastChanceToSendRefreshRequest = -1;
259
                sal_Int32 nlastChanceToSendRefreshRequest = -1;
225
                if ( rInfo.xSession->LOCK(
260
                try
226
                         (*it).first,
227
                         /* out param */ nlastChanceToSendRefreshRequest ) )
228
                {
261
                {
262
                    rInfo.xSession->LOCK( (*it).first,
263
                                          /* out param */ nlastChanceToSendRefreshRequest );
229
                    rInfo.nLastChanceToSendRefreshRequest
264
                    rInfo.nLastChanceToSendRefreshRequest
230
                        = nlastChanceToSendRefreshRequest;
265
                        = nlastChanceToSendRefreshRequest;
266
#if OSL_DEBUG_LEVEL > 0
267
                    OSL_TRACE( "Lock '%s' successfully refreshed." ,
268
                        rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
269
#endif
231
                }
270
                }
232
                else
271
                catch ( DAVException & e )
233
                {
272
                {
234
                    // refresh failed. stop auto-refresh.
273
                    // refresh failed. stop auto-refresh.
274
                    // TODO i126305 discuss:
275
                    // probably not a good idea to stop the refresh?
276
                    // may be just ignore and go on, it's possible the net is temporary down?
235
                    rInfo.nLastChanceToSendRefreshRequest = -1;
277
                    rInfo.nLastChanceToSendRefreshRequest = -1;
278
#if OSL_DEBUG_LEVEL > 0
279
                    OSL_TRACE( "SerfLockStore::refreshLocks: Lock '%s' not refreshed! (error: DAVException.mStatusCode %d)",
280
                         rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr(), e.getStatus()  );
281
#endif
236
                }
282
                }
237
            }
283
            }
238
        }
284
        }
(-)a/main/ucb/source/ucp/webdav/SerfLockStore.hxx (-4 / +4 lines)
Lines 27-32 Link Here
27
#include <osl/mutex.hxx>
27
#include <osl/mutex.hxx>
28
#include <rtl/ref.hxx>
28
#include <rtl/ref.hxx>
29
#include "SerfTypes.hxx"
29
#include "SerfTypes.hxx"
30
#include "SerfSession.hxx"
30
31
31
namespace http_dav_ucp
32
namespace http_dav_ucp
32
{
33
{
Lines 52-59 typedef struct _LockInfo Link Here
52
53
53
    _LockInfo( rtl::Reference< SerfSession > const & _xSession,
54
    _LockInfo( rtl::Reference< SerfSession > const & _xSession,
54
              sal_Int32 _nLastChanceToSendRefreshRequest )
55
              sal_Int32 _nLastChanceToSendRefreshRequest )
55
    : xSession( _xSession ),
56
        : xSession( _xSession )
56
      nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
57
        , nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
57
58
58
} LockInfo;
59
} LockInfo;
59
60
Lines 62-68 typedef std::map< SerfLock *, LockInfo, ltptr > LockInfoMap; Link Here
62
class SerfLockStore
63
class SerfLockStore
63
{
64
{
64
    osl::Mutex         m_aMutex;
65
    osl::Mutex         m_aMutex;
65
//    ne_lock_store    * m_pSerfLockStore;
66
    TickerThread     * m_pTickerThread;
66
    TickerThread     * m_pTickerThread;
67
    LockInfoMap        m_aLockInfoMap;
67
    LockInfoMap        m_aLockInfoMap;
68
68
Lines 70-76 public: Link Here
70
    SerfLockStore();
70
    SerfLockStore();
71
    ~SerfLockStore();
71
    ~SerfLockStore();
72
72
73
    void registerSession( HttpSession * pHttpSession );
73
    void registerSession( SerfSession aSession );
74
74
75
    SerfLock * findByUri( rtl::OUString const & rUri );
75
    SerfLock * findByUri( rtl::OUString const & rUri );
76
76
(-)a/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx (-1 / +3 lines)
Lines 30-37 namespace http_dav_ucp Link Here
30
{
30
{
31
31
32
SerfMkColReqProcImpl::SerfMkColReqProcImpl( const char* inPath,
32
SerfMkColReqProcImpl::SerfMkColReqProcImpl( const char* inPath,
33
                                            const DAVRequestHeaders& inRequestHeaders )
33
                                            const DAVRequestHeaders& inRequestHeaders,
34
                                            const char* inLockToken )
34
    : SerfRequestProcessorImpl( inPath,inRequestHeaders )
35
    : SerfRequestProcessorImpl( inPath,inRequestHeaders )
36
    , mpLockToken( inLockToken )
35
{
37
{
36
}
38
}
37
39
(-)a/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx (-1 / +4 lines)
Lines 29-37 namespace http_dav_ucp Link Here
29
29
30
class SerfMkColReqProcImpl : public SerfRequestProcessorImpl
30
class SerfMkColReqProcImpl : public SerfRequestProcessorImpl
31
{
31
{
32
private:
33
    const char* mpLockToken;
32
public:
34
public:
33
    SerfMkColReqProcImpl( const char* inPath,
35
    SerfMkColReqProcImpl( const char* inPath,
34
                          const DAVRequestHeaders& inRequestHeaders );
36
                          const DAVRequestHeaders& inRequestHeaders,
37
                          const char* inLockToken );
35
38
36
    virtual ~SerfMkColReqProcImpl();
39
    virtual ~SerfMkColReqProcImpl();
37
40
(-)a/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx (-1 / +7 lines)
Lines 32-41 namespace http_dav_ucp Link Here
32
SerfMoveReqProcImpl::SerfMoveReqProcImpl( const char* inSourcePath,
32
SerfMoveReqProcImpl::SerfMoveReqProcImpl( const char* inSourcePath,
33
                                          const DAVRequestHeaders& inRequestHeaders,
33
                                          const DAVRequestHeaders& inRequestHeaders,
34
                                          const char* inDestinationPath,
34
                                          const char* inDestinationPath,
35
                                          const bool inOverwrite )
35
                                          const bool inOverwrite,
36
                                          const char* inLockToken)
36
    : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
37
    : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
37
    , mDestPathStr( inDestinationPath )
38
    , mDestPathStr( inDestinationPath )
38
    , mbOverwrite( inOverwrite )
39
    , mbOverwrite( inOverwrite )
40
    , mpLockToken( inLockToken )
39
{
41
{
40
}
42
}
41
43
Lines 67-72 serf_bucket_t * SerfMoveReqProcImpl::createSerfRequestBucket( serf_request_t * i Link Here
67
    {
69
    {
68
        serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
70
        serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
69
    }
71
    }
72
    if(mpLockToken)
73
    {
74
        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
75
    }
70
76
71
    return req_bkt;
77
    return req_bkt;
72
}
78
}
(-)a/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx (-2 / +4 lines)
Lines 33-39 public: Link Here
33
    SerfMoveReqProcImpl( const char* inSourcePath,
33
    SerfMoveReqProcImpl( const char* inSourcePath,
34
                         const DAVRequestHeaders& inRequestHeaders,
34
                         const DAVRequestHeaders& inRequestHeaders,
35
                         const char* inDestinationPath,
35
                         const char* inDestinationPath,
36
                         const bool inOverwrite );
36
                         const bool inOverwrite,
37
                         const char* inLockToken );
37
38
38
    virtual ~SerfMoveReqProcImpl();
39
    virtual ~SerfMoveReqProcImpl();
39
40
Lines 49-55 protected: Link Here
49
50
50
private:
51
private:
51
    const char* mDestPathStr;
52
    const char* mDestPathStr;
52
    const bool mbOverwrite;
53
    const bool  mbOverwrite;
54
    const char* mpLockToken;
53
};
55
};
54
56
55
} // namespace http_dav_ucp
57
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx (+8 lines)
Lines 35-46 SerfPostReqProcImpl::SerfPostReqProcImpl( const char* inPath, Link Here
35
                                          const DAVRequestHeaders& inRequestHeaders,
35
                                          const DAVRequestHeaders& inRequestHeaders,
36
                                          const char* inData,
36
                                          const char* inData,
37
                                          apr_size_t inDataLen,
37
                                          apr_size_t inDataLen,
38
                                          const char* inLockToken,
38
                                          const char* inContentType,
39
                                          const char* inContentType,
39
                                          const char* inReferer,
40
                                          const char* inReferer,
40
                                          const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm )
41
                                          const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm )
41
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
42
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
42
    , mpPostData( inData )
43
    , mpPostData( inData )
43
    , mnPostDataLen( inDataLen )
44
    , mnPostDataLen( inDataLen )
45
    , mpLockToken( inLockToken )
44
    , mpContentType( inContentType )
46
    , mpContentType( inContentType )
45
    , mpReferer( inReferer )
47
    , mpReferer( inReferer )
46
    , xInputStream( xioInStrm )
48
    , xInputStream( xioInStrm )
Lines 52-63 SerfPostReqProcImpl::SerfPostReqProcImpl( const char* inPath, Link Here
52
                                          const DAVRequestHeaders& inRequestHeaders,
54
                                          const DAVRequestHeaders& inRequestHeaders,
53
                                          const char* inData,
55
                                          const char* inData,
54
                                          apr_size_t inDataLen,
56
                                          apr_size_t inDataLen,
57
                                          const char* inLockToken,
55
                                          const char* inContentType,
58
                                          const char* inContentType,
56
                                          const char* inReferer,
59
                                          const char* inReferer,
57
                                          const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm )
60
                                          const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm )
58
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
61
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
59
    , mpPostData( inData )
62
    , mpPostData( inData )
60
    , mnPostDataLen( inDataLen )
63
    , mnPostDataLen( inDataLen )
64
    , mpLockToken( inLockToken )
61
    , mpContentType( inContentType )
65
    , mpContentType( inContentType )
62
    , mpReferer( inReferer )
66
    , mpReferer( inReferer )
63
    , xInputStream()
67
    , xInputStream()
Lines 102-107 serf_bucket_t * SerfPostReqProcImpl::createSerfRequestBucket( serf_request_t * i Link Here
102
    {
106
    {
103
        serf_bucket_headers_set( hdrs_bkt, "Referer", mpReferer );
107
        serf_bucket_headers_set( hdrs_bkt, "Referer", mpReferer );
104
    }
108
    }
109
    if(mpLockToken)
110
    {
111
        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
112
    }
105
113
106
    return req_bkt;
114
    return req_bkt;
107
}
115
}
(-)a/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx (+3 lines)
Lines 37-42 public: Link Here
37
                         const DAVRequestHeaders& inRequestHeaders,
37
                         const DAVRequestHeaders& inRequestHeaders,
38
                         const char* inData,
38
                         const char* inData,
39
                         apr_size_t inDataLen,
39
                         apr_size_t inDataLen,
40
                         const char* inLockToken,
40
                         const char* inContentType,
41
                         const char* inContentType,
41
                         const char* inReferer,
42
                         const char* inReferer,
42
                         const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm );
43
                         const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm );
Lines 45-50 public: Link Here
45
                         const DAVRequestHeaders& inRequestHeaders,
46
                         const DAVRequestHeaders& inRequestHeaders,
46
                         const char* inData,
47
                         const char* inData,
47
                         apr_size_t inDataLen,
48
                         apr_size_t inDataLen,
49
                         const char* inLockToken,
48
                         const char* inContentType,
50
                         const char* inContentType,
49
                         const char* inReferer,
51
                         const char* inReferer,
50
                         const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm );
52
                         const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm );
Lines 64-69 protected: Link Here
64
private:
66
private:
65
    const char* mpPostData;
67
    const char* mpPostData;
66
    apr_size_t mnPostDataLen;
68
    apr_size_t mnPostDataLen;
69
    const char* mpLockToken;
67
    const char* mpContentType;
70
    const char* mpContentType;
68
    const char* mpReferer;
71
    const char* mpReferer;
69
    com::sun::star::uno::Reference< SerfInputStream > xInputStream;
72
    com::sun::star::uno::Reference< SerfInputStream > xInputStream;
(-)a/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx (-1 / +7 lines)
Lines 35-43 namespace http_dav_ucp Link Here
35
35
36
SerfPropPatchReqProcImpl::SerfPropPatchReqProcImpl( const char* inPath,
36
SerfPropPatchReqProcImpl::SerfPropPatchReqProcImpl( const char* inPath,
37
                                                    const DAVRequestHeaders& inRequestHeaders,
37
                                                    const DAVRequestHeaders& inRequestHeaders,
38
                                                    const std::vector< ProppatchValue > & inProperties )
38
                                                    const std::vector< ProppatchValue > & inProperties,
39
                                                    const char* inLockToken )
39
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
40
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
40
    , mpProperties( &inProperties )
41
    , mpProperties( &inProperties )
42
    , mpLockToken( inLockToken )
41
{
43
{
42
}
44
}
43
45
Lines 167-172 serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_ Link Here
167
        setRequestHeaders( hdrs_bkt );
169
        setRequestHeaders( hdrs_bkt );
168
170
169
        // request specific header fields
171
        // request specific header fields
172
        if(mpLockToken)
173
        {
174
            serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
175
        }
170
        if ( body_bkt != 0 && aBodyText.getLength() > 0 )
176
        if ( body_bkt != 0 && aBodyText.getLength() > 0 )
171
        {
177
        {
172
            serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
178
            serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
(-)a/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx (-1 / +3 lines)
Lines 35-41 class SerfPropPatchReqProcImpl : public SerfRequestProcessorImpl Link Here
35
public:
35
public:
36
    SerfPropPatchReqProcImpl( const char* inPath,
36
    SerfPropPatchReqProcImpl( const char* inPath,
37
                              const DAVRequestHeaders& inRequestHeaders,
37
                              const DAVRequestHeaders& inRequestHeaders,
38
                              const std::vector< ProppatchValue > & inProperties );
38
                              const std::vector< ProppatchValue > & inProperties,
39
                              const char* inLockToken );
39
40
40
    virtual ~SerfPropPatchReqProcImpl();
41
    virtual ~SerfPropPatchReqProcImpl();
41
42
Lines 51-56 protected: Link Here
51
52
52
private:
53
private:
53
    const std::vector< ProppatchValue > * mpProperties;
54
    const std::vector< ProppatchValue > * mpProperties;
55
    const  char *mpLockToken;
54
};
56
};
55
57
56
} // namespace http_dav_ucp
58
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx (-2 / +9 lines)
Lines 34-42 namespace http_dav_ucp Link Here
34
SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath,
34
SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath,
35
                                        const DAVRequestHeaders& inRequestHeaders,
35
                                        const DAVRequestHeaders& inRequestHeaders,
36
                                        const char* inData,
36
                                        const char* inData,
37
                                        const char* inLockToken,
37
                                        apr_size_t inDataLen )
38
                                        apr_size_t inDataLen )
38
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
39
    : SerfRequestProcessorImpl( inPath, inRequestHeaders )
39
    , mpData( inData )
40
    , mpData( inData )
41
    , mpLockToken( inLockToken)
40
    , mnDataLen( inDataLen )
42
    , mnDataLen( inDataLen )
41
{
43
{
42
}
44
}
Lines 57-63 serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in Link Here
57
    }
59
    }
58
60
59
    // create serf request
61
    // create serf request
60
    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest, 
62
    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
61
                                                                 "PUT",
63
                                                                 "PUT",
62
                                                                 getPathStr(),
64
                                                                 getPathStr(),
63
                                                                 body_bkt,
65
                                                                 body_bkt,
Lines 68-78 serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in Link Here
68
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
70
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
69
    // general header fields provided by caller
71
    // general header fields provided by caller
70
    setRequestHeaders( hdrs_bkt );
72
    setRequestHeaders( hdrs_bkt );
73
    if(mpLockToken)
74
    {
75
    // request specific header field
76
        serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
77
    }
71
78
72
    return req_bkt;
79
    return req_bkt;
73
}
80
}
74
81
75
void SerfPutReqProcImpl::processChunkOfResponseData( const char* /*data*/, 
82
void SerfPutReqProcImpl::processChunkOfResponseData( const char* /*data*/,
76
                                                     apr_size_t /*len*/ )
83
                                                     apr_size_t /*len*/ )
77
{
84
{
78
    // nothing to do;
85
    // nothing to do;
(-)a/main/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx (+2 lines)
Lines 33-38 public: Link Here
33
    SerfPutReqProcImpl( const char* inPath,
33
    SerfPutReqProcImpl( const char* inPath,
34
                        const DAVRequestHeaders& inRequestHeaders,
34
                        const DAVRequestHeaders& inRequestHeaders,
35
                        const char* inData,
35
                        const char* inData,
36
                        const char* inLockToken,
36
                        apr_size_t inDataLen );
37
                        apr_size_t inDataLen );
37
    
38
    
38
39
Lines 50-55 protected: Link Here
50
51
51
private:
52
private:
52
    const char* mpData;
53
    const char* mpData;
54
    const char* mpLockToken;
53
    apr_size_t mnDataLen;
55
    apr_size_t mnDataLen;
54
56
55
};
57
};
(-)a/main/ucb/source/ucp/webdav/SerfRequestProcessor.cxx (-24 / +191 lines)
Lines 30-35 Link Here
30
30
31
#include <apr_strings.h>
31
#include <apr_strings.h>
32
32
33
//to examine returned http code
34
#include "DAVException.hxx"
35
33
namespace http_dav_ucp
36
namespace http_dav_ucp
34
{
37
{
35
38
Lines 111-121 bool SerfRequestProcessor::processPropFind( const Depth inDepth, Link Here
111
114
112
// PROPPATCH
115
// PROPPATCH
113
bool SerfRequestProcessor::processPropPatch( const std::vector< ProppatchValue > & inProperties,
116
bool SerfRequestProcessor::processPropPatch( const std::vector< ProppatchValue > & inProperties,
117
                                             const com::sun::star::ucb::Lock  inLock,
114
                                             apr_status_t& outSerfStatus )
118
                                             apr_status_t& outSerfStatus )
115
{
119
{
120
    char * inLockToken = static_cast<char*>(0);
121
    if(inLock.LockTokens.getLength() > 0)
122
    {
123
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
124
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
125
    }
116
    mpProcImpl = createPropPatchReqProcImpl( mPathStr,
126
    mpProcImpl = createPropPatchReqProcImpl( mPathStr,
117
                                             mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
127
                                             mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
118
                                             inProperties );
128
                                             inProperties,
129
                                             inLockToken );
119
    outSerfStatus = runProcessor();
130
    outSerfStatus = runProcessor();
120
131
121
    return outSerfStatus == APR_SUCCESS;
132
    return outSerfStatus == APR_SUCCESS;
Lines 194-204 bool SerfRequestProcessor::processHead( const std::vector< ::rtl::OUString > & i Link Here
194
// PUT
205
// PUT
195
bool SerfRequestProcessor::processPut( const char* inData,
206
bool SerfRequestProcessor::processPut( const char* inData,
196
                                       apr_size_t inDataLen,
207
                                       apr_size_t inDataLen,
208
                                       const com::sun::star::ucb::Lock inLock,
197
                                       apr_status_t& outSerfStatus )
209
                                       apr_status_t& outSerfStatus )
198
{
210
{
211
    char * inLockToken = static_cast<char*>(0);
212
    if(inLock.LockTokens.getLength() > 0)
213
    {
214
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
215
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
216
    }
199
    mpProcImpl = createPutReqProcImpl( mPathStr,
217
    mpProcImpl = createPutReqProcImpl( mPathStr,
200
                                       mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
218
                                       mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
201
                                       inData,
219
                                       inData,
220
                                       inLockToken,
202
                                       inDataLen );
221
                                       inDataLen );
203
    outSerfStatus = runProcessor();
222
    outSerfStatus = runProcessor();
204
223
Lines 210-215 bool SerfRequestProcessor::processPost( const char* inData, Link Here
210
                                        apr_size_t inDataLen,
229
                                        apr_size_t inDataLen,
211
                                        const rtl::OUString & inContentType,
230
                                        const rtl::OUString & inContentType,
212
                                        const rtl::OUString & inReferer,
231
                                        const rtl::OUString & inReferer,
232
                                        const com::sun::star::ucb::Lock inLock,
213
                                        const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
233
                                        const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
214
                                        apr_status_t& outSerfStatus )
234
                                        apr_status_t& outSerfStatus )
215
{
235
{
Lines 217-226 bool SerfRequestProcessor::processPost( const char* inData, Link Here
217
                                rtl::OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
237
                                rtl::OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
218
    mReferer = apr_pstrdup( mrSerfSession.getAprPool(), 
238
    mReferer = apr_pstrdup( mrSerfSession.getAprPool(), 
219
                                rtl::OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
239
                                rtl::OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
240
    char * inLockToken = static_cast<char*>(0);
241
    if(inLock.LockTokens.getLength() > 0)
242
    {
243
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
244
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
245
    }
220
    mpProcImpl = createPostReqProcImpl( mPathStr,
246
    mpProcImpl = createPostReqProcImpl( mPathStr,
221
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
247
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
222
                                        inData,
248
                                        inData,
223
                                        inDataLen,
249
                                        inDataLen,
250
                                        inLockToken,
224
                                        mContentType,
251
                                        mContentType,
225
                                        mReferer,
252
                                        mReferer,
226
                                        xioInStrm );
253
                                        xioInStrm );
Lines 234-239 bool SerfRequestProcessor::processPost( const char* inData, Link Here
234
                                        apr_size_t inDataLen,
261
                                        apr_size_t inDataLen,
235
                                        const rtl::OUString & inContentType,
262
                                        const rtl::OUString & inContentType,
236
                                        const rtl::OUString & inReferer,
263
                                        const rtl::OUString & inReferer,
264
                                        const com::sun::star::ucb::Lock inLock,
237
                                        const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
265
                                        const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
238
                                        apr_status_t& outSerfStatus )
266
                                        apr_status_t& outSerfStatus )
239
{
267
{
Lines 241-250 bool SerfRequestProcessor::processPost( const char* inData, Link Here
241
                                rtl::OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
269
                                rtl::OUStringToOString( inContentType, RTL_TEXTENCODING_UTF8 ).getStr() );
242
    mReferer = apr_pstrdup( mrSerfSession.getAprPool(), 
270
    mReferer = apr_pstrdup( mrSerfSession.getAprPool(), 
243
                            rtl::OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
271
                            rtl::OUStringToOString( inReferer, RTL_TEXTENCODING_UTF8 ).getStr() );
272
    char * inLockToken = static_cast<char*>(0);
273
    if(inLock.LockTokens.getLength() > 0)
274
    {
275
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
276
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
277
    }
244
    mpProcImpl = createPostReqProcImpl( mPathStr,
278
    mpProcImpl = createPostReqProcImpl( mPathStr,
245
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
279
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
246
                                        inData,
280
                                        inData,
247
                                        inDataLen,
281
                                        inDataLen,
282
                                        inLockToken,
248
                                        mContentType,
283
                                        mContentType,
249
                                        mReferer,
284
                                        mReferer,
250
                                        xioOutStrm );
285
                                        xioOutStrm );
Lines 254-273 bool SerfRequestProcessor::processPost( const char* inData, Link Here
254
}
289
}
255
290
256
// DELETE
291
// DELETE
257
bool SerfRequestProcessor::processDelete( apr_status_t& outSerfStatus )
292
bool SerfRequestProcessor::processDelete( const com::sun::star::ucb::Lock inLock,
293
                                          apr_status_t& outSerfStatus )
258
{
294
{
295
    char * inLockToken = static_cast<char*>(0);
296
    if(inLock.LockTokens.getLength() > 0)
297
    {
298
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
299
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
300
    }
259
    mpProcImpl = createDeleteReqProcImpl( mPathStr,
301
    mpProcImpl = createDeleteReqProcImpl( mPathStr,
260
                                          mrSerfSession.getRequestEnvironment().m_aRequestHeaders );
302
                                          mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
303
                                          inLockToken );
261
    outSerfStatus = runProcessor();
304
    outSerfStatus = runProcessor();
262
305
263
    return outSerfStatus == APR_SUCCESS;
306
    return outSerfStatus == APR_SUCCESS;
264
}
307
}
265
308
266
// MKCOL
309
// MKCOL
267
bool SerfRequestProcessor::processMkCol( apr_status_t& outSerfStatus )
310
bool SerfRequestProcessor::processMkCol( const com::sun::star::ucb::Lock inLock,
311
                                         apr_status_t& outSerfStatus )
268
{
312
{
313
    char * inLockToken = static_cast<char*>(0);
314
    if(inLock.LockTokens.getLength() > 0)
315
    {
316
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
317
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
318
    }
269
    mpProcImpl = createMkColReqProcImpl( mPathStr,
319
    mpProcImpl = createMkColReqProcImpl( mPathStr,
270
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders );
320
                                         mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
321
                                         inLockToken );
271
    outSerfStatus = runProcessor();
322
    outSerfStatus = runProcessor();
272
323
273
    return outSerfStatus == APR_SUCCESS;
324
    return outSerfStatus == APR_SUCCESS;
Lines 276-289 bool SerfRequestProcessor::processMkCol( apr_status_t& outSerfStatus ) Link Here
276
// COPY
327
// COPY
277
bool SerfRequestProcessor::processCopy( const rtl::OUString & inDestinationPath,
328
bool SerfRequestProcessor::processCopy( const rtl::OUString & inDestinationPath,
278
                                        const bool inOverwrite,
329
                                        const bool inOverwrite,
330
                                        const com::sun::star::ucb::Lock inLock,
279
                                        apr_status_t& outSerfStatus )
331
                                        apr_status_t& outSerfStatus )
280
{
332
{
281
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(), 
333
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(), 
282
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
334
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
335
    char * inLockToken = static_cast<char*>(0);
336
    if(inLock.LockTokens.getLength() > 0)
337
    {
338
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
339
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
340
    }
283
    mpProcImpl = createCopyReqProcImpl( mPathStr,
341
    mpProcImpl = createCopyReqProcImpl( mPathStr,
284
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
342
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
285
                                        mDestPathStr,
343
                                        mDestPathStr,
286
                                        inOverwrite );
344
                                        inOverwrite,
345
                                        inLockToken );
287
    outSerfStatus = runProcessor();
346
    outSerfStatus = runProcessor();
288
347
289
    return outSerfStatus == APR_SUCCESS;
348
    return outSerfStatus == APR_SUCCESS;
Lines 292-305 bool SerfRequestProcessor::processCopy( const rtl::OUString & inDestinationPath, Link Here
292
// MOVE
351
// MOVE
293
bool SerfRequestProcessor::processMove( const rtl::OUString & inDestinationPath,
352
bool SerfRequestProcessor::processMove( const rtl::OUString & inDestinationPath,
294
                                        const bool inOverwrite,
353
                                        const bool inOverwrite,
354
                                        const com::sun::star::ucb::Lock  inLock,
295
                                        apr_status_t& outSerfStatus )
355
                                        apr_status_t& outSerfStatus )
296
{
356
{
297
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(), 
357
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(), 
298
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
358
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
359
    char * inLockToken = static_cast<char*>(0);
360
    if(inLock.LockTokens.getLength() > 0)
361
    {
362
        inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
363
                               rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
364
    }
299
    mpProcImpl = createMoveReqProcImpl( mPathStr,
365
    mpProcImpl = createMoveReqProcImpl( mPathStr,
300
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
366
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
301
                                        mDestPathStr,
367
                                        mDestPathStr,
302
                                        inOverwrite );
368
                                        inOverwrite,
369
                                        inLockToken );
370
    outSerfStatus = runProcessor();
371
372
    return outSerfStatus == APR_SUCCESS;
373
}
374
375
//LOCK creating a new lock
376
bool SerfRequestProcessor::processLock( const rtl::OUString & inDestinationPath,
377
                                        const com::sun::star::ucb::Lock& inLock,
378
                                        DAVPropertyValue & outLock,
379
                                        apr_status_t& outSerfStatus )
380
{
381
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
382
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
383
    char * Timeout;
384
    if(inLock.Timeout == -1)
385
        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Infinite" );
386
    else
387
        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Second-%ld", inLock.Timeout );
388
389
    mpProcImpl = createLockReqProcImpl( mPathStr,
390
                                        mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
391
                                        inLock,
392
                                        Timeout,
393
                                        outLock);
394
    outSerfStatus = runProcessor();
395
396
    return outSerfStatus == APR_SUCCESS;
397
}
398
399
//LOCK refresh an existing lock
400
bool SerfRequestProcessor::processLockRefresh( const rtl::OUString & inDestinationPath,
401
                                        const com::sun::star::ucb::Lock& inLock,
402
                                        DAVPropertyValue & outLock,
403
                                        apr_status_t& outSerfStatus )
404
{
405
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
406
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
407
    char * Timeout;
408
    if(inLock.Timeout == -1)
409
        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Infinite" );
410
    else
411
        Timeout = apr_psprintf( mrSerfSession.getAprPool(), "Second-%ld", inLock.Timeout );
412
413
    char * inLockToken = apr_psprintf( mrSerfSession.getAprPool(), "(<%s>)",
414
                                 rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
415
416
    mpProcImpl = createLockRefreshProcImpl( mPathStr,
417
                                            mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
418
                                            inLock,
419
                                            inLockToken,
420
                                            Timeout,
421
                                            outLock);
422
    outSerfStatus = runProcessor();
423
424
    return outSerfStatus == APR_SUCCESS;
425
}
426
427
//ULOCK unlock an existing lock
428
bool SerfRequestProcessor::processUnlock( const rtl::OUString & inDestinationPath,
429
                                        const com::sun::star::ucb::Lock& inLock,
430
                                        apr_status_t& outSerfStatus )
431
{
432
    mDestPathStr = apr_pstrdup( mrSerfSession.getAprPool(),
433
                                rtl::OUStringToOString( inDestinationPath, RTL_TEXTENCODING_UTF8 ).getStr() );
434
435
    char * aToken = apr_psprintf( mrSerfSession.getAprPool(), "<%s>",
436
                                 rtl::OUStringToOString(inLock.LockTokens[0], RTL_TEXTENCODING_UTF8 ).getStr() );
437
438
    mpProcImpl = createUnlockProcImpl( mPathStr,
439
                                       mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
440
                                       inLock,
441
                                       aToken );
442
303
    outSerfStatus = runProcessor();
443
    outSerfStatus = runProcessor();
304
444
305
    return outSerfStatus == APR_SUCCESS;
445
    return outSerfStatus == APR_SUCCESS;
Lines 316-322 apr_status_t SerfRequestProcessor::runProcessor() Link Here
316
    }
456
    }
317
457
318
    // create serf request
458
    // create serf request
319
    serf_connection_request_create( mrSerfSession.getSerfConnection(), 
459
    OSL_ASSERT(mrSerfSession.getSerfConnection() != NULL);
460
    serf_connection_request_create( mrSerfSession.getSerfConnection(),
320
                                    Serf_SetupRequest,
461
                                    Serf_SetupRequest,
321
                                    this );
462
                                    this );
322
463
Lines 327-341 apr_status_t SerfRequestProcessor::runProcessor() Link Here
327
    apr_pool_t* pAprPool = mrSerfSession.getAprPool();
468
    apr_pool_t* pAprPool = mrSerfSession.getAprPool();
328
    while ( true )
469
    while ( true )
329
    {
470
    {
330
        status = serf_context_run( pSerfContext, 
471
        status = serf_context_run( pSerfContext,
331
                                   SERF_DURATION_FOREVER, 
472
                                   SERF_DURATION_FOREVER,
332
                                   pAprPool );
473
                                   pAprPool );
333
        if ( APR_STATUS_IS_TIMEUP( status ) )
474
        if ( APR_STATUS_IS_TIMEUP( status ) )
334
        {
475
        {
335
            continue;
476
            continue;
336
        }
477
        }
337
        if ( status != APR_SUCCESS ) 
478
        if ( status != APR_SUCCESS )
338
        {
479
        {
480
#if OSL_DEBUG_LEVEL > 0
481
            char buff[512];
482
            OSL_TRACE("SerfRequestProcessor::runProcessor, status != APR_SUCCESS: %d (%s)",status, apr_strerror(status, buff, 512));
483
#endif
339
            break;
484
            break;
340
        }
485
        }
341
        if ( mbProcessingDone )
486
        if ( mbProcessingDone )
Lines 356-361 void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus ) Link Here
356
        return;
501
        return;
357
    }
502
    }
358
503
504
    OSL_TRACE("SerfRequestProcessor::postprocessProcessor:%d",__LINE__);
359
    switch ( inStatus )
505
    switch ( inStatus )
360
    {
506
    {
361
    case APR_EGENERAL:
507
    case APR_EGENERAL:
Lines 379-386 void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus ) Link Here
379
                }
525
                }
380
                else
526
                else
381
                {
527
                {
382
                    mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR, 
528
                    mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR,
383
                                                       mHTTPStatusCodeText, 
529
                                                       mHTTPStatusCodeText,
384
                                                       mnHTTPStatusCode );
530
                                                       mnHTTPStatusCode );
385
                }
531
                }
386
                break;
532
                break;
Lines 388-399 void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus ) Link Here
388
            case SC_MOVED_TEMPORARILY:
534
            case SC_MOVED_TEMPORARILY:
389
            case SC_SEE_OTHER:
535
            case SC_SEE_OTHER:
390
            case SC_TEMPORARY_REDIRECT:
536
            case SC_TEMPORARY_REDIRECT:
391
                mpDAVException = new DAVException( DAVException::DAV_HTTP_REDIRECT, 
537
                mpDAVException = new DAVException( DAVException::DAV_HTTP_REDIRECT,
392
                                                   mRedirectLocation );
538
                                                   mRedirectLocation );
393
                break;
539
                break;
540
            case SC_LOCKED:
541
                mpDAVException = new DAVException( DAVException::DAV_LOCKED,
542
                                                   mHTTPStatusCodeText,
543
                                                   mnHTTPStatusCode );
544
                break;
394
            default:
545
            default:
395
                mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR, 
546
                mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR,
396
                                                   mHTTPStatusCodeText, 
547
                                                   mHTTPStatusCodeText,
397
                                                   mnHTTPStatusCode );
548
                                                   mnHTTPStatusCode );
398
                break;
549
                break;
399
            }
550
            }
Lines 404-416 void SerfRequestProcessor::postprocessProcessor( const apr_status_t inStatus ) Link Here
404
        mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR );
555
        mpDAVException = new DAVException( DAVException::DAV_HTTP_ERROR );
405
        break;
556
        break;
406
    }
557
    }
407
408
}
558
}
409
559
410
apr_status_t SerfRequestProcessor::provideSerfCredentials( char ** outUsername, 
560
apr_status_t SerfRequestProcessor::provideSerfCredentials( char ** outUsername,
411
                                                           char ** outPassword,
561
                                                           char ** outPassword,
412
                                                           serf_request_t * inRequest, 
562
                                                           serf_request_t * inRequest,
413
                                                           int inCode, 
563
                                                           int inCode,
414
                                                           const char *inAuthProtocol,
564
                                                           const char *inAuthProtocol,
415
                                                           const char *inRealm,
565
                                                           const char *inRealm,
416
                                                           apr_pool_t *inAprPool )
566
                                                           apr_pool_t *inAprPool )
Lines 486-492 apr_status_t SerfRequestProcessor::handleSerfResponse( serf_request_t * inSerfRe Link Here
486
636
487
    // some general response handling and error handling
637
    // some general response handling and error handling
488
    {
638
    {
489
        if ( !inSerfResponseBucket ) 
639
        if ( !inSerfResponseBucket )
490
        {
640
        {
491
            /* A NULL response can come back if the request failed completely */
641
            /* A NULL response can come back if the request failed completely */
492
            mbProcessingDone = true;
642
            mbProcessingDone = true;
Lines 495-505 apr_status_t SerfRequestProcessor::handleSerfResponse( serf_request_t * inSerfRe Link Here
495
645
496
        serf_status_line sl;
646
        serf_status_line sl;
497
        apr_status_t status = serf_bucket_response_status( inSerfResponseBucket, &sl );
647
        apr_status_t status = serf_bucket_response_status( inSerfResponseBucket, &sl );
498
        if ( status ) 
648
        if ( status )
499
        {
649
        {
500
            mbProcessingDone = false; // allow another try in order to get a response
650
            mbProcessingDone = false; // allow another try in order to get a response
501
            return status;
651
            return status;
502
        }
652
        }
653
        serf_bucket_t *headers = serf_bucket_response_get_headers( inSerfResponseBucket );
654
655
        // check header according:
656
        // http://tools.ietf.org/html/rfc7231#section-7.4.2
657
        // need to do this so we can adjust the protocol accordingly
658
        // serf_bucket_headers_get is case independent
659
        const char* server = serf_bucket_headers_get( headers, "server" );
660
        if( server )
661
        {
662
            //update the server type on session
663
            mrSerfSession.setServerHeaderField( ::rtl::OUString::createFromAscii( server ) );
664
        }
665
        //the following extension is MS IIS specific,
666
        //see https://msdn.microsoft.com/en-us/library/cc250064.aspx
667
        //site last checked on 2015-03-02
668
        //TODO i126305 need to be added when serf is updated to a version supporting Windows authentication
669
        //const char* msDavExtErr = serf_bucket_headers_get( headers, "X-MSDAVEXT_ERROR" );
670
503
        // TODO - check, if response status code handling is correct
671
        // TODO - check, if response status code handling is correct
504
        mnHTTPStatusCode = ( sl.version != 0 && sl.code >= 0 )
672
        mnHTTPStatusCode = ( sl.version != 0 && sl.code >= 0 )
505
                           ? static_cast< sal_uInt16 >( sl.code )
673
                           ? static_cast< sal_uInt16 >( sl.code )
Lines 508-514 apr_status_t SerfRequestProcessor::handleSerfResponse( serf_request_t * inSerfRe Link Here
508
        {
676
        {
509
            mHTTPStatusCodeText = ::rtl::OUString::createFromAscii( sl.reason );
677
            mHTTPStatusCodeText = ::rtl::OUString::createFromAscii( sl.reason );
510
        }
678
        }
511
        if ( ( sl.version == 0 || sl.code < 0 ) || 
679
        if ( ( sl.version == 0 || sl.code < 0 ) ||
512
             mnHTTPStatusCode >= 300 )
680
             mnHTTPStatusCode >= 300 )
513
        {
681
        {
514
            if ( mnHTTPStatusCode == 301 ||
682
            if ( mnHTTPStatusCode == 301 ||
Lines 517-523 apr_status_t SerfRequestProcessor::handleSerfResponse( serf_request_t * inSerfRe Link Here
517
                 mnHTTPStatusCode == 307 )
685
                 mnHTTPStatusCode == 307 )
518
            {
686
            {
519
                // new location for certain redirections
687
                // new location for certain redirections
520
                serf_bucket_t *headers = serf_bucket_response_get_headers( inSerfResponseBucket );
521
                const char* location = serf_bucket_headers_get( headers, "Location" );
688
                const char* location = serf_bucket_headers_get( headers, "Location" );
522
                if ( location )
689
                if ( location )
523
                {
690
                {
(-)a/main/ucb/source/ucp/webdav/SerfRequestProcessor.hxx (-2 / +28 lines)
Lines 32-37 Link Here
32
#include "DAVResource.hxx"
32
#include "DAVResource.hxx"
33
#include "DAVException.hxx"
33
#include "DAVException.hxx"
34
34
35
#include "SerfTypes.hxx"
35
#include "SerfInputStream.hxx"
36
#include "SerfInputStream.hxx"
36
#include <com/sun/star/io/XOutputStream.hpp>
37
#include <com/sun/star/io/XOutputStream.hpp>
37
38
Lines 62-67 public: Link Here
62
63
63
    // PROPPATCH
64
    // PROPPATCH
64
    bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
65
    bool processPropPatch( const std::vector< ProppatchValue > & inProperties,
66
                           const com::sun::star::ucb::Lock  inLock,
65
                           apr_status_t& outSerfStatus );
67
                           apr_status_t& outSerfStatus );
66
68
67
    // GET
69
    // GET
Lines 92-97 public: Link Here
92
    // PUT
94
    // PUT
93
    bool processPut( const char* inData,
95
    bool processPut( const char* inData,
94
                     apr_size_t inDataLen,
96
                     apr_size_t inDataLen,
97
                     const com::sun::star::ucb::Lock  inLock,
95
                     apr_status_t& outSerfStatus );
98
                     apr_status_t& outSerfStatus );
96
99
97
    // POST
100
    // POST
Lines 99-104 public: Link Here
99
                      apr_size_t inDataLen,
102
                      apr_size_t inDataLen,
100
                      const rtl::OUString & inContentType,
103
                      const rtl::OUString & inContentType,
101
                      const rtl::OUString & inReferer,
104
                      const rtl::OUString & inReferer,
105
                      const com::sun::star::ucb::Lock  inLock,
102
                      const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
106
                      const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm,
103
                      apr_status_t& outSerfStatus );
107
                      apr_status_t& outSerfStatus );
104
108
Lines 107-131 public: Link Here
107
                      apr_size_t inDataLen,
111
                      apr_size_t inDataLen,
108
                      const rtl::OUString & inContentType,
112
                      const rtl::OUString & inContentType,
109
                      const rtl::OUString & inReferer,
113
                      const rtl::OUString & inReferer,
114
                      const com::sun::star::ucb::Lock  inLock,
110
                      const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
115
                      const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm,
111
                      apr_status_t& outSerfStatus );
116
                      apr_status_t& outSerfStatus );
112
117
113
    // DELETE
118
    // DELETE
114
    bool processDelete( apr_status_t& outSerfStatus );
119
    bool processDelete( const com::sun::star::ucb::Lock inLock,
120
                        apr_status_t& outSerfStatus );
115
121
116
    // MKCOL
122
    // MKCOL
117
    bool processMkCol( apr_status_t& outSerfStatus );
123
    bool processMkCol( const com::sun::star::ucb::Lock inLock,
124
                       apr_status_t& outSerfStatus );
118
125
119
    // COPY
126
    // COPY
120
    bool processCopy( const rtl::OUString & inDestinationPath,
127
    bool processCopy( const rtl::OUString & inDestinationPath,
121
                      const bool inOverwrite,
128
                      const bool inOverwrite,
129
                      const com::sun::star::ucb::Lock inLock,
122
                      apr_status_t& outSerfStatus );
130
                      apr_status_t& outSerfStatus );
123
131
124
    // MOVE
132
    // MOVE
125
    bool processMove( const rtl::OUString & inDestinationPath,
133
    bool processMove( const rtl::OUString & inDestinationPath,
126
                      const bool inOverwrite,
134
                      const bool inOverwrite,
135
                      const com::sun::star::ucb::Lock inLock,
127
                      apr_status_t& outSerfStatus );
136
                      apr_status_t& outSerfStatus );
128
137
138
    // LOCK
139
    bool processLock( const rtl::OUString & inDestinationPath,
140
                      const com::sun::star::ucb::Lock& inLock,
141
                      DAVPropertyValue & outLock,
142
                      apr_status_t& outSerfStatus );
143
144
    // LOCK refresh
145
    bool processLockRefresh( const rtl::OUString & inDestinationPath,
146
                      const com::sun::star::ucb::Lock& inLock,
147
                      DAVPropertyValue & outLock,
148
                      apr_status_t& outSerfStatus );
149
150
    //UNLOCK
151
    bool processUnlock( const rtl::OUString & inDestinationPath,
152
                        const com::sun::star::ucb::Lock& inLock,
153
                        apr_status_t& outSerfStatus );
154
129
    apr_status_t provideSerfCredentials( char ** outUsername, 
155
    apr_status_t provideSerfCredentials( char ** outUsername, 
130
                                         char ** outPassword,
156
                                         char ** outPassword,
131
                                         serf_request_t * inRequest, 
157
                                         serf_request_t * inRequest, 
(-)a/main/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx (-10 / +72 lines)
Lines 22-27 Link Here
22
// MARKER(update_precomp.py): autogen include statement, do not remove
22
// MARKER(update_precomp.py): autogen include statement, do not remove
23
#include "precompiled_ucb.hxx"
23
#include "precompiled_ucb.hxx"
24
24
25
#include "SerfTypes.hxx"
25
#include "SerfRequestProcessorImplFac.hxx"
26
#include "SerfRequestProcessorImplFac.hxx"
26
#include "SerfPropFindReqProcImpl.hxx"
27
#include "SerfPropFindReqProcImpl.hxx"
27
#include "SerfPropPatchReqProcImpl.hxx"
28
#include "SerfPropPatchReqProcImpl.hxx"
Lines 33-38 Link Here
33
#include "SerfMkColReqProcImpl.hxx"
34
#include "SerfMkColReqProcImpl.hxx"
34
#include "SerfCopyReqProcImpl.hxx"
35
#include "SerfCopyReqProcImpl.hxx"
35
#include "SerfMoveReqProcImpl.hxx"
36
#include "SerfMoveReqProcImpl.hxx"
37
#include "SerfLockReqProcImpl.hxx"
38
#include "SerfLockRefreshProcImpl.hxx"
39
#include "SerfUnlockProcImpl.hxx"
36
40
37
namespace http_dav_ucp
41
namespace http_dav_ucp
38
{
42
{
Lines 64-74 namespace http_dav_ucp Link Here
64
68
65
    SerfRequestProcessorImpl* createPropPatchReqProcImpl( const char* inPath,
69
    SerfRequestProcessorImpl* createPropPatchReqProcImpl( const char* inPath,
66
                                                          const DAVRequestHeaders& inRequestHeaders,
70
                                                          const DAVRequestHeaders& inRequestHeaders,
67
                                                          const std::vector< ProppatchValue > & inProperties )
71
                                                          const std::vector< ProppatchValue > & inProperties,
72
                                                          const char* inLockToken )
68
    {
73
    {
69
        SerfRequestProcessorImpl* pReqProcImpl = new SerfPropPatchReqProcImpl( inPath,
74
        SerfRequestProcessorImpl* pReqProcImpl = new SerfPropPatchReqProcImpl( inPath,
70
                                                                               inRequestHeaders, 
75
                                                                               inRequestHeaders, 
71
                                                                               inProperties );
76
                                                                               inProperties,
77
                                                                               inLockToken );
72
        return pReqProcImpl;
78
        return pReqProcImpl;
73
    }
79
    }
74
80
Lines 136-146 namespace http_dav_ucp Link Here
136
    SerfRequestProcessorImpl* createPutReqProcImpl( const char* inPath,
142
    SerfRequestProcessorImpl* createPutReqProcImpl( const char* inPath,
137
                                                    const DAVRequestHeaders& inRequestHeaders,
143
                                                    const DAVRequestHeaders& inRequestHeaders,
138
                                                    const char* inData,
144
                                                    const char* inData,
145
                                                    const char* inLockToken,
139
                                                    apr_size_t inDataLen )
146
                                                    apr_size_t inDataLen )
140
    {
147
    {
141
        SerfRequestProcessorImpl* pReqProcImpl = new SerfPutReqProcImpl( inPath,
148
        SerfRequestProcessorImpl* pReqProcImpl = new SerfPutReqProcImpl( inPath,
142
                                                                         inRequestHeaders, 
149
                                                                         inRequestHeaders, 
143
                                                                         inData,
150
                                                                         inData,
151
                                                                         inLockToken,
144
                                                                         inDataLen );
152
                                                                         inDataLen );
145
        return pReqProcImpl;
153
        return pReqProcImpl;
146
    }
154
    }
Lines 149-154 namespace http_dav_ucp Link Here
149
                                                     const DAVRequestHeaders& inRequestHeaders,
157
                                                     const DAVRequestHeaders& inRequestHeaders,
150
                                                     const char* inData,
158
                                                     const char* inData,
151
                                                     apr_size_t inDataLen,
159
                                                     apr_size_t inDataLen,
160
                                                     const char* inLockToken,
152
                                                     const char* inContentType,
161
                                                     const char* inContentType,
153
                                                     const char* inReferer,
162
                                                     const char* inReferer,
154
                                                     const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm )
163
                                                     const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm )
Lines 157-162 namespace http_dav_ucp Link Here
157
                                                                          inRequestHeaders, 
166
                                                                          inRequestHeaders, 
158
                                                                          inData,
167
                                                                          inData,
159
                                                                          inDataLen,
168
                                                                          inDataLen,
169
                                                                          inLockToken,
160
                                                                          inContentType,
170
                                                                          inContentType,
161
                                                                          inReferer,
171
                                                                          inReferer,
162
                                                                          xioInStrm );
172
                                                                          xioInStrm );
Lines 167-172 namespace http_dav_ucp Link Here
167
                                                     const DAVRequestHeaders& inRequestHeaders,
177
                                                     const DAVRequestHeaders& inRequestHeaders,
168
                                                     const char* inData,
178
                                                     const char* inData,
169
                                                     apr_size_t inDataLen,
179
                                                     apr_size_t inDataLen,
180
                                                     const char* inLockToken,
170
                                                     const char* inContentType,
181
                                                     const char* inContentType,
171
                                                     const char* inReferer,
182
                                                     const char* inReferer,
172
                                                     const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm )
183
                                                     const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm )
Lines 175-180 namespace http_dav_ucp Link Here
175
                                                                          inRequestHeaders, 
186
                                                                          inRequestHeaders, 
176
                                                                          inData,
187
                                                                          inData,
177
                                                                          inDataLen,
188
                                                                          inDataLen,
189
                                                                          inLockToken,
178
                                                                          inContentType,
190
                                                                          inContentType,
179
                                                                          inReferer,
191
                                                                          inReferer,
180
                                                                          xioOutStrm );
192
                                                                          xioOutStrm );
Lines 182-223 namespace http_dav_ucp Link Here
182
    }
194
    }
183
195
184
    SerfRequestProcessorImpl* createDeleteReqProcImpl( const char* inPath,
196
    SerfRequestProcessorImpl* createDeleteReqProcImpl( const char* inPath,
185
                                                       const DAVRequestHeaders& inRequestHeaders )
197
                                                       const DAVRequestHeaders& inRequestHeaders,
198
                                                       const char * inLockToken )
186
    {
199
    {
187
        SerfRequestProcessorImpl* pReqProcImpl = new SerfDeleteReqProcImpl( inPath,
200
        SerfRequestProcessorImpl* pReqProcImpl = new SerfDeleteReqProcImpl( inPath,
188
                                                                            inRequestHeaders );
201
                                                                            inRequestHeaders,
202
                                                                            inLockToken );
189
        return pReqProcImpl;
203
        return pReqProcImpl;
190
    }
204
    }
191
205
192
    SerfRequestProcessorImpl* createMkColReqProcImpl( const char* inPath,
206
    SerfRequestProcessorImpl* createMkColReqProcImpl( const char* inPath,
193
                                                      const DAVRequestHeaders& inRequestHeaders )
207
                                                      const DAVRequestHeaders& inRequestHeaders,
208
                                                      const char * inLockToken )
194
    {
209
    {
195
        SerfRequestProcessorImpl* pReqProcImpl = new SerfMkColReqProcImpl( inPath,
210
        SerfRequestProcessorImpl* pReqProcImpl = new SerfMkColReqProcImpl( inPath,
196
                                                                           inRequestHeaders );
211
                                                                           inRequestHeaders,
212
                                                                           inLockToken );
197
        return pReqProcImpl;
213
        return pReqProcImpl;
198
    }
214
    }
199
215
200
    SerfRequestProcessorImpl* createCopyReqProcImpl( const char* inSourcePath,
216
    SerfRequestProcessorImpl* createCopyReqProcImpl( const char* inSourcePath,
201
                                                     const DAVRequestHeaders& inRequestHeaders,
217
                                                     const DAVRequestHeaders& inRequestHeaders,
202
                                                     const char* inDestinationPath,
218
                                                     const char* inDestinationPath,
203
                                                     const bool inOverwrite )
219
                                                     const bool inOverwrite,
220
                                                     const char* inLockToken )
204
    {
221
    {
205
        SerfRequestProcessorImpl* pReqProcImpl = new SerfCopyReqProcImpl( inSourcePath,
222
        SerfRequestProcessorImpl* pReqProcImpl = new SerfCopyReqProcImpl( inSourcePath,
206
                                                                          inRequestHeaders,
223
                                                                          inRequestHeaders,
207
                                                                          inDestinationPath,
224
                                                                          inDestinationPath,
208
                                                                          inOverwrite );
225
                                                                          inOverwrite,
226
                                                                          inLockToken );
209
        return pReqProcImpl;
227
        return pReqProcImpl;
210
    }
228
    }
211
229
212
    SerfRequestProcessorImpl* createMoveReqProcImpl( const char* inSourcePath,
230
    SerfRequestProcessorImpl* createMoveReqProcImpl( const char* inSourcePath,
213
                                                     const DAVRequestHeaders& inRequestHeaders,
231
                                                     const DAVRequestHeaders& inRequestHeaders,
214
                                                     const char* inDestinationPath,
232
                                                     const char* inDestinationPath,
215
                                                     const bool inOverwrite )
233
                                                     const bool inOverwrite,
234
                                                     const char* inLockToken )
216
    {
235
    {
217
        SerfRequestProcessorImpl* pReqProcImpl = new SerfMoveReqProcImpl( inSourcePath,
236
        SerfRequestProcessorImpl* pReqProcImpl = new SerfMoveReqProcImpl( inSourcePath,
218
                                                                          inRequestHeaders,
237
                                                                          inRequestHeaders,
219
                                                                          inDestinationPath,
238
                                                                          inDestinationPath,
220
                                                                          inOverwrite );
239
                                                                          inOverwrite,
240
                                                                          inLockToken );
241
        return pReqProcImpl;
242
    }
243
244
    SerfRequestProcessorImpl* createLockReqProcImpl( const char* inSourcePath,
245
                                                     const DAVRequestHeaders& inRequestHeaders,
246
                                                     const ucb::Lock& inLock,
247
                                                     const char* inTimeout,
248
                                                     DAVPropertyValue & outLock)
249
    {
250
        SerfRequestProcessorImpl* pReqProcImpl = new SerfLockReqProcImpl( inSourcePath,
251
                                                                          inRequestHeaders,
252
                                                                          inLock,
253
                                                                          inTimeout,
254
                                                                          outLock);
255
        return pReqProcImpl;
256
    }
257
258
    SerfRequestProcessorImpl* createLockRefreshProcImpl( const char* inSourcePath,
259
                                                         const DAVRequestHeaders& inRequestHeaders,
260
                                                         const ucb::Lock& inLock,
261
                                                         const char* inLockToken,
262
                                                         const char* inTimeout,
263
                                                         DAVPropertyValue & outLock)
264
    {
265
        SerfRequestProcessorImpl* pReqProcImpl = new SerfLockRefreshProcImpl( inSourcePath,
266
                                                                              inRequestHeaders,
267
                                                                              inLock,
268
                                                                              inLockToken,
269
                                                                              inTimeout,
270
                                                                              outLock);
271
        return pReqProcImpl;
272
    }
273
274
    SerfRequestProcessorImpl* createUnlockProcImpl( const char* inSourcePath,
275
                                                         const DAVRequestHeaders& inRequestHeaders,
276
                                                         const ucb::Lock& inLock,
277
                                                         const char* inToken )
278
    {
279
        SerfRequestProcessorImpl* pReqProcImpl = new SerfUnlockProcImpl( inSourcePath,
280
                                                                         inRequestHeaders,
281
                                                                         inLock,
282
                                                                         inToken );
221
        return pReqProcImpl;
283
        return pReqProcImpl;
222
    }
284
    }
223
285
(-)a/main/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.hxx (-5 / +32 lines)
Lines 27-32 Link Here
27
#include "DAVTypes.hxx"
27
#include "DAVTypes.hxx"
28
#include "DAVResource.hxx"
28
#include "DAVResource.hxx"
29
29
30
#include "SerfTypes.hxx"
30
#include "SerfRequestProcessorImpl.hxx"
31
#include "SerfRequestProcessorImpl.hxx"
31
#include "SerfInputStream.hxx"
32
#include "SerfInputStream.hxx"
32
#include <com/sun/star/io/XOutputStream.hpp>
33
#include <com/sun/star/io/XOutputStream.hpp>
Lines 46-52 namespace http_dav_ucp Link Here
46
47
47
    SerfRequestProcessorImpl* createPropPatchReqProcImpl( const char* inPath,
48
    SerfRequestProcessorImpl* createPropPatchReqProcImpl( const char* inPath,
48
                                                          const DAVRequestHeaders& inRequestHeaders,
49
                                                          const DAVRequestHeaders& inRequestHeaders,
49
                                                          const std::vector< ProppatchValue > & inProperties );
50
                                                          const std::vector< ProppatchValue > & inProperties,
51
                                                          const char* inLockToken );
50
52
51
    SerfRequestProcessorImpl* createGetReqProcImpl( const char* inPath,
53
    SerfRequestProcessorImpl* createGetReqProcImpl( const char* inPath,
52
                                                    const DAVRequestHeaders& inRequestHeaders,
54
                                                    const DAVRequestHeaders& inRequestHeaders,
Lines 76-87 namespace http_dav_ucp Link Here
76
    SerfRequestProcessorImpl* createPutReqProcImpl( const char* inPath,
78
    SerfRequestProcessorImpl* createPutReqProcImpl( const char* inPath,
77
                                                    const DAVRequestHeaders& inRequestHeaders,
79
                                                    const DAVRequestHeaders& inRequestHeaders,
78
                                                    const char* inData,
80
                                                    const char* inData,
81
                                                    const char* inLockToken,
79
                                                    apr_size_t inDataLen );
82
                                                    apr_size_t inDataLen );
80
83
81
    SerfRequestProcessorImpl* createPostReqProcImpl( const char* inPath,
84
    SerfRequestProcessorImpl* createPostReqProcImpl( const char* inPath,
82
                                                     const DAVRequestHeaders& inRequestHeaders,
85
                                                     const DAVRequestHeaders& inRequestHeaders,
83
                                                     const char* inData,
86
                                                     const char* inData,
84
                                                     apr_size_t inDataLen,
87
                                                     apr_size_t inDataLen,
88
                                                     const char* inLockToken,
85
                                                     const char* inContentType,
89
                                                     const char* inContentType,
86
                                                     const char* inReferer,
90
                                                     const char* inReferer,
87
                                                     const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm );
91
                                                     const com::sun::star::uno::Reference< SerfInputStream >& xioInStrm );
Lines 90-114 namespace http_dav_ucp Link Here
90
                                                     const DAVRequestHeaders& inRequestHeaders,
94
                                                     const DAVRequestHeaders& inRequestHeaders,
91
                                                     const char* inData,
95
                                                     const char* inData,
92
                                                     apr_size_t inDataLen,
96
                                                     apr_size_t inDataLen,
97
                                                     const char* inLockToken,
93
                                                     const char* inContentType,
98
                                                     const char* inContentType,
94
                                                     const char* inReferer,
99
                                                     const char* inReferer,
95
                                                     const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm );
100
                                                     const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xioOutStrm );
96
101
97
    SerfRequestProcessorImpl* createDeleteReqProcImpl( const char* inPath,
102
    SerfRequestProcessorImpl* createDeleteReqProcImpl( const char* inPath,
98
                                                       const DAVRequestHeaders& inRequestHeaders );
103
                                                       const DAVRequestHeaders& inRequestHeaders,
104
                                                       const char * inLockToken );
99
105
100
    SerfRequestProcessorImpl* createMkColReqProcImpl( const char* inPath,
106
    SerfRequestProcessorImpl* createMkColReqProcImpl( const char* inPath,
101
                                                      const DAVRequestHeaders& inRequestHeaders );
107
                                                      const DAVRequestHeaders& inRequestHeaders,
108
                                                      const char * inLockToken );
102
109
103
    SerfRequestProcessorImpl* createCopyReqProcImpl( const char* inSourcePath,
110
    SerfRequestProcessorImpl* createCopyReqProcImpl( const char* inSourcePath,
104
                                                     const DAVRequestHeaders& inRequestHeaders,
111
                                                     const DAVRequestHeaders& inRequestHeaders,
105
                                                     const char* inDestinationPath,
112
                                                     const char* inDestinationPath,
106
                                                     const bool inOverwrite );
113
                                                     const bool inOverwrite,
114
                                                     const char* inLockToken );
107
115
108
    SerfRequestProcessorImpl* createMoveReqProcImpl( const char* inSourcePath,
116
    SerfRequestProcessorImpl* createMoveReqProcImpl( const char* inSourcePath,
109
                                                     const DAVRequestHeaders& inRequestHeaders,
117
                                                     const DAVRequestHeaders& inRequestHeaders,
110
                                                     const char* inDestinationPath,
118
                                                     const char* inDestinationPath,
111
                                                     const bool inOverwrite );
119
                                                     const bool inOverwrite,
120
                                                     const char* inLockToken );
121
122
    SerfRequestProcessorImpl* createLockReqProcImpl( const char* inSourcePath,
123
                                                     const DAVRequestHeaders& inRequestHeaders,
124
                                                     const ucb::Lock& inLock,
125
                                                     const char* inTimeout,
126
                                                     DAVPropertyValue & outLock );
127
128
    SerfRequestProcessorImpl* createLockRefreshProcImpl( const char* inSourcePath,
129
                                                     const DAVRequestHeaders& inRequestHeaders,
130
                                                     const ucb::Lock& inLock,
131
                                                     const char* inToken,
132
                                                     const char* inTimeout,
133
                                                     DAVPropertyValue & outLock );
134
135
    SerfRequestProcessorImpl* createUnlockProcImpl( const char* inSourcePath,
136
                                                     const DAVRequestHeaders& inRequestHeaders,
137
                                                     const ucb::Lock& inLock,
138
                                                     const char* inToken );
112
139
113
} // namespace http_dav_ucp
140
} // namespace http_dav_ucp
114
141
(-)a/main/ucb/source/ucp/webdav/SerfSession.cxx (-185 / +243 lines)
Lines 26-31 Link Here
26
#include <vector>
26
#include <vector>
27
#include <string.h>
27
#include <string.h>
28
#include <rtl/string.h>
28
#include <rtl/string.h>
29
#include <rtl/ustrbuf.hxx>
30
#include <osl/time.h>
29
#include "comphelper/sequence.hxx"
31
#include "comphelper/sequence.hxx"
30
#include "ucbhelper/simplecertificatevalidationrequest.hxx"
32
#include "ucbhelper/simplecertificatevalidationrequest.hxx"
31
33
Lines 57-66 Link Here
57
using namespace com::sun::star;
59
using namespace com::sun::star;
58
using namespace http_dav_ucp;
60
using namespace http_dav_ucp;
59
61
60
61
// -------------------------------------------------------------------
62
// -------------------------------------------------------------------
62
// static members!
63
// static members!
63
//SerfLockStore SerfSession::m_aSerfLockStore;
64
SerfLockStore SerfSession::m_aSerfLockStore;
64
65
65
// -------------------------------------------------------------------
66
// -------------------------------------------------------------------
66
// Constructor
67
// Constructor
Lines 75-80 SerfSession::SerfSession( Link Here
75
    , m_aUri( inUri )
76
    , m_aUri( inUri )
76
    , m_aProxyName()
77
    , m_aProxyName()
77
    , m_nProxyPort( 0 )
78
    , m_nProxyPort( 0 )
79
    , m_aServerHeaderField()
78
    , m_pSerfConnection( 0 )
80
    , m_pSerfConnection( 0 )
79
    , m_pSerfContext( 0 )
81
    , m_pSerfContext( 0 )
80
    , m_bIsHeadRequestInProgress( false )
82
    , m_bIsHeadRequestInProgress( false )
Lines 97-102 SerfSession::~SerfSession( ) Link Here
97
    {
99
    {
98
        serf_connection_close( m_pSerfConnection );
100
        serf_connection_close( m_pSerfConnection );
99
        m_pSerfConnection = 0;
101
        m_pSerfConnection = 0;
102
        OSL_TRACE("SerfSession::~SerfSession: closed serf connection");
100
    }
103
    }
101
}
104
}
102
105
Lines 126-131 void SerfSession::Init() Link Here
126
129
127
        // Not yet initialized. Create new session.
130
        // Not yet initialized. Create new session.
128
        bCreateNewSession = true;
131
        bCreateNewSession = true;
132
        OSL_TRACE("SerfSession::Init: serf connection created");
129
    }
133
    }
130
    else
134
    else
131
    {
135
    {
Lines 166-172 void SerfSession::Init() Link Here
166
        if ( m_aProxyName.getLength() )
170
        if ( m_aProxyName.getLength() )
167
        {
171
        {
168
            apr_sockaddr_t *proxy_address = NULL;
172
            apr_sockaddr_t *proxy_address = NULL;
169
            status = apr_sockaddr_info_get( &proxy_address, 
173
            status = apr_sockaddr_info_get( &proxy_address,
170
                                                               rtl::OUStringToOString( m_aProxyName, RTL_TEXTENCODING_UTF8 ).getStr(), 
174
                                                               rtl::OUStringToOString( m_aProxyName, RTL_TEXTENCODING_UTF8 ).getStr(), 
171
                                                               APR_UNSPEC,
175
                                                               APR_UNSPEC,
172
                                                               static_cast<apr_port_t>(m_nProxyPort), 
176
                                                               static_cast<apr_port_t>(m_nProxyPort), 
Lines 223-228 char* SerfSession::getHostinfo() Link Here
223
    return m_aUri.getAprUri()->hostinfo;
227
    return m_aUri.getAprUri()->hostinfo;
224
}
228
}
225
229
230
// -------------------------------------------------------------------
231
// helper function
232
// it composes the uri for lockstore registration
233
rtl::OUString SerfSession::composeCurrentUri(const rtl::OUString & inPath)
234
{
235
    rtl::OUString aScheme( m_aUri.GetScheme() );
236
    rtl::OUStringBuffer aBuf( aScheme );
237
    aBuf.appendAscii( "://" );
238
    if ( m_aUri.GetUserInfo().getLength() > 0 )
239
    {
240
        aBuf.append( m_aUri.GetUserInfo() );
241
        aBuf.appendAscii( "@" );
242
    }
243
    // Is host a numeric IPv6 address?
244
    if ( ( m_aUri.GetHost().indexOf( ':' ) != -1 ) &&
245
         ( m_aUri.GetHost()[ 0 ] != sal_Unicode( '[' ) ) )
246
    {
247
        aBuf.appendAscii( "[" );
248
        aBuf.append( m_aUri.GetHost() );
249
        aBuf.appendAscii( "]" );
250
    }
251
    else
252
    {
253
        aBuf.append( m_aUri.GetHost() );
254
    }
255
256
    // append port, but only, if not default port.
257
    bool bAppendPort = true;
258
    sal_Int32 aPort = m_aUri.GetPort();
259
    switch ( aPort )
260
    {
261
    case DEFAULT_HTTP_PORT:
262
        bAppendPort = aScheme.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http" ) );
263
        break;
264
265
    case DEFAULT_HTTPS_PORT:
266
        bAppendPort = !aScheme.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "https" ) );
267
        break;
268
    }
269
    if ( bAppendPort )
270
    {
271
        aBuf.appendAscii( ":" );
272
        aBuf.append( rtl::OUString::valueOf( aPort ) );
273
    }
274
    aBuf.append( inPath );
275
276
    rtl::OUString   aUri(aBuf.makeStringAndClear() );
277
    return aUri;
278
}
226
279
227
// -------------------------------------------------------------------
280
// -------------------------------------------------------------------
228
// virtual
281
// virtual
Lines 259-269 apr_status_t SerfSession::setupSerfConnection( apr_socket_t * inAprSocket, Link Here
259
                                               apr_pool_t* /*inAprPool*/ )
312
                                               apr_pool_t* /*inAprPool*/ )
260
{
313
{
261
    serf_bucket_t *tmpInputBkt;
314
    serf_bucket_t *tmpInputBkt;
262
    tmpInputBkt = serf_context_bucket_socket_create( getSerfContext(), 
315
    tmpInputBkt = serf_context_bucket_socket_create( getSerfContext(),
263
                                                     inAprSocket, 
316
                                                     inAprSocket,
264
                                                     getSerfBktAlloc() );
317
                                                     getSerfBktAlloc() );
265
    
318
266
    if ( isSSLNeeded() ) 
319
    if ( isSSLNeeded() )
267
    {
320
    {
268
        tmpInputBkt = serf_bucket_ssl_decrypt_create( tmpInputBkt,
321
        tmpInputBkt = serf_bucket_ssl_decrypt_create( tmpInputBkt,
269
                                                      0,
322
                                                      0,
Lines 276-282 apr_status_t SerfSession::setupSerfConnection( apr_socket_t * inAprSocket, Link Here
276
            NULL,
329
            NULL,
277
            Serf_CertificateChainValidation,
330
            Serf_CertificateChainValidation,
278
            this);
331
            this);
279
        serf_ssl_set_hostname( serf_bucket_ssl_decrypt_context_get( tmpInputBkt ), 
332
        serf_ssl_set_hostname( serf_bucket_ssl_decrypt_context_get( tmpInputBkt ),
280
                               getHostinfo() );
333
                               getHostinfo() );
281
334
282
        *outSerfOutputBucket = serf_bucket_ssl_encrypt_create( *outSerfOutputBucket, 
335
        *outSerfOutputBucket = serf_bucket_ssl_encrypt_create( *outSerfOutputBucket, 
Lines 290-299 apr_status_t SerfSession::setupSerfConnection( apr_socket_t * inAprSocket, Link Here
290
}
343
}
291
344
292
apr_status_t SerfSession::provideSerfCredentials( bool bGiveProvidedCredentialsASecondTry,
345
apr_status_t SerfSession::provideSerfCredentials( bool bGiveProvidedCredentialsASecondTry,
293
                                                  char ** outUsername, 
346
                                                  char ** outUsername,
294
                                                  char ** outPassword,
347
                                                  char ** outPassword,
295
                                                  serf_request_t * /*inRequest*/, 
348
                                                  serf_request_t * /*inRequest*/,
296
                                                  int /*inCode*/, 
349
                                                  int /*inCode*/,
297
                                                  const char *inAuthProtocol,
350
                                                  const char *inAuthProtocol,
298
                                                  const char *inRealm,
351
                                                  const char *inRealm,
299
                                                  apr_pool_t *inAprPool )
352
                                                  apr_pool_t *inAprPool )
Lines 600-606 serf_bucket_t* SerfSession::acceptSerfResponse( serf_request_t * inSerfRequest, Link Here
600
                                                             SerfBktAlloc );
653
                                                             SerfBktAlloc );
601
654
602
    // create response bucket
655
    // create response bucket
603
    responseBkt = serf_bucket_response_create( responseBkt, 
656
    responseBkt = serf_bucket_response_create( responseBkt,
604
                                               SerfBktAlloc );
657
                                               SerfBktAlloc );
605
658
606
    if ( isHeadRequestInProgress() )
659
    if ( isHeadRequestInProgress() )
Lines 693-699 void SerfSession::PROPPATCH( const rtl::OUString & inPath, Link Here
693
746
694
    apr_status_t status = APR_SUCCESS;
747
    apr_status_t status = APR_SUCCESS;
695
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
748
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
749
    //check whether a lock on this resource is already owned
750
    rtl::OUString aUri( composeCurrentUri( inPath ) );
751
    ucb::Lock inLock;
752
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
753
    if ( pLock )
754
    {
755
        inLock = pLock->getLock();
756
    }
696
    aReqProc->processPropPatch( inValues,
757
    aReqProc->processPropPatch( inValues,
758
                                inLock,
697
                                status );
759
                                status );
698
760
699
    HandleError( aReqProc );
761
    HandleError( aReqProc );
Lines 843-850 void SerfSession::PUT( const rtl::OUString & inPath, Link Here
843
    if ( !getDataFromInputStream( inInputStream, aDataToSend, false ) )
905
    if ( !getDataFromInputStream( inInputStream, aDataToSend, false ) )
844
        throw DAVException( DAVException::DAV_INVALID_ARG );
906
        throw DAVException( DAVException::DAV_INVALID_ARG );
845
    apr_status_t status = APR_SUCCESS;
907
    apr_status_t status = APR_SUCCESS;
908
909
    //check whether a lock on this resource is already owned
910
    rtl::OUString aUri( composeCurrentUri( inPath ) );
911
    ucb::Lock inLock;
912
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
913
    if ( pLock )
914
    {
915
        inLock = pLock->getLock();
916
    }
846
    aReqProc->processPut( reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
917
    aReqProc->processPut( reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
847
                          aDataToSend.getLength(),
918
                          aDataToSend.getLength(),
919
                          inLock,
848
                          status );
920
                          status );
849
921
850
    HandleError( aReqProc );
922
    HandleError( aReqProc );
Lines 874-883 SerfSession::POST( const rtl::OUString & inPath, Link Here
874
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
946
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
875
    uno::Reference< SerfInputStream > xInputStream( new SerfInputStream );
947
    uno::Reference< SerfInputStream > xInputStream( new SerfInputStream );
876
    apr_status_t status = APR_SUCCESS;
948
    apr_status_t status = APR_SUCCESS;
949
    //check whether a lock on this resource is already owned
950
    rtl::OUString aUri( composeCurrentUri( inPath ) );
951
    ucb::Lock inLock;
952
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
953
    if ( pLock )
954
    {
955
        inLock = pLock->getLock();
956
    }
877
    aReqProc->processPost( reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
957
    aReqProc->processPost( reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
878
                           aDataToSend.getLength(),
958
                           aDataToSend.getLength(),
879
                           rContentType,
959
                           rContentType,
880
                           rReferer,
960
                           rReferer,
961
                           inLock,
881
                           xInputStream,
962
                           xInputStream,
882
                           status );
963
                           status );
883
964
Lines 908-917 void SerfSession::POST( const rtl::OUString & inPath, Link Here
908
989
909
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
990
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
910
    apr_status_t status = APR_SUCCESS;
991
    apr_status_t status = APR_SUCCESS;
992
    //check whether a lock on this resource is already owned
993
    rtl::OUString aUri( composeCurrentUri( inPath ) );
994
    ucb::Lock inLock;
995
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
996
    if ( pLock )
997
    {
998
        inLock = pLock->getLock();
999
    }
911
    aReqProc->processPost( reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
1000
    aReqProc->processPost( reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
912
                           aDataToSend.getLength(),
1001
                           aDataToSend.getLength(),
913
                           rContentType,
1002
                           rContentType,
914
                           rReferer,
1003
                           rReferer,
1004
                           inLock,
915
                           oOutputStream,
1005
                           oOutputStream,
916
                           status );
1006
                           status );
917
1007
Lines 931-937 void SerfSession::MKCOL( const rtl::OUString & inPath, Link Here
931
1021
932
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1022
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
933
    apr_status_t status = APR_SUCCESS;
1023
    apr_status_t status = APR_SUCCESS;
934
    aReqProc->processMkCol( status );
1024
    //check whether a lock on the destination resource is already owned
1025
    rtl::OUString aUri( composeCurrentUri( inPath ) );
1026
    ucb::Lock inLock;
1027
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
1028
    if ( pLock )
1029
    {
1030
        inLock = pLock->getLock();
1031
    }
1032
    aReqProc->processMkCol( inLock, status );
935
1033
936
    HandleError( aReqProc );
1034
    HandleError( aReqProc );
937
}
1035
}
Lines 952-959 void SerfSession::COPY( const rtl::OUString & inSourceURL, Link Here
952
    SerfUri theSourceUri( inSourceURL );
1050
    SerfUri theSourceUri( inSourceURL );
953
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( theSourceUri.GetPath() ) );
1051
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( theSourceUri.GetPath() ) );
954
    apr_status_t status = APR_SUCCESS;
1052
    apr_status_t status = APR_SUCCESS;
1053
    //check whether a lock on the destination resource is already owned
1054
    rtl::OUString aUri( composeCurrentUri( inDestinationURL ) );
1055
    ucb::Lock inLock;
1056
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
1057
    if ( pLock )
1058
    {
1059
        inLock = pLock->getLock();
1060
    }
955
    aReqProc->processCopy( inDestinationURL,
1061
    aReqProc->processCopy( inDestinationURL,
956
                           (inOverWrite ? true : false),
1062
                           (inOverWrite ? true : false),
1063
                           inLock,
957
                           status );
1064
                           status );
958
1065
959
    HandleError( aReqProc );
1066
    HandleError( aReqProc );
Lines 975-982 void SerfSession::MOVE( const rtl::OUString & inSourceURL, Link Here
975
    SerfUri theSourceUri( inSourceURL );
1082
    SerfUri theSourceUri( inSourceURL );
976
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( theSourceUri.GetPath() ) );
1083
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( theSourceUri.GetPath() ) );
977
    apr_status_t status = APR_SUCCESS;
1084
    apr_status_t status = APR_SUCCESS;
1085
    //check whether a lock on the destination resource is already owned
1086
    rtl::OUString aUri( composeCurrentUri( inDestinationURL ) );
1087
    ucb::Lock inLock;
1088
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
1089
    if ( pLock )
1090
    {
1091
        inLock = pLock->getLock();
1092
    }
978
    aReqProc->processMove( inDestinationURL,
1093
    aReqProc->processMove( inDestinationURL,
979
                           (inOverWrite ? true : false),
1094
                           (inOverWrite ? true : false),
1095
                           inLock,
980
                           status );
1096
                           status );
981
1097
982
    HandleError( aReqProc );
1098
    HandleError( aReqProc );
Lines 995-1019 void SerfSession::DESTROY( const rtl::OUString & inPath, Link Here
995
1111
996
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1112
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
997
    apr_status_t status = APR_SUCCESS;
1113
    apr_status_t status = APR_SUCCESS;
998
    aReqProc->processDelete( status );
1114
    //check whether a lock on this resource is already owned
1115
    rtl::OUString aUri( composeCurrentUri( inPath ) );
1116
    ucb::Lock inLock;
1117
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
1118
    if ( pLock )
1119
    {
1120
        inLock = pLock->getLock();
1121
    }
1122
    aReqProc->processDelete( inLock, status );
999
1123
1000
    HandleError( aReqProc );
1124
    HandleError( aReqProc );
1001
}
1125
}
1002
1126
1003
// -------------------------------------------------------------------
1127
// -------------------------------------------------------------------
1004
/*
1128
1005
namespace
1129
namespace
1006
{
1130
{
1007
    sal_Int32 lastChanceToSendRefreshRequest( TimeValue const & rStart,
1131
    sal_Int32 lastChanceToSendRefreshRequest( TimeValue const & rStart,
1008
                                              int timeout )
1132
                                              sal_Int32 timeout )
1009
    {
1133
    {
1010
        TimeValue aEnd;
1134
        TimeValue aEnd;
1011
        osl_getSystemTime( &aEnd );
1135
        osl_getSystemTime( &aEnd );
1012
1136
1013
        // Try to estimate a safe absolute time for sending the
1137
        // Try to estimate a safe absolute time for sending the
1014
        // lock refresh request.
1138
        // lock refresh request.
1015
        sal_Int32 lastChanceToSendRefreshRequest = -1;
1139
        sal_Int32 lastChanceToSendRefreshRequest = DAVINFINITY;
1016
        if ( timeout != NE_TIMEOUT_INFINITE )
1140
        if ( timeout != DAVINFINITY )
1017
        {
1141
        {
1018
            sal_Int32 calltime = aEnd.Seconds - rStart.Seconds;
1142
            sal_Int32 calltime = aEnd.Seconds - rStart.Seconds;
1019
            if ( calltime <= timeout )
1143
            if ( calltime <= timeout )
Lines 1030-1137 namespace Link Here
1030
    }
1154
    }
1031
1155
1032
} // namespace
1156
} // namespace
1033
*/
1157
1034
// -------------------------------------------------------------------
1158
// -------------------------------------------------------------------
1035
// LOCK (set new lock)
1159
// LOCK (set new lock)
1036
// -------------------------------------------------------------------
1160
// -------------------------------------------------------------------
1037
void SerfSession::LOCK( const ::rtl::OUString & inPath,
1161
void SerfSession::LOCK( const ::rtl::OUString & inPath,
1038
                        ucb::Lock & /*rLock*/,
1162
                        ucb::Lock & rLock,
1039
                        const DAVRequestEnvironment & rEnv )
1163
                        const DAVRequestEnvironment & rEnv )
1040
    throw ( DAVException )
1164
    throw ( DAVException )
1041
{
1165
{
1042
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1166
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1043
1167
1044
    Init( rEnv );
1168
    //before locking, search in the lock store if we already own a lock for this resource
1045
1169
    //if present, return with exception DAV_LOCKED_SELF
1046
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1170
    rtl::OUString   aUri( composeCurrentUri( inPath ) );
1047
    HandleError( aReqProc );
1171
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
1048
    /* Create a depth zero, exclusive write lock, with default timeout
1172
    if ( pLock )
1049
     * (allowing a server to pick a default).  token, owner and uri are
1050
     * unset. */
1051
    /*
1052
    SerfLock * theLock = ne_lock_create();
1053
1054
    // Set the lock uri
1055
    ne_uri aUri;
1056
    ne_uri_parse( rtl::OUStringToOString( makeAbsoluteURL( inPath ),
1057
                                          RTL_TEXTENCODING_UTF8 ).getStr(),
1058
                  &aUri );
1059
    theLock->uri = aUri;
1060
1061
    // Set the lock depth
1062
    switch( rLock.Depth )
1063
    {
1173
    {
1064
    case ucb::LockDepth_ZERO:
1174
//already present, meaning already locked by the same AOO session and already in the lockstore
1065
        theLock->depth = NE_DEPTH_ZERO;
1175
//just return, nothing to do
1066
        break;
1176
        return;
1067
    case ucb::LockDepth_ONE:
1068
        theLock->depth = NE_DEPTH_ONE;
1069
        break;
1070
    case ucb::LockDepth_INFINITY:
1071
        theLock->depth = NE_DEPTH_INFINITE;
1072
        break;
1073
    default:
1074
        throw DAVException( DAVException::DAV_INVALID_ARG );
1075
    }
1177
    }
1076
1178
1077
    // Set the lock scope
1179
    Init( rEnv );
1078
    switch ( rLock.Scope )
1180
1079
    {
1181
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1080
    case ucb::LockScope_EXCLUSIVE:
1182
    apr_status_t status = APR_SUCCESS;
1081
        theLock->scope = ne_lockscope_exclusive;
1082
        break;
1083
    case ucb::LockScope_SHARED:
1084
        theLock->scope = ne_lockscope_shared;
1085
        break;
1086
    default:
1087
        throw DAVException( DAVException::DAV_INVALID_ARG );
1088
    }
1089
1183
1090
    // Set the lock timeout
1184
    //the returned property, a sequence of locks
1091
    theLock->timeout = (long)rLock.Timeout;
1185
    //only the first is used
1186
    DAVPropertyValue outLock;
1092
1187
1093
    // Set the lock owner
1094
    rtl::OUString aValue;
1095
    rLock.Owner >>= aValue;
1096
    theLock->owner =
1097
        ne_strdup( rtl::OUStringToOString( aValue,
1098
                                           RTL_TEXTENCODING_UTF8 ).getStr() );
1099
    TimeValue startCall;
1188
    TimeValue startCall;
1100
    osl_getSystemTime( &startCall );
1189
    osl_getSystemTime( &startCall );
1190
    aReqProc->processLock(inPath, rLock, outLock, status);
1101
1191
1102
    int theRetVal = ne_lock( m_pHttpSession, theLock );
1192
    //HandleError will handle the error and throw an exception, if needed
1103
1193
    HandleError( aReqProc );
1104
    if ( theRetVal == NE_OK )
1105
    {
1106
        m_aSerfLockStore.addLock( theLock,
1107
                                  this,
1108
                                  lastChanceToSendRefreshRequest(
1109
                                      startCall, theLock->timeout ) );
1110
1111
        uno::Sequence< rtl::OUString > aTokens( 1 );
1112
        aTokens[ 0 ] = rtl::OUString::createFromAscii( theLock->token );
1113
        rLock.LockTokens = aTokens;
1114
1194
1115
        OSL_TRACE( "SerfSession::LOCK: created lock for %s. token: %s",
1195
    if(outLock.Name.compareToAscii(RTL_CONSTASCII_STRINGPARAM( "DAV:lockdiscovery" )) == 0 )
1116
                   rtl::OUStringToOString( makeAbsoluteURL( inPath ),
1117
                                           RTL_TEXTENCODING_UTF8 ).getStr(),
1118
                   theLock->token );
1119
    }
1120
    else
1121
    {
1196
    {
1122
        ne_lock_destroy( theLock );
1197
        //got a lock, use only the first returned
1123
1198
        uno::Sequence< ucb::Lock >      aLocks;
1124
        OSL_TRACE( "SerfSession::LOCK: obtaining lock for %s failed!",
1199
        outLock.Value >>= aLocks;
1125
                   rtl::OUStringToOString( makeAbsoluteURL( inPath ),
1200
        ucb::Lock aLock = aLocks[0];
1126
                                           RTL_TEXTENCODING_UTF8 ).getStr() );
1201
1202
        SerfLock* aNewLock = new SerfLock( aLock, aUri, inPath );
1203
        // add the store the new lock
1204
        m_aSerfLockStore.addLock(aNewLock,this,
1205
                                 lastChanceToSendRefreshRequest(
1206
                                     startCall, static_cast< sal_Int32 >(aLock.Timeout) ) );
1127
    }
1207
    }
1128
1208
1129
    HandleError( theRetVal, inPath, rEnv );
1130
    */
1131
}
1209
}
1132
1210
1133
// -------------------------------------------------------------------
1211
// -------------------------------------------------------------------
1134
// LOCK (refresh existing lock)
1212
// LOCK (refresh existing lock from DAVResourceAccess)
1135
// -------------------------------------------------------------------
1213
// -------------------------------------------------------------------
1136
sal_Int64 SerfSession::LOCK( const ::rtl::OUString & /*inPath*/,
1214
sal_Int64 SerfSession::LOCK( const ::rtl::OUString & /*inPath*/,
1137
                             sal_Int64 nTimeout,
1215
                             sal_Int64 nTimeout,
Lines 1172-1263 sal_Int64 SerfSession::LOCK( const ::rtl::OUString & /*inPath*/, Link Here
1172
}
1250
}
1173
1251
1174
// -------------------------------------------------------------------
1252
// -------------------------------------------------------------------
1175
// LOCK (refresh existing lock)
1253
// LOCK (refresh existing lock from SerfLockStore)
1176
// -------------------------------------------------------------------
1254
// -------------------------------------------------------------------
1177
bool SerfSession::LOCK( SerfLock * /*pLock*/,
1255
bool SerfSession::LOCK( SerfLock * pLock,
1178
                        sal_Int32 & /*rlastChanceToSendRefreshRequest*/ )
1256
                        sal_Int32 & rlastChanceToSendRefreshRequest )
1179
{
1257
{
1180
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1258
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1259
    rtl::OUString inPath = pLock->getResourcePath();
1181
1260
1182
    return true;
1261
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1183
    /*
1262
    apr_status_t status = APR_SUCCESS;
1184
    // refresh existing lock.
1263
1264
    //the returned property, a sequence of locks
1265
    //only the first is used
1266
    DAVPropertyValue outLock;
1185
1267
1186
    TimeValue startCall;
1268
    TimeValue startCall;
1187
    osl_getSystemTime( &startCall );
1269
    osl_getSystemTime( &startCall );
1188
1270
1189
    if ( ne_lock_refresh( m_pHttpSession, pLock ) == NE_OK )
1271
    // refresh existing lock.
1190
    {
1272
    aReqProc->processLockRefresh( inPath, pLock->getLock(), outLock, status);
1191
        rlastChanceToSendRefreshRequest
1192
            = lastChanceToSendRefreshRequest( startCall, pLock->timeout );
1193
1273
1194
        OSL_TRACE( "Lock successfully refreshed." );
1274
    // TODO: possible enhancement as the following:
1195
        return true;
1275
    // - use an interaction handler to alert the user if the lock was not refreshed,
1196
    }
1276
    //   offering to try again with a new session, asking the user for credential, if necessary.
1197
    else
1277
    //   This may happen if the WebDAV server goes off-line for whatever reason, or the connection is dropped for time-out
1198
    {
1278
    //   To implement this behavior, some redesigning of the current session implementation may be needed.
1199
        OSL_TRACE( "Lock not refreshed!" );
1279
    //
1200
        return false;
1280
1201
    }
1281
    //HandleError will handle the error and throw an exception, if needed
1202
    */
1282
    HandleError( aReqProc );
1283
1284
    uno::Sequence< ucb::Lock >      aLocks;
1285
    outLock.Value >>= aLocks;
1286
    ucb::Lock aLock = aLocks[0];
1287
1288
    //if ok, udate the lastchance refresh time in lock
1289
    rlastChanceToSendRefreshRequest
1290
        = lastChanceToSendRefreshRequest( startCall, static_cast< sal_Int32 >(aLock.Timeout) );
1291
1292
    return true;
1203
}
1293
}
1204
1294
1205
// -------------------------------------------------------------------
1295
// -------------------------------------------------------------------
1206
// UNLOCK
1296
// UNLOCK called from external (DAVResourceAccess)
1207
// -------------------------------------------------------------------
1297
// -------------------------------------------------------------------
1208
void SerfSession::UNLOCK( const ::rtl::OUString & /*inPath*/,
1298
void SerfSession::UNLOCK( const ::rtl::OUString & inPath,
1209
                          const DAVRequestEnvironment & /*rEnv*/ )
1299
                          const DAVRequestEnvironment & rEnv )
1210
    throw ( DAVException )
1300
    throw ( DAVException )
1211
{
1301
{
1212
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1302
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1213
1303
1214
    /*
1304
    rtl::OUString aUri( composeCurrentUri( inPath ) );
1215
    // get the neon lock from lock store
1305
    SerfLock * pLock = m_aSerfLockStore.findByUri( aUri );
1216
    SerfLock * theLock
1306
    if ( !pLock )
1217
        = m_aSerfLockStore.findByUri( makeAbsoluteURL( inPath ) );
1307
    {
1218
    if ( !theLock )
1219
        throw DAVException( DAVException::DAV_NOT_LOCKED );
1308
        throw DAVException( DAVException::DAV_NOT_LOCKED );
1309
    }
1220
1310
1221
    Init( rEnv );
1311
    Init( rEnv );
1222
1312
1223
    int theRetVal = ne_unlock( m_pHttpSession, theLock );
1313
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1314
    apr_status_t status = APR_SUCCESS;
1224
1315
1225
    if ( theRetVal == NE_OK )
1316
    ucb::Lock inLock = pLock->getLock();
1226
    {
1317
    //remove lock from lockstore
1227
        m_aSerfLockStore.removeLock( theLock );
1318
    // so, if something goes wrong, we don't refresh it anymore
1228
        ne_lock_destroy( theLock );
1319
    m_aSerfLockStore.removeLock(pLock);
1229
    }
1320
    delete pLock;
1230
    else
1231
    {
1232
        OSL_TRACE( "SerfSession::UNLOCK: unlocking of %s failed.",
1233
                   rtl::OUStringToOString( makeAbsoluteURL( inPath ),
1234
                                           RTL_TEXTENCODING_UTF8 ).getStr() );
1235
    }
1236
1321
1237
    HandleError( theRetVal, inPath, rEnv );
1322
    // remove existing lock
1238
    */
1323
    aReqProc->processUnlock( inPath, inLock, status);
1324
1325
    //HandleError will handle the error and throw an exception, if needed
1326
    HandleError( aReqProc );
1239
}
1327
}
1240
1328
1241
// -------------------------------------------------------------------
1329
// -------------------------------------------------------------------
1242
// UNLOCK
1330
// UNLOCK (called from SerfLockStore)
1243
// -------------------------------------------------------------------
1331
// -------------------------------------------------------------------
1244
bool SerfSession::UNLOCK( SerfLock * /*pLock*/ )
1332
bool SerfSession::UNLOCK( SerfLock * pLock )
1245
{
1333
{
1246
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1334
    osl::Guard< osl::Mutex > theGuard( m_aMutex );
1335
    rtl::OUString inPath = pLock->getResourcePath();
1336
1337
    boost::shared_ptr<SerfRequestProcessor> aReqProc( createReqProc( inPath ) );
1338
    apr_status_t status = APR_SUCCESS;
1339
1340
    rtl::OUString   aToken;
1341
    aToken = pLock->getLock().LockTokens[0];
1342
1343
    aReqProc->processUnlock( inPath, pLock->getLock(), status);
1344
1345
    //HandleError will handle the error and throw an exception, if needed
1346
    HandleError( aReqProc );
1247
1347
1248
    return true;
1348
    return true;
1249
    /*
1250
    if ( ne_unlock( m_pHttpSession, pLock ) == NE_OK )
1251
    {
1252
        OSL_TRACE( "UNLOCK succeeded." );
1253
        return true;
1254
    }
1255
    else
1256
    {
1257
        OSL_TRACE( "UNLOCK failed!" );
1258
        return false;
1259
    }
1260
    */
1261
}
1349
}
1262
1350
1263
// -------------------------------------------------------------------
1351
// -------------------------------------------------------------------
Lines 1315-1320 bool containsLocktoken( const uno::Sequence< ucb::Lock > & rLocks, Link Here
1315
*/
1403
*/
1316
1404
1317
// -------------------------------------------------------------------
1405
// -------------------------------------------------------------------
1406
// This method doesn't seem to be used.
1407
// In any case the default behavior is to ask a lock whith a life of 3 minutes
1408
// it will then be refreshed automatically (see SerfLockStore class)
1409
// In case of AOO crash the lock will expire by itself
1318
bool SerfSession::removeExpiredLocktoken( const rtl::OUString & /*inURL*/,
1410
bool SerfSession::removeExpiredLocktoken( const rtl::OUString & /*inURL*/,
1319
                                          const DAVRequestEnvironment & /*rEnv*/ )
1411
                                          const DAVRequestEnvironment & /*rEnv*/ )
1320
{
1412
{
Lines 1612-1648 SerfSession::isDomainMatch( rtl::OUString certHostName ) Link Here
1612
    }
1704
    }
1613
    return sal_False;
1705
    return sal_False;
1614
}
1706
}
1615
1616
/*
1617
// ---------------------------------------------------------------------
1618
rtl::OUString SerfSession::makeAbsoluteURL( rtl::OUString const & rURL ) const
1619
{
1620
    try
1621
    {
1622
        // Is URL relative or already absolute?
1623
        if ( rURL[ 0 ] != sal_Unicode( '/' ) )
1624
        {
1625
            // absolute.
1626
            return rtl::OUString( rURL );
1627
        }
1628
        else
1629
        {
1630
            ne_uri aUri;
1631
            memset( &aUri, 0, sizeof( aUri ) );
1632
1633
            ne_fill_server_uri( m_pHttpSession, &aUri );
1634
            aUri.path
1635
                = ne_strdup( rtl::OUStringToOString(
1636
                    rURL, RTL_TEXTENCODING_UTF8 ).getStr() );
1637
            SerfUri aSerfUri( &aUri );
1638
            ne_uri_free( &aUri );
1639
            return aSerfUri.GetURI();
1640
        }
1641
    }
1642
    catch ( DAVException const & )
1643
    {
1644
    }
1645
    // error.
1646
    return rtl::OUString();
1647
}
1648
*/
(-)a/main/ucb/source/ucp/webdav/SerfSession.hxx (-3 / +13 lines)
Lines 27-35 Link Here
27
#include <vector>
27
#include <vector>
28
#include <boost/shared_ptr.hpp>
28
#include <boost/shared_ptr.hpp>
29
#include <osl/mutex.hxx>
29
#include <osl/mutex.hxx>
30
#include "DAVResource.hxx"
30
#include "DAVSession.hxx"
31
#include "DAVSession.hxx"
31
#include "SerfTypes.hxx"
32
#include "SerfTypes.hxx"
32
//#include "SerfLockStore.hxx"
33
#include "SerfLockStore.hxx"
33
#include "SerfUri.hxx"
34
#include "SerfUri.hxx"
34
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
35
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
35
36
Lines 54-59 private: Link Here
54
    
55
    
55
    rtl::OUString           m_aProxyName;
56
    rtl::OUString           m_aProxyName;
56
    sal_Int32               m_nProxyPort;
57
    sal_Int32               m_nProxyPort;
58
    // The server, according RFC7231
59
    // http://tools.ietf.org/html/rfc7231#section-7.4.2
60
    rtl::OUString           m_aServerHeaderField;
57
    
61
    
58
    SerfConnection*         m_pSerfConnection;
62
    SerfConnection*         m_pSerfConnection;
59
    serf_context_t*         m_pSerfContext;
63
    serf_context_t*         m_pSerfContext;
Lines 66-77 private: Link Here
66
70
67
    DAVRequestEnvironment m_aEnv;
71
    DAVRequestEnvironment m_aEnv;
68
72
69
//    static SerfLockStore m_aSerfLockStore;
73
    static SerfLockStore m_aSerfLockStore;
70
74
71
    char* getHostinfo();
75
    char* getHostinfo();
72
    bool isSSLNeeded();
76
    bool isSSLNeeded();
73
77
74
    SerfRequestProcessor* createReqProc( const rtl::OUString & inPath );
78
    SerfRequestProcessor*   createReqProc( const rtl::OUString & inPath );
79
80
    rtl::OUString           composeCurrentUri( const rtl::OUString & inPath );
75
81
76
protected:
82
protected:
77
    virtual ~SerfSession();
83
    virtual ~SerfSession();
Lines 258-263 public: Link Here
258
264
259
    sal_Bool isDomainMatch( rtl::OUString certHostName );
265
    sal_Bool isDomainMatch( rtl::OUString certHostName );
260
266
267
    const rtl::OUString & getServerHeaderField() { return m_aServerHeaderField; };
268
269
    void setServerHeaderField( rtl::OUString aServerHeaderField ) { m_aServerHeaderField = aServerHeaderField; };
270
261
private:
271
private:
262
    friend class SerfLockStore;
272
    friend class SerfLockStore;
263
273
(-)a/main/ucb/source/ucp/webdav/SerfTypes.hxx (-2 / +31 lines)
Lines 25-37 Link Here
25
#define INCLUDED_SERFTYPES_HXX
25
#define INCLUDED_SERFTYPES_HXX
26
26
27
#include <serf.h>
27
#include <serf.h>
28
#include <com/sun/star/ucb/Lock.hpp>
29
#include "DAVTypes.hxx"
30
#include "DAVRequestEnvironment.hxx"
31
32
using namespace com::sun::star;
33
34
namespace http_dav_ucp
35
{
28
36
29
typedef serf_connection_t SerfConnection;
37
typedef serf_connection_t SerfConnection;
30
38
31
// TODO, figure out type of <SerfLock>
39
class SerfLock
32
typedef int SerfLock;
40
{
41
private:
42
    ucb::Lock               mLock;
43
    const rtl::OUString     mResourceUri;
44
    const rtl::OUString     mPathStr;
45
    // const DAVRequestEnvironment& mrRequestEnvironment;
46
public:
47
48
    SerfLock(const ucb::Lock inLock, rtl::OUString inUri, rtl::OUString inPath)
49
        : mLock( inLock )
50
        , mResourceUri( inUri )
51
        , mPathStr( inPath )
52
        // , mrRequestEnvironment( rEnv )
53
        {};
54
55
    void setLock(const ucb::Lock inLock)  { mLock = inLock; };
56
    const ucb::Lock                 getLock() { return mLock; };
57
    const rtl::OUString             getResourceUri() { return mResourceUri; };
58
    const rtl::OUString             getResourcePath() { return mPathStr; };
59
    // const DAVRequestEnvironment&    getRequestEnvironment() { return mrRequestEnvironment; };
60
};
33
61
34
// TODO, check if we need it later on
62
// TODO, check if we need it later on
35
typedef struct { const char *nspace, *name; } SerfPropName;
63
typedef struct { const char *nspace, *name; } SerfPropName;
36
64
65
};
37
#endif // INCLUDED_SERFTYPES_HXX
66
#endif // INCLUDED_SERFTYPES_HXX
(-)a/main/ucb/source/ucp/webdav/SerfUnlockProcImpl.cxx (+92 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
// MARKER(update_precomp.py): autogen include statement, do not remove
23
#include "precompiled_ucb.hxx"
24
25
#include "SerfTypes.hxx"
26
#include "SerfUnlockProcImpl.hxx"
27
#include "DAVProperties.hxx"
28
29
#include "webdavresponseparser.hxx"
30
#include <serf/serf.h>
31
#include <rtl/ustrbuf.hxx>
32
#include <apr/apr_strings.h>
33
34
namespace http_dav_ucp
35
{
36
37
SerfUnlockProcImpl::SerfUnlockProcImpl( const char* inSourcePath,
38
                                        const DAVRequestHeaders& inRequestHeaders,
39
                                        const ucb::Lock& inLock,
40
                                        const char* inLockToken )
41
    : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
42
    , mLock( inLock )
43
    , mpLockToken( inLockToken )
44
    , xInputStream( new SerfInputStream() )
45
{
46
47
}
48
49
SerfUnlockProcImpl::~SerfUnlockProcImpl()
50
{
51
}
52
53
serf_bucket_t * SerfUnlockProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
54
{
55
    // create serf request
56
    serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
57
                                                                 "UNLOCK",
58
                                                                 getPathStr(),
59
                                                                 0,
60
                                                                 serf_request_get_alloc( inSerfRequest ) );
61
    // set request header fields
62
    serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
63
    if (hdrs_bkt != NULL)
64
    {
65
        // general header fields provided by caller
66
        setRequestHeaders( hdrs_bkt );
67
68
        // request specific header fields
69
        serf_bucket_headers_set( hdrs_bkt, "Lock-Token", mpLockToken );
70
    }
71
    else
72
    {
73
        OSL_ASSERT("Headers Bucket missing");
74
    }
75
76
    return req_bkt;
77
}
78
79
void SerfUnlockProcImpl::processChunkOfResponseData( const char* data, 
80
                                                      apr_size_t len )
81
{
82
    if ( xInputStream.is() )
83
    {
84
        xInputStream->AddToStream( data, len );
85
    }
86
}
87
88
void SerfUnlockProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ )
89
{
90
}
91
92
} // namespace http_dav_ucp
(-)a/main/ucb/source/ucp/webdav/SerfUnlockProcImpl.hxx (+69 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
#ifndef INCLUDED_SERFUNLOCKPROCIMPL_HXX
23
#define INCLUDED_SERFUNLOCKPROCIMPL_HXX
24
25
#include "SerfTypes.hxx"
26
#include "SerfRequestProcessorImpl.hxx"
27
28
#include "SerfInputStream.hxx"
29
30
#include <vector>
31
#include <rtl/ustring.hxx>
32
#include "SerfTypes.hxx"
33
#include "DAVTypes.hxx"
34
#include "DAVResource.hxx"
35
36
namespace http_dav_ucp
37
{
38
39
    class SerfUnlockProcImpl : public SerfRequestProcessorImpl
40
    {
41
42
    protected:
43
        const ucb::Lock     mLock;
44
        const char*         mpLockToken;
45
        com::sun::star::uno::Reference< SerfInputStream > xInputStream;
46
47
    public:
48
        SerfUnlockProcImpl( const char* inSourcePath,
49
                            const DAVRequestHeaders& inRequestHeaders,
50
                            const ucb::Lock& inLock,
51
                            const char* inLockToken );
52
53
        virtual ~SerfUnlockProcImpl();
54
55
        virtual
56
        serf_bucket_t * createSerfRequestBucket( serf_request_t * inSerfRequest );
57
58
    protected:
59
        virtual
60
        void processChunkOfResponseData( const char* data, apr_size_t len );
61
62
        virtual
63
        void handleEndOfResponseData( serf_bucket_t * inSerfResponseBucket );
64
65
    };
66
67
} // namespace http_dav_ucp
68
69
#endif // INCLUDED_SERFUNLOCKPROCIMPL_HXX
(-)a/main/ucb/source/ucp/webdav/makefile.mk (+5 lines)
Lines 131-136 SLOFILES=\ Link Here
131
    $(SLO)$/SerfMkColReqProcImpl.obj \
131
    $(SLO)$/SerfMkColReqProcImpl.obj \
132
    $(SLO)$/SerfCopyReqProcImpl.obj \
132
    $(SLO)$/SerfCopyReqProcImpl.obj \
133
    $(SLO)$/SerfMoveReqProcImpl.obj \
133
    $(SLO)$/SerfMoveReqProcImpl.obj \
134
    $(SLO)$/SerfLockReqProcImpl.obj \
135
    $(SLO)$/SerfLockRefreshProcImpl.obj \
136
    $(SLO)$/SerfUnlockProcImpl.obj \
137
    $(SLO)$/SerfLockStore.obj \
134
    $(SLO)$/SerfSession.obj \
138
    $(SLO)$/SerfSession.obj \
135
    $(SLO)$/SerfCallbacks.obj \
139
    $(SLO)$/SerfCallbacks.obj \
136
    $(SLO)$/SerfInputStream.obj \
140
    $(SLO)$/SerfInputStream.obj \
Lines 148-153 SHL1IMPLIB=i$(TARGET) Link Here
148
SHL1VERSIONMAP=$(SOLARENV)/src/component.map
152
SHL1VERSIONMAP=$(SOLARENV)/src/component.map
149
153
150
SHL1STDLIBS+=\
154
SHL1STDLIBS+=\
155
        $(TOOLSLIB) \
151
        $(CPPUHELPERLIB) \
156
        $(CPPUHELPERLIB) \
152
        $(CPPULIB)       \
157
        $(CPPULIB)       \
153
        $(SALLIB)        \
158
        $(SALLIB)        \
(-)a/main/ucb/source/ucp/webdav/webdavcontent.cxx (-24 / +156 lines)
Lines 53-58 Link Here
53
#include <com/sun/star/ucb/InsertCommandArgument.hpp>
53
#include <com/sun/star/ucb/InsertCommandArgument.hpp>
54
#include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
54
#include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
55
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
55
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
56
#include <com/sun/star/ucb/InteractiveLockingLockNotAvailableException.hpp>
56
#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
57
#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
57
#include <com/sun/star/ucb/InteractiveLockingLockExpiredException.hpp>
58
#include <com/sun/star/ucb/InteractiveLockingLockExpiredException.hpp>
58
#include <com/sun/star/ucb/InteractiveLockingNotLockedException.hpp>
59
#include <com/sun/star/ucb/InteractiveLockingNotLockedException.hpp>
Lines 84-89 Link Here
84
#include "ContentProperties.hxx"
85
#include "ContentProperties.hxx"
85
#include "SerfUri.hxx"
86
#include "SerfUri.hxx"
86
#include "UCBDeadPropertyValue.hxx"
87
#include "UCBDeadPropertyValue.hxx"
88
#include <boost/current_function.hpp>
87
89
88
using namespace com::sun::star;
90
using namespace com::sun::star;
89
using namespace http_dav_ucp;
91
using namespace http_dav_ucp;
Lines 728-750 uno::Any SAL_CALL Content::execute( Link Here
728
        post( aArg, Environment );
730
        post( aArg, Environment );
729
    }
731
    }
730
    else if ( aCommand.Name.equalsAsciiL(
732
    else if ( aCommand.Name.equalsAsciiL(
731
                  RTL_CONSTASCII_STRINGPARAM( "lock" ) ) &&
733
                  RTL_CONSTASCII_STRINGPARAM( "lock" ) ) )
732
              supportsExclusiveWriteLock( Environment ) )
733
    {
734
    {
734
        //////////////////////////////////////////////////////////////////
735
        //////////////////////////////////////////////////////////////////
735
        // lock
736
        // lock
736
        //////////////////////////////////////////////////////////////////
737
        //////////////////////////////////////////////////////////////////
737
738
        lock( Environment );
738
        lock( Environment );
739
    }
739
    }
740
    else if ( aCommand.Name.equalsAsciiL(
740
    else if ( aCommand.Name.equalsAsciiL(
741
                  RTL_CONSTASCII_STRINGPARAM( "unlock" ) ) &&
741
                  RTL_CONSTASCII_STRINGPARAM( "unlock" ) ) )
742
              supportsExclusiveWriteLock( Environment ) )
743
    {
742
    {
744
        //////////////////////////////////////////////////////////////////
743
        //////////////////////////////////////////////////////////////////
745
        // unlock
744
        // unlock
746
        //////////////////////////////////////////////////////////////////
745
        //////////////////////////////////////////////////////////////////
747
748
        unlock( Environment );
746
        unlock( Environment );
749
    }
747
    }
750
    else if ( aCommand.Name.equalsAsciiL(
748
    else if ( aCommand.Name.equalsAsciiL(
Lines 1454-1460 uno::Reference< sdbc::XRow > Content::getPropertyValues( Link Here
1454
1452
1455
            if ( !bHasAll )
1453
            if ( !bHasAll )
1456
            {
1454
            {
1457
                // Only DAV resources support PROPFIND
1455
                // Only DAV resources support PROPFIND,
1456
                // check already done above in the outer 'if' head
1458
                std::vector< rtl::OUString > aPropNames;
1457
                std::vector< rtl::OUString > aPropNames;
1459
1458
1460
                uno::Sequence< beans::Property > aProperties(
1459
                uno::Sequence< beans::Property > aProperties(
Lines 1475-1491 uno::Reference< sdbc::XRow > Content::getPropertyValues( Link Here
1475
1474
1476
                        while ( it != end )
1475
                        while ( it != end )
1477
                        {
1476
                        {
1478
                            if ( *it == rName )
1477
                            if ( *it == rName ) {
1478
                                //the failed property in cache is the same as the requested one
1479
                                //add to the requested properties list
1480
                                aProperties[ nProps ] = rProperties[ n ];
1481
                                nProps++;
1479
                                break;
1482
                                break;
1483
                            }
1480
1484
1481
                            ++it;
1485
                            ++it;
1482
                        }
1486
                        }
1483
1484
                        if ( it == end )
1485
                        {
1486
                            aProperties[ nProps ] = rProperties[ n ];
1487
                            nProps++;
1488
                        }
1489
                    }
1487
                    }
1490
1488
1491
                    aProperties.realloc( nProps );
1489
                    aProperties.realloc( nProps );
Lines 3013-3018 void Content::lock( Link Here
3013
        const uno::Reference< ucb::XCommandEnvironment >& Environment )
3011
        const uno::Reference< ucb::XCommandEnvironment >& Environment )
3014
    throw( uno::Exception )
3012
    throw( uno::Exception )
3015
{
3013
{
3014
    // i126305 TODO: add a check to see if this is really a DAV resource ?
3015
    // currently if the lock is not supported
3016
    // we got an error from the server that should be checked by the client (framework)
3017
    rtl::OUString aURL;
3018
    if ( m_bTransient )
3019
    {
3020
        aURL = getParentURL();
3021
        if ( aURL.lastIndexOf( '/' ) != ( aURL.getLength() - 1 ) )
3022
            aURL += rtl::OUString::createFromAscii( "/" );
3023
3024
        aURL += m_aEscapedTitle;
3025
    }
3026
    else
3027
    {
3028
        aURL = m_xIdentifier->getContentIdentifier();
3029
    }
3030
3016
    try
3031
    try
3017
    {
3032
    {
3018
        std::auto_ptr< DAVResourceAccess > xResAccess;
3033
        std::auto_ptr< DAVResourceAccess > xResAccess;
Lines 3021-3036 void Content::lock( Link Here
3021
            xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) );
3036
            xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) );
3022
        }
3037
        }
3023
3038
3039
        // TODO i126305 to discuss:
3040
        // the owner string is the string that will be returned when the lock will be
3041
        // interrogated, via lockdiscovery.
3042
        // It should tell a user who is holding the document lock.
3043
        // The string currently set as owner is the one most useful now, telling what application locked the resource.
3044
        // May be it would be better put here something better ?
3045
        // Some string be added to office config? Or name of the user there? Or a document property user selectable?
3046
        // in case of adding it in config, the lock command should be added a string for the owner, and this
3047
        // will be in turn filled in by the framework (e.g. the ucb client).
3048
        // Of course in case of a configuration item, the string should be checked against internationalization
3049
        // and how to manage it in webdav protocol, this was not checked while solving i126305.
3024
        uno::Any aOwnerAny;
3050
        uno::Any aOwnerAny;
3025
        aOwnerAny
3051
        aOwnerAny
3026
            <<= rtl::OUString::createFromAscii( "http://ucb.openoffice.org" );
3052
            <<= rtl::OUString::createFromAscii( "Apache OpenOffice - https://www.openoffice.org" );
3027
3053
3054
        // TODO i126305 to discuss:
3055
        // on some webdav server, the 180 time formerly used appears to be too long,
3056
        // in this case, in response to a lock refresh operation we receive an error
3057
        // as 'Connection reset by peer', meaning the session was timed out by the other end.
3058
        // For now drop the defaul time to 120 seconds, seems better.
3059
        // In the future, another way of keeping the connection alive should be devised.
3028
        ucb::Lock aLock(
3060
        ucb::Lock aLock(
3029
            ucb::LockScope_EXCLUSIVE,
3061
            ucb::LockScope_EXCLUSIVE,
3030
            ucb::LockType_WRITE,
3062
            ucb::LockType_WRITE,
3031
            ucb::LockDepth_ZERO,
3063
            ucb::LockDepth_ZERO,
3032
            aOwnerAny,
3064
            aOwnerAny,
3033
            180, // lock timeout in secs
3065
            120, // lock timeout in secs
3034
            //-1, // infinite lock
3066
            //-1, // infinite lock
3035
            uno::Sequence< ::rtl::OUString >() );
3067
            uno::Sequence< ::rtl::OUString >() );
3036
3068
Lines 3043-3048 void Content::lock( Link Here
3043
    }
3075
    }
3044
    catch ( DAVException const & e )
3076
    catch ( DAVException const & e )
3045
    {
3077
    {
3078
        switch(e.getStatus())
3079
        {
3080
        case SC_LOCKED:
3081
        {
3082
            rtl::OUString aOwner( getLockOwner( Environment ) );
3083
3084
            throw(ucb::InteractiveLockingLockedException(
3085
                      rtl::OUString::createFromAscii( "Locked!" ),
3086
                      static_cast< cppu::OWeakObject * >( this ),
3087
                      task::InteractionClassification_ERROR,
3088
                      aURL,
3089
                      e.getExtendedError(),
3090
                      sal_False,
3091
                      aOwner ));
3092
        }
3093
        break;
3094
        case SC_METHOD_NOT_ALLOWED:
3095
            // this it's not always received, but the RFC4918 (which supersed RFC2518)
3096
            // tells about this in:
3097
            // http://tools.ietf.org/html/rfc4918#appendix-D.1
3098
            // throw exception, will be interpreted by the lock requester (framework)
3099
            // it is actually a info, not an error
3100
            throw ucb::InteractiveLockingLockNotAvailableException( e.getData(),
3101
                                                                    static_cast< cppu::OWeakObject * >( this ),
3102
                                                                    task::InteractionClassification_INFO,
3103
                                                                    aURL,
3104
                                                                    e.getExtendedError() );
3105
            break;
3106
            //i126305 TODO
3107
            //see http://tools.ietf.org/html/rfc4918#section-9.10.6
3108
            //not sure how to handle them, for the time being a dialog box is shown,
3109
            //the client (framework) should manage it
3110
        case SC_CONFLICT:
3111
        case SC_PRECONDITION_FAILED:
3112
        default:
3113
            //fallthrou
3114
            ;
3115
        }
3046
        cancelCommandExecution( e, Environment, sal_False );
3116
        cancelCommandExecution( e, Environment, sal_False );
3047
        // Unreachable
3117
        // Unreachable
3048
    }
3118
    }
Lines 3070-3077 void Content::unlock( Link Here
3070
    }
3140
    }
3071
    catch ( DAVException const & e )
3141
    catch ( DAVException const & e )
3072
    {
3142
    {
3073
        cancelCommandExecution( e, Environment, sal_False );
3143
        //i126305 TODO need to rise an exception of the right type ?
3144
        //meaning that the lock can not be released, since there is no such
3145
        //exception we use ucb::InteractiveNetworkReadException
3146
        throw ucb::InteractiveNetworkReadException( e.getData(),
3147
                                                    static_cast< cppu::OWeakObject * >( this ),
3148
                                                    task::InteractionClassification_INFO,
3149
                                                    e.getData() );//perhaps a more better should be used ?
3074
        // Unreachable
3150
        // Unreachable
3151
        cancelCommandExecution( e, Environment, sal_False );
3075
    }
3152
    }
3076
}
3153
}
3077
3154
Lines 3292-3298 uno::Any Content::MapDAVException( const DAVException & e, sal_Bool bWrite ) Link Here
3292
                static_cast< cppu::OWeakObject * >( this ),
3369
                static_cast< cppu::OWeakObject * >( this ),
3293
                task::InteractionClassification_ERROR,
3370
                task::InteractionClassification_ERROR,
3294
                aURL,
3371
                aURL,
3295
                sal_False ); // not SelfOwned
3372
                e.getExtendedError(),
3373
                sal_False,  // not SelfOwned
3374
                rtl::OUString() );
3296
#else
3375
#else
3297
        {
3376
        {
3298
            uno::Sequence< uno::Any > aArgs( 1 );
3377
            uno::Sequence< uno::Any > aArgs( 1 );
Lines 3319-3325 uno::Any Content::MapDAVException( const DAVException & e, sal_Bool bWrite ) Link Here
3319
                static_cast< cppu::OWeakObject * >( this ),
3398
                static_cast< cppu::OWeakObject * >( this ),
3320
                task::InteractionClassification_ERROR,
3399
                task::InteractionClassification_ERROR,
3321
                aURL,
3400
                aURL,
3322
                sal_True ); // SelfOwned
3401
                e.getExtendedError(),
3402
                sal_True,  // SelfOwned
3403
                e.getOwner() );
3323
        break;
3404
        break;
3324
3405
3325
    case DAVException::DAV_NOT_LOCKED:
3406
    case DAVException::DAV_NOT_LOCKED:
Lines 3328-3334 uno::Any Content::MapDAVException( const DAVException & e, sal_Bool bWrite ) Link Here
3328
                rtl::OUString::createFromAscii( "Not locked!" ),
3409
                rtl::OUString::createFromAscii( "Not locked!" ),
3329
                static_cast< cppu::OWeakObject * >( this ),
3410
                static_cast< cppu::OWeakObject * >( this ),
3330
                task::InteractionClassification_ERROR,
3411
                task::InteractionClassification_ERROR,
3331
                aURL );
3412
                aURL,
3413
                rtl::OUString() );//no extended info here
3332
        break;
3414
        break;
3333
3415
3334
    case DAVException::DAV_LOCK_EXPIRED:
3416
    case DAVException::DAV_LOCK_EXPIRED:
Lines 3337-3349 uno::Any Content::MapDAVException( const DAVException & e, sal_Bool bWrite ) Link Here
3337
                rtl::OUString::createFromAscii( "Lock expired!" ),
3419
                rtl::OUString::createFromAscii( "Lock expired!" ),
3338
                static_cast< cppu::OWeakObject * >( this ),
3420
                static_cast< cppu::OWeakObject * >( this ),
3339
                task::InteractionClassification_ERROR,
3421
                task::InteractionClassification_ERROR,
3340
                aURL );
3422
                aURL,
3423
                rtl::OUString() );//no extended info here
3341
        break;
3424
        break;
3342
3425
3343
    default:
3426
    default:
3427
        rtl::OUStringBuffer buf( 512 );
3428
        buf.appendAscii( BOOST_CURRENT_FUNCTION );
3429
        buf.appendAscii( ":" );
3430
        buf.append( (sal_Int32) __LINE__ );
3431
        buf.appendAscii( " - Unknown DAV error: " );
3432
        buf.append( (sal_Int32) e.getError() );
3344
        aException <<=
3433
        aException <<=
3345
            ucb::InteractiveNetworkGeneralException(
3434
            ucb::InteractiveNetworkGeneralException(
3346
                rtl::OUString(),
3435
                rtl::OUString(buf.makeStringAndClear()),
3347
                static_cast< cppu::OWeakObject * >( this ),
3436
                static_cast< cppu::OWeakObject * >( this ),
3348
                task::InteractionClassification_ERROR );
3437
                task::InteractionClassification_ERROR );
3349
        break;
3438
        break;
Lines 3450-3456 const Content::ResourceType & Content::getResourceType( Link Here
3450
            // this is a DAV resource.
3539
            // this is a DAV resource.
3451
            std::vector< DAVResource > resources;
3540
            std::vector< DAVResource > resources;
3452
            std::vector< rtl::OUString > aPropNames;
3541
            std::vector< rtl::OUString > aPropNames;
3453
            uno::Sequence< beans::Property > aProperties( 5 );
3542
            uno::Sequence< beans::Property > aProperties( 6 );
3454
            aProperties[ 0 ].Name
3543
            aProperties[ 0 ].Name
3455
                = rtl::OUString::createFromAscii( "IsFolder" );
3544
                = rtl::OUString::createFromAscii( "IsFolder" );
3456
            aProperties[ 1 ].Name
3545
            aProperties[ 1 ].Name
Lines 3461-3466 const Content::ResourceType & Content::getResourceType( Link Here
3461
                = rtl::OUString::createFromAscii( "MediaType" );
3550
                = rtl::OUString::createFromAscii( "MediaType" );
3462
            aProperties[ 4 ].Name
3551
            aProperties[ 4 ].Name
3463
                = DAVProperties::SUPPORTEDLOCK;
3552
                = DAVProperties::SUPPORTEDLOCK;
3553
            //we will need this to check for existing locks
3554
            aProperties[ 5 ].Name
3555
                = DAVProperties::LOCKDISCOVERY;
3464
3556
3465
            ContentProperties::UCBNamesToDAVNames(
3557
            ContentProperties::UCBNamesToDAVNames(
3466
                aProperties, aPropNames );
3558
                aProperties, aPropNames );
Lines 3469-3476 const Content::ResourceType & Content::getResourceType( Link Here
3469
                DAVZERO, aPropNames, resources, xEnv );
3561
                DAVZERO, aPropNames, resources, xEnv );
3470
3562
3471
            // TODO - is this really only one?
3563
            // TODO - is this really only one?
3564
            // only one resource is received, see at:
3565
            // WebDAVResponseParser::endElement()
3566
            //   case WebDAVName_response
3567
            //in file: ucb/source/ucp/webdav/webdavresponseparser.cxx:
3472
            if ( resources.size() == 1 )
3568
            if ( resources.size() == 1 )
3473
            {
3569
            {
3570
                // there is a single resource
3474
                m_xCachedProps.reset(
3571
                m_xCachedProps.reset(
3475
                    new CachableContentProperties( resources[ 0 ] ) );
3572
                    new CachableContentProperties( resources[ 0 ] ) );
3476
                m_xCachedProps->containsAllNames(
3573
                m_xCachedProps->containsAllNames(
Lines 3507-3509 const Content::ResourceType & Content::getResourceType( Link Here
3507
{
3604
{
3508
    return getResourceType( xEnv, m_xResAccess );
3605
    return getResourceType( xEnv, m_xResAccess );
3509
}
3606
}
3607
3608
rtl::OUString Content::getLockOwner( const uno::Reference< ucb::XCommandEnvironment >& Environment )
3609
{
3610
    rtl::OUString aOwner;
3611
    try
3612
    {
3613
        //DAVProperties::LOCKDISCOVERY is not cached, need to get it from the server
3614
        uno::Sequence< beans::Property > aProperties( 1 );
3615
        aProperties[ 0 ].Name   = DAVProperties::LOCKDISCOVERY;
3616
        aProperties[ 0 ].Handle = -1;
3617
3618
        uno::Reference< sdbc::XRow > xRow( getPropertyValues( aProperties, Environment ) );
3619
3620
        sal_Int32 nCount = aProperties.getLength();
3621
        uno::Sequence< uno::Any > aValues( nCount );
3622
        uno::Any* pValues = aValues.getArray();
3623
        pValues[ 0 ] = xRow->getObject( 1, uno::Reference< container::XNameAccess >() );
3624
3625
        uno::Sequence< ::com::sun::star::ucb::Lock >  aLocks;
3626
3627
        if(aValues.getConstArray()[ 0 ] >>= aLocks)
3628
            if(aLocks.getLength() > 0)
3629
            {
3630
                ucb::Lock aLock = aLocks[0];
3631
                aLock.Owner >>= aOwner;
3632
                OSL_TRACE("Content::getLockOwner - aOwner: '%s', <<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
3633
                           rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr());
3634
3635
            }
3636
    }
3637
    catch ( uno::Exception&)
3638
    { }
3639
3640
    return aOwner;
3641
}
(-)a/main/ucb/source/ucp/webdav/webdavcontent.hxx (-15 / +19 lines)
Lines 83-88 class Content : public ::ucbhelper::ContentImplHelper, Link Here
83
    rtl::OUString     m_aEscapedTitle;
83
    rtl::OUString     m_aEscapedTitle;
84
    ResourceType      m_eResourceType;
84
    ResourceType      m_eResourceType;
85
    ContentProvider*  m_pProvider; // No need for a ref, base class holds object
85
    ContentProvider*  m_pProvider; // No need for a ref, base class holds object
86
    // True if the DEV resource is a 'unmapped URL' as it is named in RFC4918
86
    bool              m_bTransient;
87
    bool              m_bTransient;
87
    bool              m_bCollection;
88
    bool              m_bCollection;
88
    bool              m_bDidGetOrHead;
89
    bool              m_bDidGetOrHead;
Lines 137-156 private: Link Here
137
                     const std::auto_ptr< DAVResourceAccess > & rResAccess )
138
                     const std::auto_ptr< DAVResourceAccess > & rResAccess )
138
        throw ( ::com::sun::star::uno::Exception );
139
        throw ( ::com::sun::star::uno::Exception );
139
140
140
    // Command "open"
141
    /// Command "open"
141
    com::sun::star::uno::Any open(
142
    com::sun::star::uno::Any open(
142
                const com::sun::star::ucb::OpenCommandArgument2 & rArg,
143
                const com::sun::star::ucb::OpenCommandArgument2 & rArg,
143
                const com::sun::star::uno::Reference<
144
                const com::sun::star::uno::Reference<
144
                    com::sun::star::ucb::XCommandEnvironment > & xEnv )
145
                    com::sun::star::ucb::XCommandEnvironment > & xEnv )
145
        throw( ::com::sun::star::uno::Exception );
146
        throw( ::com::sun::star::uno::Exception );
146
147
147
    // Command "post"
148
    /// Command "post"
148
    void post( const com::sun::star::ucb::PostCommandArgument2 & rArg,
149
    void post( const com::sun::star::ucb::PostCommandArgument2 & rArg,
149
               const com::sun::star::uno::Reference<
150
               const com::sun::star::uno::Reference<
150
                    com::sun::star::ucb::XCommandEnvironment > & xEnv )
151
                    com::sun::star::ucb::XCommandEnvironment > & xEnv )
151
        throw( ::com::sun::star::uno::Exception );
152
        throw( ::com::sun::star::uno::Exception );
152
153
153
    // Command "insert"
154
    /// Command "insert"
154
    void insert( const ::com::sun::star::uno::Reference<
155
    void insert( const ::com::sun::star::uno::Reference<
155
                     ::com::sun::star::io::XInputStream > & xInputStream,
156
                     ::com::sun::star::io::XInputStream > & xInputStream,
156
                 sal_Bool bReplaceExisting,
157
                 sal_Bool bReplaceExisting,
Lines 158-179 private: Link Here
158
                     com::sun::star::ucb::XCommandEnvironment >& Environment )
159
                     com::sun::star::ucb::XCommandEnvironment >& Environment )
159
        throw( ::com::sun::star::uno::Exception );
160
        throw( ::com::sun::star::uno::Exception );
160
161
161
    // Command "transfer"
162
    /// Command "transfer"
162
    void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
163
    void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs,
163
                   const com::sun::star::uno::Reference<
164
                   const com::sun::star::uno::Reference<
164
                       com::sun::star::ucb::XCommandEnvironment >& Environment )
165
                       com::sun::star::ucb::XCommandEnvironment >& Environment )
165
        throw( ::com::sun::star::uno::Exception );
166
        throw( ::com::sun::star::uno::Exception );
166
167
167
    // Command "delete"
168
    /// Command "delete"
168
    void destroy( sal_Bool bDeletePhysical )
169
    void destroy( sal_Bool bDeletePhysical )
169
        throw( ::com::sun::star::uno::Exception );
170
        throw( ::com::sun::star::uno::Exception );
170
171
171
    // Command "lock"
172
    /// Command "lock"
172
    void lock( const com::sun::star::uno::Reference<
173
    void lock( const com::sun::star::uno::Reference<
173
                  com::sun::star::ucb::XCommandEnvironment >& Environment )
174
                  com::sun::star::ucb::XCommandEnvironment >& Environment )
174
        throw( ::com::sun::star::uno::Exception );
175
        throw( ::com::sun::star::uno::Exception );
175
176
176
    // Command "unlock"
177
    /// Command "unlock"
177
    void unlock( const com::sun::star::uno::Reference<
178
    void unlock( const com::sun::star::uno::Reference<
178
                  com::sun::star::ucb::XCommandEnvironment >& Environment )
179
                  com::sun::star::ucb::XCommandEnvironment >& Environment )
179
        throw( ::com::sun::star::uno::Exception );
180
        throw( ::com::sun::star::uno::Exception );
Lines 193-199 private: Link Here
193
        const com::sun::star::uno::Reference<
194
        const com::sun::star::uno::Reference<
194
            com::sun::star::ucb::XCommandEnvironment >& Environment );
195
            com::sun::star::ucb::XCommandEnvironment >& Environment );
195
196
196
    // XPropertyContainer replacement
197
    /// XPropertyContainer replacement
197
    void addProperty( const com::sun::star::ucb::PropertyCommandArgument &aCmdArg,
198
    void addProperty( const com::sun::star::ucb::PropertyCommandArgument &aCmdArg,
198
                      const com::sun::star::uno::Reference<
199
                      const com::sun::star::uno::Reference<
199
                      com::sun::star::ucb::XCommandEnvironment >& Environment )
200
                      com::sun::star::ucb::XCommandEnvironment >& Environment )
Lines 226-238 public: Link Here
226
        throw ( ::com::sun::star::ucb::ContentCreationException );
227
        throw ( ::com::sun::star::ucb::ContentCreationException );
227
    virtual ~Content();
228
    virtual ~Content();
228
229
229
    // XInterface
230
    /// XInterface
230
    XINTERFACE_DECL()
231
    XINTERFACE_DECL()
231
232
232
    // XTypeProvider
233
    /// XTypeProvider
233
    XTYPEPROVIDER_DECL()
234
    XTYPEPROVIDER_DECL()
234
235
235
    // XServiceInfo
236
    /// XServiceInfo
236
    virtual ::rtl::OUString SAL_CALL
237
    virtual ::rtl::OUString SAL_CALL
237
    getImplementationName()
238
    getImplementationName()
238
        throw( ::com::sun::star::uno::RuntimeException );
239
        throw( ::com::sun::star::uno::RuntimeException );
Lines 241-252 public: Link Here
241
    getSupportedServiceNames()
242
    getSupportedServiceNames()
242
        throw( ::com::sun::star::uno::RuntimeException );
243
        throw( ::com::sun::star::uno::RuntimeException );
243
244
244
    // XContent
245
    /// XContent
245
    virtual rtl::OUString SAL_CALL
246
    virtual rtl::OUString SAL_CALL
246
    getContentType()
247
    getContentType()
247
        throw( com::sun::star::uno::RuntimeException );
248
        throw( com::sun::star::uno::RuntimeException );
248
249
249
    // XCommandProcessor
250
    /// XCommandProcessor
250
    virtual com::sun::star::uno::Any SAL_CALL
251
    virtual com::sun::star::uno::Any SAL_CALL
251
    execute( const com::sun::star::ucb::Command& aCommand,
252
    execute( const com::sun::star::ucb::Command& aCommand,
252
             sal_Int32 CommandId,
253
             sal_Int32 CommandId,
Lines 259-265 public: Link Here
259
    abort( sal_Int32 CommandId )
260
    abort( sal_Int32 CommandId )
260
        throw( com::sun::star::uno::RuntimeException );
261
        throw( com::sun::star::uno::RuntimeException );
261
262
262
    // XPropertyContainer
263
    /// XPropertyContainer
263
    virtual void SAL_CALL
264
    virtual void SAL_CALL
264
    addProperty( const rtl::OUString& Name,
265
    addProperty( const rtl::OUString& Name,
265
                 sal_Int16 Attributes,
266
                 sal_Int16 Attributes,
Lines 295-301 public: Link Here
295
296
296
    DAVResourceAccess & getResourceAccess() { return *m_xResAccess; }
297
    DAVResourceAccess & getResourceAccess() { return *m_xResAccess; }
297
298
298
    // Called from resultset data supplier.
299
    /** Called from resultset data supplier. */
299
    static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
300
    static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
300
    getPropertyValues( const ::com::sun::star::uno::Reference<
301
    getPropertyValues( const ::com::sun::star::uno::Reference<
301
                           ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
302
                           ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
Lines 305-310 public: Link Here
305
                       const rtl::Reference<
306
                       const rtl::Reference<
306
                           ::ucbhelper::ContentProviderImplHelper >& rProvider,
307
                           ::ucbhelper::ContentProviderImplHelper >& rProvider,
307
                       const ::rtl::OUString& rContentId );
308
                       const ::rtl::OUString& rContentId );
309
310
    /** returns the owner of current resource lock */
311
    rtl::OUString getLockOwner( const uno::Reference< ucb::XCommandEnvironment >& Environment );
308
};
312
};
309
313
310
}
314
}
(-)a/main/ucb/source/ucp/webdav/webdavprovider.cxx (+1 lines)
Lines 47-52 using namespace http_dav_ucp; Link Here
47
rtl::OUString &WebDAVUserAgent::operator()() const
47
rtl::OUString &WebDAVUserAgent::operator()() const
48
{
48
{
49
    rtl::OUStringBuffer aBuffer;
49
    rtl::OUStringBuffer aBuffer;
50
    aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Apache " ));
50
    aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "$ooName/$ooSetupVersion" ));
51
    aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "$ooName/$ooSetupVersion" ));
51
#if OSL_DEBUG_LEVEL > 0
52
#if OSL_DEBUG_LEVEL > 0
52
#ifdef APR_VERSION
53
#ifdef APR_VERSION
(-)a/main/ucb/source/ucp/webdav/webdavresponseparser.cxx (-21 / +218 lines)
Lines 29-34 Link Here
29
#include <com/sun/star/xml/sax/InputSource.hpp>
29
#include <com/sun/star/xml/sax/InputSource.hpp>
30
#include <comphelper/processfactory.hxx>
30
#include <comphelper/processfactory.hxx>
31
#include <comphelper/seqstream.hxx>
31
#include <comphelper/seqstream.hxx>
32
#include <com/sun/star/ucb/Lock.hpp>
33
#include <com/sun/star/ucb/LockDepth.hpp>
32
#include <com/sun/star/ucb/LockEntry.hpp>
34
#include <com/sun/star/ucb/LockEntry.hpp>
33
#include <com/sun/star/ucb/LockScope.hpp>
35
#include <com/sun/star/ucb/LockScope.hpp>
34
#include <com/sun/star/ucb/LockType.hpp>
36
#include <com/sun/star/ucb/LockType.hpp>
Lines 94-99 namespace Link Here
94
        WebDAVName_locktype,
96
        WebDAVName_locktype,
95
        WebDAVName_write,
97
        WebDAVName_write,
96
        WebDAVName_shared,
98
        WebDAVName_shared,
99
        WebDAVName_lockdiscovery,
100
        WebDAVName_activelock,
101
        WebDAVName_depth,
102
        WebDAVName_owner,
103
        WebDAVName_timeout,
104
        WebDAVName_locktoken,
97
        WebDAVName_status,
105
        WebDAVName_status,
98
        WebDAVName_getlastmodified,
106
        WebDAVName_getlastmodified,
99
        WebDAVName_creationdate,
107
        WebDAVName_creationdate,
Lines 125-130 namespace Link Here
125
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("locktype"), WebDAVName_locktype));
133
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("locktype"), WebDAVName_locktype));
126
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("write"), WebDAVName_write));
134
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("write"), WebDAVName_write));
127
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("shared"), WebDAVName_shared));
135
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("shared"), WebDAVName_shared));
136
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("lockdiscovery"), WebDAVName_lockdiscovery));
137
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("activelock"), WebDAVName_activelock));
138
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("depth"), WebDAVName_depth));
139
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("owner"), WebDAVName_owner));
140
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("timeout"), WebDAVName_timeout));
141
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("locktoken"), WebDAVName_locktoken));
128
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("status"), WebDAVName_status));
142
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("status"), WebDAVName_status));
129
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getlastmodified"), WebDAVName_getlastmodified));
143
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getlastmodified"), WebDAVName_getlastmodified));
130
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("creationdate"), WebDAVName_creationdate));
144
            aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("creationdate"), WebDAVName_creationdate));
Lines 288-294 namespace Link Here
288
    enum WebDAVResponseParserMode
302
    enum WebDAVResponseParserMode
289
    {
303
    {
290
        WebDAVResponseParserMode_PropFind = 0,
304
        WebDAVResponseParserMode_PropFind = 0,
291
        WebDAVResponseParserMode_PropName
305
        WebDAVResponseParserMode_PropName,
306
        WebDAVResponseParserMode_LockResponse
292
    };
307
    };
293
308
294
    class WebDAVResponseParser : public cppu::WeakImplHelper1< com::sun::star::xml::sax::XDocumentHandler >
309
    class WebDAVResponseParser : public cppu::WeakImplHelper1< com::sun::star::xml::sax::XDocumentHandler >
Lines 296-318 namespace Link Here
296
    private:
311
    private:
297
        std::vector< http_dav_ucp::DAVResource >      maResult_PropFind;
312
        std::vector< http_dav_ucp::DAVResource >      maResult_PropFind;
298
        std::vector< http_dav_ucp::DAVResourceInfo >  maResult_PropName;
313
        std::vector< http_dav_ucp::DAVResourceInfo >  maResult_PropName;
314
        http_dav_ucp::DAVPropertyValue                maResult_Lock;
299
315
300
        WebDAVContext*                              mpContext;
316
        WebDAVContext*                              mpContext;
301
        ::rtl::OUString                             maHref;
317
        ::rtl::OUString                             maHref;
318
        ::rtl::OUString                             maHrefLocks; //this is used for locks, when lockdiscoveryactive
319
302
        ::rtl::OUString                             maStatus;
320
        ::rtl::OUString                             maStatus;
303
        std::vector< http_dav_ucp::DAVPropertyValue > maResponseProperties;
321
        std::vector< http_dav_ucp::DAVPropertyValue > maResponseProperties;
304
        std::vector< http_dav_ucp::DAVPropertyValue > maPropStatProperties;
322
        std::vector< http_dav_ucp::DAVPropertyValue > maPropStatProperties;
305
        std::vector< ::rtl::OUString >              maResponseNames;
323
        std::vector< ::rtl::OUString >              maResponseNames;
306
        std::vector< ::rtl::OUString >              maPropStatNames;
324
        std::vector< ::rtl::OUString >              maPropStatNames;
325
        uno::Sequence< ::rtl::OUString >            maLockTokens;
307
        uno::Sequence< ucb::LockEntry >             maLockEntries;
326
        uno::Sequence< ucb::LockEntry >             maLockEntries;
327
        uno::Sequence< ucb::Lock >                  maLocks;    //the returned locks following a lockdiscovery request
308
        ucb::LockScope                              maLockScope;
328
        ucb::LockScope                              maLockScope;
309
        ucb::LockType                               maLockType;
329
        ucb::LockType                               maLockType;
310
        WebDAVResponseParserMode                    meWebDAVResponseParserMode;
330
        ucb::LockDepth                              maLockDepth;
331
        ::rtl::OUString                             maLockOwner;
332
        sal_Int64                                   maLockTimeout;
333
        ::rtl::OUString                             maLockToken;
334
335
      WebDAVResponseParserMode                    meWebDAVResponseParserMode;
311
336
312
        // bitfield
337
        // bitfield
313
        bool                                        mbResourceTypeCollection : 1;
338
        bool                                        mbResourceTypeCollection : 1;
314
        bool                                        mbLockScopeSet : 1;
339
        bool                                        mbLockScopeSet : 1;
315
        bool                                        mbLockTypeSet : 1;
340
        bool                                        mbLockTypeSet : 1;
341
        bool                                        mbLockTokenSet : 1;
342
        //TODO: add other flag to manage reading od token, depth, timeout, owner
343
        bool                                        mbLockDiscoveryActive : 1;
316
344
317
        // local helpers
345
        // local helpers
318
        bool whitespaceIsAvailable() const
346
        bool whitespaceIsAvailable() const
Lines 323-330 namespace Link Here
323
        {
351
        {
324
            return mpContext && mpContext->getParent() && aWebDAVName == mpContext->getParent()->getWebDAVName();
352
            return mpContext && mpContext->getParent() && aWebDAVName == mpContext->getParent()->getWebDAVName();
325
        }
353
        }
326
        bool propertyIsReady() const 
354
        bool propertyIsReady() const
327
        { 
355
        {
328
            return hasParent(WebDAVName_prop) && whitespaceIsAvailable();
356
            return hasParent(WebDAVName_prop) && whitespaceIsAvailable();
329
        }
357
        }
330
        bool isCollectingProperties() const
358
        bool isCollectingProperties() const
Lines 335-340 namespace Link Here
335
        {
363
        {
336
            return WebDAVResponseParserMode_PropName == meWebDAVResponseParserMode;
364
            return WebDAVResponseParserMode_PropName == meWebDAVResponseParserMode;
337
        }
365
        }
366
        bool isWaitingLockResponse() const
367
        {
368
            return WebDAVResponseParserMode_LockResponse == meWebDAVResponseParserMode;
369
        }
338
        bool collectThisPropertyAsName() const
370
        bool collectThisPropertyAsName() const
339
        {
371
        {
340
            return isCollectingPropNames() && hasParent(WebDAVName_prop);
372
            return isCollectingPropNames() && hasParent(WebDAVName_prop);
Lines 360-366 namespace Link Here
360
        // Methods XDocumentHandler
392
        // Methods XDocumentHandler
361
        virtual void SAL_CALL startDocument(  ) throw (xml::sax::SAXException, uno::RuntimeException);
393
        virtual void SAL_CALL startDocument(  ) throw (xml::sax::SAXException, uno::RuntimeException);
362
        virtual void SAL_CALL endDocument(  ) throw (xml::sax::SAXException, uno::RuntimeException);
394
        virtual void SAL_CALL endDocument(  ) throw (xml::sax::SAXException, uno::RuntimeException);
363
        virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException);
395
        virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs )
396
            throw (xml::sax::SAXException, uno::RuntimeException);
364
        virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException);
397
        virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException);
365
        virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException);
398
        virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException);
366
        virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (xml::sax::SAXException, uno::RuntimeException);
399
        virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (xml::sax::SAXException, uno::RuntimeException);
Lines 369-393 namespace Link Here
369
402
370
        const std::vector< http_dav_ucp::DAVResource >& getResult_PropFind() const { return maResult_PropFind; }
403
        const std::vector< http_dav_ucp::DAVResource >& getResult_PropFind() const { return maResult_PropFind; }
371
        const std::vector< http_dav_ucp::DAVResourceInfo >& getResult_PropName() const { return maResult_PropName; }
404
        const std::vector< http_dav_ucp::DAVResourceInfo >& getResult_PropName() const { return maResult_PropName; }
405
        const http_dav_ucp::DAVPropertyValue& getResult_Lock() const { return maResult_Lock; }
372
    };
406
    };
373
407
374
    WebDAVResponseParser::WebDAVResponseParser(WebDAVResponseParserMode eWebDAVResponseParserMode)
408
    WebDAVResponseParser::WebDAVResponseParser(WebDAVResponseParserMode eWebDAVResponseParserMode)
375
    :   maResult_PropFind(),
409
    :   maResult_PropFind(),
376
        maResult_PropName(),
410
        maResult_PropName(),
411
        maResult_Lock(),
377
        mpContext(0),
412
        mpContext(0),
378
        maHref(),
413
        maHref(),
414
        maHrefLocks(),
379
        maStatus(),
415
        maStatus(),
380
        maResponseProperties(),
416
        maResponseProperties(),
381
        maPropStatProperties(),
417
        maPropStatProperties(),
382
        maResponseNames(),
418
        maResponseNames(),
383
        maPropStatNames(),
419
        maPropStatNames(),
420
        maLockTokens(),
384
        maLockEntries(),
421
        maLockEntries(),
422
        maLocks(),
385
        maLockScope(ucb::LockScope_EXCLUSIVE),
423
        maLockScope(ucb::LockScope_EXCLUSIVE),
386
        maLockType(ucb::LockType_WRITE),
424
        maLockType(ucb::LockType_WRITE),
425
        maLockDepth(ucb::LockDepth_ZERO),
426
        maLockOwner(),
427
        maLockTimeout(0),
387
        meWebDAVResponseParserMode(eWebDAVResponseParserMode),
428
        meWebDAVResponseParserMode(eWebDAVResponseParserMode),
388
        mbResourceTypeCollection(false),
429
        mbResourceTypeCollection(false),
389
        mbLockScopeSet(false),
430
        mbLockScopeSet(false),
390
        mbLockTypeSet(false)
431
        mbLockTypeSet(false),
432
        mbLockDiscoveryActive(false)
391
    {
433
    {
392
    }
434
    }
393
435
Lines 410-416 namespace Link Here
410
        OSL_ENSURE(!mpContext, "Parser end with existing content (!)");
452
        OSL_ENSURE(!mpContext, "Parser end with existing content (!)");
411
    }
453
    }
412
454
413
    void SAL_CALL WebDAVResponseParser::startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
455
    void SAL_CALL WebDAVResponseParser::startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs )
456
        throw (xml::sax::SAXException, uno::RuntimeException)
414
    {
457
    {
415
        const sal_Int32 nLen(aName.getLength());
458
        const sal_Int32 nLen(aName.getLength());
416
459
Lines 418-424 namespace Link Here
418
        {
461
        {
419
            // create new context (push)
462
            // create new context (push)
420
            mpContext = new WebDAVContext(mpContext, aName, xAttribs);
463
            mpContext = new WebDAVContext(mpContext, aName, xAttribs);
421
            
464
422
            if(collectThisPropertyAsName())
465
            if(collectThisPropertyAsName())
423
            {
466
            {
424
                // When collecting property names and parent is prop there is no need
467
                // When collecting property names and parent is prop there is no need
Lines 491-496 namespace Link Here
491
                                mbLockTypeSet = false;
534
                                mbLockTypeSet = false;
492
                                break;
535
                                break;
493
                            }
536
                            }
537
                            case WebDAVName_lockdiscovery:
538
                            {
539
                                // lockentry start, reset maLocks
540
                                maLocks.realloc(0);
541
                                mbLockDiscoveryActive = true;
542
                                break;
543
                            }
544
                            case WebDAVName_activelock:
545
                            {
546
                                //  activelockstart, reset vars
547
                                mbLockScopeSet = false;
548
                                mbLockTypeSet = false;
549
                                mbLockTokenSet = false;
550
                                maLockTokens.realloc(0);
551
                                maHrefLocks = ::rtl::OUString();
552
                                break;
553
                            }
554
                            case WebDAVName_locktoken:
555
                            {
556
                                mbLockTokenSet = true;
557
                                break;
558
                            }
494
                        }
559
                        }
495
                        break;
560
                        break;
496
                    }
561
                    }
Lines 537-543 namespace Link Here
537
                                // href end, save it if we have whitespace
602
                                // href end, save it if we have whitespace
538
                                if(whitespaceIsAvailable())
603
                                if(whitespaceIsAvailable())
539
                                {
604
                                {
540
                                    maHref = mpContext->getWhiteSpace();
605
                                    if(mbLockDiscoveryActive)
606
                                    {
607
                                        maHrefLocks = mpContext->getWhiteSpace();
608
                                    }
609
                                    else
610
                                    {
611
                                        maHref = mpContext->getWhiteSpace();
612
                                    }
541
                                }
613
                                }
542
                                break;
614
                                break;
543
                            }
615
                            }
Lines 662-668 namespace Link Here
662
                            case WebDAVName_exclusive:
734
                            case WebDAVName_exclusive:
663
                            {
735
                            {
664
                                // exclusive lockscope end
736
                                // exclusive lockscope end
665
                                if(hasParent(WebDAVName_lockscope))
737
                                if(hasParent(WebDAVName_lockscope) || hasParent(WebDAVName_activelock))
666
                                {
738
                                {
667
                                    maLockScope = ucb::LockScope_EXCLUSIVE;
739
                                    maLockScope = ucb::LockScope_EXCLUSIVE;
668
                                    mbLockScopeSet = true;
740
                                    mbLockScopeSet = true;
Lines 672-678 namespace Link Here
672
                            case WebDAVName_shared:
744
                            case WebDAVName_shared:
673
                            {
745
                            {
674
                                // shared lockscope end
746
                                // shared lockscope end
675
                                if(hasParent(WebDAVName_lockscope))
747
                                if(hasParent(WebDAVName_lockscope) || hasParent(WebDAVName_activelock))
676
                                {
748
                                {
677
                                    maLockScope = ucb::LockScope_SHARED;
749
                                    maLockScope = ucb::LockScope_SHARED;
678
                                    mbLockScopeSet = true;
750
                                    mbLockScopeSet = true;
Lines 682-694 namespace Link Here
682
                            case WebDAVName_write:
754
                            case WebDAVName_write:
683
                            {
755
                            {
684
                                // write locktype end
756
                                // write locktype end
685
                                if(hasParent(WebDAVName_locktype))
757
                                if(hasParent(WebDAVName_locktype) || hasParent(WebDAVName_activelock))
686
                                {
758
                                {
687
                                    maLockType = ucb::LockType_WRITE;
759
                                    maLockType = ucb::LockType_WRITE;
688
                                    mbLockTypeSet = true;
760
                                    mbLockTypeSet = true;
689
                                }
761
                                }
690
                                break;
762
                                break;
691
                            }
763
                            }
764
                            case WebDAVName_lockdiscovery:
765
                            {
766
                                // lockdiscovery end
767
                                if(hasParent(WebDAVName_prop))
768
                                {
769
                                    static ::rtl::OUString aStr(rtl::OUString::createFromAscii("DAV:lockdiscovery"));
770
                                    if(isWaitingLockResponse())
771
                                    {
772
                                        maResult_Lock.Name = aStr;
773
                                        maResult_Lock.Value <<= maLocks;
774
                                    }
775
                                    else
776
                                    {
777
                                        ::http_dav_ucp::DAVPropertyValue aDAVPropertyValue;
778
779
                                        aDAVPropertyValue.Name = aStr;
780
                                        aDAVPropertyValue.Value <<= maLocks;
781
                                        maPropStatProperties.push_back(aDAVPropertyValue);
782
                                    }
783
                                }
784
                                mbLockDiscoveryActive = false;
785
                                break;
786
                            }
787
                            case WebDAVName_activelock:
788
                            {
789
                                if(hasParent(WebDAVName_lockdiscovery) &&
790
                                   mbLockScopeSet && mbLockTypeSet && mbLockTokenSet)
791
                                {
792
                                    const sal_Int32 nLength(maLocks.getLength());
793
                                    ucb::Lock aLock;
794
795
                                    aLock.Scope = maLockScope;
796
                                    aLock.Type = maLockType;
797
                                    //add tokens, depth, timeout, owner
798
                                    aLock.LockTokens = maLockTokens;
799
                                    aLock.Depth = maLockDepth;
800
                                    aLock.Owner <<= maLockOwner;
801
                                    aLock.Timeout = maLockTimeout;
802
                                    maLocks.realloc(nLength + 1);
803
                                    maLocks[nLength] = aLock;
804
                                }
805
                                break;
806
                            }
807
                            case WebDAVName_locktoken:
808
                            {
809
                                if(hasParent(WebDAVName_activelock))
810
                                {
811
                                    //add a token to the list of tokens
812
                                    const sal_Int32 nLength(maLockTokens.getLength());
813
                                    maLockTokens.realloc(nLength + 1);
814
                                    maLockTokens[nLength] = maHrefLocks;
815
                                    mbLockTokenSet = true;
816
                                }
817
                                break;
818
                            }
819
                            case WebDAVName_timeout:
820
                            {
821
                                if(hasParent(WebDAVName_activelock))
822
                                {
823
                                    ::rtl::OUString aStr( mpContext->getWhiteSpace().toAsciiLowerCase());
824
                                    static ::rtl::OUString aInfinite( ::rtl::OUString::createFromAscii( "infinite" ) );
825
                                    static ::rtl::OUString aSecond( ::rtl::OUString::createFromAscii( "second-" ) );
826
                                    //look for infinity
827
                                    sal_Int32 secondIndex;
828
                                    if(aStr.indexOf(aInfinite) != -1)
829
                                    {
830
                                        maLockTimeout = -1;
831
                                    }
832
                                    else if((secondIndex = aStr.indexOf(aSecond)) != -1)
833
                                    {
834
                                        secondIndex += aSecond.getLength();
835
                                        maLockTimeout = aStr.copy(secondIndex).toInt64();
836
                                    }
837
                                }
838
                                break;
839
                            }
840
                            case WebDAVName_owner:
841
                            {
842
                                if(whitespaceIsAvailable())
843
                                {
844
                                    if(hasParent(WebDAVName_activelock))
845
                                    {
846
                                        maLockOwner = mpContext->getWhiteSpace();
847
                                    }
848
                                }
849
                                break;
850
                            }
851
                            case WebDAVName_depth:
852
                            {
853
                                if(hasParent(WebDAVName_activelock))
854
                                {
855
                                    //set depth, one of three values
856
                                    ::rtl::OUString aStr( mpContext->getWhiteSpace() );
857
                                    //default to zero, if not found
858
                                    maLockDepth = ucb::LockDepth_ZERO;
859
                                    if(aStr.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("0")))
860
                                       maLockDepth = ucb::LockDepth_ZERO;
861
                                    else if(aStr.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("1")))
862
                                       maLockDepth = ucb::LockDepth_ONE;
863
                                    else if(aStr.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("infinity")))
864
                                       maLockDepth = ucb::LockDepth_INFINITY;
865
                                }
866
                                break;
867
                            }
692
                            case WebDAVName_propstat:
868
                            case WebDAVName_propstat:
693
                            {
869
                            {
694
                                // propstat end, check status
870
                                // propstat end, check status
Lines 720-726 namespace Link Here
720
                            }
896
                            }
721
                            case WebDAVName_response:
897
                            case WebDAVName_response:
722
                            {
898
                            {
723
                                // respose end
899
                                // response end
724
                                if(maHref.getLength())
900
                                if(maHref.getLength())
725
                                {
901
                                {
726
                                    if(isCollectingProperties())
902
                                    if(isCollectingProperties())
Lines 728-734 namespace Link Here
728
                                        // create DAVResource when we have content
904
                                        // create DAVResource when we have content
729
                                        if(maResponseProperties.size())
905
                                        if(maResponseProperties.size())
730
                                        {
906
                                        {
731
                                            http_dav_ucp::DAVResource aDAVResource;
907
                                            ::http_dav_ucp::DAVResource aDAVResource;
732
908
733
                                            aDAVResource.uri = maHref;
909
                                            aDAVResource.uri = maHref;
734
                                            aDAVResource.properties = maResponseProperties;
910
                                            aDAVResource.properties = maResponseProperties;
Lines 795-801 namespace Link Here
795
    {
971
    {
796
    }
972
    }
797
973
798
    void SAL_CALL WebDAVResponseParser::processingInstruction( const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
974
    void SAL_CALL WebDAVResponseParser::processingInstruction( const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ )
975
        throw (xml::sax::SAXException, uno::RuntimeException)
799
    {
976
    {
800
    }
977
    }
801
978
Lines 813-818 namespace Link Here
813
        const uno::Reference< io::XInputStream >& xInputStream,
990
        const uno::Reference< io::XInputStream >& xInputStream,
814
        std::vector< http_dav_ucp::DAVResource >& rPropFind,
991
        std::vector< http_dav_ucp::DAVResource >& rPropFind,
815
        std::vector< http_dav_ucp::DAVResourceInfo >& rPropName,
992
        std::vector< http_dav_ucp::DAVResourceInfo >& rPropName,
993
        http_dav_ucp::DAVPropertyValue&           rPropValue,
816
        WebDAVResponseParserMode eWebDAVResponseParserMode)
994
        WebDAVResponseParserMode eWebDAVResponseParserMode)
817
    {
995
    {
818
        if(xInputStream.is())
996
        if(xInputStream.is())
Lines 822-839 namespace Link Here
822
                // prepare ParserInputSrouce
1000
                // prepare ParserInputSrouce
823
                xml::sax::InputSource myInputSource;
1001
                xml::sax::InputSource myInputSource;
824
                myInputSource.aInputStream = xInputStream;
1002
                myInputSource.aInputStream = xInputStream;
825
                
1003
826
                // get parser
1004
                // get parser
827
                uno::Reference< xml::sax::XParser > xParser(
1005
                uno::Reference< xml::sax::XParser > xParser(
828
                    comphelper::getProcessServiceFactory()->createInstance(
1006
                    comphelper::getProcessServiceFactory()->createInstance(
829
                        rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
1007
                        rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
830
                    uno::UNO_QUERY_THROW );
1008
                    uno::UNO_QUERY_THROW );
831
                
1009
832
                // create parser; connect parser and filter
1010
                // create parser; connect parser and filter
833
                WebDAVResponseParser* pWebDAVResponseParser = new WebDAVResponseParser(eWebDAVResponseParserMode);
1011
                WebDAVResponseParser* pWebDAVResponseParser = new WebDAVResponseParser(eWebDAVResponseParserMode);
834
                uno::Reference< xml::sax::XDocumentHandler > xWebDAVHdl(pWebDAVResponseParser);
1012
                uno::Reference< xml::sax::XDocumentHandler > xWebDAVHdl(pWebDAVResponseParser);
835
                xParser->setDocumentHandler(xWebDAVHdl);
1013
                xParser->setDocumentHandler(xWebDAVHdl);
836
                
1014
837
                // finally, parse the stream
1015
                // finally, parse the stream
838
                xParser->parseStream(myInputSource);
1016
                xParser->parseStream(myInputSource);
839
1017
Lines 850-855 namespace Link Here
850
                        rPropName = pWebDAVResponseParser->getResult_PropName();
1028
                        rPropName = pWebDAVResponseParser->getResult_PropName();
851
                        break;
1029
                        break;
852
                    }
1030
                    }
1031
                    case WebDAVResponseParserMode_LockResponse:
1032
                    {
1033
                        rPropValue = pWebDAVResponseParser->getResult_Lock();
1034
                        break;
1035
                    }
853
                }
1036
                }
854
            }
1037
            }
855
            catch(uno::Exception&)
1038
            catch(uno::Exception&)
Lines 869-887 namespace http_dav_ucp Link Here
869
    {
1052
    {
870
        std::vector< DAVResource > aRetval;
1053
        std::vector< DAVResource > aRetval;
871
        std::vector< DAVResourceInfo > aFoo;
1054
        std::vector< DAVResourceInfo > aFoo;
1055
        DAVPropertyValue               aFoo2;
872
1056
873
        parseWebDAVPropNameResponse(xInputStream, aRetval, aFoo, WebDAVResponseParserMode_PropFind);
1057
        parseWebDAVPropNameResponse(xInputStream, aRetval, aFoo, aFoo2, WebDAVResponseParserMode_PropFind);
874
        return aRetval;
1058
        return aRetval;
875
    }
1059
    }
876
    
1060
877
    std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const uno::Reference< io::XInputStream >& xInputStream)
1061
    std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const uno::Reference< io::XInputStream >& xInputStream)
878
    {
1062
    {
879
        std::vector< DAVResource > aFoo;
1063
        std::vector< DAVResource > aFoo;
880
        std::vector< DAVResourceInfo > aRetval;
1064
        std::vector< DAVResourceInfo > aRetval;
1065
        DAVPropertyValue               aFoo2;
1066
1067
        parseWebDAVPropNameResponse(xInputStream, aFoo, aRetval, aFoo2, WebDAVResponseParserMode_PropName);
1068
        return aRetval;
1069
    }
881
1070
882
        parseWebDAVPropNameResponse(xInputStream, aFoo, aRetval, WebDAVResponseParserMode_PropName);
1071
    http_dav_ucp::DAVPropertyValue parseWebDAVLockResponse(const uno::Reference< io::XInputStream >& xInputStream)
1072
    {
1073
        std::vector< DAVResource > aFoo2;
1074
        std::vector< DAVResourceInfo > aFoo;
1075
        http_dav_ucp::DAVPropertyValue               aRetval;
1076
1077
1078
        parseWebDAVPropNameResponse(xInputStream, aFoo2, aFoo, aRetval, WebDAVResponseParserMode_LockResponse);
883
        return aRetval;
1079
        return aRetval;
884
    }
1080
    }
1081
885
} // namespace http_dav_ucp
1082
} // namespace http_dav_ucp
886
1083
887
//////////////////////////////////////////////////////////////////////////////
1084
//////////////////////////////////////////////////////////////////////////////
(-)a/main/ucb/source/ucp/webdav/webdavresponseparser.hxx (+1 lines)
Lines 33-38 namespace http_dav_ucp Link Here
33
{
33
{
34
    std::vector< DAVResource > parseWebDAVPropFindResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
34
    std::vector< DAVResource > parseWebDAVPropFindResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
35
    std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
35
    std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
36
    DAVPropertyValue parseWebDAVLockResponse(const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream);
36
} // namespace http_dav_ucp
37
} // namespace http_dav_ucp
37
38
38
//////////////////////////////////////////////////////////////////////////////
39
//////////////////////////////////////////////////////////////////////////////
(-)a/main/ucbhelper/inc/ucbhelper/content.hxx (+21 lines)
Lines 1029-1034 public: Link Here
1029
        throw( ::com::sun::star::ucb::CommandAbortedException,
1029
        throw( ::com::sun::star::ucb::CommandAbortedException,
1030
               ::com::sun::star::uno::RuntimeException,
1030
               ::com::sun::star::uno::RuntimeException,
1031
               ::com::sun::star::uno::Exception );
1031
               ::com::sun::star::uno::Exception );
1032
    //->i126305
1033
    /** lock the resource
1034
      *
1035
      *
1036
      */
1037
    void
1038
      lock()
1039
        throw( ::com::sun::star::ucb::CommandAbortedException,
1040
               ::com::sun::star::uno::RuntimeException,
1041
               ::com::sun::star::uno::Exception );
1042
1043
    /** ulock the resource
1044
      *
1045
      *
1046
      */
1047
    void
1048
      unlock()
1049
        throw( ::com::sun::star::ucb::CommandAbortedException,
1050
               ::com::sun::star::uno::RuntimeException,
1051
               ::com::sun::star::uno::Exception );
1052
    //<-i126305
1032
};
1053
};
1033
1054
1034
} /* namespace ucbhelper */
1055
} /* namespace ucbhelper */
(-)a/main/ucbhelper/source/client/content.cxx (-1 / +35 lines)
Lines 1627-1632 sal_Bool Content::isDocument() Link Here
1627
    return sal_False;
1627
    return sal_False;
1628
}
1628
}
1629
1629
1630
//->i126305 ===============================================================
1631
void Content::lock()
1632
    throw( CommandAbortedException, RuntimeException, Exception )
1633
{
1634
    Command aCommand;
1635
    aCommand.Name     = rtl::OUString::createFromAscii( "lock" );
1636
    aCommand.Handle   = -1; // n/a
1637
    //    aCommand.Argument <<= aArg;
1638
1639
    m_xImpl->executeCommand( aCommand );
1640
1641
    //    return xSink->getInputStream();
1642
}
1643
1644
//=========================================================================
1645
void Content::unlock()
1646
    throw( CommandAbortedException, RuntimeException, Exception )
1647
{
1648
1649
    //    OpenCommandArgument2 aArg;
1650
    //aArg.Mode       = OpenMode::DOCUMENT_SHARE_DENY_NONE;
1651
    //aArg.Priority   = 0; // unused
1652
    //aArg.Sink       = xSink;
1653
    //aArg.Properties = Sequence< Property >( 0 ); // unused
1654
1655
    Command aCommand;
1656
    aCommand.Name     = rtl::OUString::createFromAscii( "unlock" );
1657
    aCommand.Handle   = -1; // n/a
1658
    //    aCommand.Argument <<= aArg;
1659
1660
    m_xImpl->executeCommand( aCommand );
1661
1662
}
1663
//<-i126305
1664
1630
//=========================================================================
1665
//=========================================================================
1631
//=========================================================================
1666
//=========================================================================
1632
//
1667
//
1633
- 

Return to issue 126305