1 --- officecfg/registry/data/org/openoffice/ucb/Configuration.xcu.old 2009-04-02 11:01:44.000000000 +0000
2 +++ officecfg/registry/data/org/openoffice/ucb/Configuration.xcu 2009-04-06 16:41:46.000000000 +0000
7 + <node oor:name="Provider14" oor:op="replace">
8 + <prop oor:name="ServiceName">
9 + <value>com.sun.star.ucb.WebDAVContentProvider</value>
11 + <prop oor:name="URLTemplate">
12 + <value>webdav</value>
14 + <prop oor:name="Arguments">
18 + <node oor:name="Provider15" oor:op="replace">
19 + <prop oor:name="ServiceName">
20 + <value>com.sun.star.ucb.WebDAVContentProvider</value>
22 + <prop oor:name="URLTemplate">
23 + <value>webdavs</value>
25 + <prop oor:name="Arguments">
29 <!-- We want the Provider to be the final fallback provider -->
30 <node oor:name="Provider999" oor:op="replace" install:module="gio">
31 <prop oor:name="ServiceName">
32 --- sal/inc/osl/file.h.old 2009-04-02 10:43:39.000000000 +0000
33 +++ sal/inc/osl/file.h 2009-04-06 16:41:46.000000000 +0000
34 @@ -139,6 +139,7 @@ typedef enum {
39 osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
42 --- sal/inc/osl/file.hxx.old 2009-04-02 10:43:39.000000000 +0000
43 +++ sal/inc/osl/file.hxx 2009-04-06 16:41:46.000000000 +0000
44 @@ -106,6 +106,7 @@ public:
45 E_USERS = osl_File_E_USERS,
46 E_OVERFLOW = osl_File_E_OVERFLOW,
47 E_NOTREADY = osl_File_E_NOTREADY,
48 + E_TXTBSY = osl_File_E_TXTBSY,
49 E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
50 E_TIMEDOUT = osl_File_E_TIMEDOUT,
51 E_NETWORK = osl_File_E_NETWORK
52 --- sal/osl/unx/file_error_transl.cxx.old 2009-04-02 10:43:46.000000000 +0000
53 +++ sal/osl/unx/file_error_transl.cxx 2009-04-06 16:41:46.000000000 +0000
54 @@ -247,6 +247,10 @@ oslFileError oslTranslateFileError(sal_B
55 osl_error = osl_File_E_TIMEDOUT;
59 + osl_error = osl_File_E_TXTBSY;
63 /* FIXME translateFileError: is this alright? Or add a new one: osl_File_E_Unknown? */
64 osl_error = osl_File_E_invalidError;
65 --- sc/source/ui/docshell/docsh.cxx.old 2009-04-02 10:45:27.000000000 +0000
66 +++ sc/source/ui/docshell/docsh.cxx 2009-04-06 16:41:46.000000000 +0000
67 @@ -823,7 +823,7 @@ BOOL __EXPORT ScDocShell::ConvertFrom( S
68 // Alle Filter brauchen die komplette Datei am Stueck (nicht asynchron),
69 // darum vorher per CreateFileStream dafuer sorgen, dass die komplette
70 // Datei uebertragen wird.
71 - rMedium.GetPhysicalName(); //! CreateFileStream direkt rufen, wenn verfuegbar
72 + rMedium.GetPhysicalName( sal_False ); //! CreateFileStream direkt rufen, wenn verfuegbar
74 SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
75 nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
76 --- sfx2/inc/sfx2/docfile.hxx
77 +++ sfx2/inc/sfx2/docfile.hxx
78 @@ -186,7 +186,7 @@ public:
79 ::com::sun::star::util::DateTime GetInitFileDate( sal_Bool bIgnoreOldValue );
81 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > GetContent() const;
82 - const String& GetPhysicalName() const;
83 + const String& GetPhysicalName( sal_Bool bForceCreateTempIfRemote = sal_True ) const;
84 void SetTemporary( sal_Bool bTemp );
85 sal_Bool IsTemporary() const;
87 @@ -260,6 +260,8 @@ public:
88 void SetCharset( ::rtl::OUString );
89 ::rtl::OUString GetBaseURL( bool bForSaving=false );
91 + sal_Bool SupportsActiveStreaming( const rtl::OUString &rName ) const;
94 //REMOVE // the storage will be truncated, if it is still not open then the stream will be truncated
95 //REMOVE ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetOutputStorage_Impl();
96 --- sfx2/source/bastyp/helper.cxx.old 2009-04-02 10:43:55.000000000 +0000
97 +++ sfx2/source/bastyp/helper.cxx 2009-04-06 16:41:46.000000000 +0000
98 @@ -796,16 +796,15 @@ ErrCode SfxContentHelper::QueryDiskSpace
100 // -----------------------------------------------------------------------
102 -ULONG SfxContentHelper::GetSize( const String& rContent )
103 +sal_Int64 SfxContentHelper::GetSize( const String& rContent )
106 - sal_Int64 nTemp = 0;
107 + sal_Int64 nSize = -1;
108 INetURLObject aObj( rContent );
109 DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
112 ::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
113 - aCnt.getPropertyValue( OUString::createFromAscii( "Size" ) ) >>= nTemp;
114 + aCnt.getPropertyValue( OUString::createFromAscii( "Size" ) ) >>= nSize;
116 catch( ucb::CommandAbortedException& )
118 @@ -815,7 +814,6 @@ ULONG SfxContentHelper::GetSize( const S
120 DBG_ERRORFILE( "Any other exception" );
122 - nSize = (UINT32)nTemp;
126 --- sfx2/source/dialog/dinfdlg.cxx.old 2009-04-02 10:43:54.000000000 +0000
127 +++ sfx2/source/dialog/dinfdlg.cxx 2009-04-06 16:41:46.000000000 +0000
128 @@ -1153,8 +1153,9 @@ void SfxDocumentPage::Reset( const SfxIt
130 // determine size and type
131 String aSizeText( aUnknownSize );
132 - if ( aURL.GetProtocol() == INET_PROT_FILE )
133 - aSizeText = CreateSizeText( SfxContentHelper::GetSize( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) );
134 + sal_Int64 nSize = SfxContentHelper::GetSize( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
136 + aSizeText = CreateSizeText( static_cast< ULONG >( nSize ) );
137 aShowSizeFT.SetText( aSizeText );
139 String aDescription = SvFileInformationManager::GetDescription( INetURLObject(rMainURL) );
140 --- sfx2/source/doc/docfile.cxx
141 +++ sfx2/source/doc/docfile.cxx
143 //------------------------------------------------------------------
144 sal_Bool SfxMedium::DocNeedsFileDateCheck()
146 - return ( !IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
147 + return ( !IsReadOnly() && SupportsActiveStreaming( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
150 //------------------------------------------------------------------
151 @@ -749,10 +749,13 @@ sal_Bool SfxMedium::CloseOutStream_Impl(
154 //------------------------------------------------------------------
155 -const String& SfxMedium::GetPhysicalName() const
156 +const String& SfxMedium::GetPhysicalName( sal_Bool bForceCreateTempIfRemote ) const
158 if ( !aName.Len() && aLogicName.Len() )
159 - (( SfxMedium*)this)->CreateFileStream();
161 + if ( bForceCreateTempIfRemote || !SupportsActiveStreaming( aLogicName ) )
162 + (( SfxMedium*)this)->CreateFileStream();
165 // return the name then
167 @@ -796,8 +799,6 @@ sal_Bool SfxMedium::Commit()
168 if ( bResult && DocNeedsFileDateCheck() )
169 GetInitFileDate( sal_True );
171 - // remove truncation mode from the flags
172 - nStorOpenMode &= (~STREAM_TRUNC);
176 @@ -928,11 +929,31 @@ sal_Bool SfxMedium::TryStorage()
179 //------------------------------------------------------------------
180 +sal_Bool SfxMedium::SupportsActiveStreaming( const rtl::OUString &rName ) const
182 + if ( ::utl::LocalFileHelper::IsLocalFile( rName ) )
185 + ::ucbhelper::Content aTmpContent;
186 + Reference< ::com::sun::star::ucb::XCommandEnvironment > xDummyEnv;
187 + if ( ::ucbhelper::Content::create( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv, aTmpContent ) )
189 + Any aAny = aTmpContent.getPropertyValue(
190 + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "SupportsActiveStreaming" )) );
192 + sal_Bool bSupportsStreaming = sal_False;
193 + return ( ( aAny >>= bSupportsStreaming ) && bSupportsStreaming );
199 +//------------------------------------------------------------------
200 sal_Bool SfxMedium::BasedOnOriginalFile_Impl()
202 return ( !pImp->pTempFile && !( aLogicName.Len() && pImp->m_bSalvageMode )
203 && GetURLObject().GetMainURL( INetURLObject::NO_DECODE ).getLength()
204 - && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
205 + && SupportsActiveStreaming( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
206 && ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
209 @@ -996,10 +1017,105 @@ uno::Reference < embed::XStorage > SfxMe
211 DBG_ASSERT( !pOutStream, "OutStream in a readonly Medium?!" );
213 - // TODO/LATER: The current solution is to store the document temporary and then copy it to the target location;
214 - // in future it should be stored directly and then copied to the temporary location, since in this case no
215 - // file attributes have to be preserved and system copying mechanics could be used instead of streaming.
216 + // medium based on OutputStream: must work with TempFile
217 + if( aLogicName.CompareToAscii( "private:stream", 14 ) == COMPARE_EQUAL
218 + || !::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
219 CreateTempFileNoCopy();
220 + // if Medium already contains a stream - TODO/LATER: store stream/outputstream in ImplData, not in Medium
221 + else if ( GetItemSet()->GetItemState( SID_STREAM ) < SFX_ITEM_SET )
223 + // check whether the backup should be created
224 + StorageBackup_Impl();
227 + return uno::Reference< embed::XStorage >();
229 + ::rtl::OUString aOutputURL = GetOutputStorageURL_Impl();
231 + SFX_ITEMSET_ARG( GetItemSet(), pOverWrite, SfxBoolItem, SID_OVERWRITE, sal_False );
232 + SFX_ITEMSET_ARG( GetItemSet(), pRename, SfxBoolItem, SID_RENAME, sal_False );
233 + sal_Bool bRename = pRename ? pRename->GetValue() : FALSE;
234 + sal_Bool bOverWrite = pOverWrite ? pOverWrite->GetValue() : !bRename;
236 + // the target file must be truncated before a storage based on it is created
239 + uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
240 + uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess(
241 + xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ),
242 + uno::UNO_QUERY_THROW );
244 + uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
245 + ::ucbhelper::Content aContent = ::ucbhelper::Content( aOutputURL, xDummyEnv );
247 + uno::Reference< io::XStream > xStream;
248 + sal_Bool bDeleteOnFailure = sal_False;
252 + xStream = aContent.openWriteableStreamNoLock();
256 + // the stream should not exist, it should not be possible to open it
257 + if ( xStream->getOutputStream().is() )
258 + xStream->getOutputStream()->closeOutput();
259 + if ( xStream->getInputStream().is() )
260 + xStream->getInputStream()->closeInput();
262 + xStream = uno::Reference< io::XStream >();
263 + SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
266 + catch ( ucb::InteractiveIOException const & e )
268 + if ( e.Code == ucb::IOErrorCode_NOT_EXISTING )
271 + SvMemoryStream aStream(0,0);
272 + uno::Reference< io::XInputStream > xInput( new ::utl::OInputStreamWrapper( aStream ) );
273 + ucb::InsertCommandArgument aInsertArg;
274 + aInsertArg.Data = xInput;
275 + aInsertArg.ReplaceExisting = sal_False;
276 + aContent.executeCommand( rtl::OUString::createFromAscii( "insert" ), uno::makeAny( aInsertArg ) );
278 + // Try to open one more time
279 + xStream = aContent.openWriteableStreamNoLock();
280 + bDeleteOnFailure = sal_True;
286 + if ( xStream.is() )
288 + if ( BasedOnOriginalFile_Impl() )
290 + // the storage will be based on original file, the wrapper should be used
291 + xStream = new OPostponedTruncationFileStream( aOutputURL, xFactory, xSimpleFileAccess, xStream, bDeleteOnFailure );
295 + // the storage will be based on the temporary file, the stream can be truncated directly
296 + uno::Reference< io::XOutputStream > xOutStream = xStream->getOutputStream();
297 + uno::Reference< io::XTruncate > xTruncate( xOutStream, uno::UNO_QUERY );
298 + if ( !xTruncate.is() )
299 + throw uno::RuntimeException();
301 + xTruncate->truncate();
302 + xOutStream->flush();
305 + pImp->xStream = xStream;
306 + GetItemSet()->Put( SfxUsrAnyItem( SID_STREAM, makeAny( xStream ) ) );
309 + catch( uno::Exception& )
311 + // TODO/LATER: try to use the temporary file in case the target content can not be opened, it might happen in case of some FS, the copy functionality might work in this case
312 + SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
318 @@ -1381,7 +1497,7 @@ uno::Reference < embed::XStorage > SfxMe
322 - if ( IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
323 + if ( IsReadOnly() && SupportsActiveStreaming( aLogicName ) )
325 //TODO/LATER: performance problem if not controlled by special Mode in SfxMedium
326 //(should be done only for permanently open storages)
327 @@ -2210,7 +2326,7 @@ void SfxMedium::Transfer_Impl()
328 xComEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler,
329 Reference< ::com::sun::star::ucb::XProgressHandler >() );
331 - if ( ::utl::LocalFileHelper::IsLocalFile( aDest.GetMainURL( INetURLObject::NO_DECODE ) ) || !aDest.removeSegment() )
332 + if ( SupportsActiveStreaming( aDest.GetMainURL( INetURLObject::NO_DECODE ) ) || !aDest.removeSegment() )
334 TransactedTransferForFS_Impl( aSource, aDest, xComEnv );
336 @@ -2542,7 +2658,7 @@ void SfxMedium::GetMedium_Impl()
337 aMedium.erase( comphelper::MediaDescriptor::PROP_READONLY() );
338 aMedium.addInputStream();
340 - else if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
341 + else if ( SupportsActiveStreaming( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
343 // use the special locking approach only for file URLs
344 aMedium.addInputStreamOwnLock();
345 --- sfx2/source/inc/helper.hxx.old 2009-04-02 10:43:59.000000000 +0000
346 +++ sfx2/source/inc/helper.hxx 2009-04-06 16:41:46.000000000 +0000
347 @@ -69,7 +69,7 @@ public:
349 static sal_Bool MakeFolder( const String& rFolder );
350 static ErrCode QueryDiskSpace( const String& rPath, sal_Int64& rFreeBytes );
351 - static ULONG GetSize( const String& rContent );
352 + static sal_Int64 GetSize( const String& rContent );
353 static sal_Bool IsYounger( const String& rIsYoung, const String& rIsOlder );
355 // please don't use this!
356 --- sfx2/source/view/viewfrm.cxx.old 2009-04-02 10:44:00.000000000 +0000
357 +++ sfx2/source/view/viewfrm.cxx 2009-04-06 16:41:46.000000000 +0000
358 @@ -631,6 +631,11 @@ void SfxViewFrame::ExecReload_Impl( SfxR
360 ( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
362 + // we must do the same for the contents that support active
364 + if ( !bHandsOff && pMedium && pMedium->SupportsActiveStreaming( aURL ) )
365 + bHandsOff = sal_True;
367 // bestehende SfxMDIFrames f"ur dieses Doc leeren
368 // eigenes Format oder R/O jetzt editierbar "offnen?
369 SfxViewNotificatedFrameList_Impl aFrames;
370 --- tools/inc/tools/urlobj.hxx.old 2009-04-06 16:41:45.000000000 +0000
371 +++ tools/inc/tools/urlobj.hxx 2009-04-06 16:41:46.000000000 +0000
372 @@ -141,9 +141,14 @@ enum INetProtocol
373 INET_PROT_TELNET = 28,
374 INET_PROT_VND_SUN_STAR_EXPAND = 29,
375 INET_PROT_VND_SUN_STAR_TDOC = 30,
376 - INET_PROT_GENERIC = 31,
377 - INET_PROT_SMB = 32,
379 + INET_PROT_SMB = 31,
380 + INET_PROT_DAV = 32,
381 + INET_PROT_DAVS = 33,
382 + INET_PROT_WEBDAV = 34,
383 + INET_PROT_WEBDAVS = 35,
384 + INET_PROT_GENERIC = 36,
385 + INET_PROT_GENERIC_HIERARCHICAL = 37,
389 //============================================================================
390 --- tools/source/fsys/urlobj.cxx.old 2009-04-06 16:41:45.000000000 +0000
391 +++ tools/source/fsys/urlobj.cxx 2009-04-06 16:41:46.000000000 +0000
392 @@ -374,21 +374,21 @@ static INetURLObject::SchemeInfo const a
394 { "ftp", "ftp://", 21, true, true, false, true, true, true, true,
396 - { "http", "http://", 80, true, false, false, false, true, true,
397 + { "http", "http://", 80, true, true, false, true, true, true,
399 { "file", "file://", 0, true, false, false, false, true, false,
401 { "mailto", "mailto:", 0, false, false, false, false, false,
402 false, false, true },
403 - { "vnd.sun.star.webdav", "vnd.sun.star.webdav://", 80, true, false,
404 - false, false, true, true, true, true },
405 + { "vnd.sun.star.webdav", "vnd.sun.star.webdav://", 80, true, true,
406 + false, true, true, true, true, true },
407 { "news", "news:", 0, false, false, false, false, false, false, false,
409 { "private", "private:", 0, false, false, false, false, false,
410 false, false, true },
411 { "vnd.sun.star.help", "vnd.sun.star.help://", 0, true, false, false,
412 false, false, false, true, true },
413 - { "https", "https://", 443, true, false, false, false, true, true,
414 + { "https", "https://", 443, true, true, false, true, true, true,
416 { "slot", "slot:", 0, false, false, false, false, false, false,
418 @@ -432,9 +432,19 @@ static INetURLObject::SchemeInfo const a
419 false, false, false, false, false },
420 { "vnd.sun.star.tdoc", "vnd.sun.star.tdoc:", 0, false, false, false,
421 false, false, false, true, false },
422 - { "", "", 0, false, false, false, false, false, false, false, false },
423 { "smb", "smb://", 139, true, true, false, true, true, true, true,
426 + { "dav", "dav://", 80, true, true, false, true, true, true, true,
428 + { "davs", "davs://", 443, true, true, false, true, true, true,
430 + { "webdav", "webdav://", 80, true, true, false, true, true, true, true,
432 + { "webdavs", "webdavs://", 443, true, true, false, true, true, true,
434 + { "", "", 0, false, false, false, false, false, false, false, false },
435 + { "", "", 0, false, false, false, false, false, false, true, false }
439 inline INetURLObject::SchemeInfo const &
440 @@ -849,7 +859,10 @@ bool INetURLObject::setAbsURIRef(rtl::OU
441 aSynScheme = parseScheme(&p1, pEnd, nFragmentDelimiter);
442 if (aSynScheme.getLength() > 0)
444 - m_eScheme = INET_PROT_GENERIC;
445 + if (p1 != pEnd && *p1 == '/')
446 + m_eScheme = INET_PROT_GENERIC_HIERARCHICAL;
448 + m_eScheme = INET_PROT_GENERIC;
452 @@ -866,8 +879,9 @@ bool INetURLObject::setAbsURIRef(rtl::OU
456 - if (m_eScheme != INET_PROT_GENERIC) {
457 - aSynScheme = rtl::OUString::createFromAscii(getSchemeInfo().m_pScheme);
458 + const char *pSchemeName = getSchemeInfo().m_pScheme;
459 + if (pSchemeName[0] != '\0') {
460 + aSynScheme = rtl::OUString::createFromAscii(pSchemeName);
462 m_aScheme.set(aSynAbsURIRef, aSynScheme, aSynAbsURIRef.getLength());
463 aSynAbsURIRef.append(sal_Unicode(':'));
464 @@ -2120,6 +2134,8 @@ INetURLObject::getPrefix(sal_Unicode con
465 PrefixInfo::INTERNAL },
466 { "cid:", 0, INET_PROT_CID, PrefixInfo::OFFICIAL },
467 { "data:", 0, INET_PROT_DATA, PrefixInfo::OFFICIAL },
468 + { "dav:", 0, INET_PROT_DAV, PrefixInfo::OFFICIAL },
469 + { "davs:", 0, INET_PROT_DAVS, PrefixInfo::OFFICIAL },
470 { "db:", "staroffice.db:", INET_PROT_DB, PrefixInfo::INTERNAL },
471 { "file:", 0, INET_PROT_FILE, PrefixInfo::OFFICIAL },
472 { "ftp:", 0, INET_PROT_FTP, PrefixInfo::OFFICIAL },
473 @@ -2201,6 +2217,8 @@ INetURLObject::getPrefix(sal_Unicode con
474 PrefixInfo::OFFICIAL },
475 { "vnd.sun.star.wfs:", 0, INET_PROT_VND_SUN_STAR_WFS,
476 PrefixInfo::OFFICIAL },
477 + { "webdav:", 0, INET_PROT_WEBDAV, PrefixInfo::OFFICIAL },
478 + { "webdavs:", 0, INET_PROT_WEBDAVS, PrefixInfo::OFFICIAL },
479 { "wfs:", "vnd.sun.star.wfs:", INET_PROT_VND_SUN_STAR_WFS,
480 PrefixInfo::ALIAS } };
481 PrefixInfo const * pFirst = aMap + 1;
482 @@ -3004,6 +3022,10 @@ bool INetURLObject::parsePath(INetProtoc
483 case INET_PROT_VND_SUN_STAR_WEBDAV:
484 case INET_PROT_HTTPS:
486 + case INET_PROT_DAV:
487 + case INET_PROT_DAVS:
488 + case INET_PROT_WEBDAV:
489 + case INET_PROT_WEBDAVS:
490 if (pPos < pEnd && *pPos != '/')
492 while (pPos < pEnd && *pPos != nQueryDelimiter
493 @@ -3422,6 +3444,7 @@ bool INetURLObject::parsePath(INetProtoc
496 case INET_PROT_GENERIC:
497 + case INET_PROT_GENERIC_HIERARCHICAL:
498 while (pPos < pEnd && *pPos != nFragmentDelimiter)
500 EscapeType eEscapeType;
501 @@ -4133,10 +4156,13 @@ bool INetURLObject::ConcatData(INetProto
504 m_eScheme = eTheScheme;
505 - if (HasError() || m_eScheme == INET_PROT_GENERIC)
506 + const char *pSchemeName = getSchemeInfo().m_pScheme;
508 + if (HasError() || pSchemeName[0] == '\0')
511 m_aAbsURIRef.setLength(0);
512 - m_aAbsURIRef.appendAscii(getSchemeInfo().m_pScheme);
513 + m_aAbsURIRef.appendAscii(pSchemeName);
514 m_aAbsURIRef.append(sal_Unicode(':'));
515 if (getSchemeInfo().m_bAuthority)
517 --- tools/workben/urltest.cxx.old 2009-04-02 10:36:25.000000000 +0000
518 +++ tools/workben/urltest.cxx 2009-04-06 16:41:46.000000000 +0000
519 @@ -1476,7 +1476,7 @@ main()
521 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("A-b.3:/%2f?x#y"));
522 urlobj = INetURLObject(url);
523 - bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
524 + bSuccess &= assertEqual(url, INET_PROT_GENERIC_HIERARCHICAL, urlobj.GetProtocol());
525 bSuccess &= assertEqual(
526 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a-b.3:/%2F?x#y")),
527 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
528 @@ -1504,7 +1504,7 @@ main()
530 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:/"));
531 urlobj = INetURLObject(url);
532 - bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
533 + bSuccess &= assertEqual(url, INET_PROT_GENERIC_HIERARCHICAL, urlobj.GetProtocol());
534 bSuccess &= assertEqual(
536 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
537 @@ -1542,7 +1542,7 @@ main()
539 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("A-b.3:/%2f?x#y"));
540 urlobj = INetURLObject(url, INET_PROT_CID);
541 - bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
542 + bSuccess &= assertEqual(url, INET_PROT_GENERIC_HIERARCHICAL, urlobj.GetProtocol());
543 bSuccess &= assertEqual(
544 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a-b.3:/%2F?x#y")),
545 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
546 @@ -1563,7 +1563,7 @@ main()
548 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:/"));
549 urlobj = INetURLObject(url, INET_PROT_CID);
550 - bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
551 + bSuccess &= assertEqual(url, INET_PROT_GENERIC_HIERARCHICAL, urlobj.GetProtocol());
552 bSuccess &= assertEqual(
554 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
555 --- ucb/source/ucp/file/filglob.cxx.old 2009-04-02 11:01:37.000000000 +0000
556 +++ ucb/source/ucp/file/filglob.cxx 2009-04-06 16:41:46.000000000 +0000
557 @@ -361,17 +361,13 @@ namespace fileaccess {
558 // not enough memory for allocating structures
559 ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
561 - case FileBase::E_BUSY:
563 - ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
565 - case FileBase::E_AGAIN:
566 - // Operation would block
568 + case FileBase::E_BUSY: // Text file busy
569 + case FileBase::E_AGAIN: // Operation would block
570 + case FileBase::E_NOLCK: // No record locks available
571 + case FileBase::E_TXTBSY:// Text file busy
572 ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
574 - case FileBase::E_NOLCK: // No record locks available
575 - ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
578 case FileBase::E_FAULT: // Bad address
579 case FileBase::E_LOOP: // Too many symbolic links encountered
580 --- ucb/source/ucp/webdav/DAVRequestEnvironment.hxx.old 2009-04-02 11:01:38.000000000 +0000
581 +++ ucb/source/ucp/webdav/DAVRequestEnvironment.hxx 2009-04-06 16:41:46.000000000 +0000
583 #include <rtl/ref.hxx>
584 #include "DAVAuthListener.hxx"
586 +#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_
587 +#include <com/sun/star/ucb/XCommandEnvironment.hpp>
592 typedef std::pair< rtl::OUString, rtl::OUString > DAVRequestHeader;
593 @@ -46,12 +50,12 @@ struct DAVRequestEnvironment
594 // rtl::Reference< DAVStatusListener > m_xStatusListener;
595 // rtl::Reference< DAVProgressListener > m_xStatusListener;
596 DAVRequestHeaders m_aRequestHeaders;
597 - uno::Reference< ucb::XCommandEnvironment > m_xEnv;
598 + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv;
600 -DAVRequestEnvironment( const rtl::OUString & rRequestURI,
601 + DAVRequestEnvironment( const rtl::OUString & rRequestURI,
602 const rtl::Reference< DAVAuthListener > & xListener,
603 const DAVRequestHeaders & rRequestHeaders,
604 - const uno::Reference< ucb::XCommandEnvironment > & xEnv)
605 + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv)
606 : m_aRequestURI( rRequestURI ),
607 m_xAuthListener( xListener ),
608 m_aRequestHeaders( rRequestHeaders ),
609 --- ucb/source/ucp/webdav/DAVResourceAccess.cxx
610 +++ ucb/source/ucp/webdav/DAVResourceAccess.cxx
612 #include "DAVAuthListenerImpl.hxx"
613 #include "DAVResourceAccess.hxx"
615 +#include <comphelper/processfactory.hxx>
616 +#include <ucbhelper/commandenvironment.hxx>
618 using namespace webdav_ucp;
619 using namespace com::sun::star;
621 @@ -61,58 +64,57 @@ int DAVAuthListener_Impl::authenticate(
622 ::rtl::OUString & outPassWord,
623 const sal_Bool & bAllowPersistentStoring)
627 - uno::Reference< task::XInteractionHandler > xIH
628 - = m_xEnv->getInteractionHandler();
631 - // #102871# - Supply username and password from previous try.
632 - // Password container service depends on this!
633 - if ( inoutUserName.getLength() == 0 )
634 - inoutUserName = m_aPrevUsername;
636 - if ( outPassWord.getLength() == 0 )
637 - outPassWord = m_aPrevPassword;
639 - rtl::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest
640 - = new ucbhelper::SimpleAuthenticationRequest( inHostName,
645 - bAllowPersistentStoring);
646 - xIH->handle( xRequest.get() );
647 + uno::Reference< task::XInteractionHandler > xIH;
649 - rtl::Reference< ucbhelper::InteractionContinuation > xSelection
650 - = xRequest->getSelection();
652 - if ( xSelection.is() )
654 - // Handler handled the request.
655 - uno::Reference< task::XInteractionAbort > xAbort(
656 - xSelection.get(), uno::UNO_QUERY );
657 - if ( !xAbort.is() )
659 - const rtl::Reference<
660 - ucbhelper::InteractionSupplyAuthentication > & xSupp
661 - = xRequest->getAuthenticationSupplier();
663 - inoutUserName = xSupp->getUserName();
664 - outPassWord = xSupp->getPassword();
666 - // #102871# - Remember username and password.
667 - m_aPrevUsername = inoutUserName;
668 - m_aPrevPassword = outPassWord;
670 + xIH = m_xEnv->getInteractionHandler();
672 + xIH = DAVResourceAccess::createCommandEnvironment()->getInteractionHandler();
677 + // #102871# - Supply username and password from previous try.
678 + // Password container service depends on this!
679 + if ( inoutUserName.getLength() == 0 )
680 + inoutUserName = m_aPrevUsername;
682 + if ( outPassWord.getLength() == 0 )
683 + outPassWord = m_aPrevPassword;
685 + rtl::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest
686 + = new ucbhelper::SimpleAuthenticationRequest( inHostName,
691 + bAllowPersistentStoring );
692 + xIH->handle( xRequest.get() );
694 + rtl::Reference< ucbhelper::InteractionContinuation > xSelection
695 + = xRequest->getSelection();
697 + if ( !xSelection.is() )
700 + // Handler handled the request.
701 + uno::Reference< task::XInteractionAbort > xAbort(
702 + xSelection.get(), uno::UNO_QUERY );
706 + const rtl::Reference< ucbhelper::InteractionSupplyAuthentication > & xSupp
707 + = xRequest->getAuthenticationSupplier();
709 + inoutUserName = xSupp->getUserName();
710 + outPassWord = xSupp->getPassword();
712 + // #102871# - Remember username and password.
713 + m_aPrevUsername = inoutUserName;
714 + m_aPrevPassword = outPassWord;
728 //=========================================================================
729 @@ -444,15 +446,16 @@ void DAVResourceAccess::GET(
732 //=========================================================================
733 -uno::Reference< io::XInputStream > DAVResourceAccess::GET(
734 +uno::Reference< io::XStream > DAVResourceAccess::GET(
735 const std::vector< rtl::OUString > & rHeaderNames,
736 DAVResource & rResource,
737 - const uno::Reference< ucb::XCommandEnvironment > & xEnv )
738 + const uno::Reference< ucb::XCommandEnvironment > & xEnv,
739 + sal_Bool bAllowEmpty )
740 throw( DAVException )
744 - uno::Reference< io::XInputStream > xStream;
745 + uno::Reference< io::XStream > xStream;
749 @@ -472,7 +475,8 @@ uno::Reference< io::XInputStream > DAVRe
750 DAVRequestEnvironment(
752 new DAVAuthListener_Impl( xEnv ),
753 - aHeaders, xEnv ) );
757 catch ( DAVException & e )
759 @@ -606,6 +610,45 @@ void DAVResourceAccess::PUT(
762 //=========================================================================
763 +void DAVResourceAccess::PUT(
764 + const char * buffer, size_t size,
765 + const uno::Reference< ucb::XCommandEnvironment > & xEnv )
766 +throw( DAVException )
770 + bool bRetry = false;
771 + int errorCount = 0;
777 + DAVRequestHeaders aHeaders;
778 + getUserRequestHeaders( xEnv,
780 + rtl::OUString::createFromAscii( "PUT" ),
783 + m_xSession->PUT( getRequestURI(),
785 + DAVRequestEnvironment(
787 + new DAVAuthListener_Impl( xEnv ),
788 + aHeaders, xEnv ) );
790 + catch ( DAVException & e )
793 + bRetry = handleException( e, errorCount );
801 +//=========================================================================
802 uno::Reference< io::XInputStream > DAVResourceAccess::POST(
803 const rtl::OUString & rContentType,
804 const rtl::OUString & rReferer,
805 @@ -888,22 +931,44 @@ void DAVResourceAccess::DESTROY(
807 //=========================================================================
808 void DAVResourceAccess::LOCK (
809 - const ucb::Lock & /*rLock*/,
810 - const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
812 + const uno::Reference< ucb::XCommandEnvironment > & xEnv )
813 throw( DAVException )
816 - OSL_ENSURE( sal_False, "DAVResourceAccess::LOCK - NYI" );
819 + DAVRequestHeaders aHeaders;
820 + getUserRequestHeaders( xEnv,
822 + rtl::OUString::createFromAscii( "LOCK" ),
825 + m_xSession->LOCK( rLock,
826 + DAVRequestEnvironment(
828 + new DAVAuthListener_Impl( xEnv ),
829 + aHeaders, xEnv ) );
832 //=========================================================================
833 void DAVResourceAccess::UNLOCK (
834 - const ucb::Lock & /*rLock*/,
835 - const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
837 + const uno::Reference< ucb::XCommandEnvironment > & xEnv )
838 throw( DAVException )
841 - OSL_ENSURE( sal_False, "DAVResourceAccess::UNLOCK - NYI" );
844 + DAVRequestHeaders aHeaders;
845 + getUserRequestHeaders( xEnv,
847 + rtl::OUString::createFromAscii( "UNLOCK" ),
850 + m_xSession->UNLOCK( rLock,
851 + DAVRequestEnvironment(
853 + new DAVAuthListener_Impl( xEnv ),
854 + aHeaders, xEnv ) );
857 //=========================================================================
858 @@ -1008,6 +1073,18 @@ void DAVResourceAccess::getUserRequestHe
863 +com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > DAVResourceAccess::createCommandEnvironment( void )
865 + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
866 + uno::Reference< task::XInteractionHandler > xInteractionHandler = uno::Reference< task::XInteractionHandler > (
867 + xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), uno::UNO_QUERY );
868 + ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, uno::Reference< ucb::XProgressHandler >() );
870 + return uno::Reference< ucb::XCommandEnvironment >( static_cast< ucb::XCommandEnvironment* >( pCommandEnv ), uno::UNO_QUERY );
874 //=========================================================================
875 sal_Bool DAVResourceAccess::detectRedirectCycle(
876 const rtl::OUString& rRedirectURL )
877 --- ucb/source/ucp/webdav/DAVResourceAccess.hxx.old 2009-04-02 11:01:38.000000000 +0000
878 +++ ucb/source/ucp/webdav/DAVResourceAccess.hxx 2009-04-06 16:41:46.000000000 +0000
879 @@ -134,11 +134,12 @@ public:
880 com::sun::star::ucb::XCommandEnvironment > & xEnv )
881 throw( DAVException );
883 - com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
884 + com::sun::star::uno::Reference< com::sun::star::io::XStream >
885 GET( const std::vector< rtl::OUString > & rHeaderNames, // empty == 'all'
886 DAVResource & rResource,
887 const com::sun::star::uno::Reference<
888 - com::sun::star::ucb::XCommandEnvironment > & xEnv )
889 + com::sun::star::ucb::XCommandEnvironment > & xEnv,
890 + sal_Bool bAllowEmpty = sal_False )
891 throw( DAVException );
894 @@ -157,6 +158,11 @@ public:
895 com::sun::star::ucb::XCommandEnvironment > & xEnv )
896 throw( DAVException );
899 + PUT( const char * buffer, size_t size,
900 + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
901 + throw( DAVException );
903 com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
904 POST( const rtl::OUString & rContentType,
905 const rtl::OUString & rReferer,
906 @@ -204,13 +210,13 @@ public:
907 throw( DAVException );
910 - LOCK( const com::sun::star::ucb::Lock & rLock,
911 + LOCK( com::sun::star::ucb::Lock & rLock,
912 const com::sun::star::uno::Reference<
913 com::sun::star::ucb::XCommandEnvironment > & xEnv )
914 throw( DAVException );
917 - UNLOCK( const com::sun::star::ucb::Lock & rLock,
918 + UNLOCK( com::sun::star::ucb::Lock & rLock,
919 const com::sun::star::uno::Reference<
920 com::sun::star::ucb::XCommandEnvironment > & xEnv )
921 throw( DAVException );
922 @@ -223,6 +229,8 @@ public:
923 const rtl::OUString & rMethod,
924 DAVRequestHeaders & rRequestHeaders );
926 + static com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > createCommandEnvironment( void );
929 const rtl::OUString & getRequestURI() const;
930 sal_Bool detectRedirectCycle( const rtl::OUString& rRedirectURL )
931 --- ucb/source/ucp/webdav/DAVSession.hxx
932 +++ ucb/source/ucp/webdav/DAVSession.hxx
936 #include <rtl/ustring.hxx>
937 +#include <com/sun/star/io/XStream.hpp>
938 #include <com/sun/star/io/XInputStream.hpp>
939 #include <com/sun/star/io/XOutputStream.hpp>
940 +#include <com/sun/star/ucb/Lock.hpp>
942 #include "DAVException.hxx"
943 #include "DAVProperties.hxx"
944 #include "DAVResource.hxx"
946 #include "DAVTypes.hxx"
947 #include "DAVRequestEnvironment.hxx"
954 @@ -114,11 +115,12 @@ public:
955 const DAVRequestEnvironment & rEnv )
956 throw( DAVException ) = 0;
958 - virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
959 + virtual com::sun::star::uno::Reference< com::sun::star::io::XStream >
960 GET( const ::rtl::OUString & inPath,
961 const std::vector< ::rtl::OUString > & inHeaderNames,
962 DAVResource & ioResource,
963 - const DAVRequestEnvironment & rEnv )
964 + const DAVRequestEnvironment & rEnv,
965 + sal_Bool bAllowEmpty )
966 throw( DAVException ) = 0;
968 virtual void GET( const ::rtl::OUString & inPath,
969 @@ -134,6 +136,12 @@ public:
971 throw( DAVException ) = 0;
973 + virtual void PUT( const ::rtl::OUString & inPath,
974 + const char * buffer,
976 + const DAVRequestEnvironment & rEnv )
977 + throw ( DAVException ) = 0;
979 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
980 POST( const rtl::OUString & inPath,
981 const rtl::OUString & rContentType,
982 @@ -173,16 +181,14 @@ public:
983 const DAVRequestEnvironment & rEnv )
984 throw( DAVException ) = 0;
986 - // Note: Uncomment the following if locking support is required
988 - virtual void LOCK ( const Lock & inLock,
989 + virtual void LOCK ( com::sun::star::ucb::Lock & rLock,
990 const DAVRequestEnvironment & rEnv )
991 throw( DAVException ) = 0;
993 - virtual void UNLOCK ( const Lock & inLock,
994 + virtual void UNLOCK ( com::sun::star::ucb::Lock & rLock,
995 const DAVRequestEnvironment & rEnv )
996 throw( DAVException ) = 0;
1000 rtl::Reference< DAVSessionFactory > m_xFactory;
1002 --- ucb/source/ucp/webdav/NeonInputStream.cxx.old 2009-04-02 11:01:38.000000000 +0000
1003 +++ ucb/source/ucp/webdav/NeonInputStream.cxx 2009-04-06 16:41:46.000000000 +0000
1005 // MARKER(update_precomp.py): autogen include statement, do not remove
1006 #include "precompiled_ucb.hxx"
1007 #include "NeonInputStream.hxx"
1008 +#include "DAVResourceAccess.hxx"
1010 #include <rtl/memory.h>
1011 +#include <com/sun/star/ucb/CommandFailedException.hpp>
1013 +#include <comphelper/processfactory.hxx>
1014 +#include <com/sun/star/lang/XMultiServiceFactory.hpp>
1018 using namespace cppu;
1019 -using namespace rtl;
1020 using namespace com::sun::star::io;
1021 -using namespace com::sun::star::uno;
1022 +using namespace com::sun::star;
1023 using namespace webdav_ucp;
1026 // -------------------------------------------------------------------
1028 // -------------------------------------------------------------------
1029 -NeonInputStream::NeonInputStream( void )
1032 +NeonInputStream::NeonInputStream()
1035 + m_bDirty( sal_False )
1039 @@ -62,24 +69,59 @@ NeonInputStream::~NeonInputStream( void
1040 // -------------------------------------------------------------------
1041 void NeonInputStream::AddToStream( const char * inBuf, sal_Int32 inLen )
1043 - mInputBuffer.realloc( sal::static_int_cast<sal_Int32>(mLen) + inLen );
1044 - rtl_copyMemory( mInputBuffer.getArray() + mLen, inBuf, inLen );
1046 + OSL_ENSURE( !m_bDirty, "Cannot AddToStream() when it was already written to it." );
1048 + m_aInputBuffer.realloc( sal::static_int_cast<sal_Int32>(m_nLen) + inLen );
1049 + rtl_copyMemory( m_aInputBuffer.getArray() + m_nLen, inBuf, inLen );
1053 +// -------------------------------------------------------------------
1054 +// Associate a URL with this stream
1055 +// -------------------------------------------------------------------
1056 +void NeonInputStream::SetURL( const rtl::OUString &rURL )
1058 + osl::MutexGuard aGuard( m_aLock );
1063 // -------------------------------------------------------------------
1065 // -------------------------------------------------------------------
1066 -Any NeonInputStream::queryInterface( const Type &type )
1067 - throw( RuntimeException )
1068 +uno::Any NeonInputStream::queryInterface( const uno::Type &type )
1069 + throw( uno::RuntimeException )
1071 - Any aRet = ::cppu::queryInterface( type,
1072 - static_cast< XInputStream * >( this ),
1073 - static_cast< XSeekable * >( this ) );
1074 + uno::Any aRet = ::cppu::queryInterface( type,
1075 + static_cast< XStream * >( this ),
1076 + static_cast< XInputStream * >( this ),
1077 + static_cast< XOutputStream * >( this ),
1078 + static_cast< XSeekable * >( this ),
1079 + static_cast< XTruncate * >( this ) );
1080 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( type );
1083 // -------------------------------------------------------------------
1085 +// -------------------------------------------------------------------
1086 +com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
1087 +NeonInputStream::getInputStream( void )
1088 + throw( com::sun::star::uno::RuntimeException )
1090 + return uno::Reference< XInputStream >( this );
1093 +// -------------------------------------------------------------------
1095 +// -------------------------------------------------------------------
1096 +com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL
1097 +NeonInputStream::getOutputStream( void )
1098 + throw( com::sun::star::uno::RuntimeException )
1100 + return uno::Reference< XOutputStream >( this );
1103 +// -------------------------------------------------------------------
1105 // "Reads" the specified number of bytes from the stream
1106 // -------------------------------------------------------------------
1107 @@ -92,7 +134,7 @@ sal_Int32 SAL_CALL NeonInputStream::read
1109 // Work out how much we're actually going to write
1110 sal_Int32 theBytes2Read = nBytesToRead;
1111 - sal_Int32 theBytesLeft = sal::static_int_cast<sal_Int32>(mLen - mPos);
1112 + sal_Int32 theBytesLeft = sal::static_int_cast<sal_Int32>(m_nLen - m_nPos);
1113 if ( theBytes2Read > theBytesLeft )
1114 theBytes2Read = theBytesLeft;
1116 @@ -101,10 +143,10 @@ sal_Int32 SAL_CALL NeonInputStream::read
1120 - aData.getArray(), mInputBuffer.getConstArray() + mPos, theBytes2Read );
1121 + aData.getArray(), m_aInputBuffer.getConstArray() + m_nPos, theBytes2Read );
1123 // Update our stream position for next time
1124 - mPos += theBytes2Read;
1125 + m_nPos += theBytes2Read;
1127 return theBytes2Read;
1129 @@ -133,9 +175,9 @@ void SAL_CALL NeonInputStream::skipBytes
1130 ::com::sun::star::io::IOException,
1131 ::com::sun::star::uno::RuntimeException )
1133 - mPos += nBytesToSkip;
1134 - if ( mPos >= mLen )
1136 + m_nPos += nBytesToSkip;
1137 + if ( m_nPos >= m_nLen )
1141 // -------------------------------------------------------------------
1142 @@ -147,7 +189,7 @@ sal_Int32 SAL_CALL NeonInputStream::avai
1143 ::com::sun::star::io::IOException,
1144 ::com::sun::star::uno::RuntimeException )
1146 - return sal::static_int_cast<sal_Int32>(mLen - mPos);
1147 + return sal::static_int_cast<sal_Int32>(m_nLen - m_nPos);
1150 // -------------------------------------------------------------------
1151 @@ -168,12 +210,12 @@ void SAL_CALL NeonInputStream::seek( sal
1152 ::com::sun::star::io::IOException,
1153 ::com::sun::star::uno::RuntimeException )
1155 - if ( location < 0 )
1156 - throw ::com::sun::star::lang::IllegalArgumentException();
1157 + if ( location < 0 )
1158 + throw ::com::sun::star::lang::IllegalArgumentException();
1160 - if ( location <= mLen )
1163 + if ( location <= m_nLen )
1164 + m_nPos = location;
1166 throw ::com::sun::star::lang::IllegalArgumentException();
1169 @@ -184,7 +226,7 @@ sal_Int64 SAL_CALL NeonInputStream::getP
1170 throw( ::com::sun::star::io::IOException,
1171 ::com::sun::star::uno::RuntimeException )
1177 // -------------------------------------------------------------------
1178 @@ -194,5 +236,108 @@ sal_Int64 SAL_CALL NeonInputStream::getL
1179 throw( ::com::sun::star::io::IOException,
1180 ::com::sun::star::uno::RuntimeException )
1186 +// -------------------------------------------------------------------
1188 +// -------------------------------------------------------------------
1189 +void SAL_CALL NeonInputStream::writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
1190 + throw( com::sun::star::io::NotConnectedException,
1191 + com::sun::star::io::BufferSizeExceededException,
1192 + com::sun::star::io::IOException,
1193 + com::sun::star::uno::RuntimeException)
1195 +#if OSL_DEBUG_LEVEL > 0
1196 + fprintf( stderr, "WebDAV: writeBytes()\n" );
1199 + sal_Int32 nDataLen = aData.getLength();
1200 + OSL_ASSERT( nDataLen >= 0 );
1202 + // Anything to do?
1203 + if ( nDataLen == 0 )
1206 + // Update the length of the stream & size of the buffer
1207 + if ( m_nLen < m_nPos + nDataLen )
1209 + m_nLen = m_nPos + nDataLen;
1210 + if ( m_aInputBuffer.getLength() < m_nLen )
1211 + m_aInputBuffer.realloc( sal::static_int_cast<sal_Int32>( m_nLen ) );
1214 + rtl_copyMemory( m_aInputBuffer.getArray() + m_nPos, aData.getConstArray(), nDataLen );
1215 + m_nPos += nDataLen;
1217 + m_bDirty = sal_True;
1220 +// -------------------------------------------------------------------
1222 +// -------------------------------------------------------------------
1223 +void SAL_CALL NeonInputStream::flush( void )
1224 + throw( NotConnectedException, BufferSizeExceededException,
1225 + IOException, uno::RuntimeException )
1229 +#if OSL_DEBUG_LEVEL > 0
1230 + fprintf( stderr, "WebDAV: flush(), saving the changed file.\n" );
1232 + // FIXME It's really hacky to create the new session
1233 + // But so far it seems I have no other chance...
1234 + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
1235 + rtl::Reference< DAVSessionFactory > rDAVFactory( new DAVSessionFactory() );
1237 + DAVResourceAccess aResourceAccess( xFactory, rDAVFactory, m_aURL );
1240 + aResourceAccess.PUT( reinterpret_cast<const char*>( m_aInputBuffer.getConstArray() ), m_nLen,
1241 + DAVResourceAccess::createCommandEnvironment() );
1243 + catch ( DAVException & e )
1245 + throw ucb::CommandFailedException(
1247 + uno::Reference< uno::XInterface >(),
1248 + uno::makeAny( e.getData() ) );
1251 + m_bDirty = sal_False;
1255 +// -------------------------------------------------------------------
1257 +// -------------------------------------------------------------------
1258 +void SAL_CALL NeonInputStream::closeOutput( void )
1259 + throw( com::sun::star::io::NotConnectedException,
1260 + com::sun::star::io::IOException,
1261 + com::sun::star::uno::RuntimeException )
1265 +#if OSL_DEBUG_LEVEL > 0
1266 + fprintf( stderr, "WebDAV: TODO write on closeOutput(), the stream is dirty!\n" );
1271 +// -------------------------------------------------------------------
1273 +// -------------------------------------------------------------------
1274 +void SAL_CALL NeonInputStream::truncate( void )
1275 + throw( com::sun::star::io::IOException,
1276 + com::sun::star::uno::RuntimeException )
1278 +#if OSL_DEBUG_LEVEL > 0
1279 + fprintf( stderr, "WebDAV: truncate()\n" );
1284 + m_nLen = m_nPos = 0;
1285 + m_bDirty = sal_True;
1288 --- ucb/source/ucp/webdav/NeonInputStream.hxx.old 2009-04-02 11:01:38.000000000 +0000
1289 +++ ucb/source/ucp/webdav/NeonInputStream.hxx 2009-04-06 16:41:46.000000000 +0000
1291 #define _NEONINPUTSTREAM_HXX_
1293 #include <sal/types.h>
1294 +#include <osl/mutex.hxx>
1295 +#include <osl/signal.h>
1296 #include <rtl/ustring.hxx>
1297 #include <cppuhelper/weak.hxx>
1299 +#include <com/sun/star/io/XStream.hpp>
1300 #include <com/sun/star/io/XInputStream.hpp>
1301 +#include <com/sun/star/io/XOutputStream.hpp>
1302 #include <com/sun/star/io/XSeekable.hpp>
1303 +#include <com/sun/star/io/XTruncate.hpp>
1304 +#include <com/sun/star/ucb/Lock.hpp>
1306 +#include "DAVRequestEnvironment.hxx"
1308 namespace webdav_ucp
1310 @@ -45,21 +53,33 @@ namespace webdav_ucp
1311 // A simple XInputStream implementation provided specifically for use
1312 // by the DAVSession::GET method.
1313 // -------------------------------------------------------------------
1314 -class NeonInputStream : public ::com::sun::star::io::XInputStream,
1315 +class NeonInputStream : public ::com::sun::star::io::XStream,
1316 + public ::com::sun::star::io::XInputStream,
1317 + public ::com::sun::star::io::XOutputStream,
1318 public ::com::sun::star::io::XSeekable,
1319 + public ::com::sun::star::io::XTruncate,
1320 public ::cppu::OWeakObject
1323 - com::sun::star::uno::Sequence< sal_Int8 > mInputBuffer;
1328 - NeonInputStream( void );
1329 - virtual ~NeonInputStream();
1331 + com::sun::star::uno::Sequence< sal_Int8 > m_aInputBuffer;
1332 + sal_Int64 m_nLen; // cannot be just m_aInputBuffer.getLength() - the buffer can be bigger
1335 + sal_Bool m_bDirty;
1337 + rtl::OUString m_aURL;
1339 + osl::Mutex m_aLock;
1341 - // Add some data to the end of the stream
1342 - void AddToStream( const char * inBuf, sal_Int32 inLen );
1344 + NeonInputStream( void );
1345 + virtual ~NeonInputStream();
1347 + // Add some data to the end of the stream
1348 + void AddToStream( const char * inBuf, sal_Int32 inLen );
1350 + // Associate a URL with this stream
1351 + void SetURL( const rtl::OUString &rURL );
1354 virtual com::sun::star::uno::Any SAL_CALL queryInterface(
1355 @@ -74,6 +94,12 @@ class NeonInputStream : public ::com::su
1357 { OWeakObject::release(); }
1360 + virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL getInputStream( void )
1361 + throw( com::sun::star::uno::RuntimeException );
1363 + virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( void )
1364 + throw( com::sun::star::uno::RuntimeException );
1367 virtual sal_Int32 SAL_CALL readBytes(
1368 @@ -121,6 +147,30 @@ class NeonInputStream : public ::com::su
1369 virtual sal_Int64 SAL_CALL getLength()
1370 throw( ::com::sun::star::io::IOException,
1371 ::com::sun::star::uno::RuntimeException );
1374 + virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
1375 + throw( com::sun::star::io::NotConnectedException,
1376 + com::sun::star::io::BufferSizeExceededException,
1377 + com::sun::star::io::IOException,
1378 + com::sun::star::uno::RuntimeException);
1380 + virtual void SAL_CALL flush( void )
1381 + throw( com::sun::star::io::NotConnectedException,
1382 + com::sun::star::io::BufferSizeExceededException,
1383 + com::sun::star::io::IOException,
1384 + com::sun::star::uno::RuntimeException);
1387 + virtual void SAL_CALL closeOutput( void )
1388 + throw( com::sun::star::io::NotConnectedException,
1389 + com::sun::star::io::IOException,
1390 + com::sun::star::uno::RuntimeException );
1393 + virtual void SAL_CALL truncate( void )
1394 + throw( com::sun::star::io::IOException,
1395 + com::sun::star::uno::RuntimeException );
1398 } // namespace webdav_ucp
1399 --- ucb/source/ucp/webdav/NeonSession.cxx.old 2009-04-02 11:01:38.000000000 +0000
1400 +++ ucb/source/ucp/webdav/NeonSession.cxx 2009-04-06 16:41:46.000000000 +0000
1402 #ifndef _SIMPLECERTIFICATIONVALIDATIONREQUEST_HXX_
1403 #include "ucbhelper/simplecertificatevalidationrequest.hxx"
1405 +#include <ucbhelper/cancelcommandexecution.hxx>
1407 #include <cppuhelper/bootstrap.hxx>
1409 @@ -153,6 +154,12 @@ static sal_uInt16 makeStatusCode( const
1410 return sal_uInt16( rStatusText.copy( 0, nPos ).toInt32() );
1413 +static sal_uInt16 getStatusCode( HttpSession *pSession )
1415 + rtl::OUString aText = rtl::OUString::createFromAscii( ne_get_error( pSession ) );
1416 + return makeStatusCode( aText );
1419 // -------------------------------------------------------------------
1420 struct NeonRequestContext
1422 @@ -196,12 +203,13 @@ struct NeonRequestContext
1423 // -------------------------------------------------------------------
1425 #if NEON_VERSION >= 0x0250
1426 -extern "C" int NeonSession_ResponseBlockReader(void * inUserData,
1429 -extern "C" void NeonSession_ResponseBlockReader(void * inUserData,
1432 - const char * inBuf,
1434 +NeonSession_ResponseBlockReader( void * inUserData,
1435 + const char * inBuf,
1438 // neon calls this function with (inLen == 0)...
1440 @@ -226,12 +234,13 @@ extern "C" void NeonSession_ResponseBloc
1441 // -------------------------------------------------------------------
1443 #if NEON_VERSION >= 0x0250
1444 -extern "C" int NeonSession_ResponseBlockWriter( void * inUserData,
1447 -extern "C" void NeonSession_ResponseBlockWriter( void * inUserData,
1450 - const char * inBuf,
1452 +NeonSession_ResponseBlockWriter( void * inUserData,
1453 + const char * inBuf,
1456 // neon calls this function with (inLen == 0)...
1458 @@ -299,11 +308,10 @@ extern "C" int NeonSession_NeonAuth( voi
1462 - NeonUri uri( theSession->getRequestEnvironment().m_aRequestURI );
1463 - rtl::OUString aUserInfo( uri.GetUserInfo() );
1464 + rtl::OUString aUserInfo( theSession->getUserInfo() );
1465 if ( aUserInfo.getLength() )
1467 - sal_Int32 nPos = aUserInfo.indexOf( '@' );
1468 + sal_Int32 nPos = aUserInfo.indexOf( ':' );
1471 theUserName = aUserInfo;
1472 @@ -564,6 +572,8 @@ extern "C" void NeonSession_PreSendReque
1476 +NeonLockStore * NeonSession::s_aNeonLockStore = NULL;
1478 // -------------------------------------------------------------------
1480 // -------------------------------------------------------------------
1481 @@ -581,6 +591,7 @@ NeonSession::NeonSession(
1482 m_aScheme = theUri.GetScheme();
1483 m_aHostName = theUri.GetHost();
1484 m_nPort = theUri.GetPort();
1485 + m_aUserInfo = theUri.GetUserInfo();
1489 @@ -594,14 +605,6 @@ NeonSession::~NeonSession( )
1491 ne_session_destroy( m_pHttpSession );
1493 - // Note: Uncomment the following if locking support is required
1495 - if ( mNeonLockSession != NULL )
1497 - ne_lock_unregister( mNeonLockSession );
1498 - mNeonLockSession = NULL;
1503 delete static_cast<RequestDataMap*>(m_pRequestData);
1504 @@ -629,6 +632,9 @@ void NeonSession::Init()
1505 throw DAVException( DAVException::DAV_SESSION_CREATE,
1506 NeonUri::makeConnectionEndPointString(
1507 m_aHostName, m_nPort ) );
1508 +#if OSL_DEBUG_LEVEL > 0
1509 + ne_debug_init( stderr, NE_DBG_LOCKS );
1511 // #122205# - libxml2 needs to be initialized once if used by
1512 // multithreaded programs like OOo.
1514 @@ -746,14 +752,15 @@ void NeonSession::Init()
1518 - // Note: Uncomment the following if locking support is required
1520 - mNeonLockSession = ne_lock_register( m_pHttpSession );
1521 + if ( !s_aNeonLockStore )
1522 + s_aNeonLockStore = ne_lockstore_create();
1524 - if ( mNeonLockSession == NULL )
1525 + if ( s_aNeonLockStore == NULL )
1526 throw DAVException( DAVException::DAV_SESSION_CREATE,
1527 - theUri::makeConnectionEndPointString() );
1529 + NeonUri::makeConnectionEndPointString( m_aHostName, m_nPort ) );
1531 + // Register the lock store
1532 + ne_lockstore_register( s_aNeonLockStore, m_pHttpSession );
1534 // Register for redirects.
1535 ne_redirect_register( m_pHttpSession );
1536 @@ -1088,11 +1095,12 @@ void NeonSession::GET( const rtl::OUStri
1537 // -------------------------------------------------------------------
1539 // -------------------------------------------------------------------
1540 -uno::Reference< io::XInputStream >
1541 +uno::Reference< io::XStream >
1542 NeonSession::GET( const rtl::OUString & inPath,
1543 const std::vector< ::rtl::OUString > & inHeaderNames,
1544 DAVResource & ioResource,
1545 - const DAVRequestEnvironment & rEnv )
1546 + const DAVRequestEnvironment & rEnv,
1547 + sal_Bool bAllowEmpty )
1548 throw ( DAVException )
1550 osl::Guard< osl::Mutex > theGuard( m_aMutex );
1551 @@ -1104,16 +1112,23 @@ NeonSession::GET( const rtl::OUString &
1552 ioResource.uri = inPath;
1553 ioResource.properties.clear();
1555 - rtl::Reference< NeonInputStream > xInputStream( new NeonInputStream );
1556 - NeonRequestContext aCtx( xInputStream, inHeaderNames, ioResource );
1557 + rtl::Reference< NeonInputStream > xStream( new NeonInputStream );
1558 + NeonRequestContext aCtx( xStream, inHeaderNames, ioResource );
1559 int theRetVal = GET( m_pHttpSession,
1560 rtl::OUStringToOString(
1561 inPath, RTL_TEXTENCODING_UTF8 ),
1562 NeonSession_ResponseBlockReader,
1565 - HandleError( theRetVal );
1566 - return uno::Reference< io::XInputStream >( xInputStream.get() );
1568 + HandleError( theRetVal );
1570 + catch ( DAVException const & e )
1572 + if ( !bAllowEmpty || ( e.getStatus() != SC_NOT_FOUND ) )
1575 + return uno::Reference< io::XStream >( xStream.get() );
1578 // -------------------------------------------------------------------
1579 @@ -1153,22 +1168,38 @@ void NeonSession::PUT( const rtl::OUStri
1580 const DAVRequestEnvironment & rEnv )
1581 throw ( DAVException )
1583 + // initialization etc. is performed in the other PUT
1585 + uno::Sequence< sal_Int8 > aDataToSend;
1586 + if ( !getDataFromInputStream( inInputStream, aDataToSend, false ) )
1587 + throw DAVException( DAVException::DAV_INVALID_ARG );
1590 + reinterpret_cast< const char * >( aDataToSend.getConstArray() ),
1591 + aDataToSend.getLength(),
1595 +// -------------------------------------------------------------------
1597 +// -------------------------------------------------------------------
1598 +void NeonSession::PUT( const rtl::OUString &inPath,
1599 + const char * buffer,
1601 + const DAVRequestEnvironment & rEnv )
1602 + throw ( DAVException )
1604 osl::Guard< osl::Mutex > theGuard( m_aMutex );
1610 - uno::Sequence< sal_Int8 > aDataToSend;
1611 - if ( !getDataFromInputStream( inInputStream, aDataToSend, false ) )
1612 - throw DAVException( DAVException::DAV_INVALID_ARG );
1614 int theRetVal = PUT( m_pHttpSession,
1615 rtl::OUStringToOString(
1616 inPath, RTL_TEXTENCODING_UTF8 ),
1617 - reinterpret_cast< const char * >(
1618 - aDataToSend.getConstArray() ),
1619 - aDataToSend.getLength() );
1623 HandleError( theRetVal );
1625 @@ -1344,9 +1375,7 @@ void NeonSession::DESTROY( const rtl::OU
1626 // -------------------------------------------------------------------
1628 // -------------------------------------------------------------------
1629 -// Note: Uncomment the following if locking support is required
1631 -void NeonSession::LOCK( const Lock & inLock,
1632 +void NeonSession::LOCK( ucb::Lock & rLock,
1633 const DAVRequestEnvironment & rEnv )
1634 throw ( DAVException )
1636 @@ -1356,16 +1385,13 @@ void NeonSession::LOCK( const Lock & inL
1640 - Lockit( inLock, true );
1641 + Lockit( rLock, true );
1645 // -------------------------------------------------------------------
1647 // -------------------------------------------------------------------
1648 -// Note: Uncomment the following if locking support is required
1650 -void NeonSession::UNLOCK( const Lock & inLock,
1651 +void NeonSession::UNLOCK( ucb::Lock & rLock,
1652 const DAVRequestEnvironment & rEnv )
1653 throw ( DAVException )
1655 @@ -1375,9 +1401,8 @@ void NeonSession::UNLOCK( const Lock & i
1659 - Lockit( inLock, false );
1660 + Lockit( rLock, false );
1664 // -------------------------------------------------------------------
1665 const ucbhelper::InternetProxyServer & NeonSession::getProxySettings() const
1666 @@ -1416,7 +1441,10 @@ void NeonSession::HandleError( int nErro
1667 case NE_ERROR: // Generic error
1669 rtl::OUString aText = rtl::OUString::createFromAscii(
1670 - ne_get_error( m_pHttpSession ) );
1671 + ne_get_error( m_pHttpSession ) );
1672 +#if OSL_DEBUG_LEVEL > 0
1673 + fprintf( stderr, "WebDAV: got error '%s'\n", rtl::OUStringToOString( aText, RTL_TEXTENCODING_UTF8 ).getStr() );
1675 throw DAVException( DAVException::DAV_HTTP_ERROR,
1677 makeStatusCode( aText ) );
1678 @@ -1473,77 +1501,156 @@ void NeonSession::HandleError( int nErro
1682 -// Note: Uncomment the following if locking support is required
1684 -void NeonSession::Lockit( const Lock & inLock, bool inLockit )
1685 +void NeonSession::Lockit( ucb::Lock & rLock, bool bLockit )
1686 throw ( DAVException )
1688 osl::Guard< osl::Mutex > theGuard( m_aMutex );
1690 - // Create the neon lock
1691 - NeonLock * theLock = new NeonLock;
1694 - // Set the lock uri
1695 - NeonUri theUri( inLock.uri );
1696 - theLock->uri = const_cast< char * >
1697 - ( rtl::OUStringToOString(
1698 - theUri.GetPath(), RTL_TEXTENCODING_UTF8 ).getStr() );
1699 + if ( !s_aNeonLockStore )
1700 + throw DAVException( DAVException::DAV_INVALID_ARG );
1704 - // Set the lock depth
1705 - switch( inLock.depth )
1709 - theLock->depth = int ( inLock.depth );
1712 - throw DAVException( DAVException::DAV_INVALID_ARG );
1716 + ne_uri_parse( rtl::OUStringToOString( m_aEnv.m_aRequestURI, RTL_TEXTENCODING_UTF8 ).getStr(),
1719 +#if NEON_VERSION < 0x0260
1720 +#define FILLIN( field, val ) aUri.field = aUri.field? aUri.field: strdup( rtl::OUStringToOString( val, RTL_TEXTENCODING_UTF8 ).getStr() )
1721 + FILLIN( scheme, m_aScheme );
1722 + FILLIN( host, m_aHostName );
1723 + aUri.port = aUri.port? aUri.port: m_nPort;
1727 - // Set the lock scope
1728 - switch ( inLock.scope )
1731 - theLock->scope = ne_lockscope_exclusive;
1734 - theLock->scope = ne_lockscope_shared;
1737 - throw DAVException( DAVException::DAV_INVALID_ARG );
1740 + // Create the neon lock
1741 + NeonLock * theLock = ne_lockstore_findbyuri( s_aNeonLockStore, &aUri );
1742 + bool bAlreadyExists = false;
1744 + bAlreadyExists = true;
1747 + theLock = ne_lock_create();
1749 - // Set the lock owner
1750 - const char * theOwner = rtl::OUStringToOString( inLock.owner,
1751 - RTL_TEXTENCODING_UTF8 );
1752 - theLock->owner = const_cast< char * > ( theOwner );
1754 - // Set the lock timeout
1755 - // Note: Neon ignores the timeout
1756 - //theLock->timeout = inLock.timeout;
1757 + // Set the lock uri
1758 + theLock->uri = aUri;
1760 - theRetVal = ne_lock( m_pHttpSession, theLock );
1764 + // Set the lock depth
1765 + switch( rLock.Depth )
1767 + case ucb::LockDepth_ZERO: theLock->depth = NE_DEPTH_ZERO; break;
1768 + case ucb::LockDepth_ONE: theLock->depth = NE_DEPTH_ONE; break;
1769 + case ucb::LockDepth_INFINITY: theLock->depth = NE_DEPTH_INFINITE; break;
1771 + throw DAVException( DAVException::DAV_INVALID_ARG );
1774 - // Set the lock token
1775 - rtl::OUString theToken = inLock.locktoken.getConstArray()[ 0 ];
1776 - theLock->token = const_cast< char * >
1777 - ( rtl::OUStringToOString(
1778 - theToken, RTL_TEXTENCODING_UTF8 ).getStr() );
1779 + // Set the lock scope
1780 + switch ( rLock.Scope )
1782 + case ucb::LockScope_EXCLUSIVE: theLock->scope = ne_lockscope_exclusive; break;
1783 + case ucb::LockScope_SHARED: theLock->scope = ne_lockscope_shared; break;
1785 + throw DAVException( DAVException::DAV_INVALID_ARG );
1789 - theRetVal = ne_unlock( m_pHttpSession, theLock );
1791 + // Set the lock owner
1792 + rtl::OUString aValue;
1793 + rLock.Owner >>= aValue;
1795 - HandleError( theRetVal );
1796 + theLock->owner = strdup( rtl::OUStringToOString( aValue, RTL_TEXTENCODING_UTF8 ).getStr() );
1798 + // Set the lock timeout
1799 + // We re-new the lock while the stream is open
1800 + theLock->timeout = rLock.Timeout;
1806 + if ( bAlreadyExists )
1808 +#if NEON_VERSION >= 0x0260
1809 + nRet = ne_lock_refresh( m_pHttpSession, theLock );
1811 + // workaround for a bug in neon 0.24
1812 + // we have to call with a bigger structure that is used internally
1813 + // and initialize parts of it
1817 + struct ne_lock active; /* activelock */
1818 + char *token; /* the token we're after. */
1823 + struct lock_ctx ctx;
1825 + memset( &ctx, 0, sizeof ctx );
1826 + ctx.cdata = ne_buffer_create();
1828 + memcpy( &ctx, theLock, sizeof( *theLock ) );
1829 + nRet = ne_lock_refresh( m_pHttpSession, reinterpret_cast<NeonLock*>( &ctx ) );
1831 + ne_buffer_destroy( ctx.cdata );
1833 + if ( ( nRet == NE_ERROR ) && strncmp (ne_get_error (m_pHttpSession), "No activelock ", strlen ("No activelock ")) == 0 )
1835 + bAlreadyExists = false;
1836 + ne_lockstore_remove( s_aNeonLockStore, theLock );
1839 + if ( !bAlreadyExists )
1841 + nRet = ne_lock( m_pHttpSession, theLock );
1843 + if ( nRet == NE_OK )
1845 + ne_lockstore_add( s_aNeonLockStore, theLock );
1847 + uno::Sequence< rtl::OUString > aTokens( 1 );
1848 + aTokens[0] = rtl::OUString::createFromAscii( theLock->token );
1849 + rLock.LockTokens = aTokens;
1851 +#if OSL_DEBUG_LEVEL > 0
1852 + fprintf( stderr, "WebDAV: locked the URL, the token is: %s\n", theLock->token );
1857 + if ( ( nRet == NE_ERROR ) && getStatusCode( m_pHttpSession ) == SC_LOCKED )
1859 + ucbhelper::cancelCommandExecution( ucb::IOErrorCode_LOCKING_VIOLATION,
1860 + uno::Sequence< uno::Any >( 0 ), // FIXME more info about the file?
1862 + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "a locking error occured" ) ),
1863 + uno::Reference< ucb::XCommandProcessor >() );
1865 +#if OSL_DEBUG_LEVEL > 0
1866 + else if ( nRet == NE_OK )
1867 + fprintf( stderr, "WebDAV: locked/refreshed lock OK\n" );
1869 + fprintf( stderr, "WebDAV: failed to lock the file: %s\n", ne_get_error( m_pHttpSession ) );
1874 + // Set the lock token
1875 + if ( rLock.LockTokens.getLength() > 0 )
1877 + rtl::OUString theToken = rLock.LockTokens.getConstArray()[ 0 ];
1878 + theLock->token = strdup( rtl::OUStringToOString( theToken, RTL_TEXTENCODING_UTF8 ).getStr() );
1880 +#if OSL_DEBUG_LEVEL > 0
1881 + fprintf( stderr, "WebDAV: going to unlock the URL, the token is: %s\n", theLock->token );
1884 + ne_unlock( m_pHttpSession, theLock );
1885 + ne_lockstore_remove( s_aNeonLockStore, theLock );
1886 + // FIXME even ne_lock_destroy( theLock )?
1892 // -------------------------------------------------------------------
1894 --- ucb/source/ucp/webdav/NeonSession.hxx
1895 +++ ucb/source/ucp/webdav/NeonSession.hxx
1896 @@ -57,6 +57,7 @@ class NeonSession : public DAVSession
1897 rtl::OUString m_aScheme;
1898 rtl::OUString m_aHostName;
1899 rtl::OUString m_aProxyName;
1900 + rtl::OUString m_aUserInfo;
1902 sal_Int32 m_nProxyPort;
1903 HttpSession * m_pHttpSession;
1904 @@ -70,8 +71,7 @@ class NeonSession : public DAVSession
1906 DAVRequestEnvironment m_aEnv;
1908 - // Note: Uncomment the following if locking support is required
1909 - // NeonLockSession * mNeonLockSession;
1910 + static NeonLockStore *s_aNeonLockStore;
1912 static bool m_bGlobalsInited;
1914 @@ -92,6 +92,8 @@ class NeonSession : public DAVSession
1915 const DAVRequestEnvironment & getRequestEnvironment() const
1918 + const rtl::OUString & getUserInfo() const { return m_aUserInfo; }
1921 OPTIONS( const ::rtl::OUString & inPath,
1922 DAVCapabilities & outCapabilities,
1923 @@ -142,11 +144,12 @@ class NeonSession : public DAVSession
1924 throw ( DAVException );
1926 virtual com::sun::star::uno::Reference<
1927 - com::sun::star::io::XInputStream >
1928 + com::sun::star::io::XStream >
1929 GET( const ::rtl::OUString & inPath,
1930 const std::vector< ::rtl::OUString > & inHeaderNames,
1931 DAVResource & ioResource,
1932 - const DAVRequestEnvironment & rEnv )
1933 + const DAVRequestEnvironment & rEnv,
1934 + sal_Bool bAllowEmpty = sal_False )
1935 throw ( DAVException );
1938 @@ -165,6 +168,13 @@ class NeonSession : public DAVSession
1939 const DAVRequestEnvironment & rEnv )
1940 throw ( DAVException );
1943 + PUT( const ::rtl::OUString & inPath,
1944 + const char * buffer,
1946 + const DAVRequestEnvironment & rEnv )
1947 + throw ( DAVException );
1949 virtual com::sun::star::uno::Reference<
1950 com::sun::star::io::XInputStream >
1951 POST( const rtl::OUString & inPath,
1952 @@ -209,16 +219,13 @@ class NeonSession : public DAVSession
1953 virtual void ABORT()
1954 throw ( DAVException );
1956 - // Note: Uncomment the following if locking support is required
1958 - virtual void LOCK (const Lock & inLock,
1959 - const DAVRequestEnvironment & rEnv )
1960 + virtual void LOCK ( com::sun::star::ucb::Lock & rLock,
1961 + const DAVRequestEnvironment & rEnv )
1962 throw ( DAVException );
1964 - virtual void UNLOCK (const Lock & inLock,
1965 - const DAVRequestEnvironment & rEnv )
1966 + virtual void UNLOCK ( com::sun::star::ucb::Lock & rLock,
1967 + const DAVRequestEnvironment & rEnv )
1968 throw ( DAVException );
1972 const rtl::OUString & getHostName() const { return m_aHostName; }
1973 @@ -239,9 +246,8 @@ class NeonSession : public DAVSession
1975 const ucbhelper::InternetProxyServer & getProxySettings() const;
1977 - // Note: Uncomment the following if locking support is required
1978 - // void Lockit( const Lock & inLock, bool inLockit )
1979 - // throw ( DAVException );
1980 + void Lockit( com::sun::star::ucb::Lock & rLock, bool bLockit )
1981 + throw ( DAVException );
1983 // low level GET implementation, used by public GET implementations
1984 static int GET( ne_session * sess,
1985 --- ucb/source/ucp/webdav/NeonTypes.hxx.old 2009-04-02 11:01:38.000000000 +0000
1986 +++ ucb/source/ucp/webdav/NeonTypes.hxx 2009-04-06 16:41:46.000000000 +0000
1988 #include <ne_utils.h>
1989 #include <ne_basic.h>
1990 #include <ne_props.h>
1991 +#include <ne_locks.h>
1993 typedef ne_session HttpSession;
1994 typedef ne_status HttpStatus;
1995 @@ -43,4 +44,7 @@ typedef ne_server_capabilities Http
1996 typedef ne_propname NeonPropName;
1997 typedef ne_prop_result_set NeonPropFindResultSet;
1999 +typedef ne_lock_store NeonLockStore;
2000 +typedef struct ne_lock NeonLock;
2002 #endif // _NEONTYPES_HXX_
2003 --- ucb/source/ucp/webdav/webdavcontent.cxx.old 2009-04-02 11:01:38.000000000 +0000
2004 +++ ucb/source/ucp/webdav/webdavcontent.cxx 2009-04-06 16:41:46.000000000 +0000
2007 *************************************************************************/
2008 #include <osl/diagnose.h>
2009 +#include <osl/thread.hxx>
2011 #include "osl/doublecheckedlocking.h"
2012 #include <rtl/uri.hxx>
2014 #include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp>
2015 #include <com/sun/star/beans/PropertyValue.hpp>
2016 #include <com/sun/star/io/XActiveDataSink.hpp>
2017 +#include <com/sun/star/io/XActiveDataStreamer.hpp>
2018 #include <com/sun/star/io/XOutputStream.hpp>
2019 #include <com/sun/star/lang/IllegalAccessException.hpp>
2020 #include "com/sun/star/ucb/AuthenticationRequest.hpp"
2021 #include <com/sun/star/ucb/CommandFailedException.hpp>
2022 #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
2023 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
2024 -#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_
2025 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
2027 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
2028 #include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
2029 -#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKGENBERALEXCEPTION_HPP_
2030 #include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp>
2032 #include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
2033 #include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
2034 #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
2036 #include "NeonUri.hxx"
2037 #include "UCBDeadPropertyValue.hxx"
2039 +#include "NeonInputStream.hxx"
2041 using namespace com::sun::star;
2042 using namespace webdav_ucp;
2044 @@ -345,6 +345,123 @@ void SAL_CALL CommandEnvironment_Impl::h
2045 //=========================================================================
2046 //=========================================================================
2048 +// Our signal - 246 is just a random number ;-)
2049 +#define TICKER_THREAD_USER_SIGNAL ( OSL_SIGNAL_USER_RESERVED + 246 )
2051 +// -------------------------------------------------------------------
2052 +// A thread that 'ticks' - emits the user signal every second
2053 +// -------------------------------------------------------------------
2054 +class TickerThread : public osl::Thread
2060 + TickerThread() : osl::Thread(), m_bFinish( false ) {}
2062 + void finish() { m_bFinish = true; }
2066 + virtual void SAL_CALL run();
2069 +void TickerThread::run()
2071 + // we have to go through the loop more often to be able to finish ~quickly
2072 + const int nNth = 25;
2074 + int nCount = nNth;
2075 + while ( !m_bFinish )
2077 + if ( nCount-- <= 0 )
2079 + osl_raiseSignal( TICKER_THREAD_USER_SIGNAL, NULL );
2085 + aTV.Nanosec = 1000000000/nNth;
2090 +// -------------------------------------------------------------------
2091 +// A class that takes care of creating and destroying the ticker thread
2092 +// -------------------------------------------------------------------
2093 +class TickerThreadController
2095 + osl::Mutex m_aMutex;
2097 + TickerThread *m_pTickerThread;
2101 + TickerThreadController() : m_nCount( 0 ), m_pTickerThread( NULL ) {}
2107 +void TickerThreadController::start()
2109 + osl::MutexGuard aGuard( m_aMutex );
2111 + if ( ( m_nCount++ == 0 ) && !m_pTickerThread )
2113 + m_pTickerThread = new TickerThread();
2114 + m_pTickerThread->create();
2118 +void TickerThreadController::stop()
2120 + osl::MutexGuard aGuard( m_aMutex );
2122 + if ( ( --m_nCount == 0 ) && m_pTickerThread )
2124 + m_pTickerThread->finish();
2125 + m_pTickerThread->join();
2127 + delete m_pTickerThread;
2128 + m_pTickerThread = NULL;
2132 +// -------------------------------------------------------------------
2134 +// -------------------------------------------------------------------
2135 +oslSignalAction Content::HandleLockingSignal( void* pData, oslSignalInfo* pSignalInfo )
2137 + Content *pContent = static_cast< Content *>( pData );
2139 +#if OSL_DEBUG_LEVEL > 0
2140 + fprintf( stderr, "Content::HandleLockingSignal: pContent=%p pSignalInfo=%p\n", pContent, pSignalInfo );
2144 + return osl_Signal_ActCallNextHdl;
2146 + if ( pSignalInfo &&
2147 + pSignalInfo->Signal == osl_Signal_User &&
2148 + pSignalInfo->UserSignal == TICKER_THREAD_USER_SIGNAL )
2150 + pContent->RefreshLock();
2152 + else if ( !pSignalInfo || ( pSignalInfo->Signal != osl_Signal_User ) )
2154 + // terminating or something
2155 + pContent->m_xResAccess->UNLOCK( *pContent->m_pLock, pContent->m_xLockEnv );
2156 + delete pContent->m_pLock;
2157 + pContent->m_pLock = NULL;
2160 + return osl_Signal_ActCallNextHdl;
2163 +static TickerThreadController sTickerThreadController;
2165 //=========================================================================
2166 // ctr for content on an existing webdav resource
2168 @@ -358,7 +475,11 @@ Content::Content(
2169 m_pProvider( pProvider ),
2170 m_bTransient( false ),
2171 m_bCollection( false ),
2172 - m_bDidGetOrHead( false )
2173 + m_bDidGetOrHead( false ),
2174 + m_bForceReadOnly( false ),
2176 + m_nToExpire( -1 ),
2177 + m_pSignalHandler( NULL )
2181 @@ -369,6 +490,14 @@ Content::Content(
2183 NeonUri aURI( Identifier->getContentIdentifier() );
2184 m_aEscapedTitle = aURI.GetPathBaseName();
2186 + m_pSignalHandler = osl_addSignalHandler( HandleLockingSignal, this );
2188 +#if OSL_DEBUG_LEVEL > 0
2189 + fprintf( stderr, "Content::Content (existing resource): this=%p m_pSignalHandler=%p\n", this, m_pSignalHandler );
2190 + fprintf( stderr, " identifier=%s\n", rtl::OUStringToOString( Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8 ).getStr() );
2192 + sTickerThreadController.start();
2194 catch ( DAVException const & )
2196 @@ -390,12 +518,24 @@ Content::Content(
2197 m_pProvider( pProvider ),
2198 m_bTransient( true ),
2199 m_bCollection( isCollection ),
2200 - m_bDidGetOrHead( false )
2201 + m_bDidGetOrHead( false ),
2202 + m_bForceReadOnly( false ),
2204 + m_nToExpire( -1 ),
2205 + m_pSignalHandler( NULL )
2209 m_xResAccess.reset( new DAVResourceAccess(
2210 rxSMgr, rSessionFactory, Identifier->getContentIdentifier() ) );
2212 + m_pSignalHandler = osl_addSignalHandler( HandleLockingSignal, this );
2214 +#if OSL_DEBUG_LEVEL > 0
2215 + fprintf( stderr, "Content::Content (nonexistent resource): this=%p m_pSignalHandler=%p\n", this, m_pSignalHandler );
2216 + fprintf( stderr, " identifier=%s\n", rtl::OUStringToOString( Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8 ).getStr() );
2218 + sTickerThreadController.start();
2220 catch ( DAVException const & )
2222 @@ -409,6 +548,47 @@ Content::Content(
2226 +#if OSL_DEBUG_LEVEL > 0
2227 + fprintf( stderr, "Content::~Content: this=%p m_pSignalHandler=%p\n", this, m_pSignalHandler );
2229 + sTickerThreadController.stop();
2231 + osl_removeSignalHandler( m_pSignalHandler );
2233 + if (m_pLock != NULL)
2236 + m_xResAccess->UNLOCK( *m_pLock, m_xLockEnv );
2240 + catch ( ucb::CommandFailedException const & )
2246 +// -------------------------------------------------------------------
2247 +// Lock the resource again
2248 +// -------------------------------------------------------------------
2249 +void Content::RefreshLock( void )
2251 + osl::MutexGuard aGuard( m_aLock );
2253 +#if OSL_DEBUG_LEVEL > 0
2254 + fprintf( stderr, "Content::RefreshLock(): m_nToExpire=%d m_pLock=%p\n", m_nToExpire, m_pLock);
2257 + if ( m_nToExpire > 0 )
2260 + // Refresh the lock if it expires in less than 30 s
2261 + if ( m_pLock && m_nToExpire >= 0 && m_nToExpire < 30 )
2263 + m_xResAccess->LOCK( *m_pLock, m_xLockEnv );
2265 + m_nToExpire = m_pLock->Timeout;
2269 //=========================================================================
2270 @@ -630,6 +811,11 @@ uno::Any SAL_CALL Content::execute(
2271 ucb::CommandAbortedException,
2272 uno::RuntimeException )
2274 +#if OSL_DEBUG_LEVEL > 0
2275 + fprintf( stderr, "WebDAV: Content::execute(): this=%p command=%s\n",
2276 + this, rtl::OUStringToOString( aCommand.Name, RTL_TEXTENCODING_UTF8 ).getStr() );
2281 if ( aCommand.Name.equalsAsciiL(
2282 @@ -1000,6 +1000,11 @@
2283 if ( !Name.getLength() )
2284 throw lang::IllegalArgumentException();
2286 +#if OSL_DEBUG_LEVEL > 0
2287 + fprintf( stderr, "WebDAV: Content::addProperty(): this=%p property=%s\n",
2288 + this, rtl::OUStringToOString( Name, RTL_TEXTENCODING_UTF8 ).getStr() );
2291 // Check property type.
2292 if ( !UCBDeadPropertyValue::supportsType( DefaultValue.getValueType() ) )
2294 @@ -1100,6 +1100,11 @@
2295 // Try to remove property from server.
2296 //////////////////////////////////////////////////////////////////////
2298 +#if OSL_DEBUG_LEVEL > 0
2299 + fprintf( stderr, "WebDAV: Content::removeProperty(): this=%p property=%s\n",
2300 + this, rtl::OUStringToOString( Name, RTL_TEXTENCODING_UTF8 ).getStr() );
2305 std::vector< ProppatchValue > aProppatchValues;
2306 @@ -1349,6 +1535,31 @@ uno::Reference< sdbc::XRow > Content::ge
2307 uno::Reference< ucb::XContentIdentifier > xIdentifier;
2308 rtl::Reference< ::ucbhelper::ContentProviderImplHelper > xProvider;
2310 +#if OSL_DEBUG_LEVEL > 0
2311 + fprintf( stderr, "WebDAV: Content::getPropertyValues(): answering the following properties: " );
2312 + for ( int i = 0; i < rProperties.getLength(); ++i )
2313 + fprintf( stderr, " %s,",
2314 + rtl::OUStringToOString( rProperties[i].Name, RTL_TEXTENCODING_UTF8 ).getStr() );
2315 + fprintf( stderr, "\n" );
2318 + // WebDAV supports XActiveDataStreamer
2319 + // We have to return TRUE on
2320 + // - SupportsActiveStreaming - always
2321 + // - IsReadOnly - if we forced read only due to failed locking
2322 + if ( rProperties.getLength() == 1 )
2324 + if ( rProperties[ 0 ].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SupportsActiveStreaming" ) ) ||
2325 + ( rProperties[ 0 ].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsReadOnly" ) ) && m_bForceReadOnly ) )
2327 + rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
2328 + = new ::ucbhelper::PropertyValueSet( m_xSMgr );
2329 + xRow->appendBoolean( rProperties[0], sal_True );
2331 + return uno::Reference< sdbc::XRow >( xRow.get() );
2336 osl::Guard< osl::Mutex > aGuard( m_aMutex );
2338 @@ -1475,8 +1686,13 @@ uno::Reference< sdbc::XRow > Content::ge
2340 if ( !bNetworkAccessAllowed )
2342 - cancelCommandExecution( e, xEnv );
2344 + if ( e.getStatus() == SC_NOT_FOUND )
2348 + cancelCommandExecution( e, xEnv );
2354 @@ -2000,6 +2000,10 @@
2358 +#if OSL_DEBUG_LEVEL > 0
2359 + fprintf( stderr, "WebDAV: Content::open() this=%p\n", this );
2362 sal_Bool bOpenFolder = ( ( rArg.Mode == ucb::OpenMode::ALL ) ||
2363 ( rArg.Mode == ucb::OpenMode::FOLDERS ) ||
2364 ( rArg.Mode == ucb::OpenMode::DOCUMENTS ) );
2365 @@ -2092,13 +2308,17 @@ uno::Any Content::open(
2369 - if ( rArg.Sink.is() )
2372 + if ( !rArg.Sink.is() )
2377 if ( ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
2378 ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) )
2380 +#if OSL_DEBUG_LEVEL > 0
2381 + fprintf( stderr, "WebDAV: rArg.Mode currently(?) unsupported\n" );
2383 // Currently(?) unsupported.
2384 ucbhelper::cancelCommandExecution(
2386 @@ -2115,6 +2332,9 @@ uno::Any Content::open(
2387 = uno::Reference< io::XOutputStream >( rArg.Sink, uno::UNO_QUERY );
2390 +#if OSL_DEBUG_LEVEL > 0
2391 + fprintf( stderr, "WebDAV: rArg.Sink is XOutputStream\n" );
2396 @@ -2159,6 +2379,60 @@ uno::Any Content::open(
2398 if ( xDataSink.is() )
2400 +#if OSL_DEBUG_LEVEL > 0
2401 + fprintf( stderr, "WebDAV: rArg.Sink is XActiveDataSink\n" );
2403 + // PULL: wait for client read
2407 + osl::MutexGuard aGuard( m_aMutex );
2409 + // throw away previously cached headers.
2410 + m_xCachedProps.reset();
2412 + // fill inputsream sync; return if all data present
2413 + DAVResource aResource;
2414 + std::vector< rtl::OUString > aHeaders;
2415 + // // Obtain list containing all HTTP headers that can
2416 + // // be mapped to UCB properties.
2417 + // ContentProperties::getMappableHTTPHeaders( aHeaders );
2418 + uno::Reference< io::XInputStream > xIn
2419 + = m_xResAccess->GET( aHeaders, aResource, xEnv )->getInputStream();
2422 + osl::MutexGuard aGuard( m_aMutex );
2424 + m_xCachedProps.reset(
2425 + new ContentProperties( aResource ) );
2428 + xDataSink->setInputStream( xIn );
2430 + catch ( DAVException const & e )
2432 + cancelCommandExecution( e, xEnv );
2438 + uno::Reference< io::XActiveDataStreamer > xDataStreamer
2439 + = uno::Reference< io::XActiveDataStreamer >( rArg.Sink,
2441 + if ( xDataStreamer.is() && !m_bForceReadOnly )
2443 +#if OSL_DEBUG_LEVEL > 0
2444 + fprintf( stderr, "WebDAV: rArg.Sink is XActiveDataStreamer\n" );
2446 + // prepare the lock
2447 + m_pLock = new ucb::Lock;
2448 + m_pLock->Depth = ucb::LockDepth_ZERO;
2449 + m_pLock->Scope = ucb::LockScope_EXCLUSIVE;
2450 + m_pLock->Timeout = 2*60; // 2 minutes
2452 + m_nToExpire = m_pLock->Timeout;
2454 // PULL: wait for client read
2457 @@ -2174,9 +2448,31 @@ uno::Any Content::open(
2458 DAVResource aResource;
2459 std::vector< rtl::OUString > aHeaders;
2461 - uno::Reference< io::XInputStream > xIn
2462 - = xResAccess->GET( aHeaders, aResource, xEnv );
2464 + m_xResAccess->LOCK( *m_pLock, xEnv );
2465 + m_xLockEnv = xEnv;
2467 + catch ( ucb::CommandFailedException const &e )
2470 + ucb::InteractiveIOException aIoException;
2471 + if ( ( e.Reason >>= aIoException ) && ( aIoException.Code == ucb::IOErrorCode_LOCKING_VIOLATION ) )
2475 + // yes => we must be read only at the next try
2476 + m_bForceReadOnly = sal_True;
2482 + uno::Reference< io::XStream > xStream
2483 + = xResAccess->GET( aHeaders, aResource, xEnv, sal_True );
2484 m_bDidGetOrHead = true;
2486 + // pass the URL to the stream
2487 + static_cast< NeonInputStream* >( xStream.get() )->SetURL( m_xResAccess->getURL() );
2490 osl::MutexGuard aGuard( m_aMutex );
2491 @@ -2191,16 +2487,24 @@ uno::Any Content::open(
2492 new DAVResourceAccess( *xResAccess.get() ) );
2495 - xDataSink->setInputStream( xIn );
2496 + xDataStreamer->setStream( xStream );
2498 catch ( DAVException const & e )
2500 + m_xResAccess->UNLOCK( *m_pLock, xEnv );
2503 + m_bForceReadOnly = sal_False;
2505 cancelCommandExecution( e, xEnv );
2511 +#if OSL_DEBUG_LEVEL > 0
2512 + fprintf( stderr, "WebDAV: unsupported rArg.Sink\n" );
2514 // Note: aOpenCommand.Sink may contain an XStream
2515 // implementation. Support for this type of
2516 // sink is optional...
2517 @@ -2228,9 +2532,16 @@ void Content::post(
2518 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
2519 throw( uno::Exception )
2521 +#if OSL_DEBUG_LEVEL > 0
2522 + fprintf( stderr, "WebDAV: Content::post() this=%p\n", this );
2525 uno::Reference< io::XActiveDataSink > xSink( rArg.Sink, uno::UNO_QUERY );
2528 +#if OSL_DEBUG_LEVEL > 0
2529 + fprintf( stderr, "WebDAV: rArg.Sink is XActiveDataSink\n" );
2533 std::auto_ptr< DAVResourceAccess > xResAccess;
2534 @@ -2262,6 +2569,9 @@ void Content::post(
2535 uno::Reference< io::XOutputStream > xResult( rArg.Sink, uno::UNO_QUERY );
2538 +#if OSL_DEBUG_LEVEL > 0
2539 + fprintf( stderr, "WebDAV: rArg.Sink is XOutputStream\n" );
2543 std::auto_ptr< DAVResourceAccess > xResAccess;
2544 @@ -2291,6 +2601,9 @@ void Content::post(
2548 +#if OSL_DEBUG_LEVEL > 0
2549 + fprintf( stderr, "WebDAV: rArg.Sink is XActiveDataStreamer (or something)\n" );
2551 ucbhelper::cancelCommandExecution(
2553 ucb::UnsupportedDataSinkException(
2554 @@ -2600,6 +2600,10 @@
2555 rtl::OUString aEscapedTitle;
2556 std::auto_ptr< DAVResourceAccess > xResAccess;
2558 +#if OSL_DEBUG_LEVEL > 0
2559 + fprintf( stderr, "WebDAV: Content::insert() this=%p\n", this );
2563 osl::Guard< osl::Mutex > aGuard( m_aMutex );
2565 @@ -2643,11 +2956,23 @@ void Content::transfer(
2566 rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) );
2568 else if ( aScheme.equalsAsciiL(
2569 + RTL_CONSTASCII_STRINGPARAM( PLAIN_WEBDAV_URL_SCHEME ) ) )
2571 + sourceURI.SetScheme(
2572 + rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) );
2574 + else if ( aScheme.equalsAsciiL(
2575 RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) )
2577 sourceURI.SetScheme(
2578 rtl::OUString::createFromAscii( HTTPS_URL_SCHEME ) );
2580 + else if ( aScheme.equalsAsciiL(
2581 + RTL_CONSTASCII_STRINGPARAM( PLAIN_WEBDAVS_URL_SCHEME ) ) )
2583 + sourceURI.SetScheme(
2584 + rtl::OUString::createFromAscii( HTTPS_URL_SCHEME ) );
2588 if ( !aScheme.equalsAsciiL(
2589 @@ -2674,6 +2999,18 @@ void Content::transfer(
2590 RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) )
2591 targetURI.SetScheme(
2592 rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) );
2593 + else if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL(
2594 + RTL_CONSTASCII_STRINGPARAM( PLAIN_WEBDAV_URL_SCHEME ) ) )
2595 + targetURI.SetScheme(
2596 + rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) );
2597 + else if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL(
2598 + RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) )
2599 + targetURI.SetScheme(
2600 + rtl::OUString::createFromAscii( HTTPS_URL_SCHEME ) );
2601 + else if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL(
2602 + RTL_CONSTASCII_STRINGPARAM( PLAIN_WEBDAVS_URL_SCHEME ) ) )
2603 + targetURI.SetScheme(
2604 + rtl::OUString::createFromAscii( HTTPS_URL_SCHEME ) );
2606 // @@@ This implementation of 'transfer' only works
2607 // if the source and target are located at same host.
2608 --- ucb/source/ucp/webdav/webdavcontent.hxx.old 2009-04-02 11:01:38.000000000 +0000
2609 +++ ucb/source/ucp/webdav/webdavcontent.hxx 2009-04-06 16:41:46.000000000 +0000
2614 +#include <osl/signal.h>
2615 #include <rtl/ref.hxx>
2616 #include <com/sun/star/ucb/ContentCreationException.hpp>
2617 #include <com/sun/star/ucb/XContentCreator.hpp>
2618 +#include <com/sun/star/ucb/Lock.hpp>
2619 #include <ucbhelper/contenthelper.hxx>
2621 #include "DAVResourceAccess.hxx"
2622 #include "PropertyMap.hxx"
2624 @@ -91,6 +94,9 @@ class Content : public ::ucbhelper::Cont
2627 bool m_bDidGetOrHead;
2628 + bool m_bForceReadOnly;
2629 + com::sun::star::ucb::Lock *m_pLock;
2630 + uno::Reference< ucb::XCommandEnvironment > m_xLockEnv;
2631 std::vector< rtl::OUString > m_aFailedPropNames;
2634 @@ -184,6 +190,17 @@ private:
2636 static bool shouldAccessNetworkAfterException( const DAVException & e );
2638 + oslSignalHandler m_pSignalHandler;
2640 + osl::Mutex m_aLock;
2642 + // Refresh the lock of the resource
2643 + void RefreshLock( void );
2645 + // Refresh the lock if necessary, or unlock the resource when
2646 + // OOo crashes or is terminated
2647 + static oslSignalAction HandleLockingSignal( void* pData, oslSignalInfo* pInfo );
2650 Content( const ::com::sun::star::uno::Reference<
2651 ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
2652 --- ucb/source/ucp/webdav/webdavcontentcaps.cxx.old 2009-04-02 11:01:38.000000000 +0000
2653 +++ ucb/source/ucp/webdav/webdavcontentcaps.cxx 2009-04-06 16:41:46.000000000 +0000
2654 @@ -263,6 +263,24 @@ bool ContentProvider::getProperty(
2656 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
2657 beans::PropertyAttribute::BOUND ) );
2662 + RTL_CONSTASCII_USTRINGPARAM( "SupportsActiveStreaming" ) ),
2664 + getCppuBooleanType(),
2665 + beans::PropertyAttribute::BOUND
2666 + | beans::PropertyAttribute::READONLY ) );
2671 + RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
2673 + getCppuBooleanType(),
2674 + beans::PropertyAttribute::BOUND
2675 + | beans::PropertyAttribute::READONLY ) );
2679 --- ucb/source/ucp/webdav/webdavprovider.cxx.old 2009-04-02 11:01:38.000000000 +0000
2680 +++ ucb/source/ucp/webdav/webdavprovider.cxx 2009-04-06 16:41:46.000000000 +0000
2682 **************************************************************************
2684 *************************************************************************/
2686 +#include <string.h>
2688 #include <ucbhelper/contentidentifier.hxx>
2689 #include "webdavprovider.hxx"
2690 #include "webdavcontent.hxx"
2691 @@ -138,7 +141,11 @@ ContentProvider::queryContent(
2692 RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) &&
2693 !aScheme.equalsAsciiL(
2694 RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) &&
2695 - !aScheme.equalsAsciiL(
2696 + !aScheme.equalsAsciiL(
2697 + RTL_CONSTASCII_STRINGPARAM( PLAIN_WEBDAV_URL_SCHEME ) ) &&
2698 + !aScheme.equalsAsciiL(
2699 + RTL_CONSTASCII_STRINGPARAM( PLAIN_WEBDAVS_URL_SCHEME ) ) &&
2700 + !aScheme.equalsAsciiL(
2701 RTL_CONSTASCII_STRINGPARAM( FTP_URL_SCHEME ) ) )
2702 throw ucb::IllegalIdentifierException();
2704 @@ -157,32 +164,27 @@ ContentProvider::queryContent(
2705 uno::Reference< ucb::XContentIdentifier > xCanonicId;
2707 bool bNewId = false;
2708 - if ( aScheme.equalsAsciiL(
2709 - RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) )
2713 + } const *pScheme, pReplace[] = {
2714 + { WEBDAV_URL_SCHEME, HTTP_URL_SCHEME },
2715 + { DAV_URL_SCHEME, HTTP_URL_SCHEME },
2716 + { DAVS_URL_SCHEME, HTTPS_URL_SCHEME },
2717 + { PLAIN_WEBDAV_URL_SCHEME, HTTP_URL_SCHEME },
2718 + { PLAIN_WEBDAVS_URL_SCHEME, HTTPS_URL_SCHEME },
2721 + for ( pScheme = pReplace; pScheme->from ; ++pScheme )
2723 - aURL = aURL.replaceAt( 0,
2724 - WEBDAV_URL_SCHEME_LENGTH,
2725 - rtl::OUString::createFromAscii(
2726 - HTTP_URL_SCHEME ) );
2729 - else if ( aScheme.equalsAsciiL(
2730 - RTL_CONSTASCII_STRINGPARAM( DAV_URL_SCHEME ) ) )
2732 - aURL = aURL.replaceAt( 0,
2733 - DAV_URL_SCHEME_LENGTH,
2734 - rtl::OUString::createFromAscii(
2735 - HTTP_URL_SCHEME ) );
2738 - else if ( aScheme.equalsAsciiL(
2739 - RTL_CONSTASCII_STRINGPARAM( DAVS_URL_SCHEME ) ) )
2741 - aURL = aURL.replaceAt( 0,
2742 - DAVS_URL_SCHEME_LENGTH,
2743 - rtl::OUString::createFromAscii(
2744 - HTTPS_URL_SCHEME ) );
2746 + if ( aScheme.equalsAscii( pScheme->from ) )
2748 + aURL = aURL.replaceAt( 0,
2749 + strlen( pScheme->from ),
2750 + rtl::OUString::createFromAscii( pScheme->to ) );
2756 sal_Int32 nPos = aURL.lastIndexOf( '/' );
2757 @@ -208,6 +208,12 @@
2759 xCanonicId = Identifier;
2761 +#if OSL_DEBUG_LEVEL > 0
2762 + fprintf( stderr, "ContentProvider::queryContent(): bNewId=%s, xCanonicId=%s\n",
2763 + bNewId ? "YES" : "NO",
2764 + rtl::OUStringToOString( xCanonicId->getContentIdentifier(), RTL_TEXTENCODING_UTF8 ).getStr() );
2767 osl::MutexGuard aGuard( m_aMutex );
2769 // Check, if a content with given id already exists...
2770 @@ -232,4 +234,3 @@ ContentProvider::queryContent(
2775 --- ucb/source/ucp/webdav/webdavprovider.hxx.old 2009-04-02 11:01:38.000000000 +0000
2776 +++ ucb/source/ucp/webdav/webdavprovider.hxx 2009-04-06 16:41:46.000000000 +0000
2777 @@ -52,13 +52,10 @@ namespace webdav_ucp {
2778 // contents ) according to this scheme.
2779 #define WEBDAV_URL_SCHEME \
2780 "vnd.sun.star.webdav"
2781 -#define WEBDAV_URL_SCHEME_LENGTH 19
2783 #define HTTP_URL_SCHEME "http"
2784 -#define HTTP_URL_SCHEME_LENGTH 4
2786 #define HTTPS_URL_SCHEME "https"
2787 -#define HTTPS_URL_SCHEME_LENGTH 5
2789 #define DAV_URL_SCHEME "dav"
2790 #define DAV_URL_SCHEME_LENGTH 3
2791 @@ -70,6 +67,12 @@ namespace webdav_ucp {
2793 #define FTP_URL_SCHEME "ftp"
2795 +#define DAV_URL_SCHEME "dav"
2796 +#define DAVS_URL_SCHEME "davs"
2798 +#define PLAIN_WEBDAV_URL_SCHEME "webdav"
2799 +#define PLAIN_WEBDAVS_URL_SCHEME "webdavs"
2801 #define HTTP_CONTENT_TYPE \
2802 "application/" HTTP_URL_SCHEME "-content"
2804 --- unotools/source/ucbhelper/ucblockbytes.cxx.old 2009-04-02 10:57:40.000000000 +0000
2805 +++ unotools/source/ucbhelper/ucblockbytes.cxx 2009-04-06 16:41:46.000000000 +0000
2806 @@ -964,6 +964,10 @@ static sal_Bool UCBOpenContentSync(
2807 if( ! aScheme.equalsIgnoreAsciiCaseAscii("http") &&
2808 ! aScheme.equalsIgnoreAsciiCaseAscii("https") &&
2809 ! aScheme.equalsIgnoreAsciiCaseAscii("vnd.sun.star.webdav") &&
2810 + ! aScheme.equalsIgnoreAsciiCaseAscii("dav") &&
2811 + ! aScheme.equalsIgnoreAsciiCaseAscii("davs") &&
2812 + ! aScheme.equalsIgnoreAsciiCaseAscii("webdav") &&
2813 + ! aScheme.equalsIgnoreAsciiCaseAscii("webdavs") &&
2814 ! aScheme.equalsIgnoreAsciiCaseAscii("ftp"))
2815 return _UCBOpenContentSync(
2816 xLockBytes,xContent,rArg,xSink,xInteract,xProgress,xHandler);
2817 @@ -1541,7 +1545,13 @@ ErrCode UcbLockBytes::Flush() const
2818 Reference <XOutputStream > xOutputStream = getOutputStream_Impl();
2819 if ( !xOutputStream.is() )
2820 return ERRCODE_IO_CANTWRITE;
2821 - xOutputStream->flush();
2823 + xOutputStream->flush();
2827 + return ERRCODE_IO_CANTWRITE;
2829 return ERRCODE_NONE;