diff options
23 files changed, 2275 insertions, 1845 deletions
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index 99bdd6d4316d..80ecbb95afbf 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucb.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kso $ $Date: 2001-04-05 09:49:55 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:50:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,12 +65,12 @@ *************************************************************************/ +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ #include <cppuhelper/interfacecontainer.hxx> #endif -#ifndef _VOS_MUTEX_HXX_ -#include <vos/mutex.hxx> -#endif #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ #include <com/sun/star/lang/IllegalArgumentException.hpp> #endif @@ -89,6 +89,9 @@ #ifndef _UCBHELPER_CONFIGUREUCB_HXX_ #include <ucbhelper/configureucb.hxx> #endif +#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ +#include <ucbhelper/cancelcommandexecution.hxx> +#endif #ifndef _IDENTIFY_HXX #include "identify.hxx" @@ -124,7 +127,7 @@ UniversalContentBroker::UniversalContentBroker( m_nInitCount( 0 ), //@@@ see initialize() method m_nCommandId( 0 ) { - VOS_ENSURE( m_xSMgr.is(), + OSL_ENSURE( m_xSMgr.is(), "UniversalContentBroker ctor: No service manager" ); } @@ -499,7 +502,8 @@ Any SAL_CALL UniversalContentBroker::execute( ////////////////////////////////////////////////////////////////////// if ( ( aCommand.Handle == GETCOMMANDINFO_HANDLE ) || - ( aCommand.Name.compareToAscii( GETCOMMANDINFO_NAME ) == 0 ) ) + aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( GETCOMMANDINFO_NAME ) ) ) { ////////////////////////////////////////////////////////////////// // getCommandInfo @@ -508,23 +512,27 @@ Any SAL_CALL UniversalContentBroker::execute( aRet <<= getCommandInfo(); } else if ( ( aCommand.Handle == GLOBALTRANSFER_HANDLE ) || - ( aCommand.Name.compareToAscii( GLOBALTRANSFER_NAME ) == 0 ) ) + aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM(GLOBALTRANSFER_NAME ) ) ) { ////////////////////////////////////////////////////////////////// // globalTransfer ////////////////////////////////////////////////////////////////// GlobalTransferCommandArgument aTransferArg; - if ( aCommand.Argument >>= aTransferArg ) + if ( !( aCommand.Argument >>= aTransferArg ) ) { - globalTransfer( aTransferArg, Environment ); - } - else - { - VOS_ENSURE( sal_False, - "UniversalContentBroker::execute - invalid parameter!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + makeAny( IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } + + globalTransfer( aTransferArg, Environment ); } else { @@ -532,9 +540,12 @@ Any SAL_CALL UniversalContentBroker::execute( // Unknown command ////////////////////////////////////////////////////////////////// - VOS_ENSURE( sal_False, - "UniversalContentBroker::execute - unknown command!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + makeAny( UnsupportedCommandException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable } return aRet; diff --git a/ucb/source/core/ucb.xml b/ucb/source/core/ucb.xml index 162b3d5e66d9..f6be5a4a8d16 100644 --- a/ucb/source/core/ucb.xml +++ b/ucb/source/core/ucb.xml @@ -111,9 +111,9 @@ <project-build-dependency> cppuhelper </project-build-dependency> <project-build-dependency> ucbhelper </project-build-dependency> - <runtime-module-dependency> sal2 </runtime-module-dependency> - <runtime-module-dependency> cppu2 </runtime-module-dependency> - <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency> + <runtime-module-dependency> sal3 </runtime-module-dependency> + <runtime-module-dependency> cppu3 </runtime-module-dependency> + <runtime-module-dependency> cppuhelper3$(COM) </runtime-module-dependency> <runtime-module-dependency> ucbhelper1$(COM) </runtime-module-dependency> <type> com.sun.star.beans.PropertyAttribute </type> @@ -143,6 +143,7 @@ <type> com.sun.star.ucb.GlobalTransferCommandArgument </type> <type> com.sun.star.ucb.InsertCommandArgument </type> <type> com.sun.star.ucb.InteractiveBadTransferURLException </type> + <type> com.sun.star.ucb.NameClashException </type> <type> com.sun.star.ucb.OpenCommandArgument2 </type> <type> com.sun.star.ucb.OpenMode </type> <type> com.sun.star.ucb.RecipientInfo </type> @@ -150,6 +151,7 @@ <type> com.sun.star.ucb.SendInfo </type> <type> com.sun.star.ucb.SendMediaTypes </type> <type> com.sun.star.ucb.TransferInfo </type> + <type> com.sun.star.ucb.UnsupportedNameClashException </type> <type> com.sun.star.ucb.XCommandInfo </type> <type> com.sun.star.ucb.XCommandProcessor </type> <type> com.sun.star.ucb.XContentAccess </type> diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx index 8c056dad4569..d2ab8fe3da94 100644 --- a/ucb/source/core/ucbcmds.cxx +++ b/ucb/source/core/ucbcmds.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucbcmds.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-04-20 15:40:03 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:50:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,6 +104,9 @@ #ifndef _COM_SUN_STAR_UCB_NAMECLASH_HPP_ #include <com/sun/star/ucb/NameClash.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_NAMECLASHEXCEPTION_HPP_ +#include <com/sun/star/ucb/NameClashException.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_ #include <com/sun/star/ucb/OpenCommandArgument2.hpp> #endif @@ -113,6 +116,9 @@ #ifndef _COM_SUN_STAR_UCB_TRANSFERINFO_HPP_ #include <com/sun/star/ucb/TransferInfo.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDNAMECLASHEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedNameClashException.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_XCOMMANDINFO_HPP_ #include <com/sun/star/ucb/XCommandInfo.hpp> #endif @@ -129,6 +135,9 @@ #ifndef _UCBHELPER_COMMANDENVIRONMENTPROXY_HXX #include <ucbhelper/commandenvironmentproxy.hxx> #endif +#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ +#include <ucbhelper/cancelcommandexecution.hxx> +#endif #ifndef _UCBCMDS_HXX #include "ucbcmds.hxx" @@ -137,14 +146,35 @@ #include "ucb.hxx" #endif +using namespace com::sun; using namespace com::sun::star; -using namespace com::sun::star::ucb; namespace ucb_commands { //========================================================================= // +// struct TransferCommandContext. +// +//========================================================================= + +struct TransferCommandContext +{ + uno::Reference< lang::XMultiServiceFactory > xSMgr; + uno::Reference< star::ucb::XCommandProcessor > xProcessor; + uno::Reference< star::ucb::XCommandEnvironment > xEnv; + star::ucb::GlobalTransferCommandArgument aArg; + + TransferCommandContext( + const uno::Reference< lang::XMultiServiceFactory > & rxSMgr, + const uno::Reference< star::ucb::XCommandProcessor > & rxProcessor, + const uno::Reference< star::ucb::XCommandEnvironment > & rxEnv, + const star::ucb::GlobalTransferCommandArgument & rArg ) + : xSMgr( rxSMgr ), xProcessor( rxProcessor ), xEnv( rxEnv ), aArg( rArg ) {} +}; + +//========================================================================= +// // class ActiveDataSink. // //========================================================================= @@ -216,9 +246,10 @@ uno::Reference< io::XInputStream > SAL_CALL ActiveDataSink::getInputStream() // //========================================================================= -class CommandProcessorInfo : public cppu::OWeakObject, public XCommandInfo +class CommandProcessorInfo : public cppu::OWeakObject, + public star::ucb::XCommandInfo { - uno::Sequence< CommandInfo > * m_pInfo; + uno::Sequence< star::ucb::CommandInfo > * m_pInfo; public: CommandProcessorInfo(); @@ -231,14 +262,14 @@ public: virtual void SAL_CALL release(); // XCommandInfo methods - virtual uno::Sequence< CommandInfo > SAL_CALL getCommands() + virtual uno::Sequence< star::ucb::CommandInfo > SAL_CALL getCommands() throw( uno::RuntimeException ); - virtual CommandInfo SAL_CALL + virtual star::ucb::CommandInfo SAL_CALL getCommandInfoByName( const rtl::OUString& Name ) - throw( UnsupportedCommandException, uno::RuntimeException ); - virtual CommandInfo SAL_CALL + throw( star::ucb::UnsupportedCommandException, uno::RuntimeException ); + virtual star::ucb::CommandInfo SAL_CALL getCommandInfoByHandle( sal_Int32 Handle ) - throw( UnsupportedCommandException, uno::RuntimeException ); + throw( star::ucb::UnsupportedCommandException, uno::RuntimeException ); virtual sal_Bool SAL_CALL hasCommandByName( const rtl::OUString& Name ) throw( uno::RuntimeException ); virtual sal_Bool SAL_CALL hasCommandByHandle( sal_Int32 Handle ) @@ -248,19 +279,20 @@ public: //========================================================================= CommandProcessorInfo::CommandProcessorInfo() { - m_pInfo = new uno::Sequence< CommandInfo >( 2 ); + m_pInfo = new uno::Sequence< star::ucb::CommandInfo >( 2 ); (*m_pInfo)[ 0 ] - = CommandInfo( + = star::ucb::CommandInfo( rtl::OUString::createFromAscii( GETCOMMANDINFO_NAME ), // Name GETCOMMANDINFO_HANDLE, // Handle getCppuVoidType() ); // ArgType (*m_pInfo)[ 1 ] - = CommandInfo( + = star::ucb::CommandInfo( rtl::OUString::createFromAscii( GLOBALTRANSFER_NAME ), // Name GLOBALTRANSFER_HANDLE, // Handle - getCppuType( static_cast< - GlobalTransferCommandArgument * >( 0 ) ) ); // ArgType + getCppuType( + static_cast< + star::ucb::GlobalTransferCommandArgument * >( 0 ) ) ); // ArgType } //========================================================================= @@ -278,7 +310,7 @@ uno::Any SAL_CALL CommandProcessorInfo::queryInterface( { uno::Any aRet = cppu::queryInterface( rType, - static_cast< XCommandInfo * >( this ) ); + static_cast< star::ucb::XCommandInfo * >( this ) ); return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); } @@ -298,40 +330,41 @@ void SAL_CALL CommandProcessorInfo::release() //========================================================================= // virtual -uno::Sequence< CommandInfo > SAL_CALL CommandProcessorInfo::getCommands() +uno::Sequence< star::ucb::CommandInfo > SAL_CALL +CommandProcessorInfo::getCommands() throw( uno::RuntimeException ) { - return uno::Sequence< CommandInfo >( *m_pInfo ); + return uno::Sequence< star::ucb::CommandInfo >( *m_pInfo ); } //========================================================================= // virtual -CommandInfo SAL_CALL CommandProcessorInfo::getCommandInfoByName( - const rtl::OUString& Name ) - throw( UnsupportedCommandException, uno::RuntimeException ) +star::ucb::CommandInfo SAL_CALL +CommandProcessorInfo::getCommandInfoByName( const rtl::OUString& Name ) + throw( star::ucb::UnsupportedCommandException, uno::RuntimeException ) { for ( sal_Int32 n = 0; n < m_pInfo->getLength(); ++n ) { if ( (*m_pInfo)[ n ].Name == Name ) - return CommandInfo( (*m_pInfo)[ n ] ); + return star::ucb::CommandInfo( (*m_pInfo)[ n ] ); } - throw UnsupportedCommandException(); + throw star::ucb::UnsupportedCommandException(); } //========================================================================= // virtual -CommandInfo SAL_CALL CommandProcessorInfo::getCommandInfoByHandle( - sal_Int32 Handle ) - throw( UnsupportedCommandException, uno::RuntimeException ) +star::ucb::CommandInfo SAL_CALL +CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle ) + throw( star::ucb::UnsupportedCommandException, uno::RuntimeException ) { for ( sal_Int32 n = 0; n < m_pInfo->getLength(); ++n ) { if ( (*m_pInfo)[ n ].Handle == Handle ) - return CommandInfo( (*m_pInfo)[ n ] ); + return star::ucb::CommandInfo( (*m_pInfo)[ n ] ); } - throw UnsupportedCommandException(); + throw star::ucb::UnsupportedCommandException(); } //========================================================================= @@ -367,20 +400,12 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle ) //========================================================================= //========================================================================= -static void abort( const sal_Char * pReason ) -{ - OSL_ENSURE( sal_False, pReason ); - throw CommandAbortedException( rtl::OUString::createFromAscii( pReason ), - uno::Reference< uno::XInterface >() ); -} - -//========================================================================= -static uno::Reference< XContent > createNew( - const uno::Reference< XContent > & xTarget, - const GlobalTransferCommandArgument & rArg, - sal_Bool bSourceIsFolder, - sal_Bool bSourceIsDocument, - sal_Bool bSourceIsLink ) +static uno::Reference< star::ucb::XContent > createNew( + const TransferCommandContext & rContext, + const uno::Reference< star::ucb::XContent > & xTarget, + sal_Bool bSourceIsFolder, + sal_Bool bSourceIsDocument, + sal_Bool bSourceIsLink ) throw( uno::Exception ) { ////////////////////////////////////////////////////////////////////// @@ -389,17 +414,36 @@ static uno::Reference< XContent > createNew( // ////////////////////////////////////////////////////////////////////// - uno::Reference< XContentCreator > xCreator( xTarget, uno::UNO_QUERY ); + uno::Reference< star::ucb::XContentCreator > xCreator( + xTarget, uno::UNO_QUERY ); if ( !xCreator.is() ) - ucb_commands::abort( "Target is no XContentCreator!" ); + { + ucbhelper::cancelCommandExecution( star::ucb::IOErrorCode_CANT_CREATE, + rtl::OUString(), // new URL + rContext.aArg.TargetURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "Target is no XContentCreator!" ), + rContext.xProcessor ); + // Unreachable + } - uno::Sequence< ContentInfo > aTypesInfo + uno::Sequence< star::ucb::ContentInfo > aTypesInfo = xCreator->queryCreatableContentsInfo(); sal_Int32 nCount = aTypesInfo.getLength(); if ( !nCount ) - ucb_commands::abort( "No creatable types!" ); + { + ucbhelper::cancelCommandExecution( star::ucb::IOErrorCode_CANT_CREATE, + rtl::OUString(), // new URL + rContext.aArg.TargetURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "No types creatable!" ), + rContext.xProcessor ); + // Unreachable + } ////////////////////////////////////////////////////////////////////// // @@ -407,31 +451,34 @@ static uno::Reference< XContent > createNew( // ////////////////////////////////////////////////////////////////////// - uno::Reference< XContent > xNew; + uno::Reference< star::ucb::XContent > xNew; for ( sal_Int32 n = 0; n < nCount; ++n ) { sal_Int32 nAttribs = aTypesInfo[ n ].Attributes; sal_Bool bMatch = sal_False; - if ( rArg.Operation == TransferCommandOperation_LINK ) + if ( rContext.aArg.Operation + == star::ucb::TransferCommandOperation_LINK ) { // Create link - if ( nAttribs & ContentInfoAttribute::KIND_LINK ) + if ( nAttribs & star::ucb::ContentInfoAttribute::KIND_LINK ) { // Match! bMatch = sal_True; } } - else if ( ( rArg.Operation == TransferCommandOperation_COPY ) || - ( rArg.Operation == TransferCommandOperation_MOVE ) ) + else if ( ( rContext.aArg.Operation + == star::ucb::TransferCommandOperation_COPY ) || + ( rContext.aArg.Operation + == star::ucb::TransferCommandOperation_MOVE ) ) { // Copy / Move // Is source a link? Create link in target folder then. if ( bSourceIsLink ) { - if ( nAttribs & ContentInfoAttribute::KIND_LINK ) + if ( nAttribs & star::ucb::ContentInfoAttribute::KIND_LINK ) { // Match! bMatch = sal_True; @@ -440,9 +487,13 @@ static uno::Reference< XContent > createNew( else { if ( ( bSourceIsFolder == - !!( nAttribs & ContentInfoAttribute::KIND_FOLDER ) ) && + !!( nAttribs + & star::ucb::ContentInfoAttribute::KIND_FOLDER ) ) + && ( bSourceIsDocument == - !!( nAttribs & ContentInfoAttribute::KIND_DOCUMENT ) ) ) + !!( nAttribs + & star::ucb::ContentInfoAttribute::KIND_DOCUMENT ) ) + ) { // Match! bMatch = sal_True; @@ -451,7 +502,14 @@ static uno::Reference< XContent > createNew( } else { - ucb_commands::abort( "Unsupported transfer operation!" ); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Unknown transfer operation!" ), + rContext.xProcessor, + -1 ) ), + rContext.xEnv ); + // Unreachable } if ( bMatch ) @@ -465,8 +523,17 @@ static uno::Reference< XContent > createNew( xNew = xCreator->createNewContent( aTypesInfo[ n ] ); if ( !xNew.is() ) - ucb_commands::abort( "createNewContent failed!" ); - + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_CREATE, + rtl::OUString(), // new URL + rContext.aArg.TargetURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "createNewContent failed!" ), + rContext.xProcessor ); + // Unreachable + } break; } } @@ -476,36 +543,54 @@ static uno::Reference< XContent > createNew( //========================================================================= static void transferProperties( - const uno::Reference< XCommandProcessor > & xCommandProcessorS, - const uno::Reference< XCommandProcessor > & xCommandProcessorN, - const GlobalTransferCommandArgument & rArg, - const uno::Reference< XCommandEnvironment > & xEnv ) - throw( uno::Exception ) + const TransferCommandContext & rContext, + const uno::Reference< star::ucb::XCommandProcessor > & xCommandProcessorS, + const uno::Reference< star::ucb::XCommandProcessor > & xCommandProcessorN ) + throw( uno::Exception ) { - Command aGetPropertySetInfoCommand( + star::ucb::Command aGetPropertySetInfoCommand( rtl::OUString::createFromAscii( "getPropertySetInfo" ), -1, uno::Any() ); uno::Reference< beans::XPropertySetInfo > xInfo; - xCommandProcessorS->execute( aGetPropertySetInfoCommand, 0, xEnv ) + xCommandProcessorS->execute( aGetPropertySetInfoCommand, 0, rContext.xEnv ) >>= xInfo; if ( !xInfo.is() ) - ucb_commands::abort( "Unable to get propertyset info from source!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rContext.aArg.SourceURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "Unable to get propertyset info from source object!" ), + rContext.xProcessor ); + // Unreachable + } uno::Sequence< beans::Property > aAllProps = xInfo->getProperties(); - Command aGetPropsCommand1( + star::ucb::Command aGetPropsCommand1( rtl::OUString::createFromAscii( "getPropertyValues" ), -1, uno::makeAny( aAllProps ) ); uno::Reference< sdbc::XRow > xRow1; - xCommandProcessorS->execute( aGetPropsCommand1, 0, xEnv ) >>= xRow1; + xCommandProcessorS->execute( + aGetPropsCommand1, 0, rContext.xEnv ) >>= xRow1; if ( !xRow1.is() ) - ucb_commands::abort( "Unable to get properties from source object!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rContext.aArg.SourceURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "Unable to get properties from source object!" ), + rContext.xProcessor ); + // Unreachable + } // Assemble data structure for setPropertyValues command. @@ -513,10 +598,9 @@ static void transferProperties( uno::Sequence< beans::PropertyValue > aPropValues( aAllProps.getLength() + 2 ); - sal_Bool bHasTitle - = ( rArg.NewTitle.getLength() == 0 ); - sal_Bool bHasTargetURL - = ( rArg.Operation != TransferCommandOperation_LINK ); + sal_Bool bHasTitle = ( rContext.aArg.NewTitle.getLength() == 0 ); + sal_Bool bHasTargetURL = ( rContext.aArg.Operation + != star::ucb::TransferCommandOperation_LINK ); sal_Int32 nWritePos = 0; for ( sal_Int32 m = 0; m < aAllProps.getLength(); ++m ) @@ -532,7 +616,7 @@ static void transferProperties( if ( !bHasTitle ) { bHasTitle = sal_True; - aValue <<= rArg.NewTitle; + aValue <<= rContext.aArg.NewTitle; } } else if ( rCurrProp.Name.compareToAscii( "TargetURL" ) == 0 ) @@ -541,7 +625,7 @@ static void transferProperties( if ( !bHasTargetURL ) { bHasTargetURL = sal_True; - aValue <<= rArg.SourceURL; + aValue <<= rContext.aArg.SourceURL; } } @@ -571,23 +655,24 @@ static void transferProperties( } // Title needed, but not set yet? - if ( !bHasTitle && ( rArg.NewTitle.getLength() > 0 ) ) + if ( !bHasTitle && ( rContext.aArg.NewTitle.getLength() > 0 ) ) { aPropValues[ nWritePos ].Name = rtl::OUString::createFromAscii( "Title" ); aPropValues[ nWritePos ].Handle = -1; - aPropValues[ nWritePos ].Value <<= rArg.NewTitle; + aPropValues[ nWritePos ].Value <<= rContext.aArg.NewTitle; nWritePos++; } // TargetURL needed, but not set yet? - if ( !bHasTargetURL && ( rArg.Operation == TransferCommandOperation_LINK ) ) + if ( !bHasTargetURL && ( rContext.aArg.Operation + == star::ucb::TransferCommandOperation_LINK ) ) { aPropValues[ nWritePos ].Name = rtl::OUString::createFromAscii( "TargetURL" ); aPropValues[ nWritePos ].Handle = -1; - aPropValues[ nWritePos ].Value <<= rArg.SourceURL; + aPropValues[ nWritePos ].Value <<= rContext.aArg.SourceURL; nWritePos++; } @@ -596,12 +681,12 @@ static void transferProperties( // Set properties at new object. - Command aSetPropsCommand( + star::ucb::Command aSetPropsCommand( rtl::OUString::createFromAscii( "setPropertyValues" ), -1, uno::makeAny( aPropValues ) ); - xCommandProcessorN->execute( aSetPropsCommand, 0, xEnv ); + xCommandProcessorN->execute( aSetPropsCommand, 0, rContext.xEnv ); // @@@ What to do with source props that are not supported by the // new object? addProperty ??? @@ -609,10 +694,9 @@ static void transferProperties( //========================================================================= static uno::Reference< io::XInputStream > getInputStream( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const uno::Reference< XCommandProcessor > & xCommandProcessorS, - const uno::Reference< XCommandEnvironment > & xEnv ) - throw( uno::Exception ) + const TransferCommandContext & rContext, + const uno::Reference< star::ucb::XCommandProcessor > & xCommandProcessorS ) + throw( uno::Exception ) { uno::Reference< io::XInputStream > xInputStream; @@ -626,17 +710,18 @@ static uno::Reference< io::XInputStream > getInputStream( { uno::Reference< io::XActiveDataSink > xSink = new ActiveDataSink; - OpenCommandArgument2 aArg; - aArg.Mode = OpenMode::DOCUMENT; + star::ucb::OpenCommandArgument2 aArg; + aArg.Mode = star::ucb::OpenMode::DOCUMENT; aArg.Priority = 0; // unused aArg.Sink = xSink; aArg.Properties = uno::Sequence< beans::Property >( 0 ); // unused - Command aOpenCommand( rtl::OUString::createFromAscii( "open" ), - -1, - uno::makeAny( aArg ) ); + star::ucb::Command aOpenCommand( + rtl::OUString::createFromAscii( "open" ), + -1, + uno::makeAny( aArg ) ); - xCommandProcessorS->execute( aOpenCommand, 0, xEnv ); + xCommandProcessorS->execute( aOpenCommand, 0, rContext.xEnv ); xInputStream = xSink->getInputStream(); } catch ( uno::Exception const & ) @@ -654,23 +739,24 @@ static uno::Reference< io::XInputStream > getInputStream( try { uno::Reference< io::XOutputStream > xOutputStream( - xSMgr->createInstance( + rContext.xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.io.Pipe" ) ), uno::UNO_QUERY ); if ( xOutputStream.is() ) { - OpenCommandArgument2 aArg; - aArg.Mode = OpenMode::DOCUMENT; + star::ucb::OpenCommandArgument2 aArg; + aArg.Mode = star::ucb::OpenMode::DOCUMENT; aArg.Priority = 0; // unused aArg.Sink = xOutputStream; aArg.Properties = uno::Sequence< beans::Property >( 0 ); - Command aOpenCommand( rtl::OUString::createFromAscii( "open" ), - -1, - uno::makeAny( aArg ) ); + star::ucb::Command aOpenCommand( + rtl::OUString::createFromAscii( "open" ), + -1, + uno::makeAny( aArg ) ); - xCommandProcessorS->execute( aOpenCommand, 0, xEnv ); + xCommandProcessorS->execute( aOpenCommand, 0, rContext.xEnv ); xInputStream = uno::Reference< io::XInputStream >( xOutputStream, uno::UNO_QUERY ); @@ -686,9 +772,9 @@ static uno::Reference< io::XInputStream > getInputStream( //========================================================================= static uno::Reference< sdbc::XResultSet > getResultSet( - const uno::Reference< XCommandProcessor > & xCommandProcessorS, - const uno::Reference< XCommandEnvironment > & xEnv ) - throw( uno::Exception ) + const TransferCommandContext & rContext, + const uno::Reference< star::ucb::XCommandProcessor > & xCommandProcessorS ) + throw( uno::Exception ) { uno::Reference< sdbc::XResultSet > xResultSet; @@ -701,19 +787,19 @@ static uno::Reference< sdbc::XResultSet > getResultSet( aProps[ 2 ].Name = rtl::OUString::createFromAscii( "TargetURL" ); aProps[ 2 ].Handle = -1; /* unknown */ - OpenCommandArgument2 aArg; - aArg.Mode = OpenMode::ALL; + star::ucb::OpenCommandArgument2 aArg; + aArg.Mode = star::ucb::OpenMode::ALL; aArg.Priority = 0; // unused aArg.Sink = 0; aArg.Properties = aProps; - Command aOpenCommand( rtl::OUString::createFromAscii( "open" ), - -1, - uno::makeAny( aArg ) ); + star::ucb::Command aOpenCommand( rtl::OUString::createFromAscii( "open" ), + -1, + uno::makeAny( aArg ) ); try { - uno::Reference< XDynamicResultSet > xSet; - xCommandProcessorS->execute( aOpenCommand, 0, xEnv ) >>= xSet; + uno::Reference< star::ucb::XDynamicResultSet > xSet; + xCommandProcessorS->execute( aOpenCommand, 0, rContext.xEnv ) >>= xSet; if ( xSet.is() ) xResultSet = xSet->getStaticResultSet(); @@ -726,26 +812,40 @@ static uno::Reference< sdbc::XResultSet > getResultSet( } //========================================================================= -static void globalTransfer( const uno::Reference< - lang::XMultiServiceFactory > & xSMgr, - const uno::Reference< XContent > & xSource, - const uno::Reference< XContent > & xTarget, - const GlobalTransferCommandArgument & rArg, - const uno::Reference< sdbc::XRow > & xSourceProps, - const uno::Reference< XCommandEnvironment > & xEnv ) +static void globalTransfer( + const TransferCommandContext & rContext, + const uno::Reference< star::ucb::XContent > & xSource, + const uno::Reference< star::ucb::XContent > & xTarget, + const uno::Reference< sdbc::XRow > & xSourceProps ) throw( uno::Exception ) { // IsFolder: property is required. sal_Bool bSourceIsFolder = xSourceProps->getBoolean( 1 ); if ( !bSourceIsFolder && xSourceProps->wasNull() ) - ucb_commands::abort( - "Unable to get property 'IsFolder' from source object!" ); + { + ucbhelper::cancelCommandExecution( + uno::makeAny( beans::UnknownPropertyException( + rtl::OUString::createFromAscii( + "Unable to get property 'IsFolder' " + "from source object!" ), + rContext.xProcessor ) ), + rContext.xEnv ); + // Unreachable + } // IsDocument: property is required. sal_Bool bSourceIsDocument = xSourceProps->getBoolean( 2 ); if ( !bSourceIsDocument && xSourceProps->wasNull() ) - ucb_commands::abort( - "Unable to get property 'IsDocument' from source object!" ); + { + ucbhelper::cancelCommandExecution( + uno::makeAny( beans::UnknownPropertyException( + rtl::OUString::createFromAscii( + "Unable to get property 'IsDocument' " + "from source object!" ), + rContext.xProcessor ) ), + rContext.xEnv ); + // Unreachable + } // TargetURL: property is optional. sal_Bool bSourceIsLink = ( xSourceProps->getString( 3 ).getLength() > 0 ); @@ -757,13 +857,23 @@ static void globalTransfer( const uno::Reference< // ////////////////////////////////////////////////////////////////////// - uno::Reference< XContent > xNew = createNew( xTarget, - rArg, - bSourceIsFolder, - bSourceIsDocument, - bSourceIsLink ); + uno::Reference< star::ucb::XContent > xNew = createNew( rContext, + xTarget, + bSourceIsFolder, + bSourceIsDocument, + bSourceIsLink ); if ( !xNew.is() ) - ucb_commands::abort( "No matching content type at target!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_CREATE, + rtl::OUString(), // new URL + rContext.aArg.TargetURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "No matching content type at target!" ), + rContext.xProcessor ); + // Unreachable + } ////////////////////////////////////////////////////////////////////// // @@ -771,19 +881,37 @@ static void globalTransfer( const uno::Reference< // ////////////////////////////////////////////////////////////////////// - uno::Reference< XCommandProcessor > xCommandProcessorN( - xNew, uno::UNO_QUERY ); + uno::Reference< star::ucb::XCommandProcessor > xCommandProcessorN( + xNew, uno::UNO_QUERY ); if ( !xCommandProcessorN.is() ) - ucb_commands::abort( "New content is not a XCommandProcessor!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_WRITE, + xNew->getIdentifier()->getContentIdentifier(), + rContext.xEnv, + rtl::OUString::createFromAscii( + "New content is not a XCommandProcessor!" ), + rContext.xProcessor ); + // Unreachable + } // Obtain all properties from source. - uno::Reference< XCommandProcessor > xCommandProcessorS( - xSource, uno::UNO_QUERY ); + uno::Reference< star::ucb::XCommandProcessor > xCommandProcessorS( + xSource, uno::UNO_QUERY ); if ( !xCommandProcessorS.is() ) - ucb_commands::abort( "Source is not a XCommandProcessor!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rContext.aArg.SourceURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "Source content is not a XCommandProcessor!" ), + rContext.xProcessor ); + // Unreachable + } - transferProperties( xCommandProcessorS, xCommandProcessorN, rArg, xEnv ); + transferProperties( rContext, xCommandProcessorS, xCommandProcessorN ); ////////////////////////////////////////////////////////////////////// // @@ -793,9 +921,9 @@ static void globalTransfer( const uno::Reference< uno::Reference< io::XInputStream > xInputStream; - if ( bSourceIsDocument && - ( rArg.Operation != TransferCommandOperation_LINK ) ) - xInputStream = getInputStream( xSMgr, xCommandProcessorS, xEnv ); + if ( bSourceIsDocument && ( rContext.aArg.Operation + != star::ucb::TransferCommandOperation_LINK ) ) + xInputStream = getInputStream( rContext, xCommandProcessorS ); ////////////////////////////////////////////////////////////////////// // @@ -805,9 +933,9 @@ static void globalTransfer( const uno::Reference< uno::Reference< sdbc::XResultSet > xResultSet; - if ( bSourceIsFolder && - ( rArg.Operation != TransferCommandOperation_LINK ) ) - xResultSet = getResultSet( xCommandProcessorS, xEnv ); + if ( bSourceIsFolder && ( rContext.aArg.Operation + != star::ucb::TransferCommandOperation_LINK ) ) + xResultSet = getResultSet( rContext, xCommandProcessorS ); ////////////////////////////////////////////////////////////////////// // @@ -817,171 +945,250 @@ static void globalTransfer( const uno::Reference< try { - InsertCommandArgument aArg; + star::ucb::InsertCommandArgument aArg; aArg.Data = xInputStream; - switch ( rArg.NameClash ) + switch ( rContext.aArg.NameClash ) { - case NameClash::OVERWRITE: + case star::ucb::NameClash::OVERWRITE: aArg.ReplaceExisting = sal_True; break; - case NameClash::ERROR: - case NameClash::RENAME: + case star::ucb::NameClash::ERROR: + case star::ucb::NameClash::RENAME: + case star::ucb::NameClash::KEEP: // deprecated + case star::ucb::NameClash::ASK: aArg.ReplaceExisting = sal_False; break; default: aArg.ReplaceExisting = sal_False; - OSL_ENSURE( sal_False, "Unknown nameclash value!" ); + OSL_ENSURE( sal_False, "Unknown nameclash directive!" ); break; } - Command aInsertCommand( rtl::OUString::createFromAscii( "insert" ), + star::ucb::Command aInsertCommand( + rtl::OUString::createFromAscii( "insert" ), -1, uno::makeAny( aArg ) ); - xCommandProcessorN->execute( aInsertCommand, 0, xEnv ); + xCommandProcessorN->execute( aInsertCommand, 0, rContext.xEnv ); } - catch ( CommandAbortedException const & ) + catch ( star::ucb::NameClashException const & ) { - // @@@ The exception may have thousands of other reasons than - // a NameClash...! insert command should throw a special exception - // if a name clash occurs. + // The 'insert' command throws a NameClashException if the parameter + // ReplaceExisting of the command's argument was set to false and + // there exists a resource with a clashing name in the target folder + // of the operation. + + // 'insert' command has no direct support for name clashes other + // than ERROR ( ReplaceExisting == false ) and OVERWRITE + // ( ReplaceExisting == true ). So we have to implement the + // other name clash handling directives on top of the content. + + // @@@ 'insert' command should be extended that it accepts a + // name clash handling directive, exactly like 'transfer' command. - if ( rArg.NameClash == NameClash::RENAME ) + switch ( rContext.aArg.NameClash ) { - // "invent" a new valid title. + case star::ucb::NameClash::OVERWRITE: + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString::createFromAscii( + "BUG: insert + replace == true MUST NOT " + "throw NameClashException." ), + rContext.xProcessor, + rContext.aArg.NameClash ) ), + rContext.xEnv ); + // Unreachable + } - sal_Int32 nTry = 0; + case star::ucb::NameClash::ERROR: + throw; - // Obtain old title. - uno::Sequence< beans::Property > aProps( 1 ); - aProps[ 0 ].Name = rtl::OUString::createFromAscii( "Title" ); - aProps[ 0 ].Handle = -1; + case star::ucb::NameClash::RENAME: + { + // "invent" a new valid title. - Command aGetPropsCommand( - rtl::OUString::createFromAscii( "getPropertyValues" ), - -1, - uno::makeAny( aProps ) ); + sal_Int32 nTry = 0; - uno::Reference< sdbc::XRow > xRow; - xCommandProcessorN->execute( aGetPropsCommand, 0, xEnv ) >>= xRow; + // Obtain old title. + uno::Sequence< beans::Property > aProps( 1 ); + aProps[ 0 ].Name = rtl::OUString::createFromAscii( "Title" ); + aProps[ 0 ].Handle = -1; - if ( !xRow.is() ) - ucb_commands::abort( "Unable to get properties from object!" ); + star::ucb::Command aGetPropsCommand( + rtl::OUString::createFromAscii( "getPropertyValues" ), + -1, + uno::makeAny( aProps ) ); - rtl::OUString aOldTitle = xRow->getString( 1 ); - if ( !aOldTitle.getLength() ) - ucb_commands::abort( "Unable to get title from object!" ); + uno::Reference< sdbc::XRow > xRow; + xCommandProcessorN->execute( + aGetPropsCommand, 0, rContext.xEnv ) >>= xRow; - // Some pseudo-intelligence for not destroying file extensions... - rtl::OUString aOldTitlePre; - rtl::OUString aOldTitlePost; - sal_Int32 nPos = aOldTitle.lastIndexOf( '.' ); - if ( nPos != -1 ) - { - aOldTitlePre = aOldTitle.copy( 0, nPos ); - aOldTitlePost = aOldTitle.copy( nPos ); - } - else - aOldTitlePre = aOldTitle; + if ( !xRow.is() ) + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + xNew->getIdentifier()->getContentIdentifier(), + rContext.xEnv, + rtl::OUString::createFromAscii( + "Unable to get properties from new object!" ), + rContext.xProcessor ); + // Unreachable + } - if ( nPos > 0 ) - aOldTitlePre += rtl::OUString::createFromAscii( "_" ); + rtl::OUString aOldTitle = xRow->getString( 1 ); + if ( !aOldTitle.getLength() ) + { + ucbhelper::cancelCommandExecution( + uno::makeAny( beans::UnknownPropertyException( + rtl::OUString::createFromAscii( + "Unable to get property 'Title' " + "from new object!" ), + rContext.xProcessor ) ), + rContext.xEnv ); + // Unreachable + } - sal_Bool bContinue = sal_True; - do - { - nTry++; + // Some pseudo-intelligence for not destroying file extensions. + rtl::OUString aOldTitlePre; + rtl::OUString aOldTitlePost; + sal_Int32 nPos = aOldTitle.lastIndexOf( '.' ); + if ( nPos != -1 ) + { + aOldTitlePre = aOldTitle.copy( 0, nPos ); + aOldTitlePost = aOldTitle.copy( nPos ); + } + else + aOldTitlePre = aOldTitle; + + if ( nPos > 0 ) + aOldTitlePre += rtl::OUString::createFromAscii( "_" ); + + sal_Bool bContinue = sal_True; + do + { + nTry++; - rtl::OUString aNewTitle = aOldTitlePre; - aNewTitle += rtl::OUString::valueOf( nTry ); - aNewTitle += aOldTitlePost; + rtl::OUString aNewTitle = aOldTitlePre; + aNewTitle += rtl::OUString::valueOf( nTry ); + aNewTitle += aOldTitlePost; - uno::Sequence< beans::PropertyValue > aValues( 1 ); - aValues[ 0 ].Name = rtl::OUString::createFromAscii( "Title" ); - aValues[ 0 ].Handle = -1; - aValues[ 0 ].Value <<= aNewTitle; + uno::Sequence< beans::PropertyValue > aValues( 1 ); + aValues[ 0 ].Name + = rtl::OUString::createFromAscii( "Title" ); + aValues[ 0 ].Handle = -1; + aValues[ 0 ].Value <<= aNewTitle; - Command aSetPropsCommand( + star::ucb::Command aSetPropsCommand( rtl::OUString::createFromAscii( "setPropertyValues" ), -1, uno::makeAny( aValues ) ); - // Set new title - xCommandProcessorN->execute( aSetPropsCommand, 0, xEnv ); + // Set new title + xCommandProcessorN->execute( + aSetPropsCommand, 0, rContext.xEnv ); - // Retry inserting the content. - try - { - // Previous try may have read from stream. Seek to begin - // (if optional interface XSeekable is supported) or get - // a new stream. - if ( xInputStream.is() ) + // Retry inserting the content. + try { - uno::Reference< io::XSeekable > xSeekable( - xInputStream, uno::UNO_QUERY ); - if ( xSeekable.is() ) + // Previous try may have read from stream. Seek to + // begin (if optional interface XSeekable is supported) + // or get a new stream. + if ( xInputStream.is() ) { - try + uno::Reference< io::XSeekable > xSeekable( + xInputStream, uno::UNO_QUERY ); + if ( xSeekable.is() ) { - xSeekable->seek( 0 ); + try + { + xSeekable->seek( 0 ); + } + catch ( lang::IllegalArgumentException const & ) + { + xInputStream = 0; + } + catch ( io::IOException const & ) + { + xInputStream = 0; + } } - catch ( lang::IllegalArgumentException const & ) - { + else xInputStream = 0; - } - catch ( io::IOException const & ) + + if ( !xInputStream.is() ) { - xInputStream = 0; + xInputStream = getInputStream( + rContext, xCommandProcessorS ); + if ( !xInputStream.is() ) + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + xNew->getIdentifier() + ->getContentIdentifier(), + rContext.xEnv, + rtl::OUString::createFromAscii( + "Got no data stream from source!" ), + rContext.xProcessor ); + // Unreachable + } } } - else - xInputStream = 0; - if ( !xInputStream.is() ) - { - xInputStream = getInputStream( xSMgr, - xCommandProcessorS, - xEnv ); - if ( !xInputStream.is() ) - ucb_commands::abort( - "Unable to get Inputstream!" ); - } - } + star::ucb::InsertCommandArgument aArg; + aArg.Data = xInputStream; + aArg.ReplaceExisting = sal_False; - InsertCommandArgument aArg; - aArg.Data = xInputStream; - aArg.ReplaceExisting = sal_False; + star::ucb::Command aInsertCommand( + rtl::OUString::createFromAscii( "insert" ), + -1, + uno::makeAny( aArg ) ); - Command aInsertCommand( - rtl::OUString::createFromAscii( "insert" ), - -1, - uno::makeAny( aArg ) ); - - xCommandProcessorN->execute( aInsertCommand, 0, xEnv ); + xCommandProcessorN->execute( + aInsertCommand, 0, rContext.xEnv ); - // Success! - bContinue = sal_False; + // Success! + bContinue = sal_False; + } + catch ( uno::Exception const & ) + { + } } - catch ( CommandAbortedException const & ) + while ( bContinue && ( nTry < 50 ) ); + + if ( nTry == 50 ) { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString::createFromAscii( + "Unable to resolve name clash!" ), + rContext.xProcessor, + star::ucb::NameClash::RENAME ) ), + rContext.xEnv ); + // Unreachable } } - while ( bContinue && ( nTry < 50 ) ); + break; - if ( nTry == 50 ) + case star::ucb::NameClash::KEEP: // deprecated + case star::ucb::NameClash::ASK: + default: { - OSL_ENSURE( sal_False, "Cannot insert new object!" ); - throw; + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString(), + rContext.xProcessor, + rContext.aArg.NameClash ) ), + rContext.xEnv ); + // Unreachable } } - else - { - OSL_ENSURE( sal_False, "Cannot insert new object!" ); - throw; - } } catch ( uno::Exception const & ) { @@ -1006,35 +1213,54 @@ static void globalTransfer( const uno::Reference< xResultSet, uno::UNO_QUERY ); if ( !xChildRow.is() ) - ucb_commands::abort( - "Unable to get props from children of source!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rContext.aArg.SourceURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "Unable to get properties from children of source!" ), + rContext.xProcessor ); + // Unreachable + } - uno::Reference< XContentAccess > xChildAccess( - xResultSet, uno::UNO_QUERY ); + uno::Reference< star::ucb::XContentAccess > xChildAccess( + xResultSet, uno::UNO_QUERY ); if ( !xChildAccess.is() ) - ucb_commands::abort( "Unable to get children of source!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rContext.aArg.SourceURL, + rContext.xEnv, + rtl::OUString::createFromAscii( + "Unable to get children of source!" ), + rContext.xProcessor ); + // Unreachable + } if ( xResultSet->first() ) { do { - uno::Reference< XContent > xChild + uno::Reference< star::ucb::XContent > xChild = xChildAccess->queryContent(); if ( xChild.is() ) { // Recursion! - GlobalTransferCommandArgument aTransArg( - rArg.Operation, // Operation + star::ucb::GlobalTransferCommandArgument aTransArg( + rContext.aArg.Operation, // Operation xChild->getIdentifier() ->getContentIdentifier(), // SourceURL xNew->getIdentifier() ->getContentIdentifier(), // TargetURL rtl::OUString(), // NewTitle; - rArg.NameClash ); // NameClash + rContext.aArg.NameClash ); // NameClash - ucb_commands::globalTransfer( - xSMgr, xChild, xNew, aTransArg, xChildRow, xEnv ); + ucb_commands::globalTransfer( rContext, + xChild, + xNew, + xChildRow ); } } while ( xResultSet->next() ); @@ -1054,21 +1280,22 @@ static void globalTransfer( const uno::Reference< // //========================================================================= -uno::Reference< XCommandInfo > UniversalContentBroker::getCommandInfo() +uno::Reference< star::ucb::XCommandInfo > +UniversalContentBroker::getCommandInfo() { - return uno::Reference< XCommandInfo >( + return uno::Reference< star::ucb::XCommandInfo >( new ucb_commands::CommandProcessorInfo() ); } //========================================================================= void UniversalContentBroker::globalTransfer( - const GlobalTransferCommandArgument & rArg, - const uno::Reference< XCommandEnvironment > & xEnv ) + const star::ucb::GlobalTransferCommandArgument & rArg, + const uno::Reference< star::ucb::XCommandEnvironment > & xEnv ) throw( uno::Exception ) { // Remote optimization: Supply own task environment, which caches (remote) // interfaces (progress handler, interaction handler, ...) locally. - uno::Reference< XCommandEnvironment > xLocalEnv( + uno::Reference< star::ucb::XCommandEnvironment > xLocalEnv( new ::ucb::CommandEnvironmentProxy( xEnv ) ); ////////////////////////////////////////////////////////////////////// @@ -1077,38 +1304,59 @@ void UniversalContentBroker::globalTransfer( // ////////////////////////////////////////////////////////////////////// - uno::Reference< XContent > xTarget; - try - { - uno::Reference< XContentIdentifier > xId + uno::Reference< star::ucb::XContent > xTarget; + uno::Reference< star::ucb::XContentIdentifier > xId = createContentIdentifier( rArg.TargetURL ); - if ( xId.is() ) - xTarget = queryContent( xId ); - } - catch ( IllegalIdentifierException const & ) + if ( xId.is() ) { + try + { + xTarget = queryContent( xId ); + } + catch ( star::ucb::IllegalIdentifierException const & ) + { + } } if ( !xTarget.is() ) - throw CommandAbortedException(); // no target content + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rArg.TargetURL, + xEnv, + rtl::OUString::createFromAscii( + "Can't instanciate target object!" ), + this ); + // Unreachable + } - if ( ( rArg.Operation == TransferCommandOperation_COPY ) || - ( rArg.Operation == TransferCommandOperation_MOVE ) ) + if ( ( rArg.Operation == star::ucb::TransferCommandOperation_COPY ) || + ( rArg.Operation == star::ucb::TransferCommandOperation_MOVE ) ) { - uno::Reference< XCommandProcessor > xCommandProcessor( - xTarget, uno::UNO_QUERY ); + uno::Reference< star::ucb::XCommandProcessor > xCommandProcessor( + xTarget, uno::UNO_QUERY ); if ( !xCommandProcessor.is() ) - ucb_commands::abort( "Target is not a XCommandProcessor!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rArg.TargetURL, + xEnv, + rtl::OUString::createFromAscii( + "Target content is not a XCommandProcessor!" ), + this ); + // Unreachable + } try { - TransferInfo aTransferArg( - ( rArg.Operation == TransferCommandOperation_MOVE ), // MoveData + star::ucb::TransferInfo aTransferArg( + ( rArg.Operation + == star::ucb::TransferCommandOperation_MOVE ), // MoveData rArg.SourceURL, // SourceURL rArg.NewTitle, // NewTitle rArg.NameClash ); // NameClash - Command aCommand( + star::ucb::Command aCommand( rtl::OUString::createFromAscii( "transfer" ), // Name -1, // Handle uno::makeAny( aTransferArg ) ); // Argument @@ -1118,15 +1366,12 @@ void UniversalContentBroker::globalTransfer( // Command succeeded. We're done. return; } - catch ( InteractiveBadTransferURLException const & ) + catch ( star::ucb::InteractiveBadTransferURLException const & ) { // Source URL is not supported by target. Try to transfer // the content "manually". } /* - catch ( CommandAbortedException const & ) - { - } catch ( uno::Exception const & ) { } @@ -1139,25 +1384,43 @@ void UniversalContentBroker::globalTransfer( // ////////////////////////////////////////////////////////////////////// - uno::Reference< XContent > xSource; + uno::Reference< star::ucb::XContent > xSource; try { - uno::Reference< XContentIdentifier > xId + uno::Reference< star::ucb::XContentIdentifier > xId = createContentIdentifier( rArg.SourceURL ); if ( xId.is() ) xSource = queryContent( xId ); } - catch ( IllegalIdentifierException const & ) + catch ( star::ucb::IllegalIdentifierException const & ) { } if ( !xSource.is() ) - throw CommandAbortedException(); // no source content + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rArg.SourceURL, + xEnv, + rtl::OUString::createFromAscii( + "Can't instanciate source object!" ), + this ); + // Unreachable + } - uno::Reference< XCommandProcessor > xCommandProcessor( + uno::Reference< star::ucb::XCommandProcessor > xCommandProcessor( xSource, uno::UNO_QUERY ); if ( !xCommandProcessor.is() ) - ucb_commands::abort( "Source is not a XCommandProcessor!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rArg.SourceURL, + xEnv, + rtl::OUString::createFromAscii( + "Source content is not a XCommandProcessor!" ), + this ); + // Unreachable + } // Obtain interesting property values from source... @@ -1170,7 +1433,7 @@ void UniversalContentBroker::globalTransfer( aProps[ 2 ].Name = rtl::OUString::createFromAscii( "TargetURL" ); aProps[ 2 ].Handle = -1; /* unknown */ - Command aGetPropsCommand( + star::ucb::Command aGetPropsCommand( rtl::OUString::createFromAscii( "getPropertyValues" ), -1, uno::makeAny( aProps ) ); @@ -1179,11 +1442,21 @@ void UniversalContentBroker::globalTransfer( xCommandProcessor->execute( aGetPropsCommand, 0, xLocalEnv ) >>= xRow; if ( !xRow.is() ) - ucb_commands::abort( "Unable to get properties from source object!" ); + { + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + rArg.SourceURL, + xEnv, + rtl::OUString::createFromAscii( + "Unable to get properties from source object!" ), + this ); + // Unreachable + } // Do it! ucb_commands::globalTransfer( - m_xSMgr, xSource, xTarget, rArg, xRow, xLocalEnv ); + ucb_commands::TransferCommandContext( m_xSMgr, this, xLocalEnv, rArg ), + xSource, xTarget, xRow ); ////////////////////////////////////////////////////////////////////// // @@ -1191,11 +1464,11 @@ void UniversalContentBroker::globalTransfer( // ////////////////////////////////////////////////////////////////////// - if ( rArg.Operation == TransferCommandOperation_MOVE ) + if ( rArg.Operation == star::ucb::TransferCommandOperation_MOVE ) { try { - Command aCommand( + star::ucb::Command aCommand( rtl::OUString::createFromAscii( "delete" ), // Name -1, // Handle uno::makeAny( sal_Bool( sal_True ) ) ); // Argument diff --git a/ucb/source/ucp/webdav/DAVException.hxx b/ucb/source/ucp/webdav/DAVException.hxx index fe0994336b32..bd03ed68e0a2 100644 --- a/ucb/source/ucp/webdav/DAVException.hxx +++ b/ucb/source/ucp/webdav/DAVException.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVException.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:29:59 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,31 +72,45 @@ namespace webdav_ucp class DAVException { public: - enum ExceptionCode { DAV_HTTP_LOOKUP = 0, - DAV_HTTP_ERROR, - DAV_HTTP_AUTH, - DAV_HTTP_REDIRECT, - DAV_SESSION_CREATE, - DAV_REQUEST_CREATE, - DAV_INVALID_ARG, - DAV_FILE_OPEN, - DAV_FILE_WRITE, - DAV_UNKNOWN }; + enum ExceptionCode { + DAV_HTTP_ERROR = 0, // Generic error, mData = error message + DAV_HTTP_LOOKUP, // Name lookup failed, mData = server[:port] + DAV_HTTP_AUTH, // User authentication failed on server + DAV_HTTP_AUTHPROXY, // User authentication failed on proxy + DAV_HTTP_SERVERAUTH,// Server authentication failed + DAV_HTTP_PROXYAUTH, // Proxy authentication failed + DAV_HTTP_CONNECT, // Could not connect to server, mData = server[:port] + DAV_HTTP_TIMEOUT, // Connection timed out + DAV_HTTP_FAILED, // The precondition failed + DAV_HTTP_RETRY, // Retry request (http_end_request ONLY) + DAV_HTTP_REDIRECT, // See http_redirect.h, mData = new URL + DAV_SESSION_CREATE, // session creation error, mData = server[:port] + DAV_INVALID_ARG, + DAV_FILE_OPEN, // mData = file URL + DAV_FILE_WRITE }; // mData = file URL private: ExceptionCode mExceptionCode; rtl::OUString mData; + sal_uInt16 mStatusCode; public: DAVException( ExceptionCode inExceptionCode ) : - mExceptionCode( inExceptionCode ) {}; + mExceptionCode( inExceptionCode ), mStatusCode( 0 ) {}; DAVException( ExceptionCode inExceptionCode, const rtl::OUString & rData ) : - mExceptionCode( inExceptionCode ), mData( rData ) {}; + mExceptionCode( inExceptionCode ), mData( rData ), + mStatusCode( 0 ) {}; + DAVException( ExceptionCode inExceptionCode, + const rtl::OUString & rData, + sal_uInt16 nStatusCode ) : + mExceptionCode( inExceptionCode ), mData( rData ), + mStatusCode( nStatusCode ) {}; ~DAVException( ) {}; const ExceptionCode & getError() const { return mExceptionCode; } const rtl::OUString & getData() const { return mData; } + sal_uInt16 getStatus() const { return mStatusCode; } }; }; // namespace webdav_ucp diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index 1fa95a3d9711..5f5750d00490 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVResourceAccess.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: kso $ $Date: 2001-05-29 09:22:56 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -165,7 +165,7 @@ int AuthListener::authenticate( const ::rtl::OUString & inRealm, } } } - // abort. + // Abort. return -1; } @@ -191,7 +191,11 @@ DAVResourceAccess::DAVResourceAccess( m_pSessionFactory( pSessionFactory ) { if ( !initialize( rURL ) ) - throw DAVException( DAVException::DAV_SESSION_CREATE ); + { + NeonUri theUri( rURL ); + throw DAVException( DAVException::DAV_SESSION_CREATE, + theUri.makeConnectionEndPointString() ); + } } //========================================================================= @@ -199,7 +203,11 @@ void DAVResourceAccess::setURL( const rtl::OUString & rNewURL ) throw( DAVException ) { if ( !initialize( rNewURL ) ) - throw DAVException( DAVException::DAV_SESSION_CREATE ); + { + NeonUri theUri( rNewURL ); + throw DAVException( DAVException::DAV_SESSION_CREATE, + theUri.makeConnectionEndPointString() ); + } } //========================================================================= @@ -495,6 +503,7 @@ void DAVResourceAccess::UNLOCK ( const ucb::Lock & rLock, //========================================================================= // init dav session and path sal_Bool DAVResourceAccess::initialize( const rtl::OUString & rURL ) + throw ( DAVException ) { NeonUri aURI( rURL ); @@ -505,17 +514,9 @@ sal_Bool DAVResourceAccess::initialize( const rtl::OUString & rURL ) return sal_False; } - try - { - // set the webdav session - m_xSession = m_pSessionFactory->createDAVSession( rURL, m_xSMgr ); - m_xSession->setServerAuthListener( &webdavAuthListener ); - } - catch ( DAVException & ) - { - OSL_ENSURE( sal_False, "DAVResourceAccess::initialize - DAVException" ); - return sal_False; - } + // set the webdav session + m_xSession = m_pSessionFactory->createDAVSession( rURL, m_xSMgr ); + m_xSession->setServerAuthListener( &webdavAuthListener ); return sal_True; } @@ -526,10 +527,20 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e ) switch ( e.getError() ) { case DAVException::DAV_HTTP_REDIRECT: - // set new path and session - return initialize( e.getData() ); + try + { + // set new path and session + return initialize( e.getData() ); + } + catch( DAVException const & ) + { + } + return sal_False; case DAVException::DAV_HTTP_AUTH: + case DAVException::DAV_HTTP_AUTHPROXY: + case DAVException::DAV_HTTP_SERVERAUTH: + case DAVException::DAV_HTTP_PROXYAUTH: // Retry. If user cancels the login request, // we will get DAV_HTTP_ERROR and abort. return sal_True; diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.hxx b/ucb/source/ucp/webdav/DAVResourceAccess.hxx index 01ade3feb4dd..6f50b9134b45 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.hxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVResourceAccess.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: kso $ $Date: 2001-05-16 14:58:06 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,8 +67,8 @@ #ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> #endif #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ @@ -108,8 +108,8 @@ class DAVSessionFactory; class DAVResourceAccess { rtl::OUString m_aPath; - ::vos::ORef< DAVSession > m_xSession; - DAVSessionFactory* m_pSessionFactory; + rtl::Reference< DAVSession > m_xSession; + DAVSessionFactory* m_pSessionFactory; com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; @@ -217,8 +217,8 @@ public: private: sal_Bool handleException( DAVException & e ); - sal_Bool initialize( const rtl::OUString & rURL ); - + sal_Bool initialize( const rtl::OUString & rURL ) + throw ( DAVException ); }; }; // namespace webdav_ucp diff --git a/ucb/source/ucp/webdav/DAVSessionFactory.cxx b/ucb/source/ucp/webdav/DAVSessionFactory.cxx index 8baa8f467de8..9446bebda19c 100644 --- a/ucb/source/ucp/webdav/DAVSessionFactory.cxx +++ b/ucb/source/ucp/webdav/DAVSessionFactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVSessionFactory.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:29:59 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,8 +58,13 @@ * * ************************************************************************/ + +#ifndef _DAVSESSIONFACTORY_HXX_ #include "DAVSessionFactory.hxx" +#endif +#ifndef _NEONSESSION_HXX_ #include "NeonSession.hxx" +#endif #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -70,20 +75,21 @@ using namespace com::sun::star; DAVSessionFactory::~DAVSessionFactory() { - if ( m_xProxySettings.isValid() ) + if ( m_xProxySettings.is() ) { m_xProxySettings->dispose(); m_xProxySettings = 0; } } -vos::ORef< DAVSession > DAVSessionFactory::createDAVSession( +rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession( const ::rtl::OUString & inUri, const uno::Reference< lang::XMultiServiceFactory > & rxSMgr ) + throw( DAVException ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( !m_xProxySettings.isValid() ) + if ( !m_xProxySettings.is() ) m_xProxySettings = new ProxySettings( rxSMgr ); DAVSession * theSession = GetExistingSession( inUri ); diff --git a/ucb/source/ucp/webdav/DAVSessionFactory.hxx b/ucb/source/ucp/webdav/DAVSessionFactory.hxx index f1a86b1c83d9..f0c88899d112 100644 --- a/ucb/source/ucp/webdav/DAVSessionFactory.hxx +++ b/ucb/source/ucp/webdav/DAVSessionFactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DAVSessionFactory.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kso $ $Date: 2001-02-02 07:26:40 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,8 +62,13 @@ #define _DAVSESSIONFACTORY_HXX_ #include <vector> -#include <rtl/ustring.hxx> -#include <vos/ref.hxx> + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif #ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ #include <com/sun/star/uno/Reference.hxx> @@ -72,6 +77,9 @@ #ifndef _PROXYCONFIG_HXX_ #include "proxyconfig.hxx" #endif +#ifndef _DAVEXCEPTION_HXX_ +#include "DAVException.hxx" +#endif namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; @@ -85,17 +93,18 @@ class DAVSession; class DAVSessionFactory { osl::Mutex m_aMutex; - ::vos::ORef< ProxySettings > m_xProxySettings; + rtl::Reference< ProxySettings > m_xProxySettings; std::vector< DAVSession * > sActiveSessions; public: ~DAVSessionFactory(); - ::vos::ORef< DAVSession > + rtl::Reference< DAVSession > createDAVSession( const ::rtl::OUString & inUri, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& - rxSMgr ); + rxSMgr ) + throw( DAVException ); void ReleaseDAVSession( DAVSession * inSession ); diff --git a/ucb/source/ucp/webdav/NeonInputStream.hxx b/ucb/source/ucp/webdav/NeonInputStream.hxx index 9cc4cfc0e640..4a88fa80fc2b 100644 --- a/ucb/source/ucp/webdav/NeonInputStream.hxx +++ b/ucb/source/ucp/webdav/NeonInputStream.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonInputStream.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: kso $ $Date: 2000-11-10 14:36:08 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,10 +61,19 @@ #ifndef _NEONINPUTSTREAM_HXX_ #define _NEONINPUTSTREAM_HXX_ -#include <cppuhelper/weak.hxx> +#ifndef _SAL_TYPES_H_ #include <sal/types.h> +#endif +#ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> +#endif +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif + +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ #include <com/sun/star/io/XInputStream.hpp> +#endif #ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_ #include <com/sun/star/io/XSeekable.hpp> #endif diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index 754a54521388..0ddf0ef9a906 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonSession.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,6 +110,31 @@ using namespace webdav_ucp; sal_Bool NeonSession::sSockInited = sal_False; // ------------------------------------------------------------------- +// Helper fuction +// ------------------------------------------------------------------- +static sal_uInt16 makeStatusCode( const rtl::OUString & rStatusText ) +{ + // Extract status code from session error string. Unfortunately + // neon provides no direct access to the status code... + + if ( rStatusText.getLength() < 3 ) + { + OSL_ENSURE( + sal_False, "makeStatusCode - status text string to short!" ); + return 0; + } + + sal_Int32 nPos = rStatusText.indexOf( ' ' ); + if ( nPos == -1 ) + { + OSL_ENSURE( sal_False, "makeStatusCode - wrong status text format!" ); + return 0; + } + + return sal_uInt16( rStatusText.copy( 0, nPos ).toInt32() ); +} + +// ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- NeonSession::NeonSession( DAVSessionFactory* pSessionFactory, @@ -123,28 +148,31 @@ NeonSession::NeonSession( DAVSessionFactory* pSessionFactory, // to that buffer (last verified with neon 0.11.0)!!! We do this // by having the members mHostName and mProxyName, which are OStrings! - Init(); NeonUri theUri( inUri ); - mHostName = OUStringToOString( theUri.GetHost(), RTL_TEXTENCODING_UTF8 ); + mHostName = theUri.GetHost(); mPort = theUri.GetPort(); - mProxyName = OUStringToOString( rProxyCfg.aName, RTL_TEXTENCODING_UTF8 ); + mProxyName = rProxyCfg.aName; mProxyPort = rProxyCfg.nPort; + Init(); + mHttpSession = CreateSession( mHostName, theUri.GetPort(), mProxyName, rProxyCfg.nPort ); if ( mHttpSession == NULL ) - throw DAVException( DAVException::DAV_SESSION_CREATE ); + throw DAVException( DAVException::DAV_SESSION_CREATE, + theUri.makeConnectionEndPointString() ); // Note: Uncomment the following if locking support is required /* mNeonLockSession = dav_lock_register( mHttpSession ); if ( mNeonLockSession == NULL ) - throw DAVException( DAVException::DAV_SESSION_CREATE ); + throw DAVException( DAVException::DAV_SESSION_CREATE, + theUri::makeConnectionEndPointString() ); */ // Register redirect callbacks. @@ -179,8 +207,7 @@ sal_Bool NeonSession::CanUse( const OUString & inUri ) sal_Bool IsConnected = sal_False; NeonUri theUri( inUri ); if ( ( theUri.GetPort() == mPort ) && - ( OUStringToOString( theUri.GetHost(), RTL_TEXTENCODING_UTF8 ) - == mHostName ) ) + ( theUri.GetHost() == mHostName ) ) IsConnected = sal_True; return IsConnected; } @@ -591,7 +618,9 @@ void NeonSession::Init( void ) if ( sSockInited == sal_False ) { if ( sock_init() != 0 ) - throw DAVException( DAVException::DAV_SESSION_CREATE ); + throw DAVException( DAVException::DAV_SESSION_CREATE, + NeonUri::makeConnectionEndPointString( + mHostName, mPort ) ); sSockInited = sal_True; } } @@ -603,6 +632,7 @@ void NeonSession::Init( void ) void NeonSession::HandleError( int nError ) throw ( DAVException ) { + // Map error code to DAVException. switch ( nError ) { case HTTP_OK: @@ -613,15 +643,59 @@ void NeonSession::HandleError( int nError ) return; } - case HTTP_AUTH: - throw DAVException( DAVException::DAV_HTTP_AUTH ); + case HTTP_ERROR: // Generic error + { + OUString aText = OUString::createFromAscii( + http_get_error( mHttpSession ) ); + throw DAVException( DAVException::DAV_HTTP_ERROR, + aText, + makeStatusCode( aText ) ); + } + + case HTTP_LOOKUP: // Name lookup failed. + throw DAVException( DAVException::DAV_HTTP_LOOKUP, + NeonUri::makeConnectionEndPointString( + mHostName, mPort ) ); + + case HTTP_AUTH: // User authentication failed on server + throw DAVException( DAVException::DAV_HTTP_AUTH, + NeonUri::makeConnectionEndPointString( + mHostName, mPort ) ); + + case HTTP_AUTHPROXY: // User authentication failed on proxy + throw DAVException( DAVException::DAV_HTTP_AUTHPROXY, + NeonUri::makeConnectionEndPointString( + mProxyName, mProxyPort ) ); + + case HTTP_SERVERAUTH: // Server authentication failed + throw DAVException( DAVException::DAV_HTTP_SERVERAUTH, + NeonUri::makeConnectionEndPointString( + mHostName, mPort ) ); + + case HTTP_PROXYAUTH: // Proxy authentication failed + throw DAVException( DAVException::DAV_HTTP_PROXYAUTH, + NeonUri::makeConnectionEndPointString( + mProxyName, mProxyPort ) ); + + case HTTP_CONNECT: // Could not connect to server + throw DAVException( DAVException::DAV_HTTP_CONNECT, + NeonUri::makeConnectionEndPointString( + mHostName, mPort ) ); + +#if 0 + case HTTP_TIMEOUT: // Connection timed out + case HTTP_FAILED: // The precondition failed + case HTTP_RETRY: // Retry request (http_end_request ONLY) +#endif case HTTP_REDIRECT: throw DAVException( DAVException::DAV_HTTP_REDIRECT, OUString::createFromAscii( http_redirect_location( mHttpSession ) ) ); default: - throw DAVException( DAVException::DAV_HTTP_ERROR ); + throw DAVException( DAVException::DAV_HTTP_ERROR, + OUString::createFromAscii( + http_get_error( mHttpSession ) ) ); } } @@ -629,9 +703,9 @@ void NeonSession::HandleError( int nError ) // CreateSession // Creates a new neon session. // ------------------------------------------------------------------- -HttpSession * NeonSession::CreateSession( const OString & inHostName, +HttpSession * NeonSession::CreateSession( const OUString & inHostName, int inPort, - const OString & inProxyName, + const OUString & inProxyName, int inProxyPort ) throw ( DAVException ) { @@ -640,23 +714,42 @@ HttpSession * NeonSession::CreateSession( const OString & inHostName, HttpSession * theHttpSession; if ( ( theHttpSession = http_session_create() ) == NULL ) - throw DAVException( DAVException::DAV_SESSION_CREATE ); + throw DAVException( DAVException::DAV_SESSION_CREATE, + NeonUri::makeConnectionEndPointString( + inHostName, inPort ) ); + + // Set a progress callback for the session. + http_set_progress( theHttpSession, ProgressNotify, theHttpSession ); + + // Set a status notification callback for the session, to report + // connection status. + http_set_status( theHttpSession, StatusNotify, theHttpSession ); if ( inProxyName.getLength() ) { - if ( http_session_proxy( - theHttpSession, inProxyName.getStr(), inProxyPort ) != HTTP_OK ) + if ( http_session_proxy( theHttpSession, + OUStringToOString( inProxyName, + RTL_TEXTENCODING_UTF8 ) + .getStr(), + inProxyPort ) != HTTP_OK ) { http_session_destroy( theHttpSession ); - throw DAVException( DAVException::DAV_HTTP_LOOKUP ); + throw DAVException( DAVException::DAV_HTTP_LOOKUP, + NeonUri::makeConnectionEndPointString( + inProxyName, inProxyPort ) ); } } - if ( http_session_server( - theHttpSession, inHostName.getStr(), inPort ) != HTTP_OK ) + if ( http_session_server( theHttpSession, + OUStringToOString( inHostName, + RTL_TEXTENCODING_UTF8 ) + .getStr(), + inPort ) != HTTP_OK ) { http_session_destroy( theHttpSession ); - throw DAVException( DAVException::DAV_HTTP_LOOKUP ); + throw DAVException( DAVException::DAV_HTTP_LOOKUP, + NeonUri::makeConnectionEndPointString( + inHostName, inPort ) ); } return theHttpSession; @@ -787,8 +880,7 @@ int NeonSession::NeonAuth( void * inUserData, int theRetVal = theSession->mListener->authenticate( OUString::createFromAscii( inRealm ), - OStringToOUString( theSession->mHostName, - RTL_TEXTENCODING_UTF8 ), + theSession->mHostName, theUserNameBuffer, thePassWordBuffer, theSession->mEnv ); @@ -833,3 +925,26 @@ void NeonSession::RedirectNotify( // NeonSession * theSession = ( NeonSession * )userdata; } +// static +void NeonSession::ProgressNotify( void * userdata, off_t progress, off_t total ) +{ + // progress: bytes read so far + // total: total bytes to read, -1 -> total count not known +} + +// static +void NeonSession::StatusNotify( + void * userdata, http_conn_status status, const char *info ) +{ +#if 0 + typedef enum { + http_conn_namelookup, /* lookup up hostname (info = hostname) */ + http_conn_connecting, /* connecting to host (info = hostname) */ + http_conn_connected, /* connected to host (info = hostname) */ + http_conn_secure /* connection now secure (info = crypto level) */ + } http_conn_status; +#endif + + // info: hostname +} + diff --git a/ucb/source/ucp/webdav/NeonSession.hxx b/ucb/source/ucp/webdav/NeonSession.hxx index be5f1a0cda62..f0bec26a1964 100644 --- a/ucb/source/ucp/webdav/NeonSession.hxx +++ b/ucb/source/ucp/webdav/NeonSession.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonSession.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,8 +87,8 @@ class NeonSession : public DAVSession { private: osl::Mutex mMutex; - rtl::OString mHostName; - rtl::OString mProxyName; + rtl::OUString mHostName; + rtl::OUString mProxyName; sal_Int32 mPort; sal_Int32 mProxyPort; HttpSession * mHttpSession; @@ -105,7 +105,7 @@ class NeonSession : public DAVSession rtl::OUString mPrevPassWord; public: - NeonSession( DAVSessionFactory* psessionFactory, + NeonSession( DAVSessionFactory* pSessionFactory, const rtl::OUString& inUri, const ProxyConfig& rProxyCfg ) throw ( DAVException ); @@ -214,9 +214,9 @@ class NeonSession : public DAVSession throw ( DAVException ); // Create a Neon session for server at supplied host & port - HttpSession * CreateSession( const ::rtl::OString & inHostName, + HttpSession * CreateSession( const ::rtl::OUString & inHostName, int inPort, - const ::rtl::OString & inProxyName, + const ::rtl::OUString & inProxyName, int inProxyPort ) throw( DAVException ); @@ -249,6 +249,16 @@ class NeonSession : public DAVSession static void RedirectNotify( void * userdata, const char * src, const char * dest ); + + // Progress / Status callbacks. + static void NeonSession::ProgressNotify( void * userdata, + off_t progress, + off_t total ); + + // static + static void NeonSession::StatusNotify( void * userdata, + http_conn_status status, + const char *info ); }; }; // namespace_ucp diff --git a/ucb/source/ucp/webdav/NeonTypes.hxx b/ucb/source/ucp/webdav/NeonTypes.hxx index f4026bece91b..8c8833c8399d 100644 --- a/ucb/source/ucp/webdav/NeonTypes.hxx +++ b/ucb/source/ucp/webdav/NeonTypes.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonTypes.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,11 @@ #include <dav_props.h> #endif +#ifdef WIN32 +// http_request.h -> nsocket.h -> winsock2.h defines ERROR!!! +#undef ERROR +#endif + typedef http_session HttpSession; typedef http_req HttpRequest; typedef http_status HttpStatus; diff --git a/ucb/source/ucp/webdav/NeonUri.cxx b/ucb/source/ucp/webdav/NeonUri.cxx index 717027a54fa8..993ea8385bee 100644 --- a/ucb/source/ucp/webdav/NeonUri.cxx +++ b/ucb/source/ucp/webdav/NeonUri.cxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonUri.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: kso $ $Date: 2001-05-17 09:15:49 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,573 +59,37 @@ * ************************************************************************/ -#include "NeonUri.hxx" -#include "DAVException.hxx" - -#ifndef _RTL_TEXTENC_H -#include <rtl/textenc.h> -#endif -#ifndef _RTL_USTRBUF_HXX_ -#include <rtl/ustrbuf.hxx> +#ifndef _RTL_URI_HXX_ +#include <rtl/uri.hxx> #endif #ifndef _RTL_OUSTRING_HXX_ #include <rtl/ustring.hxx> #endif -#ifndef _SAL_TYPES_H_ -#include <sal/types.h> + +#ifndef _NEONURI_HXX_ +#include "NeonUri.hxx" #endif -#ifndef _VOS_DIAGNOSE_H_ -#include <vos/diagnose.hxx> +#ifndef _DAVEXCEPTION_HXX_ +#include "DAVException.hxx" #endif -using namespace rtl; using namespace webdav_ucp; -//============================================================================ -namespace webdav_ucp_impl { - -inline bool isUSASCII(sal_uInt32 nChar) -{ - return nChar <= 0x7F; -} - -inline bool isVisible(sal_uInt32 nChar) -{ - return nChar >= '!' && nChar <= '~'; -} - -inline bool isDigit(sal_uInt32 nChar) -{ - return nChar >= '0' && nChar <= '9'; -} - -inline int getHexWeight(sal_uInt32 nChar) -{ - return isDigit(nChar) ? int(nChar - '0') : - nChar >= 'A' && nChar <= 'F' ? int(nChar - 'A' + 10) : - nChar >= 'a' && nChar <= 'f' ? int(nChar - 'a' + 10) : -1; -} - -inline bool isHighSurrogate(sal_uInt32 nUTF16) -{ - return nUTF16 >= 0xD800 && nUTF16 <= 0xDBFF; -} - -inline bool isLowSurrogate(sal_uInt32 nUTF16) -{ - return nUTF16 >= 0xDC00 && nUTF16 <= 0xDFFF; -} - -inline sal_uInt32 getUTF32Character(sal_Unicode const *& rBegin, - sal_Unicode const * pEnd) -{ - VOS_ASSERT(rBegin && rBegin < pEnd); - if (rBegin + 1 < pEnd && rBegin[0] >= 0xD800 && rBegin[0] <= 0xDBFF - && rBegin[1] >= 0xDC00 && rBegin[1] <= 0xDFFF) - { - sal_uInt32 nUTF32 = sal_uInt32(*rBegin++ & 0x3FF) << 10; - return (nUTF32 | (*rBegin++ & 0x3FF)) + 0x10000; - } - else - return *rBegin++; -} - -sal_uInt32 getHexDigit(int nWeight) -{ - VOS_ASSERT(nWeight >= 0 && nWeight < 16); - static sal_Char const aDigits[16] - = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', - 'D', 'E', 'F' }; - return aDigits[nWeight]; -} - -enum EncodeMechanism -{ - ENCODE_ALL, - WAS_ENCODED, - NOT_CANONIC -}; - -enum DecodeMechanism -{ - NO_DECODE, - DECODE_TO_IURI, - DECODE_WITH_CHARSET -}; - -enum Part -{ - PART_OBSOLETE_NORMAL = 0x001, // Obsolete, do not use! - PART_OBSOLETE_FILE = 0x002, // Obsolete, do not use! - PART_OBSOLETE_PARAM = 0x004, // Obsolete, do not use! - PART_USER_PASSWORD = 0x008, - PART_IMAP_ACHAR = 0x010, - PART_VIM = 0x020, - PART_HOST_EXTRA = 0x040, - PART_FPATH = 0x080, - PART_AUTHORITY = 0x100, - PART_PATH_SEGMENTS_EXTRA = 0x200, - PART_REL_SEGMENT_EXTRA = 0x400, - PART_URIC = 0x800, - PART_HTTP_PATH = 0x1000, - PART_FILE_SEGMENT_EXTRA = 0x2000, // Obsolete, do not use! - PART_MESSAGE_ID = 0x4000, - PART_MESSAGE_ID_PATH = 0x8000, - PART_MAILTO = 0x10000, - PART_PATH_BEFORE_QUERY = 0x20000, - PART_PCHAR = 0x40000, - PART_FRAGMENT = 0x80000, // Obsolete, do not use! - PART_VISIBLE = 0x100000, - max_part = 0x80000000 - // Do not use! Only there to allow compatible changes in the future. -}; - -enum EscapeType -{ - ESCAPE_NO, - ESCAPE_OCTET, - ESCAPE_UTF32 -}; - -inline void appendEscape(rtl::OUStringBuffer & rTheText, - sal_Char cEscapePrefix, sal_uInt32 nOctet) -{ - rTheText.append(sal_Unicode(cEscapePrefix)); - rTheText.append(sal_Unicode(getHexDigit(int(nOctet >> 4)))); - rTheText.append(sal_Unicode(getHexDigit(int(nOctet & 15)))); -} - -inline bool mustEncode(sal_uInt32 nUTF32, Part ePart) -{ - enum - { - pA = PART_OBSOLETE_NORMAL, - pB = PART_OBSOLETE_FILE, - pC = PART_OBSOLETE_PARAM, - pD = PART_USER_PASSWORD, - pE = PART_IMAP_ACHAR, - pF = PART_VIM, - pG = PART_HOST_EXTRA, - pH = PART_FPATH, - pI = PART_AUTHORITY, - pJ = PART_PATH_SEGMENTS_EXTRA, - pK = PART_REL_SEGMENT_EXTRA, - pL = PART_URIC, - pM = PART_HTTP_PATH, - pN = PART_FILE_SEGMENT_EXTRA, - pO = PART_MESSAGE_ID, - pP = PART_MESSAGE_ID_PATH, - pQ = PART_MAILTO, - pR = PART_PATH_BEFORE_QUERY, - pS = PART_PCHAR, - pT = PART_FRAGMENT, - pU = PART_VISIBLE - }; - static sal_uInt32 const aMap[128] - = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* */ 0, - /* ! */ pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* " */ pU, - /* # */ pU, - /* $ */ pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* % */ pU, - /* & */ pA+pB+pC+pD+pE +pH+pI+pJ+pK+pL+pM+pN+pO+pP +pR+pS+pT+pU, - /* ' */ pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* ( */ pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* ) */ pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* * */ pA+pB+pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* + */ pA+pB+pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* , */ pA+pB+pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* - */ pA+pB+pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* . */ pA+pB+pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* / */ pA+pB+pC +pH +pJ +pL+pM +pP+pQ+pR +pT+pU, - /* 0 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 1 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 2 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 3 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 4 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 5 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 6 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 7 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 8 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* 9 */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* : */ pB+pC +pH+pI+pJ +pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* ; */ pC+pD +pI+pJ+pK+pL+pM +pO+pP+pQ+pR +pT+pU, - /* < */ pC +pO+pP +pU, - /* = */ pA+pB+pC+pD+pE +pH+pI+pJ+pK+pL+pM+pN +pR+pS+pT+pU, - /* > */ pC +pO+pP +pU, - /* ? */ pC +pL +pT+pU, - /* @ */ pC +pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* A */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* B */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* C */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* D */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* E */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* F */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* G */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* H */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* I */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* J */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* K */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* L */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* M */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* N */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* O */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* P */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* Q */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* R */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* S */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* T */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* U */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* V */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* W */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* X */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* Y */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* Z */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* [ */ pL +pU, - /* \ */ pB +pU, - /* ] */ pL +pU, - /* ^ */ pU, - /* _ */ pA+pB+pC+pD+pE +pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* ` */ +pU, - /* a */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* b */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* c */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* d */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* e */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* f */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* g */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* h */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* i */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* j */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* k */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* l */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* m */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* n */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* o */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* p */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* q */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* r */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* s */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* t */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* u */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* v */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* w */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* x */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* y */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* z */ pA+pB+pC+pD+pE+pF+pG+pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* { */ +pU, - /* | */ pB+pC +pN +pT+pU, - /* } */ +pU, - /* ~ */ pA+pB+pC+pD+pE +pH+pI+pJ+pK+pL+pM+pN+pO+pP+pQ+pR+pS+pT+pU, - /* */ 0 }; - return !isUSASCII(nUTF32) || !(aMap[nUTF32] & ePart); -} - -void appendUCS4Escape(rtl::OUStringBuffer & rTheText, sal_Char cEscapePrefix, - sal_uInt32 nUCS4) -{ - VOS_ASSERT(nUCS4 < 0x80000000); - if (nUCS4 < 0x80) - appendEscape(rTheText, cEscapePrefix, nUCS4); - else if (nUCS4 < 0x800) - { - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 6 | 0xC0); - appendEscape(rTheText, cEscapePrefix, nUCS4 & 0x3F | 0x80); - } - else if (nUCS4 < 0x10000) - { - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 12 | 0xE0); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 6 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 & 0x3F | 0x80); - } - else if (nUCS4 < 0x200000) - { - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 18 | 0xF0); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 12 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 6 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 & 0x3F | 0x80); - } - else if (nUCS4 < 0x4000000) - { - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 24 | 0xF8); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 18 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 12 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 6 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 & 0x3F | 0x80); - } - else - { - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 30 | 0xFC); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 24 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 18 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 12 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 >> 6 & 0x3F | 0x80); - appendEscape(rTheText, cEscapePrefix, nUCS4 & 0x3F | 0x80); - } -} - -void appendUCS4(rtl::OUStringBuffer & rTheText, sal_uInt32 nUCS4, - EscapeType eEscapeType, bool bOctets, Part ePart, - sal_Char cEscapePrefix, rtl_TextEncoding eCharset, - bool bKeepVisibleEscapes) -{ - bool bEscape; - rtl_TextEncoding eTargetCharset; - switch (eEscapeType) - { - case ESCAPE_NO: - if (mustEncode(nUCS4, ePart)) - { - bEscape = true; - eTargetCharset = bOctets ? RTL_TEXTENCODING_ISO_8859_1 : - RTL_TEXTENCODING_UTF8; - } - else - bEscape = false; - break; - - case ESCAPE_OCTET: - bEscape = true; - eTargetCharset = RTL_TEXTENCODING_ISO_8859_1; - break; - - case ESCAPE_UTF32: - if (mustEncode(nUCS4, ePart)) - { - bEscape = true; - eTargetCharset = eCharset; - } - else if (bKeepVisibleEscapes && isVisible(nUCS4)) - { - bEscape = true; - eTargetCharset = RTL_TEXTENCODING_ASCII_US; - } - else - bEscape = false; - break; - } - if (bEscape) - switch (eTargetCharset) - { - default: - VOS_ASSERT(false); - case RTL_TEXTENCODING_ASCII_US: - case RTL_TEXTENCODING_ISO_8859_1: - appendEscape(rTheText, cEscapePrefix, nUCS4); - break; - - case RTL_TEXTENCODING_UTF8: - appendUCS4Escape(rTheText, cEscapePrefix, nUCS4); - break; - } - else - rTheText.append(sal_Unicode(nUCS4)); -} - -sal_uInt32 getUTF32(sal_Unicode const *& rBegin, sal_Unicode const * pEnd, - bool bOctets, sal_Char cEscapePrefix, - EncodeMechanism eMechanism, rtl_TextEncoding eCharset, - EscapeType & rEscapeType) -{ - VOS_ASSERT(rBegin < pEnd); - sal_uInt32 nUTF32 = bOctets ? *rBegin++ : getUTF32Character(rBegin, pEnd); - switch (eMechanism) - { - case ENCODE_ALL: - rEscapeType = ESCAPE_NO; - break; - - case WAS_ENCODED: - { - int nWeight1; - int nWeight2; - if (nUTF32 == cEscapePrefix && rBegin + 1 < pEnd - && (nWeight1 = getHexWeight(rBegin[0])) >= 0 - && (nWeight2 = getHexWeight(rBegin[1])) >= 0) - { - rBegin += 2; - nUTF32 = nWeight1 << 4 | nWeight2; - switch (eCharset) - { - default: - VOS_ASSERT(false); - case RTL_TEXTENCODING_ASCII_US: - rEscapeType - = isUSASCII(nUTF32) ? ESCAPE_UTF32 : ESCAPE_OCTET; - break; - - case RTL_TEXTENCODING_ISO_8859_1: - rEscapeType = ESCAPE_UTF32; - break; - - case RTL_TEXTENCODING_UTF8: - if (isUSASCII(nUTF32)) - rEscapeType = ESCAPE_UTF32; - else - { - if (nUTF32 >= 0xC0 && nUTF32 <= 0xF4) - { - sal_uInt32 nEncoded; - int nShift; - sal_uInt32 nMin; - if (nUTF32 <= 0xDF) - { - nEncoded = (nUTF32 & 0x1F) << 6; - nShift = 0; - nMin = 0x80; - } - else if (nUTF32 <= 0xEF) - { - nEncoded = (nUTF32 & 0x0F) << 12; - nShift = 6; - nMin = 0x800; - } - else - { - nEncoded = (nUTF32 & 0x07) << 18; - nShift = 12; - nMin = 0x10000; - } - sal_Unicode const * p = rBegin; - bool bUTF8 = true; - for (;;) - { - if (p + 2 >= pEnd || p[0] != cEscapePrefix - || (nWeight1 = getHexWeight(p[1])) < 0 - || (nWeight2 = getHexWeight(p[2])) < 0 - || nWeight1 < 8) - { - bUTF8 = false; - break; - } - p += 3; - nEncoded - |= ((nWeight1 & 3) << 4 | nWeight2) - << nShift; - if (nShift == 0) - break; - nShift -= 6; - } - if (bUTF8 && nEncoded >= nMin - && !isHighSurrogate(nEncoded) - && !isLowSurrogate(nEncoded) - && nEncoded <= 0x10FFFF) - { - rBegin = p; - nUTF32 = nEncoded; - rEscapeType = ESCAPE_UTF32; - break; - } - } - rEscapeType = ESCAPE_OCTET; - } - break; - } - } - else - rEscapeType = ESCAPE_NO; - break; - } - - case NOT_CANONIC: - { - int nWeight1; - int nWeight2; - if (nUTF32 == cEscapePrefix && rBegin + 1 < pEnd - && ((nWeight1 = getHexWeight(rBegin[0])) >= 0) - && ((nWeight2 = getHexWeight(rBegin[1])) >= 0)) - { - rBegin += 2; - nUTF32 = nWeight1 << 4 | nWeight2; - rEscapeType = ESCAPE_OCTET; - } - else - rEscapeType = ESCAPE_NO; - break; - } - } - return nUTF32; -} - -static rtl::OUString encodeText(sal_Unicode const * pBegin, - sal_Unicode const * pEnd, bool bOctets, - Part ePart, sal_Char cEscapePrefix, - EncodeMechanism eMechanism, - rtl_TextEncoding eCharset, - bool bKeepVisibleEscapes) -{ - rtl::OUStringBuffer aResult; - while (pBegin != pEnd) - { - EscapeType eEscapeType; - sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd, bOctets, cEscapePrefix, - eMechanism, eCharset, eEscapeType); - appendUCS4(aResult, nUTF32, eEscapeType, bOctets, ePart, - cEscapePrefix, eCharset, bKeepVisibleEscapes); - } - return aResult.makeStringAndClear(); -} - -static rtl::OUString decode(sal_Unicode const * pBegin, - sal_Unicode const * pEnd, sal_Char cEscapePrefix, - DecodeMechanism eMechanism, - rtl_TextEncoding eCharset) -{ - switch (eMechanism) - { - case NO_DECODE: - return rtl::OUString(pBegin, pEnd - pBegin); - - case DECODE_TO_IURI: - eCharset = RTL_TEXTENCODING_UTF8; - break; - } - rtl::OUStringBuffer aResult; - while (pBegin < pEnd) - { - EscapeType eEscapeType; - sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd, false, cEscapePrefix, - WAS_ENCODED, eCharset, eEscapeType); - switch (eEscapeType) - { - case ESCAPE_NO: - aResult.append(sal_Unicode(nUTF32)); - break; - - case ESCAPE_OCTET: - appendEscape(aResult, cEscapePrefix, nUTF32); - break; - - case ESCAPE_UTF32: - if (eMechanism == DECODE_TO_IURI && isUSASCII(nUTF32)) - appendEscape(aResult, cEscapePrefix, nUTF32); - else - aResult.append(sal_Unicode(nUTF32)); - break; - } - } - return aResult.makeStringAndClear(); -} - -} - uri NeonUri::sUriDefaultsHTTP = { "http", NULL, DEFAULT_HTTP_PORT, NULL }; uri NeonUri::sUriDefaultsHTTPS = { "https", NULL, DEFAULT_HTTPS_PORT, NULL }; // ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- -NeonUri::NeonUri( const OUString & inUri ) +NeonUri::NeonUri( const rtl::OUString & inUri ) { if ( inUri.getLength() <= 0 ) throw DAVException( DAVException::DAV_INVALID_ARG ); - OString theInputUri( + rtl::OString theInputUri( inUri.getStr(), inUri.getLength(), RTL_TEXTENCODING_UTF8 ); - OString aProtocol + rtl::OString aProtocol = theInputUri.copy( 0, RTL_CONSTASCII_LENGTH( "https:" ) ); uri theUri; @@ -638,10 +102,10 @@ NeonUri::NeonUri( const OUString & inUri ) throw DAVException( DAVException::DAV_INVALID_ARG ); } - mScheme = OStringToOUString( theUri.scheme, RTL_TEXTENCODING_UTF8 ); - mHostName = OStringToOUString( theUri.host, RTL_TEXTENCODING_UTF8 ); - mPort = theUri.port; - mPath = OStringToOUString( theUri.path, RTL_TEXTENCODING_UTF8 ); + mScheme = rtl::OStringToOUString( theUri.scheme, RTL_TEXTENCODING_UTF8 ); + mHostName = rtl::OStringToOUString( theUri.host, RTL_TEXTENCODING_UTF8 ); + mPort = theUri.port; + mPath = rtl::OStringToOUString( theUri.path, RTL_TEXTENCODING_UTF8 ); uri_free( &theUri ); @@ -658,10 +122,10 @@ NeonUri::~NeonUri( ) void NeonUri::calculateURI () { mURI = mScheme; - mURI += OUString::createFromAscii ("://"); + mURI += rtl::OUString::createFromAscii ("://"); mURI += mHostName; - mURI += OUString::createFromAscii (":"); - mURI += OUString::valueOf (mPort); + mURI += rtl::OUString::createFromAscii (":"); + mURI += rtl::OUString::valueOf (mPort); mURI += mPath; } @@ -678,7 +142,7 @@ void NeonUri::calculateURI () if (nPos != -1) return mPath.copy (nPos + 1, mPath.getLength () - nPos - 1 - nTrail); else - return OUString::createFromAscii ("/"); + return rtl::OUString::createFromAscii ("/"); } ::rtl::OUString NeonUri::GetPathBaseNameUnescaped () const @@ -697,38 +161,47 @@ void NeonUri::calculateURI () if (nPos != -1) return mPath.copy (0, nPos + 1); else - return OUString::createFromAscii ("/"); + return rtl::OUString::createFromAscii ("/"); } -void NeonUri::AppendPath (const OUString& path) +void NeonUri::AppendPath (const rtl::OUString& path) { if (mPath.lastIndexOf ('/') != mPath.getLength () - 1) - mPath += OUString::createFromAscii ("/"); + mPath += rtl::OUString::createFromAscii ("/"); mPath += path; calculateURI (); }; // static -OUString NeonUri::escapeSegment( const OUString& segment ) +rtl::OUString NeonUri::escapeSegment( const rtl::OUString& segment ) { - return webdav_ucp_impl::encodeText( segment.getStr(), - segment.getStr() + segment.getLength(), - false, - webdav_ucp_impl::PART_PCHAR, - '%', - webdav_ucp_impl::ENCODE_ALL, - RTL_TEXTENCODING_UTF8, - false); + return rtl::Uri::encode( segment, + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); } // static -OUString NeonUri::unescape( const OUString& string ) +rtl::OUString NeonUri::unescape( const rtl::OUString& segment ) { - return webdav_ucp_impl::decode( string.getStr(), - string.getStr() + string.getLength(), - '%', - webdav_ucp_impl::DECODE_WITH_CHARSET, - RTL_TEXTENCODING_UTF8 ); + return rtl::Uri::decode( segment, + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8 ); +} + +// static +rtl::OUString NeonUri::makeConnectionEndPointString( + const rtl::OUString & rHostName, int nPort ) +{ +// rtl::OUString aServer( +// rtl::OStringToOUString( rHostName, RTL_TEXTENCODING_UTF8 ) ); + rtl::OUString aServer( rHostName ); + if ( ( nPort != DEFAULT_HTTP_PORT ) && ( nPort != DEFAULT_HTTPS_PORT ) ) + { + aServer += rtl::OUString::createFromAscii( ":" ); + aServer += rtl::OUString::valueOf( sal_Int32( nPort ) ); + } + return aServer; } diff --git a/ucb/source/ucp/webdav/NeonUri.hxx b/ucb/source/ucp/webdav/NeonUri.hxx index a92ef6262d0a..dcf4aa084f87 100644 --- a/ucb/source/ucp/webdav/NeonUri.hxx +++ b/ucb/source/ucp/webdav/NeonUri.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonUri.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,8 +61,13 @@ #ifndef _NEONURI_HXX_ #define _NEONURI_HXX_ +#ifndef URI_H #include <uri.h> +#endif + +#ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> +#endif namespace webdav_ucp { @@ -91,8 +96,6 @@ class NeonUri NeonUri( const ::rtl::OUString & inUri ); ~NeonUri( ); - const ::rtl::OUString & GetHostName( void ) const - { return mHostName; }; const ::rtl::OUString & GetURI( void ) const { return mURI; }; const ::rtl::OUString & GetScheme( void ) const @@ -116,7 +119,15 @@ class NeonUri static ::rtl::OUString escapeSegment( const ::rtl::OUString& segment ); static ::rtl::OUString unescape( const ::rtl::OUString& string ); + + // "host:port", omit ":port" for port 80 and 443 + static rtl::OUString makeConnectionEndPointString( + const rtl::OUString & rHostName, + int nPort ); + rtl::OUString makeConnectionEndPointString() const + { return makeConnectionEndPointString( GetHost(), GetPort() ); } }; }; // namespace webdav_ucp + #endif // _NEONURI_HXX_ diff --git a/ucb/source/ucp/webdav/ucpdav.xml b/ucb/source/ucp/webdav/ucpdav.xml index 16b077241a44..0724173cc77d 100644 --- a/ucb/source/ucp/webdav/ucpdav.xml +++ b/ucb/source/ucp/webdav/ucpdav.xml @@ -44,9 +44,9 @@ <project-build-dependency> vos </project-build-dependency> <project-build-dependency> ucbhelper </project-build-dependency> - <runtime-module-dependency> sal2 </runtime-module-dependency> - <runtime-module-dependency> cppu2 </runtime-module-dependency> - <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency> + <runtime-module-dependency> sal3 </runtime-module-dependency> + <runtime-module-dependency> cppu3 </runtime-module-dependency> + <runtime-module-dependency> cppuhelper3$(COM) </runtime-module-dependency> <runtime-module-dependency> vos2$(COM) </runtime-module-dependency> <runtime-module-dependency> ucbhelper1$(COM) </runtime-module-dependency> @@ -57,6 +57,7 @@ <type> com.sun.star.beans.XPropertyContainer </type> <type> com.sun.star.beans.XPropertySetInfoChangeNotifier </type> <type> com.sun.star.container.XChild </type> + <type> com.sun.star.container.XNameAccess </type> <type> com.sun.star.container.XHierarchicalNameAccess </type> <type> com.sun.star.io.XActiveDataSink </type> <type> com.sun.star.io.XInputStream </type> @@ -80,15 +81,28 @@ <type> com.sun.star.ucb.ContentInfoAttribute </type> <type> com.sun.star.ucb.InsertCommandArgument </type> <type> com.sun.star.ucb.InteractiveBadTransferURLException </type> + <type> com.sun.star.ucb.InteractiveIOException </type> + <type> com.sun.star.ucb.InteractiveNetworkConnectException </type> + <type> com.sun.star.ucb.InteractiveNetworkGeneralException </type> + <type> com.sun.star.ucb.InteractiveNetworkReadException </type> + <type> com.sun.star.ucb.InteractiveNetworkResolveNameException </type> + <type> com.sun.star.ucb.InteractiveNetworkWriteException </type> <type> com.sun.star.ucb.Link </type> <type> com.sun.star.ucb.Lock </type> + <type> com.sun.star.ucb.MissingInputStreamException </type> + <type> com.sun.star.ucb.MissingPropertiesException </type> <type> com.sun.star.ucb.NameClash </type> + <type> com.sun.star.ucb.NameClashException </type> <type> com.sun.star.ucb.OpenCommandArgument2 </type> <type> com.sun.star.ucb.OpenMode </type> <type> com.sun.star.ucb.RememberAuthentication </type> <type> com.sun.star.ucb.ResultSetException </type> <type> com.sun.star.ucb.TransferInfo </type> <type> com.sun.star.ucb.XCommandEnvironment </type> + <type> com.sun.star.ucb.UnsupportedCommandException </type> + <type> com.sun.star.ucb.UnsupportedDataSinkException </type> + <type> com.sun.star.ucb.UnsupportedNameClashException </type> + <type> com.sun.star.ucb.UnsupportedOpenModeException </type> <type> com.sun.star.ucb.XCommandInfo </type> <type> com.sun.star.ucb.XCommandInfoChangeNotifier </type> <type> com.sun.star.ucb.XCommandProcessor </type> diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx index 060d1e2b92f3..1679f9bf8a53 100644 --- a/ucb/source/ucp/webdav/webdavcontent.cxx +++ b/ucb/source/ucp/webdav/webdavcontent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavcontent.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: kso $ $Date: 2001-06-18 08:22:51 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,9 +93,30 @@ #ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveIOException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKCONNECTEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKGENBERALEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKREADEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKRESOLVENAMEEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKWRITEEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_NAMECLASH_HPP_ #include <com/sun/star/ucb/NameClash.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_NAMECLASHEXCEPTION_HPP_ +#include <com/sun/star/ucb/NameClashException.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT2_HPP_ #include <com/sun/star/ucb/OpenCommandArgument2.hpp> #endif @@ -111,6 +132,24 @@ #ifndef _COM_SUN_STAR_UCB_XPERSISTENTPROPERTYSET_HPP_ #include <com/sun/star/ucb/XPersistentPropertySet.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_MISSINGINPUTSTREAMEXCEPTION_HPP_ +#include <com/sun/star/ucb/MissingInputStreamException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_MISSINGPROPERTIESEXCEPTION_HPP_ +#include <com/sun/star/ucb/MissingPropertiesException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDCOMMANDEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedCommandException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDNAMECLASHEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedNameClashException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDOPENMODEEXCEPTION_HPP_ +#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp> +#endif #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX #include <ucbhelper/contentidentifier.hxx> @@ -118,6 +157,12 @@ #ifndef _UCBHELPER_PROPERTYVALUESET_HXX #include <ucbhelper/propertyvalueset.hxx> #endif +#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX +#include <ucbhelper/interactionrequest.hxx> +#endif +#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ +#include <ucbhelper/cancelcommandexecution.hxx> +#endif #ifndef _WEBDAV_UCP_CONTENT_HXX #include "webdavcontent.hxx" @@ -138,17 +183,8 @@ #include "UCBDeadPropertyValue.hxx" #endif -using namespace com::sun::star::container; -using namespace com::sun::star::beans; -using namespace com::sun::star::util; -using namespace com::sun::star::lang; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; -using namespace com::sun::star::io; -using namespace cppu; -using namespace rtl; - +using namespace com::sun; +using namespace com::sun::star; using namespace webdav_ucp; //========================================================================= @@ -161,11 +197,12 @@ using namespace webdav_ucp; //========================================================================= // ctr for content on an existing webdav resource -Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, - ContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier, - DAVSessionFactory* pSessionFactory ) - throw ( ContentCreationException ) +Content::Content( + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + ContentProvider* pProvider, + const uno::Reference< star::ucb::XContentIdentifier >& Identifier, + DAVSessionFactory* pSessionFactory ) + throw ( star::ucb::ContentCreationException ) : ContentImplHelper( rxSMgr, pProvider, Identifier ), m_pProvider( pProvider ), m_bTransient( sal_False ), @@ -178,7 +215,7 @@ Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, } catch ( DAVException const & ) { - throw ContentCreationException(); + throw star::ucb::ContentCreationException(); } NeonUri aURI( Identifier->getContentIdentifier() ); @@ -187,12 +224,13 @@ Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, //========================================================================= // ctr for content on an non-existing webdav resource -Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, - ContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier, - DAVSessionFactory* pSessionFactory, - sal_Bool isCollection ) - throw ( ContentCreationException ) +Content::Content( + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + ContentProvider* pProvider, + const uno::Reference< star::ucb::XContentIdentifier >& Identifier, + DAVSessionFactory* pSessionFactory, + sal_Bool isCollection ) + throw ( star::ucb::ContentCreationException ) : ContentImplHelper( rxSMgr, pProvider, Identifier, sal_False ), m_pProvider( pProvider ), m_bTransient( sal_True ), @@ -205,7 +243,7 @@ Content::Content( const Reference< XMultiServiceFactory >& rxSMgr, } catch ( DAVException const & ) { - throw ContentCreationException(); + throw star::ucb::ContentCreationException(); } // Do not set m_aEscapedTitle here! Content::insert relays on this!!! @@ -225,7 +263,7 @@ Content::~Content() // virtual void SAL_CALL Content::acquire() - throw( RuntimeException ) + throw( uno::RuntimeException ) { ContentImplHelper::acquire(); } @@ -233,22 +271,24 @@ void SAL_CALL Content::acquire() //========================================================================= // virtual void SAL_CALL Content::release() - throw( RuntimeException ) + throw( uno::RuntimeException ) { ContentImplHelper::release(); } //========================================================================= // virtual -Any SAL_CALL Content::queryInterface( const Type & rType ) - throw ( RuntimeException ) +uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) + throw ( uno::RuntimeException ) { // Note: isFolder may require network activities! So call it only // if it is really necessary!!! - Any aRet = cppu::queryInterface( rType, - static_cast< XContentCreator * >( this ) ); + uno::Any aRet = cppu::queryInterface( rType, + static_cast< star::ucb::XContentCreator * >( this ) ); if ( aRet.hasValue() ) - return isFolder( Reference< XCommandEnvironment >() ) ? aRet : Any(); + return isFolder( uno::Reference< star::ucb::XCommandEnvironment >() ) + ? aRet + : uno::Any(); return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType ); } @@ -263,45 +303,46 @@ XTYPEPROVIDER_COMMON_IMPL( Content ); //========================================================================= // virtual -Sequence< Type > SAL_CALL Content::getTypes() - throw( RuntimeException ) +uno::Sequence< uno::Type > SAL_CALL Content::getTypes() + throw( uno::RuntimeException ) { - static OTypeCollection* pCollection = NULL; + static cppu::OTypeCollection* pCollection = NULL; if ( !pCollection ) { osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) { - if ( isFolder( Reference< XCommandEnvironment >() ) ) + if ( isFolder( + uno::Reference< star::ucb::XCommandEnvironment >() ) ) { - static OTypeCollection aCollection( - CPPU_TYPE_REF( XTypeProvider ), - CPPU_TYPE_REF( XServiceInfo ), - CPPU_TYPE_REF( XComponent ), - CPPU_TYPE_REF( XContent ), - CPPU_TYPE_REF( XCommandProcessor ), - CPPU_TYPE_REF( XPropertiesChangeNotifier ), - CPPU_TYPE_REF( XCommandInfoChangeNotifier ), - CPPU_TYPE_REF( XPropertyContainer ), - CPPU_TYPE_REF( XPropertySetInfoChangeNotifier ), - CPPU_TYPE_REF( XChild ), - CPPU_TYPE_REF( XContentCreator ) ); // !! + static cppu::OTypeCollection aCollection( + CPPU_TYPE_REF( lang::XTypeProvider ), + CPPU_TYPE_REF( lang::XServiceInfo ), + CPPU_TYPE_REF( lang::XComponent ), + CPPU_TYPE_REF( star::ucb::XContent ), + CPPU_TYPE_REF( star::ucb::XCommandProcessor ), + CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), + CPPU_TYPE_REF( star::ucb::XCommandInfoChangeNotifier ), + CPPU_TYPE_REF( beans::XPropertyContainer ), + CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), + CPPU_TYPE_REF( container::XChild ), + CPPU_TYPE_REF( star::ucb::XContentCreator ) ); // !! pCollection = &aCollection; } else { - static OTypeCollection aCollection( - CPPU_TYPE_REF( XTypeProvider ), - CPPU_TYPE_REF( XServiceInfo ), - CPPU_TYPE_REF( XComponent ), - CPPU_TYPE_REF( XContent ), - CPPU_TYPE_REF( XCommandProcessor ), - CPPU_TYPE_REF( XPropertiesChangeNotifier ), - CPPU_TYPE_REF( XCommandInfoChangeNotifier ), - CPPU_TYPE_REF( XPropertyContainer ), - CPPU_TYPE_REF( XPropertySetInfoChangeNotifier ), - CPPU_TYPE_REF( XChild ) ); + static cppu::OTypeCollection aCollection( + CPPU_TYPE_REF( lang::XTypeProvider ), + CPPU_TYPE_REF( lang::XServiceInfo ), + CPPU_TYPE_REF( lang::XComponent ), + CPPU_TYPE_REF( star::ucb::XContent ), + CPPU_TYPE_REF( star::ucb::XCommandProcessor ), + CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), + CPPU_TYPE_REF( star::ucb::XCommandInfoChangeNotifier ), + CPPU_TYPE_REF( beans::XPropertyContainer ), + CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), + CPPU_TYPE_REF( container::XChild ) ); pCollection = &aCollection; } } @@ -316,20 +357,21 @@ Sequence< Type > SAL_CALL Content::getTypes() //========================================================================= // virtual -OUString SAL_CALL Content::getImplementationName() - throw( RuntimeException ) +rtl::OUString SAL_CALL Content::getImplementationName() + throw( uno::RuntimeException ) { - return OUString::createFromAscii( "com.sun.star.comp.ucb.WebDAVContent" ); + return rtl::OUString::createFromAscii( + "com.sun.star.comp.ucb.WebDAVContent" ); } //========================================================================= // virtual -Sequence< OUString > SAL_CALL Content::getSupportedServiceNames() - throw( RuntimeException ) +uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames() + throw( uno::RuntimeException ) { - Sequence< OUString > aSNS( 1 ); + uno::Sequence< rtl::OUString > aSNS( 1 ); aSNS.getArray()[ 0 ] - = OUString::createFromAscii( WEBDAV_CONTENT_SERVICE_NAME ); + = rtl::OUString::createFromAscii( WEBDAV_CONTENT_SERVICE_NAME ); return aSNS; } @@ -340,13 +382,13 @@ Sequence< OUString > SAL_CALL Content::getSupportedServiceNames() //========================================================================= // virtual -OUString SAL_CALL Content::getContentType() - throw( RuntimeException ) +rtl::OUString SAL_CALL Content::getContentType() + throw( uno::RuntimeException ) { - if ( isFolder( Reference< XCommandEnvironment >() ) ) - return OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); + if ( isFolder( uno::Reference< star::ucb::XCommandEnvironment >() ) ) + return rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); - return OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); + return rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); } //========================================================================= @@ -356,13 +398,15 @@ OUString SAL_CALL Content::getContentType() //========================================================================= // virtual -Any SAL_CALL Content::execute( const Command& aCommand, - sal_Int32 CommandId, - const Reference< - XCommandEnvironment >& Environment ) - throw( Exception, CommandAbortedException, RuntimeException ) +uno::Any SAL_CALL Content::execute( + const star::ucb::Command& aCommand, + sal_Int32 CommandId, + const uno::Reference< star::ucb::XCommandEnvironment >& Environment ) + throw( uno::Exception, + star::ucb::CommandAbortedException, + uno::RuntimeException ) { - Any aRet; + uno::Any aRet; if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) @@ -371,11 +415,17 @@ Any SAL_CALL Content::execute( const Command& aCommand, // getPropertyValues ////////////////////////////////////////////////////////////////// - Sequence< Property > Properties; + uno::Sequence< beans::Property > Properties; if ( !( aCommand.Argument >>= Properties ) ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } aRet <<= getPropertyValues( Properties, Environment ); @@ -387,17 +437,29 @@ Any SAL_CALL Content::execute( const Command& aCommand, // setPropertyValues ////////////////////////////////////////////////////////////////// - Sequence< PropertyValue > aProperties; + uno::Sequence< beans::PropertyValue > aProperties; if ( !( aCommand.Argument >>= aProperties ) ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } if ( !aProperties.getLength() ) { - OSL_ENSURE( sal_False, "No properties!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "No properties!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } setPropertyValues( aProperties, Environment ); @@ -430,89 +492,106 @@ Any SAL_CALL Content::execute( const Command& aCommand, // open ////////////////////////////////////////////////////////////////// - OpenCommandArgument2 aOpenCommand; - if ( aCommand.Argument >>= aOpenCommand ) + star::ucb::OpenCommandArgument2 aOpenCommand; + if ( !( aCommand.Argument >>= aOpenCommand ) ) { - sal_Bool bOpenFolder = - ( ( aOpenCommand.Mode == OpenMode::ALL ) || - ( aOpenCommand.Mode == OpenMode::FOLDERS ) || - ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) ); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable + } - if ( bOpenFolder && isFolder( Environment ) ) - { - // Open collection. - - Reference< XDynamicResultSet > xSet - = new DynamicResultSet( m_xSMgr, - this, - aOpenCommand, - Environment ); - aRet <<= xSet; - } + sal_Bool bOpenFolder = + ( ( aOpenCommand.Mode == star::ucb::OpenMode::ALL ) || + ( aOpenCommand.Mode == star::ucb::OpenMode::FOLDERS ) || + ( aOpenCommand.Mode == star::ucb::OpenMode::DOCUMENTS ) ); - if ( aOpenCommand.Sink.is() ) + if ( bOpenFolder && isFolder( Environment ) ) + { + // Open collection. + + uno::Reference< star::ucb::XDynamicResultSet > xSet + = new DynamicResultSet( + m_xSMgr, this, aOpenCommand, Environment ); + aRet <<= xSet; + } + + if ( aOpenCommand.Sink.is() ) + { + // Open document. + + if ( ( aOpenCommand.Mode + == star::ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) || + ( aOpenCommand.Mode + == star::ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) { - // Open document. + // Currently(?) unsupported. + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedOpenModeException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + sal_Int16( aOpenCommand.Mode ) ) ), + Environment ); + // Unreachable + } - if ( ( aOpenCommand.Mode - == OpenMode::DOCUMENT_SHARE_DENY_NONE ) || - ( aOpenCommand.Mode - == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); + uno::Reference< io::XOutputStream > xOut + = uno::Reference< io::XOutputStream >( + aOpenCommand.Sink, uno::UNO_QUERY ); + if ( xOut.is() ) + { + // PUSH: write data + try { - // Currently(?) unsupported. - throw CommandAbortedException(); + m_aResAccess.GET( xOut, Environment ); } - - OUString aURL = m_xIdentifier->getContentIdentifier(); - Reference< XOutputStream > xOut - = Reference< XOutputStream >(aOpenCommand.Sink, UNO_QUERY ); - if ( xOut.is() ) - { - // PUSH: write data + catch ( DAVException const & e ) + { + cancelCommandExecution( e, Environment ); + // Unreachable + } + } + else + { + uno::Reference< io::XActiveDataSink > xDataSink + = uno::Reference< io::XActiveDataSink >( + aOpenCommand.Sink, uno::UNO_QUERY ); + if ( xDataSink.is() ) + { + // PULL: wait for client read try { - m_aResAccess.GET( xOut, Environment ); + uno::Reference< io::XInputStream > xIn + = m_aResAccess.GET( Environment ); + xDataSink->setInputStream( xIn ); } - catch ( DAVException const & ) + catch ( DAVException const & e ) { -// OSL_ENSURE( sal_False, "GET : DAVException" ); - throw CommandAbortedException(); + cancelCommandExecution( e, Environment ); + // Unreachable } - } + } else - { - Reference< XActiveDataSink > xDataSink - = Reference< XActiveDataSink >( - aOpenCommand.Sink, UNO_QUERY ); - if ( xDataSink.is() ) - { - // PULL: wait for client read - try - { - Reference< XInputStream > xIn - = m_aResAccess.GET( Environment ); - xDataSink->setInputStream( xIn ); - } - catch ( DAVException &) - { -// OSL_ENSURE( sal_False, "GET : DAVException" ); - throw CommandAbortedException(); - } - } - else - { - // Note: aOpenCommand.Sink may contain an XStream - // implementation. Support for this type of - // sink is optional... - throw CommandAbortedException(); - } - } - } - } - else - { - OSL_ENSURE( sal_False, "Content::execute - invalid parameter!" ); - throw CommandAbortedException(); + { + // Note: aOpenCommand.Sink may contain an XStream + // implementation. Support for this type of + // sink is optional... + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedDataSinkException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + aOpenCommand.Sink ) ), + Environment ); + // Unreachable + } + } } } else if ( aCommand.Name.equalsAsciiL( @@ -522,11 +601,17 @@ Any SAL_CALL Content::execute( const Command& aCommand, // insert ////////////////////////////////////////////////////////////////// - InsertCommandArgument arg; + star::ucb::InsertCommandArgument arg; if ( !( aCommand.Argument >>= arg ) ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - return Any(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } insert( arg.Data, arg.ReplaceExisting, Environment ); @@ -550,158 +635,42 @@ Any SAL_CALL Content::execute( const Command& aCommand, { m_aResAccess.DESTROY( Environment ); } - catch ( DAVException & ) + catch ( DAVException const & e ) { - OSL_ENSURE( sal_False, "DESTROY : DAVException" ); - throw CommandAbortedException(); + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } // } // Propagate destruction. destroy( bDeletePhysical ); -// DAV resources store all additional props on server! -// // Remove own and all children's Additional Core Properties. -// removeAdditionalPropertySet( sal_True ); + // Remove own and all children's Additional Core Properties. + removeAdditionalPropertySet( sal_True ); } else if ( aCommand.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) ) + RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) + && isFolder( Environment ) ) { - TransferInfo transferArgs; - if ( !( aCommand.Argument >>= transferArgs ) ) - throw CommandAbortedException(); - - if ( !isFolder( Environment ) ) - throw CommandAbortedException(); + ////////////////////////////////////////////////////////////////// + // transfer + // ( Not available at documents ) + ////////////////////////////////////////////////////////////////// - if ( transferArgs.NameClash == NameClash::KEEP || - transferArgs.NameClash == NameClash::RENAME ) + star::ucb::TransferInfo transferArgs; + if ( !( aCommand.Argument >>= transferArgs ) ) { - // @@@ RENAME and KEEP are not directly implemented - // by WebDAV methods. KEEP is deprecated and it - // is okay to abort in this case. - - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } - try - { - NeonUri sourceURI( transferArgs.SourceURL ); - NeonUri targetURI( m_xIdentifier->getContentIdentifier() ); - - // Check source's and target's URL scheme - // - const OUString aScheme = sourceURI.GetScheme().toAsciiLowerCase(); - if ( aScheme.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) - { - sourceURI.SetScheme( - OUString::createFromAscii( HTTP_URL_SCHEME ) ); - } - else - { - if ( !aScheme.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) && - !aScheme.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) ) - throw InteractiveBadTransferURLException(); - } - - if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) - targetURI.SetScheme( - OUString::createFromAscii( HTTP_URL_SCHEME ) ); - - // @@@ This implementation of 'transfer' only works - // if the source and target are located at same host. - // (Neon does not support cross-server copy/move) - - // Check for same host - // - if ( sourceURI.GetHost().getLength() && - sourceURI.GetHost() != targetURI.GetHost() ) - throw InteractiveBadTransferURLException(); - - if ( !transferArgs.NewTitle.getLength() ) - transferArgs.NewTitle = sourceURI.GetPathBaseNameUnescaped(); - - if ( transferArgs.NewTitle.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "/" ) ) ) - throw CommandAbortedException(); - - targetURI.AppendPath( transferArgs.NewTitle ); - - OUString aTargetURL = m_xIdentifier->getContentIdentifier(); - if ( ( aTargetURL.lastIndexOf( '/' ) + 1 ) != aTargetURL.getLength() ) - aTargetURL += OUString::createFromAscii( "/" ); - - aTargetURL += transferArgs.NewTitle; - - Reference< XContentIdentifier > xTargetId - = new ::ucb::ContentIdentifier( m_xSMgr, aTargetURL ); - - Reference< XContentIdentifier > xId - = new ::ucb::ContentIdentifier( m_xSMgr, - transferArgs.SourceURL ); - - DAVResourceAccess aSourceAccess( m_xSMgr, - m_aResAccess.getSessionFactory(), - sourceURI.GetURI() ); - - if ( transferArgs.MoveData == sal_True ) - { - // Note: The static cast is okay here, because its sure that - // m_xProvider is always the WebDAVContentProvider. - vos::ORef< Content > xSource - = static_cast< Content * >( - m_xProvider->queryContent( xId ).get() ); - - aSourceAccess.MOVE( sourceURI.GetPath(), - targetURI.GetURI(), - transferArgs.NameClash - == NameClash::OVERWRITE, - Environment ); - - if ( xSource.isValid() ) - { - // Propagate destruction to listeners. - xSource->destroy( sal_True ); - } - -// DAV resources store all additional props on server! -// // Rename own and all children's Additional Core Properties. -// renameAdditionalPropertySet( xId->getContentIdentifier(), -// xTargetId->getContentIdentifier(), -// sal_True ); - } - else - { - aSourceAccess.COPY( sourceURI.GetPath(), - targetURI.GetURI(), - transferArgs.NameClash - == NameClash::OVERWRITE, - Environment ); - -// DAV resources store all additional props on server! -// // Copy own and all children's Additional Core Properties. -// copyAdditionalPropertySet( xId->getContentIdentifier(), -// xTargetId->getContentIdentifier(), -// sal_True ); - } - - // Note: The static cast is okay here, because its sure that - // m_xProvider is always the WebDAVContentProvider. - vos::ORef< Content > xTarget - = static_cast< Content * >( - m_xProvider->queryContent( xTargetId ).get() ); - - // Announce transfered content in its new folder. - xTarget->inserted(); - } - catch ( DAVException const & ) - { - throw CommandAbortedException(); - } + transfer( transferArgs, Environment ); } else { @@ -709,8 +678,12 @@ Any SAL_CALL Content::execute( const Command& aCommand, // Unsupported command ////////////////////////////////////////////////////////////////// - OSL_ENSURE( sal_False, "Content::execute - unsupported command!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( star::ucb::UnsupportedCommandException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable } return aRet; @@ -719,7 +692,7 @@ Any SAL_CALL Content::execute( const Command& aCommand, //========================================================================= // virtual void SAL_CALL Content::abort( sal_Int32 CommandId ) - throw( RuntimeException ) + throw( uno::RuntimeException ) { // @@@ Implement logic to abort running commands, if this makes // sense for your content. @@ -732,12 +705,13 @@ void SAL_CALL Content::abort( sal_Int32 CommandId ) //========================================================================= // virtual -void SAL_CALL Content::addProperty( - const OUString& Name, sal_Int16 Attributes, const Any& DefaultValue ) - throw( PropertyExistException, - IllegalTypeException, - IllegalArgumentException, - RuntimeException ) +void SAL_CALL Content::addProperty( const rtl::OUString& Name, + sal_Int16 Attributes, + const uno::Any& DefaultValue ) + throw( beans::PropertyExistException, + beans::IllegalTypeException, + lang::IllegalArgumentException, + uno::RuntimeException ) { // if ( m_bTransient ) // @@@ ??? @@ -745,14 +719,14 @@ void SAL_CALL Content::addProperty( // osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( !Name.getLength() ) - throw IllegalArgumentException(); + throw lang::IllegalArgumentException(); // Check property type. if ( !UCBDeadPropertyValue::supportsType( DefaultValue.getValueType() ) ) { OSL_ENSURE( sal_False, "Content::addProperty - " "Unsupported property type!" ); - throw IllegalTypeException(); + throw beans::IllegalTypeException(); } ////////////////////////////////////////////////////////////////////// @@ -763,14 +737,14 @@ void SAL_CALL Content::addProperty( // @@@ Need real command environment here, but where to get it from? // XPropertyContainer interface should be replaced by // XCommandProcessor commands! - Reference< XCommandEnvironment > xEnv; + uno::Reference< star::ucb::XCommandEnvironment > xEnv; // Note: This requires network access! if ( getPropertySetInfo( xEnv, sal_False /* don't cache data */ ) ->hasPropertyByName( Name ) ) { // Property does already exist. - throw PropertyExistException(); + throw beans::PropertyExistException(); } ////////////////////////////////////////////////////////////////////// @@ -788,11 +762,11 @@ void SAL_CALL Content::addProperty( m_aResAccess.PROPPATCH( aProppatchValues, xEnv ); // Notify propertyset info change listeners. - PropertySetInfoChangeEvent evt( - static_cast< OWeakObject * >( this ), + beans::PropertySetInfoChangeEvent evt( + static_cast< cppu::OWeakObject * >( this ), Name, -1, // No handle available - PropertySetInfoChange::PROPERTY_INSERTED ); + beans::PropertySetInfoChange::PROPERTY_INSERTED ); notifyPropertySetInfoChange( evt ); } catch ( DAVException const & ) @@ -805,7 +779,7 @@ void SAL_CALL Content::addProperty( if ( caps.class1 ) { // DAV resource! - throw IllegalArgumentException(); + throw lang::IllegalArgumentException(); } else { @@ -818,40 +792,40 @@ void SAL_CALL Content::addProperty( } catch ( DAVException const & ) { - throw IllegalArgumentException(); + throw lang::IllegalArgumentException(); } } } //========================================================================= // virtual -void SAL_CALL Content::removeProperty( const OUString& Name ) - throw( UnknownPropertyException, - NotRemoveableException, - RuntimeException ) +void SAL_CALL Content::removeProperty( const rtl::OUString& Name ) + throw( beans::UnknownPropertyException, + beans::NotRemoveableException, + uno::RuntimeException ) { // osl::Guard< osl::Mutex > aGuard( m_aMutex ); // @@@ Need real command environment here, but where to get it from? // XPropertyContainer interface should be replaced by // XCommandProcessor commands! - Reference< XCommandEnvironment > xEnv; + uno::Reference< star::ucb::XCommandEnvironment > xEnv; #if 0 - // @@@ REMOVEABLE z.Z. nicht richtig and der PropSetInfo gesetzt!!! + // @@@ REMOVEABLE z.Z. nicht richtig an der PropSetInfo gesetzt!!! try { - Property aProp = getPropertySetInfo( xEnv, - sal_False /* don't cache data */ ) - ->getPropertyByName( Name ); + beans::Property aProp + = getPropertySetInfo( xEnv, sal_False /* don't cache data */ ) + ->getPropertyByName( Name ); - if ( !( aProp.Attributes & PropertyAttribute::REMOVEABLE ) ) + if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) ) { // Not removeable! - throw NotRemoveableException(); + throw beans::NotRemoveableException(); } } - catch ( UnknownPropertyException const & ) + catch ( beans::UnknownPropertyException const & ) { // OSL_ENSURE( sal_False, "removeProperty - Unknown property!" ); throw; @@ -865,18 +839,18 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) try { std::vector< ProppatchValue > aProppatchValues; - ProppatchValue aValue( PROPREMOVE, Name, Any() ); + ProppatchValue aValue( PROPREMOVE, Name, uno::Any() ); aProppatchValues.push_back( aValue ); // Remove property value from server. m_aResAccess.PROPPATCH( aProppatchValues, xEnv ); // Notify propertyset info change listeners. - PropertySetInfoChangeEvent evt( - static_cast< OWeakObject * >( this ), + beans::PropertySetInfoChangeEvent evt( + static_cast< cppu::OWeakObject * >( this ), Name, -1, // No handle available - PropertySetInfoChange::PROPERTY_REMOVED ); + beans::PropertySetInfoChange::PROPERTY_REMOVED ); notifyPropertySetInfoChange( evt ); } catch ( DAVException const & ) @@ -889,7 +863,7 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) if ( caps.class1 ) { // DAV resource! - throw UnknownPropertyException(); + throw beans::UnknownPropertyException(); } else { @@ -901,7 +875,7 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) } catch ( DAVException const & ) { - throw UnknownPropertyException(); + throw beans::UnknownPropertyException(); } } } @@ -913,37 +887,38 @@ void SAL_CALL Content::removeProperty( const OUString& Name ) //========================================================================= // virtual -Sequence< ContentInfo > SAL_CALL +uno::Sequence< star::ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo() - throw( RuntimeException ) + throw( uno::RuntimeException ) { // if ( isFolder() ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - Sequence< ContentInfo > aSeq( 2 ); + uno::Sequence< star::ucb::ContentInfo > aSeq( 2 ); // document. aSeq.getArray()[ 0 ].Type - = OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); + = rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ); aSeq.getArray()[ 0 ].Attributes - = ContentInfoAttribute::INSERT_WITH_INPUTSTREAM - | ContentInfoAttribute::KIND_DOCUMENT; + = star::ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM + | star::ucb::ContentInfoAttribute::KIND_DOCUMENT; - Property aProp; + beans::Property aProp; m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); - Sequence< Property > aDocProps( 1 ); + uno::Sequence< beans::Property > aDocProps( 1 ); aDocProps.getArray()[ 0 ] = aProp; aSeq.getArray()[ 0 ].Properties = aDocProps; // folder. aSeq.getArray()[ 1 ].Type - = OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); - aSeq.getArray()[ 1 ].Attributes = ContentInfoAttribute::KIND_FOLDER; + = rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ); + aSeq.getArray()[ 1 ].Attributes + = star::ucb::ContentInfoAttribute::KIND_FOLDER; - Sequence< Property > aFolderProps( 1 ); + uno::Sequence< beans::Property > aFolderProps( 1 ); aFolderProps.getArray()[ 0 ] = aProp; aSeq.getArray()[ 1 ].Properties = aFolderProps; return aSeq; @@ -961,45 +936,46 @@ Content::queryCreatableContentsInfo() //========================================================================= // virtual -Reference< XContent > SAL_CALL Content::createNewContent( const ContentInfo& Info ) - throw( RuntimeException ) +uno::Reference< star::ucb::XContent > SAL_CALL +Content::createNewContent( const star::ucb::ContentInfo& Info ) + throw( uno::RuntimeException ) { // if ( isFolder() ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( !Info.Type.getLength() ) - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); if ( ( !Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_COLLECTION_TYPE ) ) ) && ( !Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_CONTENT_TYPE ) ) ) ) - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); OSL_ENSURE( aURL.getLength() > 0, "WebdavContent::createNewContent - empty identifier!" ); if ( ( aURL.lastIndexOf( '/' ) + 1 ) != aURL.getLength() ) - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); sal_Bool isCollection; if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_COLLECTION_TYPE ) ) ) { - aURL += OUString::createFromAscii( "[New_Collection]" ); + aURL += rtl::OUString::createFromAscii( "[New_Collection]" ); isCollection = sal_True; } else { - aURL += OUString::createFromAscii( "[New_Content]" ); + aURL += rtl::OUString::createFromAscii( "[New_Content]" ); isCollection = sal_False; } - Reference< XContentIdentifier > xId( + uno::Reference< star::ucb::XContentIdentifier > xId( new ::ucb::ContentIdentifier( m_xSMgr, aURL ) ); // create the local content @@ -1011,23 +987,23 @@ Reference< XContent > SAL_CALL Content::createNewContent( const ContentInfo& Inf m_aResAccess.getSessionFactory(), isCollection ); } - catch ( ContentCreationException & ) + catch ( star::ucb::ContentCreationException & ) { - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); } } /* else { OSL_ENSURE( sal_False, "createNewContent called on non-folder object!" ); - return Reference< XContent >(); + return uno::Reference< star::ucb::XContent >(); } */ } //========================================================================= // virtual -OUString Content::getParentURL() +rtl::OUString Content::getParentURL() { // <scheme>:// -> "" // <scheme>://foo -> "" @@ -1036,7 +1012,7 @@ OUString Content::getParentURL() // <scheme>://foo/bar/ -> <scheme>://foo/ // <scheme>://foo/bar/abc -> <scheme>://foo/bar/ - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); sal_Int32 nPos = aURL.lastIndexOf( '/' ); if ( nPos == ( aURL.getLength() - 1 ) ) @@ -1050,9 +1026,9 @@ OUString Content::getParentURL() nPos1 = aURL.lastIndexOf( '/', nPos1 ); if ( nPos1 == -1 ) - return OUString(); + return rtl::OUString(); - return OUString( aURL.copy( 0, nPos + 1 ) ); + return rtl::OUString( aURL.copy( 0, nPos + 1 ) ); } //========================================================================= @@ -1062,28 +1038,28 @@ OUString Content::getParentURL() //========================================================================= // static -Reference< XRow > Content::getPropertyValues( - const Reference< XMultiServiceFactory >& rSMgr, - const Sequence< Property >& rProperties, - const ContentProperties& rData, - const vos::ORef< ucb::ContentProviderImplHelper >& rProvider, - const OUString& rContentId ) +uno::Reference< sdbc::XRow > Content::getPropertyValues( + const uno::Reference< lang::XMultiServiceFactory >& rSMgr, + const uno::Sequence< beans::Property >& rProperties, + const ContentProperties& rData, + const rtl::Reference< ::ucb::ContentProviderImplHelper >& rProvider, + const rtl::OUString& rContentId ) { // Note: Empty sequence means "get values of all supported properties". - vos::ORef< ::ucb::PropertyValueSet > xRow + rtl::Reference< ::ucb::PropertyValueSet > xRow = new ::ucb::PropertyValueSet( rSMgr ); sal_Int32 nCount = rProperties.getLength(); if ( nCount ) { - Reference< XPropertySet > xAdditionalPropSet; + uno::Reference< beans::XPropertySet > xAdditionalPropSet; sal_Bool bTriedToGetAdditonalPropSet = sal_False; - const Property* pProps = rProperties.getConstArray(); + const beans::Property* pProps = rProperties.getConstArray(); for ( sal_Int32 n = 0; n < nCount; ++n ) { - const Property& rProp = pProps[ n ]; + const beans::Property& rProp = pProps[ n ]; // Process Core properties. @@ -1091,10 +1067,10 @@ Reference< XRow > Content::getPropertyValues( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { if ( rData.pIsFolder && *rData.pIsFolder ) - xRow->appendString( rProp, OUString::createFromAscii( + xRow->appendString( rProp, rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ) ); else - xRow->appendString( rProp, OUString::createFromAscii( + xRow->appendString( rProp, rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ) ); } else if ( rProp.Name.equalsAsciiL( @@ -1204,7 +1180,7 @@ Reference< XRow > Content::getPropertyValues( { if ( rData.plockdiscovery ) xRow->appendObject( rProp, - makeAny( *rData.plockdiscovery ) ); + uno::makeAny( *rData.plockdiscovery ) ); else xRow->appendVoid( rProp ); } @@ -1212,14 +1188,14 @@ Reference< XRow > Content::getPropertyValues( { if ( rData.presourcetype ) xRow->appendObject( rProp, - makeAny( *rData.presourcetype ) ); + uno::makeAny( *rData.presourcetype ) ); else xRow->appendVoid( rProp ); } else if ( rProp.Name.equals( DAVProperties::SOURCE ) ) { if ( rData.psource ) - xRow->appendObject( rProp, makeAny( *rData.psource ) ); + xRow->appendObject( rProp, uno::makeAny( *rData.psource ) ); else xRow->appendVoid( rProp ); } @@ -1227,7 +1203,7 @@ Reference< XRow > Content::getPropertyValues( { if ( rData.psupportedlock ) xRow->appendObject( rProp, - makeAny( *rData.psupportedlock ) ); + uno::makeAny( *rData.psupportedlock ) ); else xRow->appendVoid( rProp ); } @@ -1254,10 +1230,10 @@ Reference< XRow > Content::getPropertyValues( && !xAdditionalPropSet.is() ) { xAdditionalPropSet - = Reference< XPropertySet >( + = uno::Reference< beans::XPropertySet >( rProvider->getAdditionalPropertySet( rContentId, sal_False ), - UNO_QUERY ); + uno::UNO_QUERY ); bTriedToGetAdditonalPropSet = sal_True; } @@ -1281,30 +1257,32 @@ Reference< XRow > Content::getPropertyValues( { // Append all Core Properties. ContentProvider * pProvider - = static_cast< ContentProvider * >( rProvider.getBodyPtr() ); - Property aProp; + = static_cast< ContentProvider * >( rProvider.get() ); + beans::Property aProp; pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); if ( rData.pIsFolder && *rData.pIsFolder ) - xRow->appendString( aProp, OUString::createFromAscii( + xRow->appendString( aProp, rtl::OUString::createFromAscii( WEBDAV_COLLECTION_TYPE ) ); else - xRow->appendString( aProp, OUString::createFromAscii( + xRow->appendString( aProp, rtl::OUString::createFromAscii( WEBDAV_CONTENT_TYPE ) ); pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); xRow->appendString( aProp, rData.aTitle ); pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); if ( rData.pIsDocument ) xRow->appendBoolean( aProp, *rData.pIsDocument ); else xRow->appendBoolean( aProp, sal_True ); pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); if ( rData.pIsFolder ) xRow->appendBoolean( aProp, *rData.pIsFolder ); else @@ -1313,14 +1291,14 @@ Reference< XRow > Content::getPropertyValues( if ( rData.pSize ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); xRow->appendLong( aProp, *rData.pSize ); } if ( rData.pDateCreated ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), aProp ); xRow->appendTimestamp( aProp, *rData.pDateCreated ); } @@ -1328,7 +1306,7 @@ Reference< XRow > Content::getPropertyValues( if ( rData.pDateModified ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), aProp ); xRow->appendTimestamp( aProp, *rData.pDateModified ); } @@ -1336,7 +1314,8 @@ Reference< XRow > Content::getPropertyValues( if ( rData.pgetcontenttype ) { pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); xRow->appendString( aProp, *rData.pgetcontenttype ); } @@ -1385,7 +1364,7 @@ Reference< XRow > Content::getPropertyValues( if ( rData.plockdiscovery ) { pProvider->getProperty( DAVProperties::LOCKDISCOVERY, aProp ); - xRow->appendObject( aProp, makeAny( *rData.plockdiscovery ) ); + xRow->appendObject( aProp, uno::makeAny( *rData.plockdiscovery ) ); } if ( rData.presourcetype ) @@ -1397,13 +1376,13 @@ Reference< XRow > Content::getPropertyValues( if ( rData.psource ) { pProvider->getProperty( DAVProperties::SOURCE, aProp ); - xRow->appendObject( aProp, makeAny( *rData.psource ) ); + xRow->appendObject( aProp, uno::makeAny( *rData.psource ) ); } if ( rData.psupportedlock ) { pProvider->getProperty( DAVProperties::SUPPORTEDLOCK, aProp ); - xRow->appendObject( aProp, makeAny( *rData.psupportedlock ) ); + xRow->appendObject( aProp, uno::makeAny( *rData.psupportedlock ) ); } // Process additional properties (DAV "dead" properties). @@ -1412,7 +1391,7 @@ Reference< XRow > Content::getPropertyValues( PropertyValueMap::const_iterator it = rData.pOtherProps->begin(); PropertyValueMap::const_iterator end = rData.pOtherProps->end(); - Property aProp; + beans::Property aProp; while ( it != end ) { pProvider->getProperty( (*it).first, aProp ); @@ -1422,19 +1401,19 @@ Reference< XRow > Content::getPropertyValues( } // Append all local Additional Core Properties. - Reference< XPropertySet > xSet( + uno::Reference< beans::XPropertySet > xSet( rProvider->getAdditionalPropertySet( rContentId, sal_False ), - UNO_QUERY ); + uno::UNO_QUERY ); xRow->appendPropertySet( xSet ); } - return Reference< XRow >( xRow.getBodyPtr() ); + return uno::Reference< sdbc::XRow >( xRow.get() ); } //========================================================================= -Reference< XRow > Content::getPropertyValues( - const Sequence< Property >& rProperties, - const Reference< XCommandEnvironment >& xEnv ) +uno::Reference< sdbc::XRow > Content::getPropertyValues( + const uno::Sequence< beans::Property >& rProperties, + const uno::Reference< star::ucb::XCommandEnvironment >& xEnv ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); @@ -1446,7 +1425,9 @@ Reference< XRow > Content::getPropertyValues( ContentProperties( NeonUri::unescape( m_aEscapedTitle ), m_bCollection ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } @@ -1461,12 +1442,14 @@ Reference< XRow > Content::getPropertyValues( ContentProperties( NeonUri::unescape( m_aEscapedTitle ), m_bCollection ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } bool bSuccess = true; - std::vector< OUString > aPropNames; + std::vector< rtl::OUString > aPropNames; ContentProperties::UCBNamesToDAVNames( rProperties, aPropNames ); std::vector< DAVResource > resources; @@ -1476,9 +1459,8 @@ Reference< XRow > Content::getPropertyValues( { m_aResAccess.PROPFIND( ZERO, aPropNames, resources, xEnv ); } - catch ( DAVException & ) + catch ( DAVException const & ) { -// OSL_ENSURE( sal_False, "PROPFIND : DAVException" ); bSuccess = false; } } @@ -1490,7 +1472,9 @@ Reference< XRow > Content::getPropertyValues( return getPropertyValues( m_xSMgr, rProperties, ContentProperties( resources[ 0 ] ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } else @@ -1501,22 +1485,25 @@ Reference< XRow > Content::getPropertyValues( ContentProperties( NeonUri::unescape( m_aEscapedTitle ), sal_False /* no collection */ ), - m_xProvider, + rtl::Reference< + ::ucb::ContentProviderImplHelper >( + m_xProvider.getBodyPtr() ), m_xIdentifier->getContentIdentifier() ); } } //========================================================================= -void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, - const Reference< XCommandEnvironment >& xEnv ) +void Content::setPropertyValues( + const uno::Sequence< beans::PropertyValue >& rValues, + const uno::Reference< star::ucb::XCommandEnvironment >& xEnv ) { osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - Sequence< PropertyChangeEvent > aChanges( rValues.getLength() ); + uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; - PropertyChangeEvent aEvent; - aEvent.Source = static_cast< OWeakObject * >( this ); + beans::PropertyChangeEvent aEvent; + aEvent.Source = static_cast< cppu::OWeakObject * >( this ); aEvent.Further = sal_False; // aEvent.PropertyName = aEvent.PropertyHandle = -1; @@ -1528,61 +1515,53 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, std::vector< ProppatchValue > aProppatchValues; - Reference< XPersistentPropertySet > xAdditionalPropSet; + uno::Reference< star::ucb::XPersistentPropertySet > xAdditionalPropSet; sal_Bool bTriedToGetAdditonalPropSet = sal_False; sal_Bool bExchange = sal_False; - OUString aNewTitle; - OUString aOldTitle; + rtl::OUString aNewTitle; + rtl::OUString aOldTitle; - Reference< XPropertySetInfo > xInfo; + uno::Reference< beans::XPropertySetInfo > xInfo; - const PropertyValue* pValues = rValues.getConstArray(); + const beans::PropertyValue* pValues = rValues.getConstArray(); sal_Int32 nCount = rValues.getLength(); for ( sal_Int32 n = 0; n < nCount; ++n ) { - const PropertyValue& rValue = pValues[ n ]; + const beans::PropertyValue& rValue = pValues[ n ]; - Property aTmpProp; + beans::Property aTmpProp; m_pProvider->getProperty( rValue.Name, aTmpProp ); - if ( aTmpProp.Attributes & PropertyAttribute::READONLY ) + if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY ) { // Read-only property! continue; } - if ( !xInfo.is() ) - xInfo - = getPropertySetInfo( xEnv, sal_False /* don't cache data */ ); + ////////////////////////////////////////////////////////////////// + // Mandatory props. + ////////////////////////////////////////////////////////////////// - if ( !xInfo->hasPropertyByName( rValue.Name ) ) + if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { - // Check, whether property exists. Abort otherwise. - // PROPPATCH::set would add the property automatically, which - // is not allowed for "setPropertyValues" command! - continue; + // Read-only property! } - -// if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) -// { -// // Read-only property! -// } - /*else*/ if ( rValue.Name.equalsAsciiL( + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { - OUString aNewValue; + rtl::OUString aNewValue; if ( rValue.Value >>= aNewValue ) { // No empty titles! @@ -1603,91 +1582,112 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, } } } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) -// { -// // Read-only property! -// } -// else if ( rValue.Name.equalsAsciiL( -// RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) -// { -// // Read-only property! -// // (but could be writable, if 'getcontenttype' would be) -// } else { - if ( !bCheckedForDAV ) - { - bCheckedForDAV = sal_True; + ////////////////////////////////////////////////////////////// + // Optional props. + ////////////////////////////////////////////////////////////// - try - { - DAVCapabilities caps; - m_aResAccess.OPTIONS( caps, xEnv ); - bDAV = caps.class1; - } - catch ( DAVException const & ) - { - bDAV = sal_False; - } + if ( !xInfo.is() ) + xInfo = getPropertySetInfo( xEnv, + sal_False /* don't cache data */ ); + + if ( !xInfo->hasPropertyByName( rValue.Name ) ) + { + // Check, whether property exists. Abort otherwise. + // PROPPATCH::set would add the property automatically, which + // is not allowed for "setPropertyValues" command! + continue; } - if ( bDAV ) + if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) + { + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) ) { - // Property value will be set on server. - ProppatchValue aValue( PROPSET, rValue.Name, rValue.Value ); - aProppatchValues.push_back( aValue ); + // Read-only property! + } + else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) + { + // Read-only property! + // (but could be writable, if 'getcontenttype' would be) } else { - // Property value will be stored in local property store. - if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) + if ( !bCheckedForDAV ) { - xAdditionalPropSet = getAdditionalPropertySet( sal_False ); - bTriedToGetAdditonalPropSet = sal_True; - } + bCheckedForDAV = sal_True; - if ( xAdditionalPropSet.is() ) - { try { - Any aOldValue - = xAdditionalPropSet->getPropertyValue( - rValue.Name ); - if ( aOldValue != rValue.Value ) - { - xAdditionalPropSet->setPropertyValue( - rValue.Name, rValue.Value ); - - aEvent.PropertyName = rValue.Name; - aEvent.OldValue = aOldValue; - aEvent.NewValue = rValue.Value; - - aChanges.getArray()[ nChanged ] = aEvent; - nChanged++; - } - } - catch ( UnknownPropertyException ) - { + DAVCapabilities caps; + m_aResAccess.OPTIONS( caps, xEnv ); + bDAV = caps.class1; } - catch ( WrappedTargetException ) + catch ( DAVException const & ) { + bDAV = sal_False; } - catch ( PropertyVetoException ) + } + + if ( bDAV ) + { + // Property value will be set on server. + ProppatchValue aValue( PROPSET, rValue.Name, rValue.Value ); + aProppatchValues.push_back( aValue ); + } + else + { + // Property value will be stored in local property store. + if ( !bTriedToGetAdditonalPropSet && + !xAdditionalPropSet.is() ) { + xAdditionalPropSet + = getAdditionalPropertySet( sal_False ); + bTriedToGetAdditonalPropSet = sal_True; } - catch ( IllegalArgumentException ) + + if ( xAdditionalPropSet.is() ) { + try + { + uno::Any aOldValue + = xAdditionalPropSet->getPropertyValue( + rValue.Name ); + if ( aOldValue != rValue.Value ) + { + xAdditionalPropSet->setPropertyValue( + rValue.Name, rValue.Value ); + + aEvent.PropertyName = rValue.Name; + aEvent.OldValue = aOldValue; + aEvent.NewValue = rValue.Value; + + aChanges.getArray()[ nChanged ] = aEvent; + nChanged++; + } + } + catch ( beans::UnknownPropertyException ) + { + } + catch ( lang::WrappedTargetException ) + { + } + catch ( beans::PropertyVetoException ) + { + } + catch ( lang::IllegalArgumentException ) + { + } } } } @@ -1709,7 +1709,7 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, while ( it != end ) { aEvent.PropertyName = (*it).name; - aEvent.OldValue = Any(); // @@@ to expensive to obtain...! + aEvent.OldValue = uno::Any(); // @@@ to expensive to obtain! aEvent.NewValue = (*it).value; aChanges.getArray()[ nChanged ] = aEvent; @@ -1729,21 +1729,22 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, { // Assemble new content identifier... - OUString aNewURL = getParentURL(); + rtl::OUString aNewURL = getParentURL(); if ( aNewURL.lastIndexOf( '/' ) != ( aNewURL.getLength() - 1 ) ) - aNewURL += OUString::createFromAscii( "/" ); + aNewURL += rtl::OUString::createFromAscii( "/" ); aNewURL += NeonUri::escapeSegment( aNewTitle ); - Reference< XContentIdentifier > xNewId - = new ::ucb::ContentIdentifier( m_xSMgr, aNewURL ); - Reference< XContentIdentifier > xOldId = m_xIdentifier; + uno::Reference< star::ucb::XContentIdentifier > xNewId + = new ::ucb::ContentIdentifier( m_xSMgr, aNewURL ); + uno::Reference< star::ucb::XContentIdentifier > xOldId + = m_xIdentifier; try { NeonUri sourceURI( xOldId->getContentIdentifier() ); NeonUri targetURI( xNewId->getContentIdentifier() ); - targetURI.SetScheme( OUString::createFromAscii( "http" ) ); + targetURI.SetScheme( rtl::OUString::createFromAscii( "http" ) ); m_aResAccess.MOVE( sourceURI.GetPath(), targetURI.GetURI(), sal_False, xEnv ); @@ -1771,21 +1772,21 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues, else { // Do not set new title! - aNewTitle = OUString(); + aNewTitle = rtl::OUString(); } } catch ( DAVException const & ) { // Do not set new title! - aNewTitle = OUString(); + aNewTitle = rtl::OUString(); } } if ( aNewTitle.getLength() ) { - aEvent.PropertyName = OUString::createFromAscii( "Title" ); - aEvent.OldValue = makeAny( aOldTitle ); - aEvent.NewValue = makeAny( aNewTitle ); + aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" ); + aEvent.OldValue = uno::makeAny( aOldTitle ); + aEvent.NewValue = uno::makeAny( aNewTitle ); m_aEscapedTitle = NeonUri::escapeSegment( aNewTitle ); @@ -1811,13 +1812,13 @@ void Content::queryChildren( ContentRefList& rChildren ) ::ucb::ContentRefList aAllContents; m_xProvider->queryExistingContents( aAllContents ); - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); sal_Int32 nPos = aURL.lastIndexOf( '/' ); if ( nPos != ( aURL.getLength() - 1 ) ) { // No trailing slash found. Append. - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); } sal_Int32 nLen = aURL.getLength(); @@ -1828,7 +1829,8 @@ void Content::queryChildren( ContentRefList& rChildren ) while ( it != end ) { ::ucb::ContentImplHelperRef xChild = (*it); - OUString aChildURL = xChild->getIdentifier()->getContentIdentifier(); + rtl::OUString aChildURL + = xChild->getIdentifier()->getContentIdentifier(); // Is aURL a prefix of aChildURL? if ( ( aChildURL.getLength() > nLen ) && @@ -1852,27 +1854,74 @@ void Content::queryChildren( ContentRefList& rChildren ) } //========================================================================= -void Content::insert( const Reference< XInputStream > & xInputStream, - sal_Bool bReplaceExisting, - const Reference< XCommandEnvironment >& Environment ) - throw( CommandAbortedException ) +void Content::insert( + const uno::Reference< io::XInputStream > & xInputStream, + sal_Bool bReplaceExisting, + const uno::Reference< star::ucb::XCommandEnvironment >& Environment ) + throw( uno::Exception ) { osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - if ( m_bTransient ) + // Check, if all required properties are present. + + if ( m_aEscapedTitle.getLength() == 0 ) { - // Check, if all required properties are present. + OSL_ENSURE( sal_False, "Content::insert - Title missing!" ); + + uno::Sequence< rtl::OUString > aProps( 1 ); + aProps[ 0 ] = rtl::OUString::createFromAscii( "Title" ); + ucbhelper::cancelCommandExecution( + uno::makeAny( star::ucb::MissingPropertiesException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + aProps ) ), + Environment ); + // Unreachable + } - if ( m_aEscapedTitle.getLength() == 0 ) +#if 0 + // This an API change that will be done in the future!!! + + /* [RFC 2616] - HTTP + + The PUT method requests that the enclosed entity be stored under the + supplied Request-URI. If the Request-URI refers to an already + existing resource, the enclosed entity SHOULD be considered as a + modified version of the one residing on the origin server. + */ + + /* [RFC 2518] - WebDAV + + MKCOL creates a new collection resource at the location specified by + the Request-URI. If the resource identified by the Request-URI is + non-null then the MKCOL MUST fail. + */ + + if ( !bReplaceExisting ) + { + // Complain on PUT, continue on MKCOL. + if ( !m_bTransient || ( m_bTransient && !m_bCollection ) ) { - OSL_ENSURE( sal_False, "Content::insert - Title missing!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString::createFromAscii( + "Unable to write without overwrite!" ), + static_cast< cppu::OWeakObject * >( this ), + star::ucb::NameClash::ERROR ) ), + Environment ); + + // Unreachable } + } +#endif + if ( m_bTransient ) + { // Assemble new content identifier... - OUString aURL = getParentURL(); + rtl::OUString aURL = getParentURL(); if ( aURL.lastIndexOf( '/' ) != ( aURL.getLength() - 1 ) ) - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); aURL += m_aEscapedTitle; @@ -1885,10 +1934,56 @@ void Content::insert( const Reference< XInputStream > & xInputStream, else m_aResAccess.PUT( xInputStream, Environment ); } - catch ( DAVException const & ) + catch ( DAVException const & e ) { -// OSL_ENSURE( sal_False, "MKCOL/PUT: DAVException" ); - throw CommandAbortedException(); + if ( m_bCollection ) + { + if ( e.getStatus() == 405 ) + { + // [RFC 2518] - WebDAV + // 405 (Method Not Allowed) - MKCOL can only be + // executed on a deleted/non-existent resource. + + if ( bReplaceExisting ) + { + // Destroy old resource. + try + { + m_aResAccess.DESTROY( Environment ); + } + catch ( DAVException const & e ) + { + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable + } + + // Insert (recursion!). + insert( xInputStream, bReplaceExisting, Environment ); + + // Success! + return; + } + else + { + NeonUri aURI( aURL ); + const rtl::OUString aTitle + = aURI.GetPathBaseNameUnescaped(); + + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::NameClashException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + aTitle ) ), + Environment ); + // Unreachable + } + } + } + + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } m_xIdentifier = new ::ucb::ContentIdentifier( m_xSMgr, aURL ); @@ -1901,41 +1996,244 @@ void Content::insert( const Reference< XInputStream > & xInputStream, { if ( !xInputStream.is() ) { - OSL_ENSURE( sal_False, - "Content::insert - Persistent, but no new data stream!" ); - throw CommandAbortedException(); + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::MissingInputStreamException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable } -/* - Just try a PUT! (isFolder requires network access) - if ( isFolder( Environment ) ) - { - OSL_ENSURE( sal_False, - "Content::insert - Data stream + folder!" ); - throw CommandAbortedException(); - } -*/ try { m_aResAccess.PUT( xInputStream, Environment ); } - catch ( DAVException const & ) + catch ( DAVException const & e ) { -// OSL_ENSURE( sal_False, "Content::insert - PUT: DAVException" ); - throw CommandAbortedException(); + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } + } +} + +//========================================================================= +void Content::transfer( + const star::ucb::TransferInfo & rArgs, + const uno::Reference< star::ucb::XCommandEnvironment >& Environment ) + throw( uno::Exception ) +{ + NeonUri sourceURI( rArgs.SourceURL ); + NeonUri targetURI( m_xIdentifier->getContentIdentifier() ); + + try + { + // Check source's and target's URL scheme + // + const rtl::OUString aScheme = sourceURI.GetScheme().toAsciiLowerCase(); + if ( aScheme.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) + { + sourceURI.SetScheme( + rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); + } + else + { + if ( !aScheme.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) && + !aScheme.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) ) + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::InteractiveBadTransferURLException( + rtl::OUString::createFromAscii( + "Unsupported URL scheme!" ), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable + } + } + + if ( targetURI.GetScheme().toAsciiLowerCase().equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) + targetURI.SetScheme( + rtl::OUString::createFromAscii( HTTP_URL_SCHEME ) ); + + // @@@ This implementation of 'transfer' only works + // if the source and target are located at same host. + // (Neon does not support cross-server copy/move) + + // Check for same host + // + if ( sourceURI.GetHost().getLength() && + ( sourceURI.GetHost() != targetURI.GetHost() ) ) + { + ucbhelper::cancelCommandExecution( + uno::makeAny( star::ucb::InteractiveBadTransferURLException( + rtl::OUString::createFromAscii( + "Different hosts!" ), + static_cast< cppu::OWeakObject * >( this ) ) ), + Environment ); + // Unreachable + } + + rtl::OUString aTitle = rArgs.NewTitle; + + if ( !aTitle.getLength() ) + aTitle = sourceURI.GetPathBaseNameUnescaped(); + + if ( aTitle.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "/" ) ) ) + { + // kso: ??? + aTitle = rtl::OUString(); + } + + targetURI.AppendPath( aTitle ); + + rtl::OUString aTargetURL = m_xIdentifier->getContentIdentifier(); + if ( ( aTargetURL.lastIndexOf( '/' ) + 1 ) + != aTargetURL.getLength() ) + aTargetURL += rtl::OUString::createFromAscii( "/" ); + + aTargetURL += aTitle; + + uno::Reference< star::ucb::XContentIdentifier > xTargetId + = new ::ucb::ContentIdentifier( m_xSMgr, aTargetURL ); + + DAVResourceAccess aSourceAccess( m_xSMgr, + m_aResAccess.getSessionFactory(), + sourceURI.GetURI() ); + + if ( rArgs.MoveData == sal_True ) + { + uno::Reference< star::ucb::XContentIdentifier > xId + = new ::ucb::ContentIdentifier( m_xSMgr, rArgs.SourceURL ); + // Note: The static cast is okay here, because its sure that + // m_xProvider is always the WebDAVContentProvider. + rtl::Reference< Content > xSource + = static_cast< Content * >( + m_xProvider->queryContent( xId ).get() ); + + // [RFC 2518] - WebDAV + // If a resource exists at the destination and the Overwrite + // header is "T" then prior to performing the move the server + // MUST perform a DELETE with "Depth: infinity" on the + // destination resource. If the Overwrite header is set to + // "F" then the operation will fail. + + aSourceAccess.MOVE( sourceURI.GetPath(), + targetURI.GetURI(), + rArgs.NameClash + == star::ucb::NameClash::OVERWRITE, + Environment ); + + if ( xSource.is() ) + { + // Propagate destruction to listeners. + xSource->destroy( sal_True ); + } + +// DAV resources store all additional props on server! +// // Rename own and all children's Additional Core Properties. +// renameAdditionalPropertySet( xId->getContentIdentifier(), +// xTargetId->getContentIdentifier(), +// sal_True ); + } + else + { + // [RFC 2518] - WebDAV + // If a resource exists at the destination and the Overwrite + // header is "T" then prior to performing the copy the server + // MUST perform a DELETE with "Depth: infinity" on the + // destination resource. If the Overwrite header is set to + // "F" then the operation will fail. + + aSourceAccess.COPY( sourceURI.GetPath(), + targetURI.GetURI(), + rArgs.NameClash + == star::ucb::NameClash::OVERWRITE, + Environment ); + +// DAV resources store all additional props on server! +// // Copy own and all children's Additional Core Properties. +// copyAdditionalPropertySet( xId->getContentIdentifier(), +// xTargetId->getContentIdentifier(), +// sal_True ); + } + + // Note: The static cast is okay here, because its sure that + // m_xProvider is always the WebDAVContentProvider. + rtl::Reference< Content > xTarget + = static_cast< Content * >( + m_xProvider->queryContent( xTargetId ).get() ); + + // Announce transfered content in its new folder. + xTarget->inserted(); + } + catch ( star::ucb::IllegalIdentifierException const & ) + { + // queryContent + } + catch ( DAVException const & e ) + { + // [RFC 2518] - WebDAV + // 412 (Precondition Failed) - The server was unable to maintain + // the liveness of the properties listed in the propertybehavior + // XML element or the Overwrite header is "F" and the state of + // the destination resource is non-null. + + if ( e.getStatus() == 412 ) + { + switch ( rArgs.NameClash ) + { + case star::ucb::NameClash::ERROR: + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::NameClashException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + targetURI.GetPathBaseNameUnescaped() ) ), + Environment ); + // Unreachable + } + + case star::ucb::NameClash::OVERWRITE: + break; + + case star::ucb::NameClash::KEEP: // deprecated + case star::ucb::NameClash::RENAME: + case star::ucb::NameClash::ASK: + default: + { + ucbhelper::cancelCommandExecution( + uno::makeAny( + star::ucb::UnsupportedNameClashException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + rArgs.NameClash ) ), + Environment ); + // Unreachable + } + } + } + + cancelCommandExecution( e, Environment, sal_True ); + // Unreachable } } //========================================================================= void Content::destroy( sal_Bool bDeletePhysical ) - throw( CommandAbortedException ) + throw( uno::Exception ) { // @@@ take care about bDeletePhysical -> trashcan support - OUString aURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); - Reference< XContent > xThis = this; + uno::Reference< star::ucb::XContent > xThis = this; deleted(); @@ -1958,14 +2256,14 @@ void Content::destroy( sal_Bool bDeletePhysical ) //========================================================================= sal_Bool Content::exchangeIdentity( - const Reference< XContentIdentifier >& xNewId ) + const uno::Reference< star::ucb::XContentIdentifier >& xNewId ) { if ( !xNewId.is() ) return sal_False; osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - Reference< XContent > xThis = this; + uno::Reference< star::ucb::XContent > xThis = this; // Already persistent? if ( m_bTransient ) @@ -1979,7 +2277,7 @@ sal_Bool Content::exchangeIdentity( // Fail, if a content with given id already exists. // if ( !hasData( xNewId ) ) { - OUString aOldURL = m_xIdentifier->getContentIdentifier(); + rtl::OUString aOldURL = m_xIdentifier->getContentIdentifier(); aGuard.clear(); if ( exchange( xNewId ) ) @@ -1997,16 +2295,18 @@ sal_Bool Content::exchangeIdentity( ContentRef xChild = (*it); // Create new content identifier for the child... - Reference< XContentIdentifier > xOldChildId - = xChild->getIdentifier(); - OUString aOldChildURL = xOldChildId->getContentIdentifier(); - OUString aNewChildURL + uno::Reference< star::ucb::XContentIdentifier > + xOldChildId = xChild->getIdentifier(); + rtl::OUString aOldChildURL + = xOldChildId->getContentIdentifier(); + rtl::OUString aNewChildURL = aOldChildURL.replaceAt( 0, aOldURL.getLength(), xNewId->getContentIdentifier() ); - Reference< XContentIdentifier > xNewChildId - = new ::ucb::ContentIdentifier( m_xSMgr, aNewChildURL ); + uno::Reference< star::ucb::XContentIdentifier > + xNewChildId + = new ::ucb::ContentIdentifier( m_xSMgr, aNewChildURL ); if ( !xChild->exchangeIdentity( xNewChildId ) ) return sal_False; @@ -2024,7 +2324,8 @@ sal_Bool Content::exchangeIdentity( } //========================================================================= -sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) +sal_Bool Content::isFolder( + const uno::Reference< star::ucb::XCommandEnvironment >& xEnv ) { if ( m_bTransient ) { @@ -2032,7 +2333,7 @@ sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) } else { - std::vector< OUString > aPropNames; + std::vector< rtl::OUString > aPropNames; aPropNames.push_back( DAVProperties::RESOURCETYPE ); std::vector< DAVResource > resources; @@ -2040,10 +2341,8 @@ sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) { m_aResAccess.PROPFIND( ZERO, aPropNames, resources, xEnv ); } - catch ( DAVException & ) + catch ( DAVException const & ) { -// OSL_ENSURE( sal_False, "PROPFIND : DAVException" ); - return sal_False; } if ( resources.size() != 1 ) @@ -2054,3 +2353,112 @@ sal_Bool Content::isFolder( const Reference< XCommandEnvironment >& xEnv ) && *aContentProperties.pIsFolder ); } } + +//========================================================================= +void Content::cancelCommandExecution( + const DAVException & e, + const uno::Reference< star::ucb::XCommandEnvironment > & xEnv, + sal_Bool bWrite /* = sal_False */ ) + throw ( uno::Exception ) +{ + // Map DAVException... + uno::Any aException; + switch ( e.getError() ) + { + case DAVException::DAV_HTTP_ERROR: + if ( bWrite ) + aException <<= + star::ucb::InteractiveNetworkWriteException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + else + aException <<= + star::ucb::InteractiveNetworkReadException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + break; + + case DAVException::DAV_HTTP_LOOKUP: + aException <<= + star::ucb::InteractiveNetworkResolveNameException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + break; + +// case DAVException::DAV_HTTP_AUTH: +// break; +// +// case DAVException::DAV_HTTP_AUTHPROXY: +// break; +// +// case DAVException::DAV_HTTP_SERVERAUTH: +// break; +// +// case DAVException::DAV_HTTP_PROXYAUTH: +// break; + + case DAVException::DAV_HTTP_CONNECT: + aException <<= + star::ucb::InteractiveNetworkConnectException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR, + e.getData() ); + break; + +/* + case DAVException::DAV_HTTP_TIMEOUT: + break; +*/ + +// case DAVException::DAV_HTTP_REDIRECT: +// break; + +// case DAVException::DAV_SESSION_CREATE: +// break; + + case DAVException::DAV_INVALID_ARG: + aException <<= + lang::IllegalArgumentException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + -1 ); + break; + + case DAVException::DAV_FILE_OPEN: + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_READ, + e.getData(), + xEnv, + rtl::OUString::createFromAscii( + "Cannot open file!" ), + this ); + // Unreachable! + + case DAVException::DAV_FILE_WRITE: + ucbhelper::cancelCommandExecution( + star::ucb::IOErrorCode_CANT_WRITE, + e.getData(), + xEnv, + rtl::OUString::createFromAscii( + "Cannot write to file!" ), + this ); + // Unreachable! + + default: + aException <<= + star::ucb::InteractiveNetworkGeneralException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + task::InteractionClassification_ERROR ); + break; + } + + ucbhelper::cancelCommandExecution( aException, xEnv ); +} diff --git a/ucb/source/ucp/webdav/webdavcontent.hxx b/ucb/source/ucp/webdav/webdavcontent.hxx index 08cd8f7d37ce..e428f52222d6 100644 --- a/ucb/source/ucp/webdav/webdavcontent.hxx +++ b/ucb/source/ucp/webdav/webdavcontent.hxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavcontent.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,8 +64,8 @@ #include <list> -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> #endif #ifndef _COM_SUN_STAR_UCB_CONTENTCREATIONEXCEPTION_HPP_ @@ -99,6 +99,10 @@ namespace com { namespace sun { namespace star { namespace sdbc { class XRow; } } } } +namespace com { namespace sun { namespace star { namespace ucb { + struct TransferInfo; +} } } } + namespace webdav_ucp { @@ -148,7 +152,7 @@ private: const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); - typedef vos::ORef< Content > ContentRef; + typedef rtl::Reference< Content > ContentRef; typedef std::list< ContentRef > ContentRefList; void queryChildren( ContentRefList& rChildren); @@ -162,11 +166,24 @@ private: sal_Bool bReplaceExisting, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment ) - throw( ::com::sun::star::ucb::CommandAbortedException ); + throw( ::com::sun::star::uno::Exception ); + + // Command "transfer" + void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& Environment ) + throw( ::com::sun::star::uno::Exception ); // Command "delete" void destroy( sal_Bool bDeletePhysical ) - throw( ::com::sun::star::ucb::CommandAbortedException ); + throw( ::com::sun::star::uno::Exception ); + + void cancelCommandExecution( + const DAVException & e, + const ::com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv, + sal_Bool bWrite = sal_False ) + throw( ::com::sun::star::uno::Exception ); public: Content( const ::com::sun::star::uno::Reference< @@ -261,7 +278,7 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, const ContentProperties& rData, - const ::vos::ORef< + const rtl::Reference< ::ucb::ContentProviderImplHelper >& rProvider, const ::rtl::OUString& rContentId ); }; diff --git a/ucb/source/ucp/webdav/webdavcontentcaps.cxx b/ucb/source/ucp/webdav/webdavcontentcaps.cxx index f6ea578cc0d3..a8f27adddea1 100644 --- a/ucb/source/ucp/webdav/webdavcontentcaps.cxx +++ b/ucb/source/ucp/webdav/webdavcontentcaps.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavcontentcaps.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,11 +112,7 @@ #include "DAVSession.hxx" #endif -using namespace com::sun::star::util; -using namespace com::sun::star::beans; -using namespace com::sun::star::uno; -using namespace com::sun::star::ucb; -using namespace rtl; +using namespace com::sun::star; using namespace webdav_ucp; //========================================================================= @@ -126,7 +122,7 @@ using namespace webdav_ucp; //========================================================================= bool ContentProvider::getProperty( - const OUString & rPropName, Property & rProp, bool bStrict ) + const rtl::OUString & rPropName, beans::Property & rProp, bool bStrict ) { if ( !m_pProps ) { @@ -141,150 +137,175 @@ bool ContentProvider::getProperty( // Mandatory UCB properties. m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), + beans::Property( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), + beans::Property( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), -1, getCppuBooleanType(), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), -1, getCppuBooleanType(), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ) ); // Optional UCB properties. m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), + beans::Property( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), -1, - getCppuType( static_cast< const DateTime * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const util::DateTime * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), + beans::Property( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), -1, - getCppuType( static_cast< const DateTime * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const util::DateTime * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), -1, getCppuType( static_cast< const sal_Int64 * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); // Standard DAV properties. m_pProps->insert( - Property( + beans::Property( DAVProperties::CREATIONDATE, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::DISPLAYNAME, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::GETCONTENTLANGUAGE, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::GETCONTENTLENGTH, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::GETCONTENTTYPE , -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::GETETAG, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::GETLASTMODIFIED, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::LOCKDISCOVERY, -1, - getCppuType( static_cast< const Sequence< Lock > * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< + const uno::Sequence< + com::sun::star::ucb::Lock > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::RESOURCETYPE, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::SOURCE, -1, - getCppuType( - static_cast< const Sequence< Link > * >( 0 ) ), - PropertyAttribute::BOUND ) ); + getCppuType( static_cast< + const uno::Sequence< + com::sun::star::ucb::Link > * >( 0 ) ), + beans::PropertyAttribute::BOUND ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::SUPPORTEDLOCK, -1, - getCppuType( - static_cast< const Sequence< LockEntry > * >( 0 ) ), - PropertyAttribute::BOUND | PropertyAttribute::READONLY ) ); + getCppuType( static_cast< + const uno::Sequence< + com::sun::star::ucb::LockEntry > * >( + 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); m_pProps->insert( - Property( + beans::Property( DAVProperties::EXECUTABLE, -1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND ) ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ) ); } } @@ -292,7 +313,7 @@ bool ContentProvider::getProperty( // Lookup property. ////////////////////////////////////////////////////////////// - Property aProp; + beans::Property aProp; aProp.Name = rPropName; const PropertyMap::const_iterator it = m_pProps->find( aProp ); if ( it != m_pProps->end() ) @@ -305,11 +326,11 @@ bool ContentProvider::getProperty( return false; // All unknown props are treated as: - rProp = Property( + rProp = beans::Property( rPropName, - 1, - getCppuType( static_cast< const OUString * >( 0 ) ), - PropertyAttribute::BOUND ); + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ); } return true; @@ -322,13 +343,13 @@ bool ContentProvider::getProperty( //========================================================================= // virtual -Sequence< Property > Content::getProperties( - const Reference< XCommandEnvironment > & xEnv ) +uno::Sequence< beans::Property > Content::getProperties( + const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); // Obtain all properties supported for this resource from server. - std::vector< OUString > aProps; + std::vector< rtl::OUString > aProps; try { std::vector< DAVResourceInfo > props; @@ -343,7 +364,7 @@ Sequence< Property > Content::getProperties( } sal_Int32 nTotal = aProps.size() + 4; // number of mandatory props - Sequence< Property > aProperties( nTotal ); + uno::Sequence< beans::Property > aProperties( nTotal ); sal_Int32 nPos = 0; @@ -353,10 +374,10 @@ Sequence< Property > Content::getProperties( sal_Bool bHasContentType = sal_False; // getcontenttype <-> MediaType sal_Bool bHasContentLength = sal_False; // getcontentlength <-> Size - Property aProp; + beans::Property aProp; - std::vector< OUString >::const_iterator it = aProps.begin(); - std::vector< OUString >::const_iterator end = aProps.end(); + std::vector< rtl::OUString >::const_iterator it = aProps.begin(); + std::vector< rtl::OUString >::const_iterator end = aProps.end(); while ( it != end ) { m_pProvider->getProperty( (*it), aProp ); @@ -396,47 +417,51 @@ Sequence< Property > Content::getProperties( // Add mandatory properties. m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), aProp ); aProperties[ nPos++ ] = aProp; m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), aProp ); aProperties[ nPos++ ] = aProp; m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), aProp ); aProperties[ nPos++ ] = aProp; m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aProp ); aProperties[ nPos++ ] = aProp; // Add optional properties. if ( bHasCreationDate ) { m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), aProp ); aProperties[ nPos++ ] = aProp; } if ( bHasLastModified ) { m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ), aProp ); aProperties[ nPos++ ] = aProp; } if ( bHasContentType ) { m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aProp ); aProperties[ nPos++ ] = aProp; } if ( bHasContentLength ) { m_pProvider->getProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), aProp ); aProperties[ nPos++ ] = aProp; } @@ -444,10 +469,11 @@ Sequence< Property > Content::getProperties( } //========================================================================= -void Content::getProperties( const Reference< XCommandEnvironment > & xEnv, - PropertyMap & rProps ) +void Content::getProperties( + const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv, + PropertyMap & rProps ) { - Sequence< Property > aProps = getProperties( xEnv ); + uno::Sequence< beans::Property > aProps = getProperties( xEnv ); sal_Int32 nCount = aProps.getLength(); for ( sal_Int32 n = 0; n < nCount; ++n ) rProps.insert( aProps[ n ] ); @@ -455,8 +481,8 @@ void Content::getProperties( const Reference< XCommandEnvironment > & xEnv, //========================================================================= // virtual -Sequence< CommandInfo > Content::getCommands( - const Reference< XCommandEnvironment > & xEnv ) +uno::Sequence< com::sun::star::ucb::CommandInfo > Content::getCommands( + const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); @@ -468,56 +494,65 @@ Sequence< CommandInfo > Content::getCommands( // //================================================================= - static CommandInfo aFolderCommandInfoTable[] = + static com::sun::star::ucb::CommandInfo aFolderCommandInfoTable[] = { /////////////////////////////////////////////////////////////// // Required commands /////////////////////////////////////////////////////////////// - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), -1, getCppuVoidType() ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), -1, getCppuVoidType() ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), -1, - getCppuType( static_cast< Sequence< Property > * >( 0 ) ) + getCppuType( static_cast< + uno::Sequence< beans::Property > * >( 0 ) ) ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), -1, - getCppuType( static_cast< Sequence< PropertyValue > * >( 0 ) ) + getCppuType( static_cast< + uno::Sequence< beans::PropertyValue > * >( 0 ) ) ), /////////////////////////////////////////////////////////////// // Optional standard commands /////////////////////////////////////////////////////////////// - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), -1, getCppuBooleanType() ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), -1, - getCppuType( static_cast< InsertCommandArgument * >( 0 ) ) + getCppuType( static_cast< + com::sun::star::ucb::InsertCommandArgument * >( 0 ) ) ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), -1, - getCppuType( static_cast< OpenCommandArgument2 * >( 0 ) ) + getCppuType( static_cast< + com::sun::star::ucb::OpenCommandArgument2 * >( 0 ) ) ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), -1, - getCppuType( static_cast< TransferInfo * >( 0 ) ) + getCppuType( static_cast< + com::sun::star::ucb::TransferInfo * >( 0 ) ) ) /////////////////////////////////////////////////////////////// @@ -525,20 +560,21 @@ Sequence< CommandInfo > Content::getCommands( /////////////////////////////////////////////////////////////// /* - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "COPY" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COPY" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "MOVE" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MOVE" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), ) */ }; - return Sequence< CommandInfo >( aFolderCommandInfoTable, 8 ); + return uno::Sequence< com::sun::star::ucb::CommandInfo >( + aFolderCommandInfoTable, 8 ); } else { @@ -548,51 +584,59 @@ Sequence< CommandInfo > Content::getCommands( // //================================================================= - static CommandInfo aDocumentCommandInfoTable[] = + static com::sun::star::ucb::CommandInfo aDocumentCommandInfoTable[] = { /////////////////////////////////////////////////////////////// // Required commands /////////////////////////////////////////////////////////////// - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), -1, getCppuVoidType() ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), -1, getCppuVoidType() ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), -1, - getCppuType( static_cast< Sequence< Property > * >( 0 ) ) + getCppuType( static_cast< + uno::Sequence< beans::Property > * >( 0 ) ) ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), -1, - getCppuType( static_cast< Sequence< PropertyValue > * >( 0 ) ) + getCppuType( static_cast< + uno::Sequence< beans::PropertyValue > * >( 0 ) ) ), /////////////////////////////////////////////////////////////// // Optional standard commands /////////////////////////////////////////////////////////////// - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), -1, getCppuBooleanType() ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), -1, - getCppuType( static_cast< InsertCommandArgument * >( 0 ) ) + getCppuType( static_cast< + com::sun::star::ucb::InsertCommandArgument * >( 0 ) ) ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), -1, - getCppuType( static_cast< OpenCommandArgument2 * >( 0 ) ) + getCppuType( static_cast< + com::sun::star::ucb::OpenCommandArgument2 * >( 0 ) ) ) /////////////////////////////////////////////////////////////// @@ -600,20 +644,21 @@ Sequence< CommandInfo > Content::getCommands( /////////////////////////////////////////////////////////////// /* - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "COPY" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COPY" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), ), - CommandInfo( - OUString( RTL_CONSTASCII_USTRINGPARAM( "MOVE" ) ), + com::sun::star::ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MOVE" ) ), -1, - getCppuType( static_cast< const OUString * >( 0 ) ), + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), ) */ }; - return Sequence< CommandInfo >( aDocumentCommandInfoTable, 7 ); + return uno::Sequence< com::sun::star::ucb::CommandInfo >( + aDocumentCommandInfoTable, 7 ); } } diff --git a/ucb/source/ucp/webdav/webdavdatasupplier.cxx b/ucb/source/ucp/webdav/webdavdatasupplier.cxx index 8c1595a0dbf9..403bf357a5ee 100644 --- a/ucb/source/ucp/webdav/webdavdatasupplier.cxx +++ b/ucb/source/ucp/webdav/webdavdatasupplier.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavdatasupplier.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,14 +93,7 @@ #include "DAVSession.hxx" #endif -using namespace com::sun::star::beans; -using namespace com::sun::star::lang; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; -using namespace com::sun::star::sdbc; -using namespace rtl; -using namespace ucb; - +using namespace com::sun::star; using namespace webdav_ucp; namespace webdav_ucp @@ -114,11 +107,11 @@ namespace webdav_ucp struct ResultListEntry { - OUString aId; - Reference< XContentIdentifier > xId; - Reference< XContent > xContent; - Reference< XRow > xRow; - const ContentProperties* pData; + rtl::OUString aId; + uno::Reference< com::sun::star::ucb::XContentIdentifier > xId; + uno::Reference< com::sun::star::ucb::XContent > xContent; + uno::Reference< sdbc::XRow > xRow; + const ContentProperties* pData; ResultListEntry( const ContentProperties* pEntry ) : pData( pEntry ) {}; ~ResultListEntry() { delete pData; } @@ -140,16 +133,17 @@ typedef std::vector< ResultListEntry* > ResultList; struct DataSupplier_Impl { - osl::Mutex m_aMutex; - ResultList m_aResults; - vos::ORef< Content > m_xContent; - Reference< XMultiServiceFactory > m_xSMgr; - sal_Int32 m_nOpenMode; - sal_Bool m_bCountFinal; - - DataSupplier_Impl( const Reference< XMultiServiceFactory >& rxSMgr, - const vos::ORef< Content >& rContent, - sal_Int32 nOpenMode ) + osl::Mutex m_aMutex; + ResultList m_aResults; + rtl::Reference< Content > m_xContent; + uno::Reference< lang::XMultiServiceFactory > m_xSMgr; + sal_Int32 m_nOpenMode; + sal_Bool m_bCountFinal; + + DataSupplier_Impl( + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + const rtl::Reference< Content >& rContent, + sal_Int32 nOpenMode ) : m_xContent( rContent ), m_xSMgr( rxSMgr ), m_nOpenMode( nOpenMode ), m_bCountFinal( sal_False ) {} ~DataSupplier_Impl(); @@ -178,9 +172,10 @@ DataSupplier_Impl::~DataSupplier_Impl() //========================================================================= //========================================================================= -DataSupplier::DataSupplier( const Reference< XMultiServiceFactory >& rxSMgr, - const vos::ORef< Content >& rContent, - sal_Int32 nOpenMode ) +DataSupplier::DataSupplier( + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + const rtl::Reference< Content >& rContent, + sal_Int32 nOpenMode ) : m_pImpl( new DataSupplier_Impl( rxSMgr, rContent, nOpenMode ) ) { } @@ -194,13 +189,13 @@ DataSupplier::~DataSupplier() //========================================================================= // virtual -OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) +rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); if ( nIndex < m_pImpl->m_aResults.size() ) { - OUString aId = m_pImpl->m_aResults[ nIndex ]->aId; + rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aId; if ( aId.getLength() ) { // Already cached. @@ -210,34 +205,34 @@ OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) if ( getResult( nIndex ) ) { - OUString aId + rtl::OUString aId = m_pImpl->m_xContent->getIdentifier()->getContentIdentifier(); const ContentProperties& props = *( m_pImpl->m_aResults[ nIndex ]->pData ); if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() ) - aId += OUString::createFromAscii( "/" ); + aId += rtl::OUString::createFromAscii( "/" ); aId += props.aEscapedTitle; m_pImpl->m_aResults[ nIndex ]->aId = aId; return aId; } - return OUString(); + return rtl::OUString(); } //========================================================================= // virtual -Reference< XContentIdentifier > DataSupplier::queryContentIdentifier( - sal_uInt32 nIndex ) +uno::Reference< com::sun::star::ucb::XContentIdentifier > +DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); if ( nIndex < m_pImpl->m_aResults.size() ) { - Reference< XContentIdentifier > xId - = m_pImpl->m_aResults[ nIndex ]->xId; + uno::Reference< com::sun::star::ucb::XContentIdentifier > xId + = m_pImpl->m_aResults[ nIndex ]->xId; if ( xId.is() ) { // Already cached. @@ -245,26 +240,28 @@ Reference< XContentIdentifier > DataSupplier::queryContentIdentifier( } } - OUString aId = queryContentIdentifierString( nIndex ); + rtl::OUString aId = queryContentIdentifierString( nIndex ); if ( aId.getLength() ) { - Reference< XContentIdentifier > xId = new ContentIdentifier( aId ); + uno::Reference< com::sun::star::ucb::XContentIdentifier > xId + = new ::ucb::ContentIdentifier( aId ); m_pImpl->m_aResults[ nIndex ]->xId = xId; return xId; } - return Reference< XContentIdentifier >(); + return uno::Reference< com::sun::star::ucb::XContentIdentifier >(); } //========================================================================= // virtual -Reference< XContent > DataSupplier::queryContent( sal_uInt32 nIndex ) +uno::Reference< com::sun::star::ucb::XContent > +DataSupplier::queryContent( sal_uInt32 nIndex ) { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); if ( nIndex < m_pImpl->m_aResults.size() ) { - Reference< XContent > xContent - = m_pImpl->m_aResults[ nIndex ]->xContent; + uno::Reference< com::sun::star::ucb::XContent > xContent + = m_pImpl->m_aResults[ nIndex ]->xContent; if ( xContent.is() ) { // Already cached. @@ -272,22 +269,23 @@ Reference< XContent > DataSupplier::queryContent( sal_uInt32 nIndex ) } } - Reference< XContentIdentifier > xId = queryContentIdentifier( nIndex ); + uno::Reference< com::sun::star::ucb::XContentIdentifier > xId + = queryContentIdentifier( nIndex ); if ( xId.is() ) { try { - Reference< XContent > xContent + uno::Reference< com::sun::star::ucb::XContent > xContent = m_pImpl->m_xContent->getProvider()->queryContent( xId ); m_pImpl->m_aResults[ nIndex ]->xContent = xContent; return xContent; } - catch ( IllegalIdentifierException& ) + catch ( com::sun::star::ucb::IllegalIdentifierException& ) { } } - return Reference< XContent >(); + return uno::Reference< com::sun::star::ucb::XContent >(); } //========================================================================= @@ -341,13 +339,14 @@ sal_Bool DataSupplier::isCountFinal() //========================================================================= // virtual -Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex ) +uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( + sal_uInt32 nIndex ) { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); if ( nIndex < m_pImpl->m_aResults.size() ) { - Reference< XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow; + uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow; if ( xRow.is() ) { // Already cached. @@ -357,17 +356,19 @@ Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex ) if ( getResult( nIndex ) ) { - Reference< XRow > xRow = Content::getPropertyValues( - m_pImpl->m_xSMgr, - getResultSet()->getProperties(), - *(m_pImpl->m_aResults[ nIndex ]->pData), - m_pImpl->m_xContent->getProvider(), - queryContentIdentifierString( nIndex ) ); + uno::Reference< sdbc::XRow > xRow + = Content::getPropertyValues( + m_pImpl->m_xSMgr, + getResultSet()->getProperties(), + *(m_pImpl->m_aResults[ nIndex ]->pData), + rtl::Reference< ::ucb::ContentProviderImplHelper >( + m_pImpl->m_xContent->getProvider().getBodyPtr() ), + queryContentIdentifierString( nIndex ) ); m_pImpl->m_aResults[ nIndex ]->xRow = xRow; return xRow; } - return Reference< XRow >(); + return uno::Reference< sdbc::XRow >(); } //========================================================================= @@ -377,7 +378,7 @@ void DataSupplier::releasePropertyValues( sal_uInt32 nIndex ) osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); if ( nIndex < m_pImpl->m_aResults.size() ) - m_pImpl->m_aResults[ nIndex ]->xRow = Reference< XRow >(); + m_pImpl->m_aResults[ nIndex ]->xRow = uno::Reference< sdbc::XRow >(); } //========================================================================= @@ -389,7 +390,7 @@ void DataSupplier::close() //========================================================================= // virtual void DataSupplier::validate() - throw( ResultSetException ) + throw( com::sun::star::ucb::ResultSetException ) { } @@ -400,7 +401,7 @@ sal_Bool DataSupplier::getData() if ( !m_pImpl->m_bCountFinal ) { - std::vector< OUString > propertyNames; + std::vector< rtl::OUString > propertyNames; ContentProperties::UCBNamesToDAVNames( getResultSet()->getProperties(), propertyNames ); @@ -408,8 +409,10 @@ sal_Bool DataSupplier::getData() // needed to get a valid ContentProperties::pIsFolder value, which // is needed for OpenMode handling. - std::vector< OUString >::const_iterator it = propertyNames.begin(); - std::vector< OUString >::const_iterator end = propertyNames.end(); + std::vector< rtl::OUString >::const_iterator it + = propertyNames.begin(); + std::vector< rtl::OUString >::const_iterator end + = propertyNames.end(); while ( it != end ) { @@ -447,7 +450,7 @@ sal_Bool DataSupplier::getData() // Check resource against open mode. switch ( m_pImpl->m_nOpenMode ) { - case OpenMode::FOLDERS: + case com::sun::star::ucb::OpenMode::FOLDERS: if ( !( pContentProperties->pIsFolder && *pContentProperties->pIsFolder ) ) { @@ -456,7 +459,7 @@ sal_Bool DataSupplier::getData() } break; - case OpenMode::DOCUMENTS: + case com::sun::star::ucb::OpenMode::DOCUMENTS: if ( !( pContentProperties->pIsDocument && *pContentProperties->pIsDocument ) ) { @@ -465,7 +468,7 @@ sal_Bool DataSupplier::getData() } break; - case OpenMode::ALL: + case com::sun::star::ucb::OpenMode::ALL: default: break; } diff --git a/ucb/source/ucp/webdav/webdavdatasupplier.hxx b/ucb/source/ucp/webdav/webdavdatasupplier.hxx index 6909d8923d88..0643ff783a3d 100644 --- a/ucb/source/ucp/webdav/webdavdatasupplier.hxx +++ b/ucb/source/ucp/webdav/webdavdatasupplier.hxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavdatasupplier.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-05-16 15:30:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,12 +62,16 @@ #ifndef _WEBDAV_UCP_DATASUPPLIER_HXX #define _WEBDAV_UCP_DATASUPPLIER_HXX +#include <vector> + +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif + #ifndef _UCBHELPER_RESULTSET_HXX #include <ucbhelper/resultset.hxx> #endif -#ifndef __VECTOR__ -#include <vector> -#endif + namespace webdav_ucp { struct DataSupplier_Impl; @@ -85,7 +89,7 @@ private: public: DataSupplier( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr, - const vos::ORef< Content >& rContent, + const rtl::Reference< Content >& rContent, sal_Int32 nOpenMode); virtual ~DataSupplier(); diff --git a/ucb/source/ucp/webdav/webdavprovider.cxx b/ucb/source/ucp/webdav/webdavprovider.cxx index f7784fa94cfd..24281605f386 100644 --- a/ucb/source/ucp/webdav/webdavprovider.cxx +++ b/ucb/source/ucp/webdav/webdavprovider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavprovider.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: kso $ $Date: 2001-06-18 08:23:48 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,9 +65,6 @@ *************************************************************************/ -#ifndef _VOS_DIAGNOSE_HXX_ -#include <vos/diagnose.hxx> -#endif #ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX #include <ucbhelper/contentidentifier.hxx> #endif @@ -79,11 +76,7 @@ #include "webdavcontent.hxx" #endif -using namespace com::sun::star::lang; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; -using namespace rtl; - +using namespace com::sun::star; using namespace webdav_ucp; //========================================================================= @@ -95,7 +88,7 @@ using namespace webdav_ucp; //========================================================================= ContentProvider::ContentProvider( - const Reference< XMultiServiceFactory >& rSMgr ) + const uno::Reference< lang::XMultiServiceFactory >& rSMgr ) : ::ucb::ContentProviderImplHelper( rSMgr ), m_pProps( 0 ) { @@ -114,11 +107,10 @@ ContentProvider::~ContentProvider() // //========================================================================= -// @@@ Add own interfaces. XINTERFACE_IMPL_3( ContentProvider, - XTypeProvider, - XServiceInfo, - XContentProvider ); + lang::XTypeProvider, + lang::XServiceInfo, + com::sun::star::ucb::XContentProvider ); //========================================================================= // @@ -126,11 +118,10 @@ XINTERFACE_IMPL_3( ContentProvider, // //========================================================================= -// @@@ Add own interfaces. XTYPEPROVIDER_IMPL_3( ContentProvider, - XTypeProvider, - XServiceInfo, - XContentProvider ); + lang::XTypeProvider, + lang::XServiceInfo, + com::sun::star::ucb::XContentProvider ); //========================================================================= // @@ -139,9 +130,9 @@ XTYPEPROVIDER_IMPL_3( ContentProvider, //========================================================================= XSERVICEINFO_IMPL_1( ContentProvider, - OUString::createFromAscii( + rtl::OUString::createFromAscii( "com.sun.star.comp.WebDAVContentProvider" ), - OUString::createFromAscii( + rtl::OUString::createFromAscii( WEBDAV_CONTENT_PROVIDER_SERVICE_NAME ) ); //========================================================================= @@ -159,15 +150,18 @@ ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); //========================================================================= // virtual -Reference< XContent > SAL_CALL ContentProvider::queryContent( - const Reference< XContentIdentifier >& Identifier ) - throw( IllegalIdentifierException, RuntimeException ) +uno::Reference< com::sun::star::ucb::XContent > SAL_CALL +ContentProvider::queryContent( + const uno::Reference< + com::sun::star::ucb::XContentIdentifier >& Identifier ) + throw( com::sun::star::ucb::IllegalIdentifierException, + uno::RuntimeException ) { vos::OGuard aGuard( m_aMutex ); // Check URL scheme... - const OUString aScheme + const rtl::OUString aScheme = Identifier->getContentProviderScheme().toAsciiLowerCase(); if ( !aScheme.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( HTTP_URL_SCHEME ) ) && @@ -175,21 +169,21 @@ Reference< XContent > SAL_CALL ContentProvider::queryContent( RTL_CONSTASCII_STRINGPARAM( HTTPS_URL_SCHEME ) ) && !aScheme.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( WEBDAV_URL_SCHEME ) ) ) - throw IllegalIdentifierException(); + throw com::sun::star::ucb::IllegalIdentifierException(); // Normalize URL and create new Id, if nessacary. - OUString aURL = Identifier->getContentIdentifier(); + rtl::OUString aURL = Identifier->getContentIdentifier(); // At least: <scheme> + "://" if ( aURL.getLength() < ( aScheme.getLength() + 3 ) ) - throw IllegalIdentifierException(); + throw com::sun::star::ucb::IllegalIdentifierException(); if ( ( aURL.getStr()[ aScheme.getLength() ] != sal_Unicode( ':' ) ) || ( aURL.getStr()[ aScheme.getLength() + 1 ] != sal_Unicode( '/' ) ) || ( aURL.getStr()[ aScheme.getLength() + 2 ] != sal_Unicode( '/' ) ) ) - throw IllegalIdentifierException(); + throw com::sun::star::ucb::IllegalIdentifierException(); - Reference< XContentIdentifier > xCanonicId; + uno::Reference< com::sun::star::ucb::XContentIdentifier > xCanonicId; sal_Int32 nPos = aURL.lastIndexOf( '/' ); if ( nPos != aURL.getLength() - 1 ) @@ -197,12 +191,12 @@ Reference< XContent > SAL_CALL ContentProvider::queryContent( // Find second slash in URL. nPos = aURL.indexOf( '/', aURL.indexOf( '/' ) + 1 ); if ( nPos == -1 ) - throw IllegalIdentifierException(); + throw com::sun::star::ucb::IllegalIdentifierException(); nPos = aURL.indexOf( '/', nPos + 1 ); if ( nPos == -1 ) { - aURL += OUString::createFromAscii( "/" ); + aURL += rtl::OUString::createFromAscii( "/" ); xCanonicId = new ::ucb::ContentIdentifier( m_xSMgr, aURL ); } else @@ -212,29 +206,26 @@ Reference< XContent > SAL_CALL ContentProvider::queryContent( xCanonicId = Identifier; // Check, if a content with given id already exists... - Reference< XContent > xContent + uno::Reference< com::sun::star::ucb::XContent > xContent = queryExistingContent( xCanonicId ).getBodyPtr(); if ( xContent.is() ) return xContent; - // @@@ Decision, which content implementation to instanciate may be - // made here ( in case you have different content classes ). - // Create a new content. Note that the content will insert itself // into providers content list by calling addContent(...) from it's ctor. try { - xContent = new ::webdav_ucp::Content( + xContent = new ::webdav_ucp::Content( m_xSMgr, this, xCanonicId, &m_aDAVSessionFactory ); } - catch (ContentCreationException e) + catch ( com::sun::star::ucb::ContentCreationException const & ) { - throw IllegalIdentifierException(); + throw com::sun::star::ucb::IllegalIdentifierException(); } if ( !xContent->getIdentifier().is() ) - throw IllegalIdentifierException(); + throw com::sun::star::ucb::IllegalIdentifierException(); return xContent; } diff --git a/ucb/source/ucp/webdav/webdavresultset.cxx b/ucb/source/ucp/webdav/webdavresultset.cxx index 14d887fe59d7..35673c59a3ae 100644 --- a/ucb/source/ucp/webdav/webdavresultset.cxx +++ b/ucb/source/ucp/webdav/webdavresultset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavresultset.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: kso $ $Date: 2000-11-07 15:49:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,10 +74,8 @@ #ifndef _WEBDAV_SESSION_HXX #include "DAVSession.hxx" #endif -using namespace com::sun::star::lang; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; +using namespace com::sun::star; using namespace webdav_ucp; //========================================================================= @@ -89,10 +87,11 @@ using namespace webdav_ucp; //========================================================================= DynamicResultSet::DynamicResultSet( - const Reference< XMultiServiceFactory >& rxSMgr, - const vos::ORef< Content >& rxContent, - const OpenCommandArgument2& rCommand, - const Reference< XCommandEnvironment >& rxEnv ) + const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, + const rtl::Reference< Content >& rxContent, + const com::sun::star::ucb::OpenCommandArgument2& rCommand, + const uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& rxEnv ) : ResultSetImplHelper( rxSMgr, rCommand ), m_xContent( rxContent ), m_xEnv( rxEnv ) diff --git a/ucb/source/ucp/webdav/webdavresultset.hxx b/ucb/source/ucp/webdav/webdavresultset.hxx index e021e789ad4a..a022b9260b80 100644 --- a/ucb/source/ucp/webdav/webdavresultset.hxx +++ b/ucb/source/ucp/webdav/webdavresultset.hxx @@ -2,9 +2,9 @@ * * $RCSfile: webdavresultset.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: kso $ $Date: 2000-11-07 15:49:00 $ + * last change: $Author: kso $ $Date: 2001-06-25 08:51:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,12 +62,12 @@ #ifndef _WEBDAV_UCP_RESULTSET_HXX #define _WEBDAV_UCP_RESULTSET_HXX +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif #ifndef _UCBHELPER_RESULTSETHELPER_HXX #include <ucbhelper/resultsethelper.hxx> #endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> -#endif #ifndef _WEBDAV_UCP_CONTENT_HXX #include "webdavcontent.hxx" @@ -80,7 +80,7 @@ namespace webdav_ucp { class DynamicResultSet : public ::ucb::ResultSetImplHelper { - vos::ORef< Content > m_xContent; + rtl::Reference< Content > m_xContent; com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv; @@ -91,7 +91,7 @@ private: public: DynamicResultSet( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr, - const vos::ORef< Content >& rxContent, + const rtl::Reference< Content >& rxContent, const com::sun::star::ucb::OpenCommandArgument2& rCommand, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv ); |