From 36269f66836b17eaa7153cd78aa941468629807c Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 2 Dec 2011 00:46:23 +0100 Subject: online update: Revert the UpdateInformationProvider::load() cleanup. It turns out that the direct UCB access was deliberate to be able to provide the identification / additional information. --- extensions/source/update/feed/makefile.mk | 1 - extensions/source/update/feed/updatefeed.cxx | 50 ++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/extensions/source/update/feed/makefile.mk b/extensions/source/update/feed/makefile.mk index 496842d71524..6361f20bdd73 100644 --- a/extensions/source/update/feed/makefile.mk +++ b/extensions/source/update/feed/makefile.mk @@ -50,7 +50,6 @@ SHL1OBJS=$(SLOFILES) SHL1IMPLIB=i$(SHL1TARGET) SHL1STDLIBS= \ - $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx index f5caafc4902c..42a73015d116 100644 --- a/extensions/source/update/feed/updatefeed.cxx +++ b/extensions/source/update/feed/updatefeed.cxx @@ -27,12 +27,10 @@ ************************************************************************/ -#include #include #include #include #include -#include #include #include #include @@ -474,17 +472,49 @@ UpdateInformationProvider::storeCommandInfo( uno::Reference< io::XInputStream > UpdateInformationProvider::load(const rtl::OUString& rURL) { - beans::PropertyValue aURLValue; - aURLValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); - aURLValue.Value <<= rURL; + uno::Reference< ucb::XContentIdentifier > xId = m_xContentIdFactory->createContentIdentifier(rURL); - uno::Sequence< beans::PropertyValue > aValues( 1 ); - aValues[0] = aURLValue; + if( !xId.is() ) + throw uno::RuntimeException( + UNISTRING( "unable to obtain universal content id" ), *this); + + uno::Reference< ucb::XCommandProcessor > xCommandProcessor(m_xContentProvider->queryContent(xId), uno::UNO_QUERY_THROW); + rtl::Reference< ActiveDataSink > aSink(new ActiveDataSink()); + + ucb::OpenCommandArgument2 aOpenArgument; + aOpenArgument.Mode = ucb::OpenMode::DOCUMENT; + aOpenArgument.Priority = 32768; + aOpenArgument.Sink = *aSink; + + ucb::Command aCommand; + aCommand.Name = UNISTRING("open"); + aCommand.Argument = uno::makeAny(aOpenArgument); + + sal_Int32 nCommandId = xCommandProcessor->createCommandIdentifier(); + + storeCommandInfo(nCommandId, xCommandProcessor); + try + { + uno::Any aResult = xCommandProcessor->execute(aCommand, nCommandId, + static_cast < XCommandEnvironment *> (this)); + } + catch( const uno::Exception & /* e */ ) + { + storeCommandInfo(0, uno::Reference< ucb::XCommandProcessor > ()); + + uno::Reference< ucb::XCommandProcessor2 > xCommandProcessor2(xCommandProcessor, uno::UNO_QUERY); + if( xCommandProcessor2.is() ) + xCommandProcessor2->releaseCommandIdentifier(nCommandId); + + throw; + } + storeCommandInfo(0, uno::Reference< ucb::XCommandProcessor > ()); - ::comphelper::MediaDescriptor aMediaDesc( aValues ); - aMediaDesc.addInputStream(); + uno::Reference< ucb::XCommandProcessor2 > xCommandProcessor2(xCommandProcessor, uno::UNO_QUERY); + if( xCommandProcessor2.is() ) + xCommandProcessor2->releaseCommandIdentifier(nCommandId); - return aMediaDesc.getUnpackedValueOrDefault( ::comphelper::MediaDescriptor::PROP_INPUTSTREAM(), uno::Reference< io::XInputStream >() ); + return INPUT_STREAM(aSink->getInputStream()); } //------------------------------------------------------------------------------ -- cgit