tdf#82744: fix WebDAV lock/unlock behaviour - part 2
Changes done to the code in framework, comphelper and unotools, in no particular order - add an interaction handler dedicated to WebDAV The stock interaction handler can be missing depending on the need of the framework performing its tasks, so a dedicated handler is provided, this one is always present. - force opening of a WebDAV file. A WebDAV file sould be open r/o even if explicitly requested to open as r/w. This is a limitation of current WebDAV implementation, not of the standard. This change is needed in order to reopen correctly a file as requested by a 'Edit Mode' GUI command. Change-Id: I5368fa2c0511f1630e6d6139c6a986d33aa19082 Reviewed-on: https://gerrit.libreoffice.org/17182 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
committed by
Michael Meeks
parent
786573068d
commit
bc9a8ddbb7
@@ -23,14 +23,20 @@
|
|||||||
|
|
||||||
#include <com/sun/star/task/XInteractionAbort.hpp>
|
#include <com/sun/star/task/XInteractionAbort.hpp>
|
||||||
|
|
||||||
|
#include <com/sun/star/task/XInteractionApprove.hpp>
|
||||||
|
|
||||||
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
|
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
|
||||||
|
|
||||||
|
#include <com/sun/star/ucb/AuthenticationRequest.hpp>
|
||||||
|
|
||||||
namespace comphelper{
|
namespace comphelper{
|
||||||
|
|
||||||
StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler)
|
StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
|
||||||
|
const css::uno::Reference< css::task::XInteractionHandler >& xAuthenticationHandler)
|
||||||
: m_bUsed (false)
|
: m_bUsed (false)
|
||||||
, m_bHandledByMySelf (false)
|
, m_bHandledByMySelf (false)
|
||||||
, m_bHandledByInternalHandler(false)
|
, m_bHandledByInternalHandler(false)
|
||||||
|
, m_xAuthenticationHandler(xAuthenticationHandler)
|
||||||
{
|
{
|
||||||
::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
|
::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
|
||||||
::ucbhelper::InterceptedInteraction::InterceptedRequest aInterceptedRequest;
|
::ucbhelper::InterceptedInteraction::InterceptedRequest aInterceptedRequest;
|
||||||
@@ -47,6 +53,12 @@ StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference<
|
|||||||
aInterceptedRequest.MatchExact = false;
|
aInterceptedRequest.MatchExact = false;
|
||||||
lInterceptions.push_back(aInterceptedRequest);
|
lInterceptions.push_back(aInterceptedRequest);
|
||||||
|
|
||||||
|
aInterceptedRequest.Handle = HANDLE_AUTHENTICATIONREQUESTEXCEPTION;
|
||||||
|
aInterceptedRequest.Request <<= css::ucb::AuthenticationRequest();
|
||||||
|
aInterceptedRequest.Continuation = cppu::UnoType<css::task::XInteractionApprove>::get();
|
||||||
|
aInterceptedRequest.MatchExact = false;
|
||||||
|
lInterceptions.push_back(aInterceptedRequest);
|
||||||
|
|
||||||
setInterceptedHandler(xHandler);
|
setInterceptedHandler(xHandler);
|
||||||
setInterceptions(lInterceptions);
|
setInterceptions(lInterceptions);
|
||||||
}
|
}
|
||||||
@@ -96,6 +108,18 @@ ucbhelper::InterceptedInteraction::EInterceptionState StillReadWriteInteraction:
|
|||||||
bAbort = true;
|
bAbort = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HANDLE_AUTHENTICATIONREQUESTEXCEPTION:
|
||||||
|
{
|
||||||
|
//use internal authentication dedicated handler and return
|
||||||
|
if (m_xAuthenticationHandler.is())
|
||||||
|
{
|
||||||
|
m_xAuthenticationHandler->handle(xRequest);
|
||||||
|
return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
|
||||||
|
}
|
||||||
|
else //simply abort
|
||||||
|
bAbort = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle interaction by ourself
|
// handle interaction by ourself
|
||||||
|
@@ -325,13 +325,17 @@ void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::uno::XCompon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if ( xInteractionHandler.is() )
|
||||||
(xInteractionHandler.is() ) &&
|
{
|
||||||
(io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_INTERACTIONHANDLER()) == io_lMediaDescriptor.end())
|
if( io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_INTERACTIONHANDLER()) == io_lMediaDescriptor.end() )
|
||||||
)
|
|
||||||
{
|
{
|
||||||
io_lMediaDescriptor[utl::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
|
io_lMediaDescriptor[utl::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
|
||||||
}
|
}
|
||||||
|
if( io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()) == io_lMediaDescriptor.end() )
|
||||||
|
{
|
||||||
|
io_lMediaDescriptor[utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= xInteractionHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
|
if (io_lMediaDescriptor.find(utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
|
||||||
io_lMediaDescriptor[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()] <<= nMacroMode;
|
io_lMediaDescriptor[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()] <<= nMacroMode;
|
||||||
|
@@ -33,19 +33,23 @@ class COMPHELPER_DLLPUBLIC StillReadWriteInteraction : public ::ucbhelper::Inter
|
|||||||
private:
|
private:
|
||||||
static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION = 0;
|
static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION = 0;
|
||||||
static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
|
static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
|
||||||
|
static const sal_Int32 HANDLE_AUTHENTICATIONREQUESTEXCEPTION = 2;
|
||||||
|
|
||||||
bool m_bUsed;
|
bool m_bUsed;
|
||||||
bool m_bHandledByMySelf;
|
bool m_bHandledByMySelf;
|
||||||
bool m_bHandledByInternalHandler;
|
bool m_bHandledByInternalHandler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler);
|
StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler,
|
||||||
|
const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xAuthenticationHandler);
|
||||||
|
|
||||||
void resetInterceptions();
|
void resetInterceptions();
|
||||||
void resetErrorStates();
|
void resetErrorStates();
|
||||||
bool wasWriteError() { return (m_bUsed && m_bHandledByMySelf);}
|
bool wasWriteError() { return (m_bUsed && m_bHandledByMySelf);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xAuthenticationHandler;
|
||||||
|
|
||||||
virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest& aRequest,
|
virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest& aRequest,
|
||||||
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest) SAL_OVERRIDE;
|
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest) SAL_OVERRIDE;
|
||||||
|
|
||||||
|
@@ -71,6 +71,7 @@ class UNOTOOLS_DLLPUBLIC MediaDescriptor : public comphelper::SequenceAsHashMap
|
|||||||
static const OUString& PROP_HIDDEN();
|
static const OUString& PROP_HIDDEN();
|
||||||
static const OUString& PROP_INPUTSTREAM();
|
static const OUString& PROP_INPUTSTREAM();
|
||||||
static const OUString& PROP_INTERACTIONHANDLER();
|
static const OUString& PROP_INTERACTIONHANDLER();
|
||||||
|
static const OUString& PROP_AUTHENTICATIONHANDLER();
|
||||||
static const OUString& PROP_JUMPMARK();
|
static const OUString& PROP_JUMPMARK();
|
||||||
static const OUString& PROP_MACROEXECUTIONMODE();
|
static const OUString& PROP_MACROEXECUTIONMODE();
|
||||||
static const OUString& PROP_MEDIATYPE();
|
static const OUString& PROP_MEDIATYPE();
|
||||||
|
@@ -153,6 +153,12 @@ const OUString& MediaDescriptor::PROP_INTERACTIONHANDLER()
|
|||||||
return sProp;
|
return sProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const OUString& MediaDescriptor::PROP_AUTHENTICATIONHANDLER()
|
||||||
|
{
|
||||||
|
static const OUString sProp("AuthenticationHandler");
|
||||||
|
return sProp;
|
||||||
|
}
|
||||||
|
|
||||||
const OUString& MediaDescriptor::PROP_JUMPMARK()
|
const OUString& MediaDescriptor::PROP_JUMPMARK()
|
||||||
{
|
{
|
||||||
static const OUString sProp("JumpMark");
|
static const OUString sProp("JumpMark");
|
||||||
@@ -601,7 +607,11 @@ bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, bool bLockFi
|
|||||||
MediaDescriptor::PROP_INTERACTIONHANDLER(),
|
MediaDescriptor::PROP_INTERACTIONHANDLER(),
|
||||||
css::uno::Reference< css::task::XInteractionHandler >());
|
css::uno::Reference< css::task::XInteractionHandler >());
|
||||||
|
|
||||||
comphelper::StillReadWriteInteraction* pInteraction = new comphelper::StillReadWriteInteraction(xOrgInteraction);
|
css::uno::Reference< css::task::XInteractionHandler > xAuthenticationInteraction = getUnpackedValueOrDefault(
|
||||||
|
MediaDescriptor::PROP_AUTHENTICATIONHANDLER(),
|
||||||
|
css::uno::Reference< css::task::XInteractionHandler >());
|
||||||
|
|
||||||
|
comphelper::StillReadWriteInteraction* pInteraction = new comphelper::StillReadWriteInteraction(xOrgInteraction,xAuthenticationInteraction);
|
||||||
css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
|
css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
|
||||||
|
|
||||||
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
|
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
|
||||||
@@ -676,6 +686,15 @@ bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, bool bLockFi
|
|||||||
"unotools.misc",
|
"unotools.misc",
|
||||||
"caught Exception \"" << e.Message
|
"caught Exception \"" << e.Message
|
||||||
<< "\" while opening <" << sURL << ">");
|
<< "\" while opening <" << sURL << ">");
|
||||||
|
// If the protocol is webdav, then we need to treat the stream as readonly, even if the
|
||||||
|
// operation was requested as read/write explicitly (the WebDAV UCB implementation is monodirectional
|
||||||
|
// read or write not both at the same time).
|
||||||
|
OUString aScheme;
|
||||||
|
css::uno::Reference< css::ucb::XContentIdentifier > xContId(
|
||||||
|
aContent.get().is() ? aContent.get()->getIdentifier() : 0 );
|
||||||
|
if ( xContId.is() )
|
||||||
|
aScheme = xContId->getContentProviderScheme();
|
||||||
|
if(!aScheme.equalsIgnoreAsciiCaseAscii( "http" ) && !aScheme.equalsIgnoreAsciiCaseAscii( "https" ))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
xStream.clear();
|
xStream.clear();
|
||||||
|
Reference in New Issue
Block a user