You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by pe...@apache.org on 2015/09/25 01:52:35 UTC
svn commit: r1705201 [1/3] - in /openoffice/branches/AOO410/main: ./
comphelper/inc/comphelper/ comphelper/source/misc/
framework/source/loadenv/ offapi/com/sun/star/ucb/ sfx2/inc/sfx2/
sfx2/source/dialog/ sfx2/source/doc/ sfx2/source/view/ ucb/source/...
Author: pescetti
Date: Thu Sep 24 23:52:34 2015
New Revision: 1705201
URL: http://svn.apache.org/viewvc?rev=1705201&view=rev
Log:
#i126305# Add support for WebDAV locking.
Patch by: Giuseppe Castagno <gi...@acca-esse.eu>
Modified:
openoffice/branches/AOO410/main/ (props changed)
openoffice/branches/AOO410/main/comphelper/inc/comphelper/mediadescriptor.hxx
openoffice/branches/AOO410/main/comphelper/inc/comphelper/stillreadwriteinteraction.hxx
openoffice/branches/AOO410/main/comphelper/source/misc/mediadescriptor.cxx
openoffice/branches/AOO410/main/comphelper/source/misc/stillreadwriteinteraction.cxx
openoffice/branches/AOO410/main/framework/source/loadenv/loadenv.cxx
openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingException.idl
openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl
openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/makefile.mk
openoffice/branches/AOO410/main/sfx2/inc/sfx2/docfile.hxx
openoffice/branches/AOO410/main/sfx2/source/dialog/filedlghelper.cxx
openoffice/branches/AOO410/main/sfx2/source/doc/docfile.cxx
openoffice/branches/AOO410/main/sfx2/source/view/viewfrm.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVException.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVTypes.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCallbacks.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfRequestProcessor.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfRequestProcessor.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfRequestProcessorImplFac.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfSession.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfSession.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfTypes.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/makefile.mk
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/webdavcontent.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/webdavcontent.hxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/webdavprovider.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/webdavresponseparser.cxx
openoffice/branches/AOO410/main/ucb/source/ucp/webdav/webdavresponseparser.hxx
openoffice/branches/AOO410/main/ucbhelper/inc/ucbhelper/content.hxx
openoffice/branches/AOO410/main/ucbhelper/source/client/content.cxx
Propchange: openoffice/branches/AOO410/main/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 24 23:52:34 2015
@@ -2,4 +2,4 @@
/openoffice/branches/ia2/main:1417739-1541842
/openoffice/branches/ooxml-osba/main:1546391,1546395,1546574,1546934,1547030,1547392,1551920,1551954,1551958,1552283
/openoffice/branches/rejuvenate01/main:1480411,1534063,1534098,1536312,1549902,1560617
-/openoffice/trunk/main:1571617,1571677,1572569,1572577,1573547,1574058,1574101,1575922,1576216,1576748,1578786,1579934,1580657,1580779,1581746,1581840,1582359,1582365,1582709,1583336,1583418,1583589,1583988,1585261,1586242,1586249,1586583,1587468,1589050,1591501,1592692,1592716,1594206,1595847,1595851,1595858,1596218,1596491,1596494,1597076,1597102,1597109,1599169,1599173-1599174,1600581,1600587,1600590,1600630,1600861,1600863,1600883,1602434,1602791,1602823,1602850,1603416,1603897,1603941,1604028,1604709,1604786,1605044,1605355,1605689,1606055,1606061,1606706,1607111,1607793,1607836,1608348,1608376,1608730,1608733,1609204,1609208,1609302,1609426,1610347,1610411,1610422,1610671,1611470,1611549,1612070-1612071,1612539,1612801,1616457,1616944,1621121,1623847,1623849-1623850,1642300-1642302,1654282,1669457,1669459,1669462-1669463,1669465,1677190,1687177,1689883,1689959,1692551,1694132,1694701,1700078,1700135,1702894,1702898,1702986,1702988,1705193,1705196
+/openoffice/trunk/main:1571617,1571677,1572569,1572577,1573547,1574058,1574101,1575922,1576216,1576748,1578786,1579934,1580657,1580779,1581746,1581840,1582359,1582365,1582709,1583336,1583418,1583589,1583988,1585261,1586242,1586249,1586583,1587468,1589050,1591501,1592692,1592716,1594206,1595847,1595851,1595858,1596218,1596491,1596494,1597076,1597102,1597109,1599169,1599173-1599174,1600581,1600587,1600590,1600630,1600861,1600863,1600883,1602434,1602791,1602823,1602850,1603416,1603897,1603941,1604028,1604709,1604786,1605044,1605355,1605689,1606055,1606061,1606706,1607111,1607793,1607836,1608348,1608376,1608730,1608733,1609204,1609208,1609302,1609426,1610347,1610411,1610422,1610671,1611470,1611549,1612070-1612071,1612539,1612801,1616457,1616944,1621121,1623847,1623849-1623850,1642300-1642302,1654282,1669457,1669459,1669462-1669463,1669465,1677190,1687177,1689883,1689959,1692551,1694132,1694701,1700078,1700135,1702894,1702898,1702986,1702988,1705193,1705196,1705199
Modified: openoffice/branches/AOO410/main/comphelper/inc/comphelper/mediadescriptor.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/comphelper/inc/comphelper/mediadescriptor.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/comphelper/inc/comphelper/mediadescriptor.hxx (original)
+++ openoffice/branches/AOO410/main/comphelper/inc/comphelper/mediadescriptor.hxx Thu Sep 24 23:52:34 2015
@@ -85,6 +85,7 @@ class COMPHELPER_DLLPUBLIC MediaDescript
static const ::rtl::OUString& PROP_HIDDEN();
static const ::rtl::OUString& PROP_INPUTSTREAM();
static const ::rtl::OUString& PROP_INTERACTIONHANDLER();
+ static const ::rtl::OUString& PROP_AUTHENTICATIONHANDLER();
static const ::rtl::OUString& PROP_JUMPMARK();
static const ::rtl::OUString& PROP_MACROEXECUTIONMODE();
static const ::rtl::OUString& PROP_MEDIATYPE();
Modified: openoffice/branches/AOO410/main/comphelper/inc/comphelper/stillreadwriteinteraction.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/comphelper/inc/comphelper/stillreadwriteinteraction.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/comphelper/inc/comphelper/stillreadwriteinteraction.hxx (original)
+++ openoffice/branches/AOO410/main/comphelper/inc/comphelper/stillreadwriteinteraction.hxx Thu Sep 24 23:52:34 2015
@@ -44,18 +44,23 @@ class COMPHELPER_DLLPUBLIC StillReadWrit
private:
static const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION = 0;
static const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
+ static const sal_Int32 HANDLE_AUTHENTICATIONREQUESTEXCEPTION = 2;
sal_Bool m_bUsed;
sal_Bool m_bHandledByMySelf;
sal_Bool m_bHandledByInternalHandler;
public:
- StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler);
+ StillReadWriteInteraction(const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler,
+ const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xAuthenticationHandler);
void resetInterceptions();
void resetErrorStates();
sal_Bool wasWriteError();
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xAuthenticationHandler;
+
private:
virtual ucbhelper::InterceptedInteraction::EInterceptionState intercepted(const ::ucbhelper::InterceptedInteraction::InterceptedRequest& aRequest,
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest);
Modified: openoffice/branches/AOO410/main/comphelper/source/misc/mediadescriptor.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/comphelper/source/misc/mediadescriptor.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/comphelper/source/misc/mediadescriptor.cxx (original)
+++ openoffice/branches/AOO410/main/comphelper/source/misc/mediadescriptor.cxx Thu Sep 24 23:52:34 2015
@@ -175,6 +175,12 @@ const ::rtl::OUString& MediaDescriptor::
return sProp;
}
+const ::rtl::OUString& MediaDescriptor::PROP_AUTHENTICATIONHANDLER()
+{
+ static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("AuthenticationHandler"));
+ return sProp;
+}
+
const ::rtl::OUString& MediaDescriptor::PROP_JUMPMARK()
{
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("JumpMark"));
@@ -706,8 +712,11 @@ sal_Bool MediaDescriptor::impl_openStrea
css::uno::Reference< css::task::XInteractionHandler > xOrgInteraction = getUnpackedValueOrDefault(
MediaDescriptor::PROP_INTERACTIONHANDLER(),
css::uno::Reference< css::task::XInteractionHandler >());
+ css::uno::Reference< css::task::XInteractionHandler > xAuthenticationInteraction = getUnpackedValueOrDefault(
+ MediaDescriptor::PROP_AUTHENTICATIONHANDLER(),
+ css::uno::Reference< css::task::XInteractionHandler >());
- StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction);
+ StillReadWriteInteraction* pInteraction = new StillReadWriteInteraction(xOrgInteraction, xAuthenticationInteraction);
css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
css::uno::Reference< css::ucb::XProgressHandler > xProgress;
@@ -738,11 +747,17 @@ sal_Bool MediaDescriptor::impl_openStrea
css::uno::Reference< css::io::XInputStream > xInputStream;
sal_Bool bReadOnly = sal_False;
+ //bModeRequestedExplicitly means 'read/write mode requested explicitly'
sal_Bool bModeRequestedExplicitly = sal_False;
+ // MediaDescriptor::PROP_READONLY is present only if the mediadescriptor was used at least one time
+ // that is, it exists if the file was changed from readonly mode to read/write using the GUI interface
const_iterator pIt = find(MediaDescriptor::PROP_READONLY());
if (pIt != end())
{
pIt->second >>= bReadOnly;
+ // TODO: thinking a different way: we enable the switch to r/o even though the file
+ // was requested r/w explicitly (consider the case were we want to open a file in r/w mode (e.g. switching from r/o mode to r/w mode
+ // according to GUI request) instead of returning an error
bModeRequestedExplicitly = sal_True;
}
@@ -762,10 +777,24 @@ sal_Bool MediaDescriptor::impl_openStrea
// ignore exception, if reason was problem reasoned on
// open it in WRITEABLE mode! Then we try it READONLY
// later a second time.
- // All other errors must be handled as real error an
+ // All other errors must be handled as real error and
// break this method.
if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
- return sal_False;
+ {
+ //-> i126305
+ // If the protocol is webdav, then we need to treat the stream as readonly, even if the
+ // operation was requested as read/write explicitly (the WebDAV UCB implementation is monodirectional
+ // read or write not both at the same time).
+ rtl::OUString aScheme;
+ css::uno::Reference< css::ucb::XContentIdentifier > xContId(
+ aContent.get().is() ? aContent.get()->getIdentifier() : 0 );
+ if ( xContId.is() )
+ aScheme = xContId->getContentProviderScheme();
+ if(!aScheme.equalsIgnoreAsciiCaseAscii( "http" ) && !aScheme.equalsIgnoreAsciiCaseAscii( "https" ))
+ return sal_False;
+ //<- i126305
+ }
+
xStream.clear();
xInputStream.clear();
}
Modified: openoffice/branches/AOO410/main/comphelper/source/misc/stillreadwriteinteraction.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/comphelper/source/misc/stillreadwriteinteraction.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/comphelper/source/misc/stillreadwriteinteraction.cxx (original)
+++ openoffice/branches/AOO410/main/comphelper/source/misc/stillreadwriteinteraction.cxx Thu Sep 24 23:52:34 2015
@@ -37,14 +37,18 @@
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
#endif
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
+
namespace comphelper{
namespace css = ::com::sun::star;
-StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler)
+ StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
+ const css::uno::Reference< css::task::XInteractionHandler >& xAuthenticationHandler)
: m_bUsed (sal_False)
, m_bHandledByMySelf (sal_False)
, m_bHandledByInternalHandler(sal_False)
+ , m_xAuthenticationHandler(xAuthenticationHandler)
{
::std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
::ucbhelper::InterceptedInteraction::InterceptedRequest aInterceptedRequest;
@@ -60,7 +64,13 @@ StillReadWriteInteraction::StillReadWrit
aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
aInterceptedRequest.MatchExact = sal_False;
lInterceptions.push_back(aInterceptedRequest);
-
+
+ aInterceptedRequest.Handle = HANDLE_AUTHENTICATIONREQUESTEXCEPTION;
+ aInterceptedRequest.Request <<= css::ucb::AuthenticationRequest();
+ aInterceptedRequest.Continuation = ::getCppuType(static_cast< css::uno::Reference< css::task::XInteractionAbort >* >(0));
+ aInterceptedRequest.MatchExact = sal_False;
+ lInterceptions.push_back(aInterceptedRequest);
+
setInterceptedHandler(xHandler);
setInterceptions(lInterceptions);
}
@@ -114,6 +124,18 @@ ucbhelper::InterceptedInteraction::EInte
bAbort = sal_True;
}
break;
+ case HANDLE_AUTHENTICATIONREQUESTEXCEPTION:
+ {
+//use internal authentication dedicated handler and return
+ if (m_xAuthenticationHandler.is())
+ {
+ m_xAuthenticationHandler->handle(xRequest);
+ return ::ucbhelper::InterceptedInteraction::E_INTERCEPTED;
+ }
+ else //simply abort
+ bAbort = sal_True;;
+ }
+ break;
}
// handle interaction by ourself
Modified: openoffice/branches/AOO410/main/framework/source/loadenv/loadenv.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/framework/source/loadenv/loadenv.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/framework/source/loadenv/loadenv.cxx (original)
+++ openoffice/branches/AOO410/main/framework/source/loadenv/loadenv.cxx Thu Sep 24 23:52:34 2015
@@ -376,6 +376,7 @@ void LoadEnv::initializeUIDefaults( cons
)
{
io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteractionHandler;
+ io_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= xInteractionHandler;
}
if (io_lMediaDescriptor.find(::comphelper::MediaDescriptor::PROP_MACROEXECUTIONMODE()) == io_lMediaDescriptor.end())
Modified: openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingException.idl
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingException.idl?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingException.idl (original)
+++ openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingException.idl Thu Sep 24 23:52:34 2015
@@ -45,6 +45,12 @@ module com { module sun { module star {
/** The Url of the resource this exception is related to.
*/
string Url;
+
+ //->i126305 ---------------------------------------------------------------
+ /** Extended information, some Internet Server send this to the client
+ */
+ string ExtendedInfo;
+ //<-i126305
};
//=============================================================================
Modified: openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl (original)
+++ openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/InteractiveLockingLockedException.idl Thu Sep 24 23:52:34 2015
@@ -46,6 +46,13 @@ module com { module sun { module star {
<false/> the lock has been obtained by another principal.
*/
boolean SelfOwned;
+ //->i126305 -------------------------------------------------------------------------
+ /** The owner of the lock.
+ *
+ * Used for WevDAV interface
+ */
+ string Owner;
+ //<-i126305
};
//=============================================================================
Modified: openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/makefile.mk?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/makefile.mk (original)
+++ openoffice/branches/AOO410/main/offapi/com/sun/star/ucb/makefile.mk Thu Sep 24 23:52:34 2015
@@ -117,6 +117,7 @@ IDLFILES=\
InteractiveFileIOException.idl\
InteractiveIOException.idl\
InteractiveLockingException.idl\
+ InteractiveLockingLockNotAvailableException.idl\
InteractiveLockingLockExpiredException.idl\
InteractiveLockingLockedException.idl\
InteractiveLockingNotLockedException.idl\
Modified: openoffice/branches/AOO410/main/sfx2/inc/sfx2/docfile.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sfx2/inc/sfx2/docfile.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sfx2/inc/sfx2/docfile.hxx (original)
+++ openoffice/branches/AOO410/main/sfx2/inc/sfx2/docfile.hxx Thu Sep 24 23:52:34 2015
@@ -140,6 +140,8 @@ public:
void UseInteractionHandler( sal_Bool );
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
GetInteractionHandler();
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
+ GetAuthenticationInteractionHandler();
void setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,sal_Bool bIsReadOnly )
{ m_xInputStreamToLoadFrom = xInputStream; m_bIsReadOnly = bIsReadOnly; }
@@ -211,6 +213,9 @@ public:
sal_Bool Commit();
sal_Bool IsStorage();
+ //->i126305
+ sal_Int8 ShowLockedWebDAVDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading );
+ //<-i126305
sal_Int8 ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
sal_Bool LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
void UnlockFile( sal_Bool bReleaseLockStream );
Modified: openoffice/branches/AOO410/main/sfx2/source/dialog/filedlghelper.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sfx2/source/dialog/filedlghelper.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sfx2/source/dialog/filedlghelper.cxx (original)
+++ openoffice/branches/AOO410/main/sfx2/source/dialog/filedlghelper.cxx Thu Sep 24 23:52:34 2015
@@ -2710,7 +2710,7 @@ static int impl_isFolder( const OUString
{
}
- ::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler );
+ ::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler , uno::Reference< task::XInteractionHandler >());
try
{
Modified: openoffice/branches/AOO410/main/sfx2/source/doc/docfile.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sfx2/source/doc/docfile.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sfx2/source/doc/docfile.cxx (original)
+++ openoffice/branches/AOO410/main/sfx2/source/doc/docfile.cxx Thu Sep 24 23:52:34 2015
@@ -50,6 +50,10 @@
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XProgressHandler.hpp>
#include <com/sun/star/ucb/XCommandInfo.hpp>
+#include <com/sun/star/ucb/Lock.hpp>
+#include <com/sun/star/ucb/InteractiveLockingLockNotAvailableException.hpp>
+#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
+#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
#include <com/sun/star/util/XArchiver.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
@@ -309,6 +313,8 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xInteraction;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xCredentialInteraction;
+
sal_Bool m_bRemoveBackup;
::rtl::OUString m_aBackupURL;
@@ -486,7 +492,11 @@ void SfxMedium::CheckFileDate( const uti
//------------------------------------------------------------------
sal_Bool SfxMedium::DocNeedsFileDateCheck()
{
- return ( !IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
+ ::rtl::OUString aScheme = INetURLObject::GetScheme( GetURLObject().GetProtocol() );
+ sal_Bool bIsWebDAV = ( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+ aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) );
+ return ( !IsReadOnly() &&
+ ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) || bIsWebDAV ) );
}
//------------------------------------------------------------------
@@ -910,6 +920,86 @@ void SfxMedium::SetEncryptionDataToStora
}
}
+//->i126305 -----------------------------------------------------------------
+//for the time being the aData holds a single OUString, the owner of the lock
+sal_Int8 SfxMedium::ShowLockedWebDAVDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading )
+{
+ sal_Int8 nResult = LOCK_UI_NOLOCK;
+
+ // show the interaction regarding the document opening
+ uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
+
+ if ( ::svt::DocumentLockFile::IsInteractionAllowed() && xHandler.is() && bIsLoading )
+ {
+ ::rtl::OUString aDocumentURL = GetURLObject().GetLastName();
+ ::rtl::OUString aInfo;
+ ::rtl::Reference< ::ucbhelper::InteractionRequest > xInteractionRequestImpl;
+
+ aInfo = aData[0];
+ if(aData.getLength() > 1 && aData[1].getLength() > 0)
+ {
+ aInfo += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\n" ) );
+ aInfo += aData[1];
+ }
+
+ if ( bIsLoading )
+ {
+ xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
+ uno::makeAny( document::LockedDocumentRequest( ::rtl::OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
+ }
+ else
+ {
+ xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
+ uno::makeAny( document::LockedOnSavingRequest( ::rtl::OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
+ }
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
+ aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() );
+ aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() );
+ aContinuations[2] = new ::ucbhelper::InteractionDisapprove( xInteractionRequestImpl.get() );
+ xInteractionRequestImpl->setContinuations( aContinuations );
+
+ xHandler->handle( xInteractionRequestImpl.get() );
+
+ ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xInteractionRequestImpl->getSelection();
+ if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() )
+ {
+ SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+ else if ( uno::Reference< task::XInteractionDisapprove >( xSelected.get(), uno::UNO_QUERY ).is() )
+ {
+ // alien lock on loading, user has selected to edit a copy of document
+ // TODO/LATER: alien lock on saving, user has selected to do SaveAs to different location
+ // means that a copy of the document should be opened
+ GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
+ }
+ else // if ( XSelected == aContinuations[1] )
+ {
+ // alien lock on loading, user has selected to retry saving
+ // TODO/LATER: alien lock on saving, user has selected to retry saving
+ if ( bIsLoading )
+ GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+ else
+ nResult = LOCK_UI_TRY;
+ }
+ }
+ else
+ {
+ if ( bIsLoading )
+ {
+ // if no interaction handler is provided the default answer is open readonly
+ // that usually happens in case the document is loaded per API
+ // so the document must be opened readonly for backward compatibility
+ GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+ }
+ else
+ SetError( ERRCODE_IO_ACCESSDENIED, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+
+ return nResult;
+}
+//<-i126305
+
//------------------------------------------------------------------
sal_Int8 SfxMedium::ShowLockedDocumentDialog( const uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock )
{
@@ -1216,8 +1306,112 @@ sal_Bool SfxMedium::LockOrigFileOnDemand
}
else
{
- // this is no file URL, check whether the file is readonly
- bResult = !bContentReadonly;
+ //->i126305
+ // check if path scheme is http:// or https://
+ ::rtl::OUString aScheme = INetURLObject::GetScheme(GetURLObject().GetProtocol());
+ if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+ aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
+ {
+ //so, this is webdav stuff...
+ Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler();
+ if ( !bResult )
+ {
+ // no read-write access is necessary on loading if the document is explicitly opened as copy
+ SFX_ITEMSET_ARG( GetItemSet(), pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False);
+ bResult = ( bLoading && pTemplateItem && pTemplateItem->GetValue() );
+ }
+
+ if ( !bResult && !IsReadOnly() )
+ {
+
+ // in case of storing the document should request the output before locking
+ if ( bLoading )
+ {
+ // let the stream be opened to check the system file locking
+ GetMedium_Impl();
+ }
+
+ sal_Int8 bUIStatus = LOCK_UI_NOLOCK;
+ do
+ {
+ if( !bResult )
+ {
+ Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
+ uno::Reference< task::XInteractionHandler > xCHandler = GetAuthenticationInteractionHandler();
+ xComEnv = new ::ucbhelper::CommandEnvironment( xCHandler,
+ Reference< ::com::sun::star::ucb::XProgressHandler >() );
+ ::ucbhelper::Content aContentToLock( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv);
+ rtl::OUString aOwner;
+ try {
+ aContentToLock.lock();
+ bResult = sal_True;
+ }
+ catch( ucb::InteractiveLockingLockNotAvailableException )
+ {
+ // signalled when the lock can not be done because the method is known but not allowed on the resource
+ // the resource is still available, can be worked upon, at your risk
+ // so ask user whether he wants to open the document without any locking
+ uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
+
+ if ( xHandler.is() )
+ {
+ ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl
+ = new ::ucbhelper::InteractionRequest( uno::makeAny( document::LockFileIgnoreRequest() ) );
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
+ aContinuations[0] = new ::ucbhelper::InteractionAbort( xIgnoreRequestImpl.get() );
+ aContinuations[1] = new ::ucbhelper::InteractionApprove( xIgnoreRequestImpl.get() );
+ xIgnoreRequestImpl->setContinuations( aContinuations );
+
+ xHandler->handle( xIgnoreRequestImpl.get() );
+
+ ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
+ bResult = ( uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is() );
+ }
+ }
+ catch( ucb::InteractiveLockingLockedException& e )
+ {
+ // here get the lock owner currently active
+ aOwner = e.Owner;
+ rtl::OUString aExtendedError;
+
+ if ( !bResult && !bNoUI )
+ {
+ uno::Sequence< ::rtl::OUString > aData( 2 );
+
+ aData[0] = aOwner;
+ aData[1] = aExtendedError;
+ bUIStatus = ShowLockedWebDAVDocumentDialog( aData, bLoading );
+ if ( bUIStatus == LOCK_UI_SUCCEEDED )
+ {
+ // take the ownership over the lock file, accept the current lock (already there)
+ bResult = sal_True;
+ }
+ }
+ }
+ }
+ } while( !bResult && bUIStatus == LOCK_UI_TRY );
+ }
+
+ if ( !bResult && GetError() == ERRCODE_NONE )
+ {
+ // the error should be set in case it is storing process
+ // or the document has been opened for editing explicitly
+ SFX_ITEMSET_ARG( pSet, pReadOnlyItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
+ if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) )
+ SetError( ERRCODE_IO_ACCESSDENIED, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ else
+ GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+ }
+
+ pImp->m_bLocked = bResult;
+ }
+ else
+ {
+ // this is neither file URL nor WebDAV, check whether the file is readonly
+ bResult = !bContentReadonly;
+ }
+ //<-i126305
}
}
}
@@ -2194,7 +2388,7 @@ void SfxMedium::GetLockingStream_Impl()
SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False);
if ( pWriteStreamItem )
pWriteStreamItem->GetValue() >>= pImp->m_xLockingStream;
-
+
if ( !pImp->m_xLockingStream.is() )
{
// open the original document
@@ -2309,7 +2503,17 @@ void SfxMedium::GetMedium_Impl()
aMedium.addInputStreamOwnLock();
}
else
+ {
+ //add acheck for protocol, to see if it's http or https then add
+ //the interecation handler to be used by the authentication dialog
+ ::rtl::OUString aScheme = INetURLObject::GetScheme(GetURLObject().GetProtocol());
+ if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+ aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
+ {
+ aMedium[comphelper::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= GetAuthenticationInteractionHandler();
+ }
aMedium.addInputStream();
+ }
// the ReadOnly property set in aMedium is ignored
// the check is done in LockOrigFileOnDemand() for file and non-file URLs
@@ -2531,6 +2735,36 @@ void SfxMedium::UseInteractionHandler( s
//------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
+SfxMedium::GetAuthenticationInteractionHandler()
+{
+ // search a possible existing handler inside cached item set
+ if ( pSet )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xHandler;
+ SFX_ITEMSET_ARG( pSet, pHandler, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False);
+ if ( pHandler && (pHandler->GetValue() >>= xHandler) && xHandler.is() )
+ return xHandler;
+ }
+
+ // otherwhise return cached default handler ... if it exist.
+ if ( pImp->xCredentialInteraction.is() )
+ return pImp->xCredentialInteraction;
+
+ // create default handler and cache it!
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+ if ( xFactory.is() )
+ {
+ pImp->xCredentialInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >(
+ xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
+ return pImp->xCredentialInteraction;
+ }
+
+ return ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >();
+}
+
+//------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
SfxMedium::GetInteractionHandler()
{
// if interaction isn't allowed explicitly ... return empty reference!
@@ -2558,7 +2792,8 @@ SfxMedium::GetInteractionHandler()
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
if ( xFactory.is() )
{
- pImp->xInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >( xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
+ pImp->xInteraction = ::com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >(
+ xFactory->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), ::com::sun::star::uno::UNO_QUERY );
return pImp->xInteraction;
}
@@ -2708,38 +2943,74 @@ void SfxMedium::CloseAndRelease()
void SfxMedium::UnlockFile( sal_Bool bReleaseLockStream )
{
- if ( pImp->m_xLockingStream.is() )
+ //->i126305
+ //check if the file is local
+ if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
{
- if ( bReleaseLockStream )
+ //<-i126305
+ if ( pImp->m_xLockingStream.is() )
+ {
+ if ( bReleaseLockStream )
+ {
+ try
+ {
+ uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
+ uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
+ if ( xInStream.is() )
+ xInStream->closeInput();
+ if ( xOutStream.is() )
+ xOutStream->closeOutput();
+ }
+ catch( uno::Exception& )
+ {}
+ }
+
+ pImp->m_xLockingStream = uno::Reference< io::XStream >();
+ }
+
+ if ( pImp->m_bLocked )
{
try
{
- uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
- uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
- if ( xInStream.is() )
- xInStream->closeInput();
- if ( xOutStream.is() )
- xOutStream->closeOutput();
+ pImp->m_bLocked = sal_False;
+ ::svt::DocumentLockFile aLockFile( aLogicName );
+ // TODO/LATER: A warning could be shown in case the file is not the own one
+ aLockFile.RemoveFile();
}
catch( uno::Exception& )
{}
}
-
- pImp->m_xLockingStream = uno::Reference< io::XStream >();
+ //->i126305
}
-
- if ( pImp->m_bLocked )
+ else
{
- try
- {
- pImp->m_bLocked = sal_False;
- ::svt::DocumentLockFile aLockFile( aLogicName );
- // TODO/LATER: A warning could be shown in case the file is not the own one
- aLockFile.RemoveFile();
+ //not local, check if webdav
+ ::rtl::OUString aScheme = INetURLObject::GetScheme(GetURLObject().GetProtocol());
+ if( aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTP_SCHEME ) ||
+ aScheme.equalsIgnoreAsciiCaseAscii( INET_HTTPS_SCHEME ) )
+ {
+ if ( pImp->m_bLocked )
+ {
+ // an interaction handler should be used for authentication
+ try {
+ Reference< ::com::sun::star::task::XInteractionHandler > xHandler = GetAuthenticationInteractionHandler();
+ Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
+ xComEnv = new ::ucbhelper::CommandEnvironment( xHandler,
+ Reference< ::com::sun::star::ucb::XProgressHandler >() );
+ ::ucbhelper::Content aContentToUnlock( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv);
+ pImp->m_bLocked = sal_False;
+ aContentToUnlock.unlock();
+ }
+ catch (ucb::InteractiveNetworkReadException& e)
+ {
+ //signalled when this resource can not be unlocked, for whatever reason
+ }
+ catch( uno::Exception& )
+ {}
+ }
}
- catch( uno::Exception& )
- {}
}
+ //<-i126305
}
void SfxMedium::CloseAndReleaseStreams_Impl()
Modified: openoffice/branches/AOO410/main/sfx2/source/view/viewfrm.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sfx2/source/view/viewfrm.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sfx2/source/view/viewfrm.cxx (original)
+++ openoffice/branches/AOO410/main/sfx2/source/view/viewfrm.cxx Thu Sep 24 23:52:34 2015
@@ -303,7 +303,7 @@ void SfxViewFrame::ExecReload_Impl( SfxR
SfxFrame *pParent = GetFrame().GetParentFrame();
if ( rReq.GetSlot() == SID_RELOAD )
{
- // Bei CTRL-Reload den aktiven Frame reloaden
+ // With CTRL-Reload reload the active frame
SfxViewFrame* pActFrame = this;
while ( pActFrame )
pActFrame = pActFrame->GetActiveChildFrame_Impl();
@@ -318,8 +318,8 @@ void SfxViewFrame::ExecReload_Impl( SfxR
}
}
- // Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames
- // gemacht werden soll
+ // If only reloading of the graphs or more child frames
+ // is needed
SfxFrame& rFrame = GetFrame();
if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
{
@@ -338,16 +338,16 @@ void SfxViewFrame::ExecReload_Impl( SfxR
pChild = pNext;
}
- // Der TopLevel-Frame selbst het keine Graphiken!
+ // The TopLevel frame itself had no graphics
if ( bReloadAvailable )
return;
}
}
else
{
- // Bei CTRL-Edit den TopFrame bearbeiten
+ // With CTRL-Edit edit the top frame
sal_uInt16 nModifier = rReq.GetModifier();
-
+ //KEY_MOD1 is the Ctrl modifier key
if ( ( nModifier & KEY_MOD1 ) && pParent )
{
SfxViewFrame *pTop = GetTopViewFrame();
@@ -364,9 +364,8 @@ void SfxViewFrame::ExecReload_Impl( SfxR
if ( GetFrame().HasComponent() )
break;
- // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
- // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
- // trotzdem nicht geht!
+ // Because of double functioning of the toolbox button (with/without Ctrl)
+ // it's possible that the slot is enabled, but Ctrl-click is not.
if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ))
break;
@@ -446,11 +445,11 @@ void SfxViewFrame::ExecReload_Impl( SfxR
return;
}
- // Parameter auswerten
+ // Evaluate parameters
// sal_Bool bReload = sal_True;
if ( rReq.IsAPI() )
{
- // per API steuern ob r/w oder r/o
+ // Control through API if r/w or r/o
SFX_REQUEST_ARG(rReq, pEditItem, SfxBoolItem, SID_EDITDOC, sal_False);
if ( pEditItem )
nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
@@ -466,13 +465,27 @@ void SfxViewFrame::ExecReload_Impl( SfxR
INetURLObject aMedObj( pMed->GetName() );
- // the logic below is following, if the document seems not to need to be reloaded and the physical name is different
- // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required
- if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE &&
- aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
- !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) ))
- || pMed->IsRemote() ) )
- || pVersionItem )
+ // -> i126305
+ // the logic below is following:
+ // if the document seems not to need to be reloaded
+ // and the physical name is different to the logical one,
+ // then on file system it can be checked that the copy is still newer than the original and no document reload is required.
+ // some semplification to enhance readability of the 'if' expression
+ //
+ // on the 'http/https' protocol case, the bool bPhysObjIsYounger relies upon the getlastmodified Property of a WebDAV resource.
+ // Said property should be implemented, but sometimes it's not. This happens on some small webdav servers, where it's not
+ // implemented. On this case the reload will not work properly.
+ // Details at this link: http://tools.ietf.org/html/rfc4918#section-15, section 15.7
+ // TODO: add an indication to the user? Difficult to implement I think.
+ sal_Bool bPhysObjIsYounger = ::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) );
+ sal_Bool bIsHttpOrHttps = (aMedObj.GetProtocol() == INET_PROT_HTTP || aMedObj.GetProtocol() == INET_PROT_HTTPS);
+ if ( ( !bNeedsReload && ( ( aMedObj.GetProtocol() == INET_PROT_FILE &&
+ aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
+ !bPhysObjIsYounger )
+ || ( bIsHttpOrHttps && !bPhysObjIsYounger )
+ || ( pMed->IsRemote() && !bIsHttpOrHttps ) ) )
+ || pVersionItem )
+ // <- i126305
{
sal_Bool bOK = sal_False;
if ( !pVersionItem )
@@ -514,13 +527,15 @@ void SfxViewFrame::ExecReload_Impl( SfxR
pSh->DoSaveCompleted( pMed );
}
- // r/o-Doc kann nicht in Editmode geschaltet werden?
+ // r/o-Doc can not be switched to edit mode?
rReq.Done( sal_False );
if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
{
- // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen
+ // ::com::sun::star::sdbcx::User ask to open as template (a copy of the document)
QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
+ // this is the querybox that is opened when the file is asked to move from r/o to edit using the button
+ // on the toolbar
if ( RET_YES == aBox.Execute() )
{
SfxApplication* pApp = SFX_APP();
@@ -572,9 +587,8 @@ void SfxViewFrame::ExecReload_Impl( SfxR
case SID_RELOAD:
{
- // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
- // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
- // trotzdem nicht geht!
+ // Because of double functioning of the toolbox button (with/without Ctrl)
+ // it's possible that the slot is enabled, but Ctrl-click is not.
if ( !pSh || !pSh->CanReload_Impl() )
break;
SfxApplication* pApp = SFX_APP();
@@ -596,12 +610,12 @@ void SfxViewFrame::ExecReload_Impl( SfxR
pImp->bReloading = sal_True;
SFX_REQUEST_ARG(rReq, pURLItem, SfxStringItem,
SID_FILE_NAME, sal_False);
- // editierbar "offnen?
+ // open to edit?
sal_Bool bForEdit = !pSh->IsReadOnly();
if ( rReq.GetSlot() == SID_EDITDOC )
bForEdit = !bForEdit;
- // ggf. beim User nachfragen
+ // if necessary ask the user
sal_Bool bDo = ( GetViewShell()->PrepareClose() != sal_False );
SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
if ( bDo && GetFrame().DocIsModified_Impl() &&
@@ -615,15 +629,15 @@ void SfxViewFrame::ExecReload_Impl( SfxR
{
SfxMedium *pMedium = xOldObj->GetMedium();
- // Frameset abziehen, bevor FramesetView evtl. verschwindet
+ //Pull frameset before FramesetView possibly disappear
String aURL = pURLItem ? pURLItem->GetValue() :
pMedium->GetName();
sal_Bool bHandsOff =
( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
- // bestehende SfxMDIFrames f"ur dieses Doc leeren
- // eigenes Format oder R/O jetzt editierbar "offnen?
+ // empty existing SfxMDIFrames of this Doc
+ // own format or R/O is now open editable?
SfxObjectShellLock xNewObj;
// collect the views of the document
@@ -704,7 +718,7 @@ void SfxViewFrame::ExecReload_Impl( SfxR
xOldObj->CancelTransfers();
- // eigentliches Reload
+ //actual reload
//pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) );
if ( pSilentItem && pSilentItem->GetValue() )
@@ -727,8 +741,7 @@ void SfxViewFrame::ExecReload_Impl( SfxR
pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
xOldObj->SetModified( sal_False );
- // Altes Dok nicht cachen! Gilt nicht, wenn anderes
- // Doc geladen wird.
+ // Old Doc not cached! Does not apply if another Doc is loaded.
SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
@@ -760,6 +773,26 @@ void SfxViewFrame::ExecReload_Impl( SfxR
}
catch ( uno::Exception& )
{
+ //->i126305 OBSERVATION
+ // When this exception is thrown the r/o refresh of a file locked by another user
+ // is not completed.
+ // Code flow arrives here with a 'com.sun.star.task.ErrorCodeIOException'.
+ // It's thrown at around line 1970 of main/sfx2/source/doc/sfxbasemodel.cxx,
+ // in method 'SfxBaseModel::load'.
+ // Because of this exception, the document is not reloaded when it should be.
+ // The error generating the exception is 1287, or ERRCODE_IO_ACCESSDENIED.
+ // It seems that the reason for this is the way the property PROP_READONLY seems used
+ // in MediaDescriptor: both as property of the media and a request from GUI.
+ // See main/comphelper/source/misc/mediadescriptor.cxx around line 755, where the behavior
+ // leading to the error originates in the code flow.
+ // This problem doesn't arise in WebDAV, since the stream is monodirectional (read or write) in UCB implementation.
+ //<-i126305
+ //->i126305 WORKAROUND
+ // Code flow needs to reset the reloading, since it will no longer take part in the following code.
+ // This specific flag, if not reset, will break the code flow on the next call of this method,
+ // when it appears that the toolbar button stops functioning.
+ pImp->bReloading = sal_False;
+ //<-i126305
xNewObj->DoClose();
xNewObj = 0;
}
@@ -857,14 +890,14 @@ void SfxViewFrame::ExecReload_Impl( SfxR
SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
}
- // als erledigt recorden
+ // register as done
rReq.Done( sal_True );
rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
return;
}
else
{
- // als nicht erledigt recorden
+ // register as not done
rReq.Done();
rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_False));
pImp->bReloading = sal_False;
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVException.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVException.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVException.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVException.hxx Thu Sep 24 23:52:34 2015
@@ -138,18 +138,27 @@ class DAVException
private:
ExceptionCode mExceptionCode;
rtl::OUString mData;
+ //owner of the lock in case of DAV_LOCKED
+ rtl::OUString mOwner;
+ //extendend error information, if the server has a specific header
+ //see in SerfRequestProcessor::handleSerfResponse for detail on how this is obtained
+ rtl::OUString mExtendedError;
sal_uInt16 mStatusCode;
public:
DAVException( ExceptionCode inExceptionCode )
: mExceptionCode( inExceptionCode )
, mData()
+ , mOwner()
+ , mExtendedError()
, mStatusCode( SC_NONE )
{};
DAVException( ExceptionCode inExceptionCode,
const rtl::OUString & rData )
: mExceptionCode( inExceptionCode )
, mData( rData )
+ , mOwner()
+ , mExtendedError()
, mStatusCode( SC_NONE )
{};
DAVException( ExceptionCode inExceptionCode,
@@ -157,13 +166,29 @@ class DAVException
sal_uInt16 nStatusCode )
: mExceptionCode( inExceptionCode )
, mData( rData )
+ , mOwner()
+ , mExtendedError()
+ , mStatusCode( nStatusCode )
+ {};
+ DAVException( ExceptionCode inExceptionCode,
+ const rtl::OUString & rData,
+ const rtl::OUString & rExtendedError,
+ sal_uInt16 nStatusCode = SC_NONE )
+ : mExceptionCode( inExceptionCode )
+ , mData( rData )
+ , mOwner()
+ , mExtendedError( rExtendedError )
, mStatusCode( nStatusCode )
{};
~DAVException( ) {};
const ExceptionCode & getError() const { return mExceptionCode; }
const rtl::OUString & getData() const { return mData; }
+ const rtl::OUString & getExtendedError() const { return mExtendedError; }
sal_uInt16 getStatus() const { return mStatusCode; }
+ const rtl::OUString & getOwner() const { return mOwner; }
+ void setOwner(const rtl::OUString & rOwner) { mOwner = rOwner; }
+
};
} // namespace http_dav_ucp
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVResourceAccess.hxx Thu Sep 24 23:52:34 2015
@@ -203,7 +203,7 @@ public:
void
LOCK( com::sun::star::ucb::Lock & inLock,
const com::sun::star::uno::Reference<
- com::sun::star::ucb::XCommandEnvironment > & xEnv )
+ com::sun::star::ucb::XCommandEnvironment > & xEnv )
throw( DAVException );
#if 0 // currently not used, but please don't remove code
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVTypes.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVTypes.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVTypes.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/DAVTypes.hxx Thu Sep 24 23:52:34 2015
@@ -76,6 +76,8 @@ struct ProppatchValue
: operation( o ), name( n ), value( v ) {}
};
+enum LockScope { EXCLUSIVE = 0, SHARED = 1 };
+
} // namespace http_dav_ucp
#endif // _DAVTYPES_HXX_
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCallbacks.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCallbacks.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCallbacks.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCallbacks.cxx Thu Sep 24 23:52:34 2015
@@ -36,6 +36,7 @@ extern "C" apr_status_t Serf_ConnectSetu
apr_pool_t *pool )
{
SerfSession* pSerfSession = static_cast< SerfSession* >( setup_baton );
+ OSL_TRACE("Serf_ConnectSetup");
return pSerfSession->setupSerfConnection( skt,
read_bkt,
write_bkt,
@@ -52,6 +53,7 @@ extern "C" apr_status_t Serf_Credentials
apr_pool_t *pool )
{
SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( baton );
+ OSL_TRACE("Serf_Credential");
return pReqProc->provideSerfCredentials( username,
password,
request,
@@ -68,6 +70,7 @@ extern "C" apr_status_t Serf_Certificate
const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded,
apr_size_t nCertificateChainLength)
{
+ OSL_TRACE("Serf_CertificateChainValidation");
return static_cast<SerfSession*>(pSerfSession)
->verifySerfCertificateChain(nFailures, pCertificateChainBase64Encoded, nCertificateChainLength);
}
@@ -82,6 +85,7 @@ extern "C" apr_status_t Serf_SetupReques
apr_pool_t * pool )
{
SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( setup_baton );
+ OSL_TRACE("Serf_SetupRequest");
return pReqProc->setupSerfRequest( request,
req_bkt,
acceptor,
@@ -97,6 +101,7 @@ extern "C" serf_bucket_t* Serf_AcceptRes
apr_pool_t *pool )
{
SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( acceptor_baton );
+ OSL_TRACE("Serf_AcceptResponse");
return pReqProc->acceptSerfResponse( request,
stream,
pool );
@@ -108,6 +113,7 @@ extern "C" apr_status_t Serf_HandleRespo
apr_pool_t *pool )
{
SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( handler_baton );
+ OSL_TRACE("Serf_HandleResponse");
return pReqProc->handleSerfResponse( request,
response,
pool );
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.cxx Thu Sep 24 23:52:34 2015
@@ -32,10 +32,12 @@ namespace http_dav_ucp
SerfCopyReqProcImpl::SerfCopyReqProcImpl( const char* inSourcePath,
const DAVRequestHeaders& inRequestHeaders,
const char* inDestinationPath,
- const bool inOverwrite )
+ const bool inOverwrite,
+ const char* inLockToken )
: SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
, mDestPathStr( inDestinationPath )
, mbOverwrite( inOverwrite )
+ , mpLockToken( inLockToken )
{
}
@@ -67,6 +69,10 @@ serf_bucket_t * SerfCopyReqProcImpl::cre
{
serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
}
+ if(mpLockToken)
+ {
+ serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+ }
return req_bkt;
}
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfCopyReqProcImpl.hxx Thu Sep 24 23:52:34 2015
@@ -33,7 +33,8 @@ public:
SerfCopyReqProcImpl( const char* inSourcePath,
const DAVRequestHeaders& inRequestHeaders,
const char* inDestinationPath,
- const bool inOverwrite );
+ const bool inOverwrite,
+ const char* inLockToken );
virtual ~SerfCopyReqProcImpl();
@@ -50,6 +51,7 @@ protected:
private:
const char* mDestPathStr;
const bool mbOverwrite;
+ const char* mpLockToken;
};
} // namespace http_dav_ucp
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.cxx Thu Sep 24 23:52:34 2015
@@ -30,8 +30,10 @@ namespace http_dav_ucp
{
SerfDeleteReqProcImpl::SerfDeleteReqProcImpl( const char* inPath,
- const DAVRequestHeaders& inRequestHeaders )
+ const DAVRequestHeaders& inRequestHeaders,
+ const char* inLockToken )
: SerfRequestProcessorImpl( inPath, inRequestHeaders )
+ , mpLockToken( inLockToken )
{
}
@@ -52,6 +54,11 @@ serf_bucket_t * SerfDeleteReqProcImpl::c
serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
// general header fields provided by caller
setRequestHeaders( hdrs_bkt );
+ // specific header field
+ if(mpLockToken)
+ {
+ serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+ }
return req_bkt;
}
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfDeleteReqProcImpl.hxx Thu Sep 24 23:52:34 2015
@@ -29,9 +29,12 @@ namespace http_dav_ucp
class SerfDeleteReqProcImpl : public SerfRequestProcessorImpl
{
+private:
+ const char* mpLockToken;
public:
SerfDeleteReqProcImpl( const char* inPath,
- const DAVRequestHeaders& inRequestHeaders );
+ const DAVRequestHeaders& inRequestHeaders,
+ const char* inLockRToken );
virtual ~SerfDeleteReqProcImpl();
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.cxx Thu Sep 24 23:52:34 2015
@@ -24,11 +24,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_ucb.hxx"
-#include <ne_locks.h>
-#include <ne_uri.h>
#include <rtl/ustring.hxx>
#include <osl/time.h>
#include <osl/thread.hxx>
+#include "SerfTypes.hxx"
#include "SerfSession.hxx"
#include "SerfLockStore.hxx"
@@ -58,7 +57,7 @@ protected:
// -------------------------------------------------------------------
void TickerThread::run()
{
- OSL_TRACE( "TickerThread: start." );
+ OSL_TRACE( "TickerThread::run: start." );
// we have to go through the loop more often to be able to finish ~quickly
const int nNth = 25;
@@ -83,10 +82,8 @@ void TickerThread::run()
// -------------------------------------------------------------------
SerfLockStore::SerfLockStore()
- : m_pSerfLockStore( ne_lockstore_create() ),
- m_pTickerThread( 0 )
+ : m_pTickerThread( 0 )
{
- OSL_ENSURE( m_pSerfLockStore, "Unable to create neon lock store!" );
}
// -------------------------------------------------------------------
@@ -103,15 +100,15 @@ SerfLockStore::~SerfLockStore()
while ( it != end )
{
SerfLock * pLock = (*it).first;
- (*it).second.xSession->UNLOCK( pLock );
-
- ne_lockstore_remove( m_pSerfLockStore, pLock );
- ne_lock_destroy( pLock );
-
+ try
+ {
+ (*it).second.xSession->UNLOCK( pLock );
+ (*it).second.xSession->release();
+ }
+ catch (DAVException & )
+ {}
++it;
}
-
- ne_lockstore_destroy( m_pSerfLockStore );
}
// -------------------------------------------------------------------
@@ -140,23 +137,34 @@ void SerfLockStore::stopTicker()
}
}
+#if 0 //not currently used
// -------------------------------------------------------------------
-void SerfLockStore::registerSession( HttpSession * pHttpSession )
+void SerfLockStore::registerSession( SerfSession /* aSession */ )
{
osl::MutexGuard aGuard( m_aMutex );
- ne_lockstore_register( m_pSerfLockStore, pHttpSession );
}
+#endif
// -------------------------------------------------------------------
-SerfLock * SerfLockStore::findByUri( rtl::OUString const & rUri )
+SerfLock * SerfLockStore::findByUri( rtl::OUString const & rUri)
{
osl::MutexGuard aGuard( m_aMutex );
- ne_uri aUri;
- ne_uri_parse( rtl::OUStringToOString(
- rUri, RTL_TEXTENCODING_UTF8 ).getStr(), &aUri );
- return ne_lockstore_findbyuri( m_pSerfLockStore, &aUri );
+ LockInfoMap::const_iterator it( m_aLockInfoMap.begin() );
+ const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
+
+ while ( it != end )
+ {
+ SerfLock * pLock = (*it).first;
+ if( pLock->getResourceUri().equals( rUri ) )
+ {
+ return pLock;
+ }
+ ++it;
+ }
+
+ return static_cast<SerfLock*>(0);
}
// -------------------------------------------------------------------
@@ -166,13 +174,24 @@ void SerfLockStore::addLock( SerfLock *
{
osl::MutexGuard aGuard( m_aMutex );
- ne_lockstore_add( m_pSerfLockStore, pLock );
m_aLockInfoMap[ pLock ]
= LockInfo( xSession, nLastChanceToSendRefreshRequest );
+ //acquire this session, needed to manage the lock refresh
+ xSession->acquire();
+#if OSL_DEBUG_LEVEL > 0
+ rtl::OUString aOwner;
+ pLock->getLock().Owner >>= aOwner;
+ rtl::OUString aToken;
+ aToken = pLock->getLock().LockTokens[0];
+ OSL_TRACE("SerfLockStore::addLock: new lock added aOwner '%s', token '%s'",
+ rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr(),
+ rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
+#endif
startTicker();
}
+#if 0 //not currently used
// -------------------------------------------------------------------
void SerfLockStore::updateLock( SerfLock * pLock,
sal_Int32 nLastChanceToSendRefreshRequest )
@@ -189,17 +208,23 @@ void SerfLockStore::updateLock( SerfLock
= nLastChanceToSendRefreshRequest;
}
}
+#endif
// -------------------------------------------------------------------
void SerfLockStore::removeLock( SerfLock * pLock )
{
osl::MutexGuard aGuard( m_aMutex );
- m_aLockInfoMap.erase( pLock );
- ne_lockstore_remove( m_pSerfLockStore, pLock );
-
- if ( m_aLockInfoMap.size() == 0 )
- stopTicker();
+ LockInfoMap::iterator it( m_aLockInfoMap.find( pLock ) );
+ if(it != m_aLockInfoMap.end())
+ {
+ LockInfo & rInfo = (*it).second;
+ rInfo.xSession->release();
+ m_aLockInfoMap.erase( pLock );
+ //the caller should deallocate SerfLock class after the call!
+ if ( m_aLockInfoMap.size() == 0 )
+ stopTicker();
+ }
}
// -------------------------------------------------------------------
@@ -221,18 +246,39 @@ void SerfLockStore::refreshLocks()
<= sal_Int32( t1.Seconds ) )
{
// refresh the lock.
+#if OSL_DEBUG_LEVEL > 0
+ ucb::Lock aLock = (*it).first->getLock();
+ rtl::OUString aOwner;
+ aLock.Owner >>= aOwner;
+ rtl::OUString aToken;
+ aToken = aLock.LockTokens[0];
+ OSL_TRACE( "SerfLockStore::refreshLocks: refresh started for lock: aOwner '%s', token '%s'",
+ rtl::OUStringToOString(aOwner, RTL_TEXTENCODING_UTF8).getStr(),
+ rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
+#endif
sal_Int32 nlastChanceToSendRefreshRequest = -1;
- if ( rInfo.xSession->LOCK(
- (*it).first,
- /* out param */ nlastChanceToSendRefreshRequest ) )
+ try
{
+ rInfo.xSession->LOCK( (*it).first,
+ /* out param */ nlastChanceToSendRefreshRequest );
rInfo.nLastChanceToSendRefreshRequest
= nlastChanceToSendRefreshRequest;
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "Lock '%s' successfully refreshed." ,
+ rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() );
+#endif
}
- else
+ catch ( DAVException & e )
{
// refresh failed. stop auto-refresh.
+ // TODO i126305 discuss:
+ // probably not a good idea to stop the refresh?
+ // may be just ignore and go on, it's possible the net is temporary down?
rInfo.nLastChanceToSendRefreshRequest = -1;
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "SerfLockStore::refreshLocks: Lock '%s' not refreshed! (error: DAVException.mStatusCode %d)",
+ rtl::OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr(), e.getStatus() );
+#endif
}
}
}
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfLockStore.hxx Thu Sep 24 23:52:34 2015
@@ -27,6 +27,7 @@
#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
#include "SerfTypes.hxx"
+#include "SerfSession.hxx"
namespace http_dav_ucp
{
@@ -52,8 +53,8 @@ typedef struct _LockInfo
_LockInfo( rtl::Reference< SerfSession > const & _xSession,
sal_Int32 _nLastChanceToSendRefreshRequest )
- : xSession( _xSession ),
- nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
+ : xSession( _xSession )
+ , nLastChanceToSendRefreshRequest( _nLastChanceToSendRefreshRequest ) {}
} LockInfo;
@@ -62,7 +63,6 @@ typedef std::map< SerfLock *, LockInfo,
class SerfLockStore
{
osl::Mutex m_aMutex;
-// ne_lock_store * m_pSerfLockStore;
TickerThread * m_pTickerThread;
LockInfoMap m_aLockInfoMap;
@@ -70,7 +70,7 @@ public:
SerfLockStore();
~SerfLockStore();
- void registerSession( HttpSession * pHttpSession );
+ void registerSession( SerfSession aSession );
SerfLock * findByUri( rtl::OUString const & rUri );
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.cxx Thu Sep 24 23:52:34 2015
@@ -30,8 +30,10 @@ namespace http_dav_ucp
{
SerfMkColReqProcImpl::SerfMkColReqProcImpl( const char* inPath,
- const DAVRequestHeaders& inRequestHeaders )
+ const DAVRequestHeaders& inRequestHeaders,
+ const char* inLockToken )
: SerfRequestProcessorImpl( inPath,inRequestHeaders )
+ , mpLockToken( inLockToken )
{
}
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMkColReqProcImpl.hxx Thu Sep 24 23:52:34 2015
@@ -29,9 +29,12 @@ namespace http_dav_ucp
class SerfMkColReqProcImpl : public SerfRequestProcessorImpl
{
+private:
+ const char* mpLockToken;
public:
SerfMkColReqProcImpl( const char* inPath,
- const DAVRequestHeaders& inRequestHeaders );
+ const DAVRequestHeaders& inRequestHeaders,
+ const char* inLockToken );
virtual ~SerfMkColReqProcImpl();
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.cxx Thu Sep 24 23:52:34 2015
@@ -32,10 +32,12 @@ namespace http_dav_ucp
SerfMoveReqProcImpl::SerfMoveReqProcImpl( const char* inSourcePath,
const DAVRequestHeaders& inRequestHeaders,
const char* inDestinationPath,
- const bool inOverwrite )
+ const bool inOverwrite,
+ const char* inLockToken)
: SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
, mDestPathStr( inDestinationPath )
, mbOverwrite( inOverwrite )
+ , mpLockToken( inLockToken )
{
}
@@ -67,6 +69,10 @@ serf_bucket_t * SerfMoveReqProcImpl::cre
{
serf_bucket_headers_set( hdrs_bkt, "Overwrite", "F" );
}
+ if(mpLockToken)
+ {
+ serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+ }
return req_bkt;
}
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfMoveReqProcImpl.hxx Thu Sep 24 23:52:34 2015
@@ -33,7 +33,8 @@ public:
SerfMoveReqProcImpl( const char* inSourcePath,
const DAVRequestHeaders& inRequestHeaders,
const char* inDestinationPath,
- const bool inOverwrite );
+ const bool inOverwrite,
+ const char* inLockToken );
virtual ~SerfMoveReqProcImpl();
@@ -49,7 +50,8 @@ protected:
private:
const char* mDestPathStr;
- const bool mbOverwrite;
+ const bool mbOverwrite;
+ const char* mpLockToken;
};
} // namespace http_dav_ucp
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx Thu Sep 24 23:52:34 2015
@@ -35,12 +35,14 @@ SerfPostReqProcImpl::SerfPostReqProcImpl
const DAVRequestHeaders& inRequestHeaders,
const char* inData,
apr_size_t inDataLen,
+ const char* inLockToken,
const char* inContentType,
const char* inReferer,
const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm )
: SerfRequestProcessorImpl( inPath, inRequestHeaders )
, mpPostData( inData )
, mnPostDataLen( inDataLen )
+ , mpLockToken( inLockToken )
, mpContentType( inContentType )
, mpReferer( inReferer )
, xInputStream( xioInStrm )
@@ -52,12 +54,14 @@ SerfPostReqProcImpl::SerfPostReqProcImpl
const DAVRequestHeaders& inRequestHeaders,
const char* inData,
apr_size_t inDataLen,
+ const char* inLockToken,
const char* inContentType,
const char* inReferer,
const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm )
: SerfRequestProcessorImpl( inPath, inRequestHeaders )
, mpPostData( inData )
, mnPostDataLen( inDataLen )
+ , mpLockToken( inLockToken )
, mpContentType( inContentType )
, mpReferer( inReferer )
, xInputStream()
@@ -102,6 +106,10 @@ serf_bucket_t * SerfPostReqProcImpl::cre
{
serf_bucket_headers_set( hdrs_bkt, "Referer", mpReferer );
}
+ if(mpLockToken)
+ {
+ serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+ }
return req_bkt;
}
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPostReqProcImpl.hxx Thu Sep 24 23:52:34 2015
@@ -37,6 +37,7 @@ public:
const DAVRequestHeaders& inRequestHeaders,
const char* inData,
apr_size_t inDataLen,
+ const char* inLockToken,
const char* inContentType,
const char* inReferer,
const com::sun::star::uno::Reference< SerfInputStream > & xioInStrm );
@@ -45,6 +46,7 @@ public:
const DAVRequestHeaders& inRequestHeaders,
const char* inData,
apr_size_t inDataLen,
+ const char* inLockToken,
const char* inContentType,
const char* inReferer,
const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > & xioOutStrm );
@@ -64,6 +66,7 @@ protected:
private:
const char* mpPostData;
apr_size_t mnPostDataLen;
+ const char* mpLockToken;
const char* mpContentType;
const char* mpReferer;
com::sun::star::uno::Reference< SerfInputStream > xInputStream;
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx Thu Sep 24 23:52:34 2015
@@ -35,9 +35,11 @@ namespace http_dav_ucp
SerfPropPatchReqProcImpl::SerfPropPatchReqProcImpl( const char* inPath,
const DAVRequestHeaders& inRequestHeaders,
- const std::vector< ProppatchValue > & inProperties )
+ const std::vector< ProppatchValue > & inProperties,
+ const char* inLockToken )
: SerfRequestProcessorImpl( inPath, inRequestHeaders )
, mpProperties( &inProperties )
+ , mpLockToken( inLockToken )
{
}
@@ -167,6 +169,10 @@ serf_bucket_t * SerfPropPatchReqProcImpl
setRequestHeaders( hdrs_bkt );
// request specific header fields
+ if(mpLockToken)
+ {
+ serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken );
+ }
if ( body_bkt != 0 && aBodyText.getLength() > 0 )
{
serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" );
Modified: openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx?rev=1705201&r1=1705200&r2=1705201&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx (original)
+++ openoffice/branches/AOO410/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.hxx Thu Sep 24 23:52:34 2015
@@ -35,7 +35,8 @@ class SerfPropPatchReqProcImpl : public
public:
SerfPropPatchReqProcImpl( const char* inPath,
const DAVRequestHeaders& inRequestHeaders,
- const std::vector< ProppatchValue > & inProperties );
+ const std::vector< ProppatchValue > & inProperties,
+ const char* inLockToken );
virtual ~SerfPropPatchReqProcImpl();
@@ -51,6 +52,7 @@ protected:
private:
const std::vector< ProppatchValue > * mpProperties;
+ const char *mpLockToken;
};
} // namespace http_dav_ucp