[Libreoffice-commits] .: 2 commits - extensions/source

Jan Holesovsky kendy at kemper.freedesktop.org
Thu Dec 1 15:48:17 PST 2011


 extensions/source/update/feed/makefile.mk    |    1 
 extensions/source/update/feed/updatefeed.cxx |   68 +++++++++++++++++++++------
 2 files changed, 55 insertions(+), 14 deletions(-)

New commits:
commit 36269f66836b17eaa7153cd78aa941468629807c
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Dec 2 00:46:23 2011 +0100

    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.

diff --git a/extensions/source/update/feed/makefile.mk b/extensions/source/update/feed/makefile.mk
index 496842d..6361f20 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 f5caafc..42a7301 100644
--- a/extensions/source/update/feed/updatefeed.cxx
+++ b/extensions/source/update/feed/updatefeed.cxx
@@ -27,12 +27,10 @@
  ************************************************************************/
 
 
-#include <comphelper/mediadescriptor.hxx>
 #include <cppuhelper/implbase1.hxx>
 #include <cppuhelper/implbase4.hxx>
 #include <cppuhelper/implementationentry.hxx>
 #include <com/sun/star/beans/Property.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/XPropertySetInfo.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/configuration/theDefaultProvider.hpp>
@@ -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());
 }
 
 //------------------------------------------------------------------------------
commit dddfadf9d59fb32f20b45e6a529db8639f73dac5
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Dec 2 00:40:18 2011 +0100

    Revert "online update: Cleanup after UpdateInformationProvider::load() rewrite."
    
    This reverts commit 358ce1e9c1d85ae7590ecc2b2ddee9db81cf8b84.

diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx
index 21bfecf..f5caafc 100644
--- a/extensions/source/update/feed/updatefeed.cxx
+++ b/extensions/source/update/feed/updatefeed.cxx
@@ -210,11 +210,15 @@ private:
         uno::Reference< ucb::XCommandProcessor > const & rxCommandProcessor);
 
     UpdateInformationProvider(const uno::Reference<uno::XComponentContext>& xContext,
+                              const uno::Reference< ucb::XContentIdentifierFactory >& xContentIdFactory,
+                              const uno::Reference< ucb::XContentProvider >& xContentProvider,
                               const uno::Reference< xml::dom::XDocumentBuilder >& xDocumentBuilder,
                               const uno::Reference< xml::xpath::XXPathAPI >& xXPathAPI);
 
     const uno::Reference< uno::XComponentContext> m_xContext;
 
+    const uno::Reference< ucb::XContentIdentifierFactory > m_xContentIdFactory;
+    const uno::Reference< ucb::XContentProvider > m_xContentProvider;
     const uno::Reference< xml::dom::XDocumentBuilder > m_xDocumentBuilder;
     const uno::Reference< xml::xpath::XXPathAPI > m_xXPathAPI;
 
@@ -327,10 +331,12 @@ private:
 
 UpdateInformationProvider::UpdateInformationProvider(
     const uno::Reference<uno::XComponentContext>& xContext,
+    const uno::Reference< ucb::XContentIdentifierFactory >& xContentIdFactory,
+    const uno::Reference< ucb::XContentProvider >& xContentProvider,
     const uno::Reference< xml::dom::XDocumentBuilder >& xDocumentBuilder,
     const uno::Reference< xml::xpath::XXPathAPI >& xXPathAPI
-) : m_xContext(xContext),
-    m_xDocumentBuilder(xDocumentBuilder),
+) : m_xContext(xContext), m_xContentIdFactory(xContentIdFactory),
+    m_xContentProvider(xContentProvider), m_xDocumentBuilder(xDocumentBuilder),
     m_xXPathAPI(xXPathAPI), m_aRequestHeaderList(1)
 {
     uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
@@ -404,6 +410,12 @@ UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentCo
             UNISTRING( "unable to obtain service manager from component context" ),
             uno::Reference< uno::XInterface > ());
 
+    uno::Reference< ucb::XContentIdentifierFactory > xContentIdFactory(
+        xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ), xContext ),
+        uno::UNO_QUERY_THROW);
+
+    uno::Reference< ucb::XContentProvider > xContentProvider(xContentIdFactory, uno::UNO_QUERY_THROW);
+
     uno::Reference< xml::dom::XDocumentBuilder > xDocumentBuilder(
         xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.dom.DocumentBuilder" ), xContext ),
         uno::UNO_QUERY_THROW);
@@ -414,7 +426,7 @@ UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentCo
 
     xXPath->registerNS( UNISTRING("atom"), UNISTRING("http://www.w3.org/2005/Atom") );
 
-    return *new UpdateInformationProvider(xContext, xDocumentBuilder, xXPath);
+    return *new UpdateInformationProvider(xContext, xContentIdFactory, xContentProvider, xDocumentBuilder, xXPath);
 }
 
 //------------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list