ooo-build r13274 - in branches/ooo-build-2-4-1: . patches/src680



Author: jholesovsky
Date: Thu Jul 17 13:56:13 2008
New Revision: 13274
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13274&view=rev

Log:
2008-07-17  Jan Holesovsky  <kendy suse cz>

        * patches/src680/webdav-locking-refresh-lock.diff: Do not set lock
          timeout to infinite, instead set it to 3 minutes, and refresh 30 sec
          before expiration, n#403724.
        * patches/src680/webdav-locking-neon-refresh-hack.diff: Hack
          workarounding a bug in neon 0.24 so that ne_lock_refresh() does not
          crash.

        * patches/src680/sw-hyperlinks-without-scheme.diff: When there's no
          scheme in the hyperlink, it's probably a file, n#376389, i#91105.

        * patches/src680/tools-urlobj-smb-scheme-patch-relative-links.diff:
          Improve roundtrips of the hyperlinks to files, n#405712.


Added:
   branches/ooo-build-2-4-1/patches/src680/sw-hyperlinks-without-scheme.diff
   branches/ooo-build-2-4-1/patches/src680/tools-urlobj-smb-scheme-patch-relative-links.diff
   branches/ooo-build-2-4-1/patches/src680/webdav-locking-neon-refresh-hack.diff
   branches/ooo-build-2-4-1/patches/src680/webdav-locking-refresh-lock.diff
Modified:
   branches/ooo-build-2-4-1/ChangeLog
   branches/ooo-build-2-4-1/patches/src680/apply

Modified: branches/ooo-build-2-4-1/patches/src680/apply
==============================================================================
--- branches/ooo-build-2-4-1/patches/src680/apply	(original)
+++ branches/ooo-build-2-4-1/patches/src680/apply	Thu Jul 17 13:56:13 2008
@@ -460,9 +460,13 @@
 
 # process relative SMB paths correctly
 tools-urlobj-smb-scheme-patch.diff, n#261623, flr
+tools-urlobj-smb-scheme-patch-relative-links.diff, n#405712, jholesov
 samba-hyperlinks-sc-sd.diff, n#382718, jholesov
 tools-qa-urlobj-unittest.diff, n#261623, flr
 
+# When there's no scheme in the hyperlink, it's probably a file
+sw-hyperlinks-without-scheme.diff, n#376389, i#91105, jholesov
+
 # try autodetection if it is allowed and the current java has been removed
 jvmfwk-detect-removed-java.diff, i#83140, n#336242, pmladek
 # allow to overwrite broken java configuration; it is related
@@ -631,6 +635,13 @@
 # unlock the stream on crash/terminate/...
 webdav-locking-unlock-on-crash.diff, i#29152, jholesov
 
+# don't lock for infinite, instead set timeout to 3 minutes, and refresh 30
+# sec before expiration
+webdav-locking-refresh-lock.diff, n#403724, jholesov
+
+# workaround a bug in neon 0.24 that breaks ne_lock_refresh()
+webdav-locking-neon-refresh-hack.diff, n#403724, jholesov
+
 # NOT LOCKING RELATED!
 # Move gnome-vfs out of the startup sequence, load it only when needed
 gnome-vfs-late-init.diff, i#84137, jholesov

Added: branches/ooo-build-2-4-1/patches/src680/sw-hyperlinks-without-scheme.diff
==============================================================================
--- (empty file)
+++ branches/ooo-build-2-4-1/patches/src680/sw-hyperlinks-without-scheme.diff	Thu Jul 17 13:56:13 2008
@@ -0,0 +1,13 @@
+diff --git sw/source/filter/ww8/ww8par5.cxx sw/source/filter/ww8/ww8par5.cxx
+index 583f46d..0c8ce65 100644
+--- sw/source/filter/ww8/ww8par5.cxx
++++ sw/source/filter/ww8/ww8par5.cxx
+@@ -436,7 +436,7 @@ void SwWW8ImplReader::ConvertFFileName( String& rName, const String& rOrg )
+     //#82900# Need the more sophisticated url converter. cmc
+     if (rName.Len())
+         rName = URIHelper::SmartRel2Abs(
+-            INetURLObject(sBaseURL), rName, URIHelper::GetMaybeFileHdl());
++            INetURLObject(sBaseURL), rName, URIHelper::GetMaybeFileHdl(), false);
+ }
+ 
+ // ConvertUFNneme uebersetzt FeldParameter-Namen u. ae. in den

Added: branches/ooo-build-2-4-1/patches/src680/tools-urlobj-smb-scheme-patch-relative-links.diff
==============================================================================
--- (empty file)
+++ branches/ooo-build-2-4-1/patches/src680/tools-urlobj-smb-scheme-patch-relative-links.diff	Thu Jul 17 13:56:13 2008
@@ -0,0 +1,51 @@
+--- sw/source/filter/ww8/ww8par5.cxx	2008-07-07 18:23:57.000000000 +0200
++++ sw/source/filter/ww8/ww8par5.cxx	2008-07-07 18:24:02.000000000 +0200
+@@ -527,6 +527,7 @@ void SwWW8ImplReader::ConvertFFileName( 
+ {
+     rName = rOrg;
+     rName.SearchAndReplaceAllAscii( "\\\\", String( '\\' ));
++    rName.SearchAndReplaceAllAscii( "%20", String( ' ' ));
+ 
+     // ggfs. anhaengende Anfuehrungszeichen entfernen
+     if( rName.Len() &&  '"' == rName.GetChar( rName.Len()-1 ))
+--- sw/source/filter/ww8/wrtw8nds.cxx	2008-07-07 13:37:02.000000000 +0200
++++ sw/source/filter/ww8/wrtw8nds.cxx	2008-07-07 17:52:26.000000000 +0200
+@@ -1055,13 +1055,31 @@ void WW8_AttrIter::StartURL(const String
+             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+         };
+ 
+-	if (eProto == INET_PROT_SMB) { // #n261623# Convert smb notation to \\
+-	    sURL = aURL.GetMainURL(INetURLObject::NO_DECODE);
+-	    sURL = String(sURL.GetBuffer()+strlen("smb:"));
+-	    sURL.SearchAndReplaceAll('/', '\\');
+-	} else {
+-	    sURL = aURL.PathToFileName();
+-	}
++        // n#405712 save the file:// and smb:// hyperlinks as relative
++        sURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), sURL );
++        if ( eProto == INET_PROT_FILE && sURL.EqualsAscii( "/", 0, 1 ) )
++            sURL = aURL.PathToFileName();
++
++        // special case for the windows names
++        // (convert '/c:/blah' into 'c:/blah', regardless of the protocol -
++        // for the relativized smb case)
++        sal_Unicode aDrive = ( sURL.Len() > 1 )? sURL.GetChar( 1 ): 0;
++        if ( sURL.EqualsAscii( "/", 0, 1 ) &&
++             ( ( aDrive >= 'A' && aDrive <= 'Z' ) || ( aDrive >= 'a' && aDrive <= 'z' ) ) &&
++             sURL.EqualsAscii( ":", 2, 1 ) )
++        {
++            sURL.Erase( 0, 1 );
++            sURL.SearchAndReplaceAll( '/', '\\' );
++        }
++
++        // n#261623 convert smb notation to '\\'
++        const char pSmb[] = "smb://";
++        if ( eProto == INET_PROT_SMB &&
++             sURL.EqualsAscii( pSmb, 0, sizeof( pSmb ) - 1 ) )
++        {
++            sURL.Erase( 0, sizeof( pSmb ) - 3 );
++            sURL.SearchAndReplaceAll( '/', '\\' );
++        }
+ 
+         rWrt.pDataStrm->Write( MAGIC_C, sizeof(MAGIC_C) );
+         SwWW8Writer::WriteLong( *rWrt.pDataStrm, sURL.Len()+1 );

Added: branches/ooo-build-2-4-1/patches/src680/webdav-locking-neon-refresh-hack.diff
==============================================================================
--- (empty file)
+++ branches/ooo-build-2-4-1/patches/src680/webdav-locking-neon-refresh-hack.diff	Thu Jul 17 13:56:13 2008
@@ -0,0 +1,36 @@
+--- ucb/source/ucp/webdav/NeonSession.cxx	2008-07-04 11:22:17.000000000 +0200
++++ ucb/source/ucp/webdav/NeonSession.cxx	2008-07-04 12:56:23.000000000 +0200
+@@ -1632,7 +1632,33 @@ void NeonSession::Lockit( ucb::Lock & rL
+             }
+         }
+         else
++        {
++#if NEON_VERSION >= 0x0260
+             nRet = ne_lock_refresh( m_pHttpSession, theLock );
++#else
++            // workaround for a bug in neon 0.24
++            // we have to call with a bigger structure that is used internally
++            // and initialize parts of it
++
++            struct lock_ctx
++            {
++                struct ne_lock active; /* activelock */
++                char *token; /* the token we're after. */
++                int found;
++                ne_buffer *cdata;
++            };
++
++            struct lock_ctx ctx;
++
++            memset( &ctx, 0, sizeof ctx );
++            ctx.cdata = ne_buffer_create();
++            
++            memcpy( &ctx, theLock, sizeof( *theLock ) );
++            nRet = ne_lock_refresh( m_pHttpSession, reinterpret_cast<NeonLock*>( &ctx ) );
++
++            ne_buffer_destroy( ctx.cdata );
++#endif
++        }
+ 
+         if ( ( nRet == NE_ERROR ) && ( getStatusCode( m_pHttpSession ) == SC_LOCKED ) )
+         {

Added: branches/ooo-build-2-4-1/patches/src680/webdav-locking-refresh-lock.diff
==============================================================================
--- (empty file)
+++ branches/ooo-build-2-4-1/patches/src680/webdav-locking-refresh-lock.diff	Thu Jul 17 13:56:13 2008
@@ -0,0 +1,360 @@
+diff --git ucb/source/ucp/webdav/NeonInputStream.cxx ucb/source/ucp/webdav/NeonInputStream.cxx
+index 37a8580..abd43f2 100644
+--- ucb/source/ucp/webdav/NeonInputStream.cxx
++++ ucb/source/ucp/webdav/NeonInputStream.cxx
+@@ -41,6 +41,9 @@
+ #ifndef _RTL_MEMORY_H_
+ #include <rtl/memory.h>
+ #endif
++#ifndef _THREAD_HXX_
++#include <osl/thread.hxx>
++#endif
+ #ifndef _COM_SUN_STAR_UCB_COMMANDFAILEDEXCEPTION_HPP_
+ #include <com/sun/star/ucb/CommandFailedException.hpp>
+ #endif
+@@ -46,16 +47,117 @@ using namespace com::sun::star::io;
+ using namespace com::sun::star;
+ using namespace webdav_ucp;
+ 
+-oslSignalAction NeonInputStream::UnlockOnSignal( void* pData, oslSignalInfo* )
++// Our signal - 246 is just a random number ;-)
++#define TICKER_THREAD_USER_SIGNAL ( OSL_SIGNAL_USER_RESERVED + 246 )
++
++// -------------------------------------------------------------------
++// A thread that 'ticks' - emits the user signal every second
++// -------------------------------------------------------------------
++class TickerThread : public osl::Thread
++{
++    bool m_bFinish;
++
++public:
++
++    TickerThread() : osl::Thread(), m_bFinish( false ) {}
++
++    void finish() { m_bFinish = true; }
++
++protected:
++
++    virtual void SAL_CALL run();
++};
++
++void TickerThread::run()
++{
++    // we have to go through the loop more often to be able to finish ~quickly
++    const int nNth = 25;
++
++    int nCount = nNth;
++    while ( !m_bFinish )
++    {
++        if ( nCount-- <= 0 )
++        {
++            osl_raiseSignal( TICKER_THREAD_USER_SIGNAL, NULL );
++            nCount = nNth;
++        }
++
++        TimeValue aTV;
++        aTV.Seconds = 0;
++        aTV.Nanosec = 1000000000/nNth;
++        wait( aTV );
++    }
++}
++
++// -------------------------------------------------------------------
++// A class that takes care of creating and destroying the ticker thread
++// -------------------------------------------------------------------
++class TickerThreadController
++{
++    osl::Mutex    m_aMutex;
++    int           m_nCount;
++    TickerThread *m_pTickerThread;
++
++public:
++
++    TickerThreadController() : m_nCount( 0 ), m_pTickerThread( NULL ) {}
++
++    void start();
++    void stop();
++};
++
++void TickerThreadController::start()
++{
++    osl::MutexGuard aGuard( m_aMutex );
++    
++    if ( ( m_nCount++ == 0 ) && !m_pTickerThread )
++    {
++        m_pTickerThread = new TickerThread();
++        m_pTickerThread->create();
++    }
++}
++        
++void TickerThreadController::stop()
++{
++    osl::MutexGuard aGuard( m_aMutex );
++
++    if ( ( --m_nCount == 0 ) && m_pTickerThread )
++    {
++        m_pTickerThread->finish();
++        m_pTickerThread->join();
++
++        delete m_pTickerThread;
++        m_pTickerThread = NULL;
++    }
++}
++
++// -------------------------------------------------------------------
++// Signal handler
++// -------------------------------------------------------------------
++oslSignalAction NeonInputStream::HandleLockingSignal( void* pData, oslSignalInfo* pSignalInfo )
+ {
+     NeonInputStream *pStream = static_cast< NeonInputStream *>( pData );
+ 
+-    if ( pStream )
++    if ( !pStream )
++        return osl_Signal_ActCallNextHdl;
++
++    if ( pSignalInfo  &&
++            pSignalInfo->Signal == osl_Signal_User &&
++            pSignalInfo->UserSignal == TICKER_THREAD_USER_SIGNAL )
++    {
++        pStream->RefreshLock();
++    }
++    else if ( !pSignalInfo || ( pSignalInfo->Signal != osl_Signal_User ) )
++    {
++        // terminating or something, let's unlock the stream
+         pStream->Unlock();
++    }
+ 
+     return osl_Signal_ActCallNextHdl;
+ }
+ 
++static TickerThreadController sTickerThreadController;
++
+ // -------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------
+@@ -72,9 +72,12 @@ NeonInputStream::NeonInputStream()
+ : m_nLen( 0 ),
+   m_nPos( 0 ),
+   m_bDirty( sal_False ),
+-  m_pLock( NULL )
++  m_pLock( NULL ),
++  m_nToExpire( -1 )
+ {
+-    m_pSignalHandler = osl_addSignalHandler( NeonInputStream::UnlockOnSignal, this );
++    m_pSignalHandler = osl_addSignalHandler( NeonInputStream::HandleLockingSignal, this );
++    
++    sTickerThreadController.start();
+ }
+ 
+ // -------------------------------------------------------------------
+@@ -76,6 +181,8 @@ NeonInputStream::NeonInputStream( const uno::Reference< lang::XMultiServiceFacto
+ // -------------------------------------------------------------------
+ NeonInputStream::~NeonInputStream( void )
+ {
++    sTickerThreadController.stop();
++
+     Unlock();
+ 
+     osl_removeSignalHandler( m_pSignalHandler );
+@@ -100,12 +207,17 @@ void NeonInputStream::AddToStream( const char * inBuf, sal_Int32 inLen )
+ void NeonInputStream::SetLock( const com::sun::star::ucb::Lock &rLock,
+         const rtl::OUString &rURL )
+ {
++    osl::MutexGuard aGuard( m_aLock );
++
+     m_aURL = rURL;
+ 
+     if ( !m_pLock )
+         m_pLock = new ucb::Lock( rLock );
+     else
+         *m_pLock = rLock;
++
++    if ( m_pLock )
++        m_nToExpire = m_pLock->Timeout;
+ }
+ 
+ // -------------------------------------------------------------------
+@@ -364,10 +476,42 @@ void SAL_CALL NeonInputStream::truncate( void )
+ }
+ 
+ // -------------------------------------------------------------------
++// Lock the stream again
++// -------------------------------------------------------------------
++void NeonInputStream::RefreshLock( void )
++{
++    osl::MutexGuard aGuard( m_aLock );
++
++#if OSL_DEBUG_LEVEL > 0
++    fprintf( stderr, "WebDAV: RefreshLock() - will refresh in %d sec\n", m_nToExpire - 30 );
++#endif
++
++    if ( m_nToExpire > 0 )
++        --m_nToExpire;
++
++    // Refresh the lock if it expires in less than 30 sec
++    if ( m_pLock && m_nToExpire >= 0 && m_nToExpire < 30 )
++    {
++        // FIXME It's really hacky to create the new session
++        // But so far it seems I have no other chance...
++        uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
++        rtl::Reference< DAVSessionFactory > rDAVFactory( new DAVSessionFactory() );
++        
++        DAVResourceAccess aResourceAccess( xFactory, rDAVFactory, m_aURL );
++
++        aResourceAccess.LOCK( *m_pLock, DAVResourceAccess::createCommandEnvironment() );
++
++        m_nToExpire = m_pLock->Timeout;
++    }
++}
++
++// -------------------------------------------------------------------
+ // Unlock the stream & destroy the lock
+ // -------------------------------------------------------------------
+ void NeonInputStream::Unlock( void )
+ {
++    osl::MutexGuard aGuard( m_aLock );
++
+ #if OSL_DEBUG_LEVEL > 0
+     fprintf( stderr, "WebDAV: unlock()\n" );
+ #endif
+@@ -384,5 +527,7 @@ void NeonInputStream::Unlock( void )
+ 
+         delete m_pLock;
+         m_pLock = NULL;
++
++        m_nToExpire = -1;
+     }
+ }
+diff --git ucb/source/ucp/webdav/NeonInputStream.hxx ucb/source/ucp/webdav/NeonInputStream.hxx
+index bf8c4a7..8cda106 100644
+--- ucb/source/ucp/webdav/NeonInputStream.hxx
++++ ucb/source/ucp/webdav/NeonInputStream.hxx
+@@ -38,6 +38,9 @@
+ #ifndef _SAL_TYPES_H_
+ #include <sal/types.h>
+ #endif
++#ifndef _OSL_MUTEX_HXX_
++#include <osl/mutex.hxx>
++#endif
+ #include <osl/signal.h>
+ #ifndef _RTL_USTRING_HXX_
+ #include <rtl/ustring.hxx>
+@@ -71,6 +72,7 @@ private:
+     sal_Bool                   m_bDirty;
+ 
+     com::sun::star::ucb::Lock *m_pLock;
++    int                        m_nToExpire;
+     rtl::OUString              m_aURL;
+ 
+     oslSignalHandler           m_pSignalHandler;
+@@ -78,6 +80,8 @@ private:
+     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
+     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv;
+ 
++    osl::Mutex                 m_aLock;
++
+ public:
+              NeonInputStream( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &m_rMSF,
+                               const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > &m_rEnv );
+@@ -183,11 +187,15 @@ public:
+     
+ protected:
+ 
++    // Refresh the lock on the stream
++    void RefreshLock( void );
++
+     // Unlock the stream & destroy the lock
+     void Unlock( void );
+ 
+-    // Unlock the stream when OOo crashes/is terminated/...
+-    static oslSignalAction UnlockOnSignal( void* pData, oslSignalInfo* pInfo );
++    // Refresh the lock if necessary, or unlock the stream when
++    // OOo crashes/is terminated/...
++    static oslSignalAction HandleLockingSignal( void* pData, oslSignalInfo* pInfo );
+ };
+ 
+ } // namespace webdav_ucp
+diff --git ucb/source/ucp/webdav/NeonSession.cxx ucb/source/ucp/webdav/NeonSession.cxx
+index 4194c11..9f14c11 100644
+--- ucb/source/ucp/webdav/NeonSession.cxx
++++ ucb/source/ucp/webdav/NeonSession.cxx
+@@ -1515,7 +1515,10 @@ void NeonSession::Lockit( ucb::Lock & rLock, bool bLockit )
+ 
+     // Create the neon lock
+     NeonLock * theLock = ne_lockstore_findbyuri( s_aNeonLockStore, &aUri );
+-    if ( !theLock )
++    bool bAlreadyExists = false;
++    if ( theLock )
++        bAlreadyExists = true;
++    else
+     {
+         theLock = ne_lock_create();
+ 
+@@ -1549,28 +1552,34 @@ void NeonSession::Lockit( ucb::Lock & rLock, bool bLockit )
+         theLock->owner = strdup( rtl::OUStringToOString( aValue, RTL_TEXTENCODING_UTF8 ).getStr() );
+ 
+         // Set the lock timeout
+-        // Note: Neon ignores the timeout
+-        //theLock->timeout = rLock.timeout;
+-        theLock->timeout = -1;
++        // We re-new the lock while the stream is open
++        theLock->timeout = rLock.Timeout;
+     }
+ 
+     if ( bLockit )
+     {
+-        int nRet = ne_lock( m_pHttpSession, theLock );
+-
+-        if ( nRet == NE_OK )
++        int nRet;
++        if ( !bAlreadyExists )
+         {
+-            ne_lockstore_add( s_aNeonLockStore, theLock );
++            nRet = ne_lock( m_pHttpSession, theLock );
++
++            if ( nRet == NE_OK )
++            {
++                ne_lockstore_add( s_aNeonLockStore, theLock );
+ 
+-            uno::Sequence< rtl::OUString > aTokens( 1 );
+-            aTokens[0] = rtl::OUString::createFromAscii( theLock->token );
+-            rLock.LockTokens = aTokens;
++                uno::Sequence< rtl::OUString > aTokens( 1 );
++                aTokens[0] = rtl::OUString::createFromAscii( theLock->token );
++                rLock.LockTokens = aTokens;
+ 
+ #if OSL_DEBUG_LEVEL > 0
+-            fprintf( stderr, "WebDAV: locked the URL, the token is: %s\n", theLock->token );
++                fprintf( stderr, "WebDAV: locked the URL, the token is: %s\n", theLock->token );
+ #endif
++            }
+         }
+-        else if ( ( nRet == NE_ERROR ) && ( getStatusCode( m_pHttpSession ) == SC_LOCKED ) )
++        else
++            nRet = ne_lock_refresh( m_pHttpSession, theLock );
++
++        if ( ( nRet == NE_ERROR ) && ( getStatusCode( m_pHttpSession ) == SC_LOCKED ) )
+         {
+             ucbhelper::cancelCommandExecution( ucb::IOErrorCode_LOCKING_VIOLATION,
+                     uno::Sequence< uno::Any >( 0 ), // FIXME more info about the file?
+@@ -1579,6 +1588,8 @@ void NeonSession::Lockit( ucb::Lock & rLock, bool bLockit )
+                     uno::Reference< ucb::XCommandProcessor >() );
+         }
+ #if OSL_DEBUG_LEVEL > 0
++        else if ( nRet == NE_OK )
++            fprintf( stderr, "WebDAV: locked/refreshed lock OK\n" );
+         else
+             fprintf( stderr, "WebDAV: failed to lock the file, status code is: %d\n", getStatusCode( m_pHttpSession ) );
+ #endif
+diff --git ucb/source/ucp/webdav/webdavcontent.cxx ucb/source/ucp/webdav/webdavcontent.cxx
+index f4fcbc2..e02f66b 100644
+--- ucb/source/ucp/webdav/webdavcontent.cxx
++++ ucb/source/ucp/webdav/webdavcontent.cxx
+@@ -2192,6 +2192,7 @@ uno::Any Content::open(
+                 ucb::Lock aLock;
+                 aLock.Depth = ucb::LockDepth_ZERO;
+                 aLock.Scope = ucb::LockScope_EXCLUSIVE;
++                aLock.Timeout = 3*60; // 3 minutes
+ 
+                 // PULL: wait for client read
+                 try



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]