diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2013-05-30 06:48:39 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2013-10-28 21:14:53 +0100 |
commit | d051654df39b63bbfe23c995e85f4d708c09e629 (patch) | |
tree | fc1a2358e26b43202d93d99e674e2086415263e1 /ucb | |
parent | 3404f57c7e36f525279b126ef6a1c874aa3f2cad (diff) |
bnc#805901: Lock WebDAV document that is opened for potential modification
Really horrible fix, breaking all rules of proper abstraction etc.
Basically, two parts:
1) When opening a document over WebDAV, in Content::execute(), lock it
too. This is simple. With just this change, the WebDAV resource gets
locked but it stays locked for the rest of the soffice.bin lifetime,
even if the document is closed much earlier. This also means you can't
re-open it without re-starting LibreOffice...
The NeonLockStore (which is effectively a singleton, as the only
object of this type that exists is the static
NeonSession::m_aNeonLockStore field) destructor takes care of blowing
awway the locks when the process exists.
So obviously that is not good enough. Thus a second part is needed:
2) Then closing a document, over in SfxObjectShell::Close(), do a
horrible trick: look up the ucpdav1 module, and if it is loaded, look
up the NeonSessionUnlockByUri() function in it, and call it, passing
the document's URI.
That function, in NeonSession.cxx, looks up the NeonLock for the URI,
and if it exists, unlocks it, and removs the lock from the
NeonLockStore.
Conflicts:
ucb/source/ucp/webdav-neon/NeonLockStore.cxx
ucb/source/ucp/webdav-neon/webdavcontent.cxx
Change-Id: If9af1f8b5d3a89cdea34ccd0b751d5f671ccccba
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonLockStore.cxx | 16 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonLockStore.hxx | 2 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonSession.cxx | 11 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonSession.hxx | 3 |
4 files changed, 31 insertions, 1 deletions
diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx index 043ea7d27d72..b4bbaec868f3 100644 --- a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx +++ b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx @@ -202,6 +202,22 @@ void NeonLockStore::removeLock( NeonLock * pLock ) stopTicker(); } +void NeonLockStore::unlockLock( NeonLock * pLock ) +{ + osl::MutexGuard aGuard( m_aMutex ); + + LockInfoMap::const_iterator it( m_aLockInfoMap.begin() ); + const LockInfoMap::const_iterator end( m_aLockInfoMap.end() ); + while ( it != end ) + { + NeonLock * pLockIt = (*it).first; + if (pLockIt == pLock) + (*it).second.xSession->UNLOCK( pLock ); + ++it; + } + } + +// ------------------------------------------------------------------- void NeonLockStore::refreshLocks() { osl::MutexGuard aGuard( m_aMutex ); diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.hxx b/ucb/source/ucp/webdav-neon/NeonLockStore.hxx index dd9b18599505..1b041ad36cbb 100644 --- a/ucb/source/ucp/webdav-neon/NeonLockStore.hxx +++ b/ucb/source/ucp/webdav-neon/NeonLockStore.hxx @@ -92,6 +92,8 @@ public: void removeLock( NeonLock * pLock ); + void unlockLock( NeonLock * pLock ); + void refreshLocks(); private: diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index cee643a587dc..65afb259a19e 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -2074,4 +2074,15 @@ OUString NeonSession::makeAbsoluteURL( OUString const & rURL ) const return OUString(); } +extern "C" SAL_DLLPUBLIC_EXPORT void NeonSessionUnlockByUri(rtl::OUString uri) +{ + NeonLock *pLock = NeonSession::m_aNeonLockStore.findByUri(uri); + + if (!pLock) + return; + + NeonSession::m_aNeonLockStore.unlockLock(pLock); + NeonSession::m_aNeonLockStore.removeLock(pLock); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/webdav-neon/NeonSession.hxx b/ucb/source/ucp/webdav-neon/NeonSession.hxx index f62ec005b238..806c9f1d36fc 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.hxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.hxx @@ -65,12 +65,13 @@ private: DAVRequestEnvironment m_aEnv; static bool m_bGlobalsInited; - static NeonLockStore m_aNeonLockStore; protected: virtual ~NeonSession(); public: + static NeonLockStore m_aNeonLockStore; + NeonSession( const rtl::Reference< DAVSessionFactory > & rSessionFactory, const OUString& inUri, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rFlags, |