12a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 52a97ec55SAndrew Rist * distributed with this work for additional information 62a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 72a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 82a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 92a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 102a97ec55SAndrew Rist * 112a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 122a97ec55SAndrew Rist * 132a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 142a97ec55SAndrew Rist * software distributed under the License is distributed on an 152a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 172a97ec55SAndrew Rist * specific language governing permissions and limitations 182a97ec55SAndrew Rist * under the License. 192a97ec55SAndrew Rist * 202a97ec55SAndrew Rist *************************************************************/ 212a97ec55SAndrew Rist 222a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 289da13427SAriel Constenla-Haile #include <cppuhelper/implbase3.hxx> 29cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx> 30cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp> 31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 33cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 34cdf0e10cSrcweir #include <com/sun/star/deployment/UpdateInformationEntry.hpp> 35cdf0e10cSrcweir #include <com/sun/star/deployment/UpdateInformationProvider.hpp> 36cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp> 37cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 38cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 39cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 40cdf0e10cSrcweir #include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp> 41cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor2.hpp> 42cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> 43cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp> 44cdf0e10cSrcweir #include "com/sun/star/ucb/XInteractionSupplyAuthentication.hpp" 45cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 46cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp> 47cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 48cdf0e10cSrcweir #include <com/sun/star/task/PasswordContainerInteractionHandler.hpp> 49cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDocumentBuilder.hpp> 50cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XXPathAPI.hpp> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include <rtl/ref.hxx> 53cdf0e10cSrcweir #include <rtl/memory.h> 54cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 55cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 56cdf0e10cSrcweir #include <osl/process.h> 57cdf0e10cSrcweir #include <osl/conditn.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir namespace beans = com::sun::star::beans ; 60cdf0e10cSrcweir namespace container = com::sun::star::container ; 61cdf0e10cSrcweir namespace deployment = com::sun::star::deployment ; 62cdf0e10cSrcweir namespace io = com::sun::star::io ; 63cdf0e10cSrcweir namespace lang = com::sun::star::lang ; 64cdf0e10cSrcweir namespace task = com::sun::star::task ; 65cdf0e10cSrcweir namespace ucb = com::sun::star::ucb ; 66cdf0e10cSrcweir namespace uno = com::sun::star::uno ; 67cdf0e10cSrcweir namespace xml = com::sun::star::xml ; 68cdf0e10cSrcweir namespace sdbc = com::sun::star::sdbc ; 69cdf0e10cSrcweir 70cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 71cdf0e10cSrcweir 72cdf0e10cSrcweir //------------------------------------------------------------------------------ 73cdf0e10cSrcweir 74cdf0e10cSrcweir namespace 75cdf0e10cSrcweir { 76cdf0e10cSrcweir 77cdf0e10cSrcweir #ifdef DEBUG 78cdf0e10cSrcweir 79cdf0e10cSrcweir class InputStreamWrapper : public ::cppu::WeakImplHelper1< io::XInputStream > 80cdf0e10cSrcweir { 81cdf0e10cSrcweir uno::Reference< io::XInputStream > m_xStream; 82cdf0e10cSrcweir 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir InputStreamWrapper(const uno::Reference< io::XInputStream >& rxStream) : 85cdf0e10cSrcweir m_xStream(rxStream) {}; 86cdf0e10cSrcweir 87cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readBytes(uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) 88cdf0e10cSrcweir throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir sal_Int32 n = m_xStream->readBytes(aData, nBytesToRead); 91cdf0e10cSrcweir if ( n ) 92cdf0e10cSrcweir OSL_TRACE( "Read [%d] bytes: %s\n", n, aData.get()->elements ); 93cdf0e10cSrcweir return n; 94cdf0e10cSrcweir }; 95cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readSomeBytes(uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) 96cdf0e10cSrcweir throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir sal_Int32 n = m_xStream->readSomeBytes(aData, nMaxBytesToRead); 99cdf0e10cSrcweir if ( n ) 100cdf0e10cSrcweir OSL_TRACE( "Read [%d] bytes: %s\n", n, aData.get()->elements ); 101cdf0e10cSrcweir return n; 102cdf0e10cSrcweir }; 103cdf0e10cSrcweir virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) 104cdf0e10cSrcweir throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException) 105cdf0e10cSrcweir { m_xStream->skipBytes(nBytesToSkip); }; 106cdf0e10cSrcweir virtual sal_Int32 SAL_CALL available() 107cdf0e10cSrcweir throw (io::NotConnectedException, io::IOException, uno::RuntimeException) 108cdf0e10cSrcweir { return m_xStream->available(); }; 109cdf0e10cSrcweir virtual void SAL_CALL closeInput( ) 110cdf0e10cSrcweir throw (io::NotConnectedException, io::IOException, uno::RuntimeException) 111cdf0e10cSrcweir {}; 112cdf0e10cSrcweir }; 113cdf0e10cSrcweir 114cdf0e10cSrcweir #define INPUT_STREAM(i) new InputStreamWrapper(i) 115cdf0e10cSrcweir #else 116cdf0e10cSrcweir #define INPUT_STREAM(i) i 117cdf0e10cSrcweir #endif 118cdf0e10cSrcweir 119cdf0e10cSrcweir //------------------------------------------------------------------------------ 120cdf0e10cSrcweir 121cdf0e10cSrcweir class ActiveDataSink : public ::cppu::WeakImplHelper1< io::XActiveDataSink > 122cdf0e10cSrcweir { 123cdf0e10cSrcweir uno::Reference< io::XInputStream > m_xStream; 124cdf0e10cSrcweir 125cdf0e10cSrcweir public: 126cdf0e10cSrcweir ActiveDataSink() {}; 127cdf0e10cSrcweir 128cdf0e10cSrcweir inline operator uno::Reference< io::XActiveDataSink > () { return this; }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir virtual uno::Reference< io::XInputStream > SAL_CALL getInputStream() 131cdf0e10cSrcweir throw (uno::RuntimeException) { return m_xStream; }; 132cdf0e10cSrcweir virtual void SAL_CALL setInputStream( uno::Reference< io::XInputStream > const & rStream ) 133cdf0e10cSrcweir throw (uno::RuntimeException) { m_xStream = rStream; }; 134cdf0e10cSrcweir }; 135cdf0e10cSrcweir 136cdf0e10cSrcweir //------------------------------------------------------------------------------ 137cdf0e10cSrcweir 138cdf0e10cSrcweir class UpdateInformationProvider : 1399da13427SAriel Constenla-Haile public ::cppu::WeakImplHelper3< deployment::XUpdateInformationProvider, 140cdf0e10cSrcweir ucb::XWebDAVCommandEnvironment, 141cdf0e10cSrcweir lang::XServiceInfo > 142cdf0e10cSrcweir { 143cdf0e10cSrcweir public: 144cdf0e10cSrcweir static uno::Reference< uno::XInterface > createInstance(const uno::Reference<uno::XComponentContext>& xContext); 145cdf0e10cSrcweir 146cdf0e10cSrcweir static uno::Sequence< rtl::OUString > getServiceNames(); 147cdf0e10cSrcweir static rtl::OUString getImplName(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir uno::Reference< xml::dom::XElement > getDocumentRoot(const uno::Reference< xml::dom::XNode >& rxNode); 150cdf0e10cSrcweir uno::Reference< xml::dom::XNode > getChildNode(const uno::Reference< xml::dom::XNode >& rxNode, const rtl::OUString& rName); 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153cdf0e10cSrcweir // XUpdateInformationService 154cdf0e10cSrcweir virtual uno::Sequence< uno::Reference< xml::dom::XElement > > SAL_CALL 155cdf0e10cSrcweir getUpdateInformation( 156cdf0e10cSrcweir uno::Sequence< rtl::OUString > const & repositories, 157cdf0e10cSrcweir rtl::OUString const & extensionId 158cdf0e10cSrcweir ) throw (uno::Exception, uno::RuntimeException); 159cdf0e10cSrcweir 160cdf0e10cSrcweir virtual void SAL_CALL cancel() 161cdf0e10cSrcweir throw (uno::RuntimeException); 162cdf0e10cSrcweir 163cdf0e10cSrcweir virtual void SAL_CALL setInteractionHandler( 164cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > const & handler ) 165cdf0e10cSrcweir throw (uno::RuntimeException); 166cdf0e10cSrcweir 167cdf0e10cSrcweir virtual uno::Reference< container::XEnumeration > SAL_CALL 168cdf0e10cSrcweir getUpdateInformationEnumeration( 169cdf0e10cSrcweir uno::Sequence< rtl::OUString > const & repositories, 170cdf0e10cSrcweir rtl::OUString const & extensionId 171cdf0e10cSrcweir ) throw (uno::Exception, uno::RuntimeException); 172cdf0e10cSrcweir 173cdf0e10cSrcweir // XCommandEnvironment 174cdf0e10cSrcweir virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler() 175cdf0e10cSrcweir throw ( uno::RuntimeException ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir virtual uno::Reference< ucb::XProgressHandler > SAL_CALL getProgressHandler() 178cdf0e10cSrcweir throw ( uno::RuntimeException ) { return uno::Reference< ucb::XProgressHandler >(); }; 179cdf0e10cSrcweir 180cdf0e10cSrcweir // XWebDAVCommandEnvironment 181554deb42SAriel Constenla-Haile virtual uno::Sequence< beans::StringPair > SAL_CALL getUserRequestHeaders( 182*c5f58c9aSAriel Constenla-Haile const rtl::OUString&, ucb::WebDAVHTTPMethod ) 183cdf0e10cSrcweir throw ( uno::RuntimeException ) { return m_aRequestHeaderList; }; 184cdf0e10cSrcweir 185cdf0e10cSrcweir // XServiceInfo 186cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getImplementationName() 187cdf0e10cSrcweir throw (uno::RuntimeException); 188cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName) 189cdf0e10cSrcweir throw (uno::RuntimeException); 190cdf0e10cSrcweir virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() 191cdf0e10cSrcweir throw (uno::RuntimeException); 192cdf0e10cSrcweir 193cdf0e10cSrcweir protected: 194cdf0e10cSrcweir 195cdf0e10cSrcweir virtual ~UpdateInformationProvider(); 196554deb42SAriel Constenla-Haile static rtl::OUString getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item); 197cdf0e10cSrcweir 198cdf0e10cSrcweir private: 199cdf0e10cSrcweir uno::Reference< io::XInputStream > load(const rtl::OUString& rURL); 200cdf0e10cSrcweir 201cdf0e10cSrcweir void storeCommandInfo( sal_Int32 nCommandId, 202cdf0e10cSrcweir uno::Reference< ucb::XCommandProcessor > const & rxCommandProcessor); 203cdf0e10cSrcweir 204cdf0e10cSrcweir UpdateInformationProvider(const uno::Reference<uno::XComponentContext>& xContext, 205cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifierFactory >& xContentIdFactory, 206cdf0e10cSrcweir const uno::Reference< ucb::XContentProvider >& xContentProvider, 207cdf0e10cSrcweir const uno::Reference< xml::dom::XDocumentBuilder >& xDocumentBuilder, 208cdf0e10cSrcweir const uno::Reference< xml::xpath::XXPathAPI >& xXPathAPI); 209cdf0e10cSrcweir 210cdf0e10cSrcweir const uno::Reference< uno::XComponentContext> m_xContext; 211cdf0e10cSrcweir 212cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifierFactory > m_xContentIdFactory; 213cdf0e10cSrcweir const uno::Reference< ucb::XContentProvider > m_xContentProvider; 214cdf0e10cSrcweir const uno::Reference< xml::dom::XDocumentBuilder > m_xDocumentBuilder; 215cdf0e10cSrcweir const uno::Reference< xml::xpath::XXPathAPI > m_xXPathAPI; 216cdf0e10cSrcweir 217554deb42SAriel Constenla-Haile uno::Sequence< beans::StringPair > m_aRequestHeaderList; 218cdf0e10cSrcweir 219cdf0e10cSrcweir uno::Reference< ucb::XCommandProcessor > m_xCommandProcessor; 220cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > m_xInteractionHandler; 221cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > m_xPwContainerInteractionHandler; 222cdf0e10cSrcweir 223cdf0e10cSrcweir osl::Mutex m_aMutex; 224cdf0e10cSrcweir osl::Condition m_bCancelled; 225cdf0e10cSrcweir 226cdf0e10cSrcweir sal_Int32 m_nCommandId; 227cdf0e10cSrcweir }; 228cdf0e10cSrcweir 229cdf0e10cSrcweir //------------------------------------------------------------------------------ 230cdf0e10cSrcweir 231cdf0e10cSrcweir class UpdateInformationEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration > 232cdf0e10cSrcweir { 233cdf0e10cSrcweir public: 234cdf0e10cSrcweir UpdateInformationEnumeration(const uno::Reference< xml::dom::XNodeList >& xNodeList, 235cdf0e10cSrcweir const uno::Reference< UpdateInformationProvider > xUpdateInformationProvider) : 236cdf0e10cSrcweir m_xUpdateInformationProvider(xUpdateInformationProvider), 237cdf0e10cSrcweir m_xNodeList(xNodeList), 238cdf0e10cSrcweir m_nNodes(xNodeList.is() ? xNodeList->getLength() : 0), 239cdf0e10cSrcweir m_nCount(0) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir }; 242cdf0e10cSrcweir 243cdf0e10cSrcweir virtual ~UpdateInformationEnumeration() {}; 244cdf0e10cSrcweir 245cdf0e10cSrcweir // XEnumeration 246cdf0e10cSrcweir sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException) { return m_nCount < m_nNodes; }; 247cdf0e10cSrcweir uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir OSL_ASSERT( m_xNodeList.is() ); 250cdf0e10cSrcweir OSL_ASSERT( m_xUpdateInformationProvider.is() ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir if( !(m_nCount < m_nNodes ) ) 253cdf0e10cSrcweir throw container::NoSuchElementException(rtl::OUString::valueOf(m_nCount), *this); 254cdf0e10cSrcweir 255cdf0e10cSrcweir try 256cdf0e10cSrcweir { 257cdf0e10cSrcweir deployment::UpdateInformationEntry aEntry; 258cdf0e10cSrcweir 259cdf0e10cSrcweir uno::Reference< xml::dom::XNode > xAtomEntryNode( m_xNodeList->item(m_nCount++) ); 260cdf0e10cSrcweir 261cdf0e10cSrcweir uno::Reference< xml::dom::XNode > xSummaryNode( 262cdf0e10cSrcweir m_xUpdateInformationProvider->getChildNode( xAtomEntryNode, UNISTRING( "summary/text()" ) ) 263cdf0e10cSrcweir ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir if( xSummaryNode.is() ) 266cdf0e10cSrcweir aEntry.Description = xSummaryNode->getNodeValue(); 267cdf0e10cSrcweir 268cdf0e10cSrcweir uno::Reference< xml::dom::XNode > xContentNode( 269cdf0e10cSrcweir m_xUpdateInformationProvider->getChildNode( xAtomEntryNode, UNISTRING( "content" ) ) ); 270cdf0e10cSrcweir 271cdf0e10cSrcweir if( xContentNode.is() ) 272cdf0e10cSrcweir aEntry.UpdateDocument = m_xUpdateInformationProvider->getDocumentRoot(xContentNode); 273cdf0e10cSrcweir 274cdf0e10cSrcweir return uno::makeAny(aEntry); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir // action has been aborted 278cdf0e10cSrcweir catch( ucb::CommandAbortedException const & e) 279cdf0e10cSrcweir { throw lang::WrappedTargetException( UNISTRING( "Command aborted" ), *this, uno::makeAny(e) ); } 280cdf0e10cSrcweir 281cdf0e10cSrcweir // let runtime exception pass 282cdf0e10cSrcweir catch( uno::RuntimeException const & ) { throw; } 283cdf0e10cSrcweir 284cdf0e10cSrcweir // document not accessible 285cdf0e10cSrcweir catch( uno::Exception const & e) 286cdf0e10cSrcweir { throw lang::WrappedTargetException( UNISTRING( "Document not accessible" ), *this, uno::makeAny(e) ); } 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir private: 290cdf0e10cSrcweir const uno::Reference< UpdateInformationProvider > m_xUpdateInformationProvider; 291cdf0e10cSrcweir const uno::Reference< xml::dom::XNodeList > m_xNodeList; 292cdf0e10cSrcweir const sal_Int32 m_nNodes; 293cdf0e10cSrcweir sal_Int32 m_nCount; 294cdf0e10cSrcweir }; 295cdf0e10cSrcweir 296cdf0e10cSrcweir //------------------------------------------------------------------------------ 297cdf0e10cSrcweir 298cdf0e10cSrcweir class SingleUpdateInformationEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration > 299cdf0e10cSrcweir { 300cdf0e10cSrcweir public: 301cdf0e10cSrcweir SingleUpdateInformationEnumeration(const uno::Reference< xml::dom::XElement >& xElement) 302cdf0e10cSrcweir : m_nCount(0) { m_aEntry.UpdateDocument = xElement; }; 303cdf0e10cSrcweir virtual ~SingleUpdateInformationEnumeration() {}; 304cdf0e10cSrcweir 305cdf0e10cSrcweir // XEnumeration 306cdf0e10cSrcweir sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException) { return 0 == m_nCount; }; 307cdf0e10cSrcweir uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir if( m_nCount > 0 ) 310cdf0e10cSrcweir throw container::NoSuchElementException(rtl::OUString::valueOf(m_nCount), *this); 311cdf0e10cSrcweir 312cdf0e10cSrcweir ++m_nCount; 313cdf0e10cSrcweir return uno::makeAny(m_aEntry); 314cdf0e10cSrcweir }; 315cdf0e10cSrcweir 316cdf0e10cSrcweir private: 317cdf0e10cSrcweir sal_uInt8 m_nCount; 318cdf0e10cSrcweir deployment::UpdateInformationEntry m_aEntry; 319cdf0e10cSrcweir }; 320cdf0e10cSrcweir 321cdf0e10cSrcweir 322cdf0e10cSrcweir //------------------------------------------------------------------------------ 323cdf0e10cSrcweir 324cdf0e10cSrcweir UpdateInformationProvider::UpdateInformationProvider( 325cdf0e10cSrcweir const uno::Reference<uno::XComponentContext>& xContext, 326cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifierFactory >& xContentIdFactory, 327cdf0e10cSrcweir const uno::Reference< ucb::XContentProvider >& xContentProvider, 328cdf0e10cSrcweir const uno::Reference< xml::dom::XDocumentBuilder >& xDocumentBuilder, 329cdf0e10cSrcweir const uno::Reference< xml::xpath::XXPathAPI >& xXPathAPI 330cdf0e10cSrcweir ) : m_xContext(xContext), m_xContentIdFactory(xContentIdFactory), 331cdf0e10cSrcweir m_xContentProvider(xContentProvider), m_xDocumentBuilder(xDocumentBuilder), 332cdf0e10cSrcweir m_xXPathAPI(xXPathAPI), m_aRequestHeaderList(1) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); 335cdf0e10cSrcweir if( !xServiceManager.is() ) 336cdf0e10cSrcweir throw uno::RuntimeException( 337cdf0e10cSrcweir UNISTRING("unable to obtain service manager from component context"), 338cdf0e10cSrcweir uno::Reference< uno::XInterface >()); 339cdf0e10cSrcweir 340cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( 341cdf0e10cSrcweir xServiceManager->createInstanceWithContext( 342cdf0e10cSrcweir UNISTRING("com.sun.star.configuration.ConfigurationProvider"), 343cdf0e10cSrcweir xContext ), 344cdf0e10cSrcweir uno::UNO_QUERY_THROW); 345cdf0e10cSrcweir 346cdf0e10cSrcweir rtl::OUStringBuffer buf; 347554deb42SAriel Constenla-Haile buf.append( 348554deb42SAriel Constenla-Haile getConfigurationItem( 349554deb42SAriel Constenla-Haile xConfigurationProvider, 350554deb42SAriel Constenla-Haile UNISTRING("org.openoffice.Setup/Product"), 351554deb42SAriel Constenla-Haile UNISTRING("ooName"))); 352cdf0e10cSrcweir buf.append(sal_Unicode(' ')); 353554deb42SAriel Constenla-Haile buf.append( 354554deb42SAriel Constenla-Haile getConfigurationItem( 355554deb42SAriel Constenla-Haile xConfigurationProvider, 356554deb42SAriel Constenla-Haile UNISTRING("org.openoffice.Setup/Product"), 357554deb42SAriel Constenla-Haile UNISTRING("ooSetupVersion"))); 358cdf0e10cSrcweir rtl::OUString edition( 359cdf0e10cSrcweir UNISTRING( 360cdf0e10cSrcweir "${${BRAND_BASE_DIR}/program/edition/edition.ini:" 361cdf0e10cSrcweir "EDITIONNAME}")); 362cdf0e10cSrcweir rtl::Bootstrap::expandMacros(edition); 363cdf0e10cSrcweir if (edition.getLength() != 0) { 364cdf0e10cSrcweir buf.append(sal_Unicode(' ')); 365cdf0e10cSrcweir buf.append(edition); 366cdf0e10cSrcweir } 367554deb42SAriel Constenla-Haile rtl::OUString extension( 368554deb42SAriel Constenla-Haile getConfigurationItem( 369554deb42SAriel Constenla-Haile xConfigurationProvider, 370554deb42SAriel Constenla-Haile UNISTRING("org.openoffice.Setup/Product"), 371554deb42SAriel Constenla-Haile UNISTRING("ooSetupExtension"))); 372cdf0e10cSrcweir if (extension.getLength() != 0) { 373cdf0e10cSrcweir buf.append(sal_Unicode(' ')); 374cdf0e10cSrcweir buf.append(extension); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir rtl::OUString product(buf.makeStringAndClear()); 377cdf0e10cSrcweir 378cdf0e10cSrcweir rtl::OUString aBaseBuildId( UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" ) ); 379cdf0e10cSrcweir rtl::Bootstrap::expandMacros( aBaseBuildId ); 380cdf0e10cSrcweir 381cdf0e10cSrcweir rtl::OUString aBrandBuildId( UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" ) ); 382cdf0e10cSrcweir rtl::Bootstrap::expandMacros( aBrandBuildId ); 383cdf0e10cSrcweir 384cdf0e10cSrcweir rtl::OUString aUserAgent( UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":UpdateUserAgent}" ) ); 385cdf0e10cSrcweir rtl::Bootstrap::expandMacros( aUserAgent ); 386cdf0e10cSrcweir 387cdf0e10cSrcweir if ( ! aBaseBuildId.equals( aBrandBuildId ) ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir sal_Int32 nIndex = aUserAgent.indexOf( aBrandBuildId, 0 ); 390cdf0e10cSrcweir if ( nIndex != -1 ) 391cdf0e10cSrcweir aUserAgent = aUserAgent.replaceAt( nIndex, aBrandBuildId.getLength(), aBaseBuildId ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir for (sal_Int32 i = 0;;) { 395cdf0e10cSrcweir i = aUserAgent.indexOfAsciiL( 396cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("<PRODUCT>"), i); 397cdf0e10cSrcweir if (i == -1) { 398cdf0e10cSrcweir break; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir aUserAgent = aUserAgent.replaceAt( 401cdf0e10cSrcweir i, RTL_CONSTASCII_LENGTH("<PRODUCT>"), product); 402cdf0e10cSrcweir i += product.getLength(); 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405554deb42SAriel Constenla-Haile m_aRequestHeaderList[0].First = UNISTRING("Accept-Language"); 406554deb42SAriel Constenla-Haile m_aRequestHeaderList[0].Second = getConfigurationItem( xConfigurationProvider, UNISTRING("org.openoffice.Setup/L10N"), UNISTRING("ooLocale") ); 407cdf0e10cSrcweir if( aUserAgent.getLength() > 0 ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir m_aRequestHeaderList.realloc(2); 410554deb42SAriel Constenla-Haile m_aRequestHeaderList[1].First = UNISTRING("User-Agent"); 411554deb42SAriel Constenla-Haile m_aRequestHeaderList[1].Second = aUserAgent; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir 415cdf0e10cSrcweir //------------------------------------------------------------------------------ 416cdf0e10cSrcweir uno::Reference< uno::XInterface > 417cdf0e10cSrcweir UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentContext>& xContext) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); 420cdf0e10cSrcweir if( !xServiceManager.is() ) 421cdf0e10cSrcweir throw uno::RuntimeException( 422cdf0e10cSrcweir UNISTRING( "unable to obtain service manager from component context" ), 423cdf0e10cSrcweir uno::Reference< uno::XInterface > ()); 424cdf0e10cSrcweir 425cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifierFactory > xContentIdFactory( 426cdf0e10cSrcweir xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ), xContext ), 427cdf0e10cSrcweir uno::UNO_QUERY_THROW); 428cdf0e10cSrcweir 429cdf0e10cSrcweir uno::Reference< ucb::XContentProvider > xContentProvider(xContentIdFactory, uno::UNO_QUERY_THROW); 430cdf0e10cSrcweir 431cdf0e10cSrcweir uno::Reference< xml::dom::XDocumentBuilder > xDocumentBuilder( 432cdf0e10cSrcweir xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.dom.DocumentBuilder" ), xContext ), 433cdf0e10cSrcweir uno::UNO_QUERY_THROW); 434cdf0e10cSrcweir 435cdf0e10cSrcweir uno::Reference< xml::xpath::XXPathAPI > xXPath( 436cdf0e10cSrcweir xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.xpath.XPathAPI" ), xContext ), 437cdf0e10cSrcweir uno::UNO_QUERY_THROW); 438cdf0e10cSrcweir 439cdf0e10cSrcweir xXPath->registerNS( UNISTRING("atom"), UNISTRING("http://www.w3.org/2005/Atom") ); 440cdf0e10cSrcweir 441cdf0e10cSrcweir return *new UpdateInformationProvider(xContext, xContentIdFactory, xContentProvider, xDocumentBuilder, xXPath); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir //------------------------------------------------------------------------------ 445cdf0e10cSrcweir 446cdf0e10cSrcweir UpdateInformationProvider::~UpdateInformationProvider() 447cdf0e10cSrcweir { 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir //------------------------------------------------------------------------------ 451cdf0e10cSrcweir 452554deb42SAriel Constenla-Haile rtl::OUString 453cdf0e10cSrcweir UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item) 454cdf0e10cSrcweir { 455554deb42SAriel Constenla-Haile rtl::OUString sRet; 456cdf0e10cSrcweir beans::PropertyValue aProperty; 457cdf0e10cSrcweir aProperty.Name = UNISTRING("nodepath"); 458cdf0e10cSrcweir aProperty.Value = uno::makeAny(node); 459cdf0e10cSrcweir 460cdf0e10cSrcweir uno::Sequence< uno::Any > aArgumentList( 1 ); 461cdf0e10cSrcweir aArgumentList[0] = uno::makeAny( aProperty ); 462cdf0e10cSrcweir 463cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess( 464cdf0e10cSrcweir configurationProvider->createInstanceWithArguments( 465cdf0e10cSrcweir UNISTRING("com.sun.star.configuration.ConfigurationAccess"), 466cdf0e10cSrcweir aArgumentList ), 467cdf0e10cSrcweir uno::UNO_QUERY_THROW); 468cdf0e10cSrcweir 469554deb42SAriel Constenla-Haile xNameAccess->getByName(item) >>= sRet; 470554deb42SAriel Constenla-Haile return sRet; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir //------------------------------------------------------------------------------ 474cdf0e10cSrcweir 475cdf0e10cSrcweir void 476cdf0e10cSrcweir UpdateInformationProvider::storeCommandInfo( 477cdf0e10cSrcweir sal_Int32 nCommandId, 478cdf0e10cSrcweir uno::Reference< ucb::XCommandProcessor > const & rxCommandProcessor) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 481cdf0e10cSrcweir 482cdf0e10cSrcweir m_nCommandId = nCommandId; 483cdf0e10cSrcweir m_xCommandProcessor = rxCommandProcessor; 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir //------------------------------------------------------------------------------ 487cdf0e10cSrcweir 488cdf0e10cSrcweir uno::Reference< io::XInputStream > 489cdf0e10cSrcweir UpdateInformationProvider::load(const rtl::OUString& rURL) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId = m_xContentIdFactory->createContentIdentifier(rURL); 492cdf0e10cSrcweir 493cdf0e10cSrcweir if( !xId.is() ) 494cdf0e10cSrcweir throw uno::RuntimeException( 495cdf0e10cSrcweir UNISTRING( "unable to obtain universal content id" ), *this); 496cdf0e10cSrcweir 497cdf0e10cSrcweir uno::Reference< ucb::XCommandProcessor > xCommandProcessor(m_xContentProvider->queryContent(xId), uno::UNO_QUERY_THROW); 498cdf0e10cSrcweir rtl::Reference< ActiveDataSink > aSink(new ActiveDataSink()); 499cdf0e10cSrcweir 500cdf0e10cSrcweir ucb::OpenCommandArgument2 aOpenArgument; 501cdf0e10cSrcweir aOpenArgument.Mode = ucb::OpenMode::DOCUMENT; 502cdf0e10cSrcweir aOpenArgument.Priority = 32768; 503cdf0e10cSrcweir aOpenArgument.Sink = *aSink; 504cdf0e10cSrcweir 505cdf0e10cSrcweir ucb::Command aCommand; 506cdf0e10cSrcweir aCommand.Name = UNISTRING("open"); 507cdf0e10cSrcweir aCommand.Argument = uno::makeAny(aOpenArgument); 508cdf0e10cSrcweir 509cdf0e10cSrcweir sal_Int32 nCommandId = xCommandProcessor->createCommandIdentifier(); 510cdf0e10cSrcweir 511cdf0e10cSrcweir storeCommandInfo(nCommandId, xCommandProcessor); 512cdf0e10cSrcweir try 513cdf0e10cSrcweir { 514cdf0e10cSrcweir uno::Any aResult = xCommandProcessor->execute(aCommand, nCommandId, 515cdf0e10cSrcweir static_cast < XCommandEnvironment *> (this)); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir catch( const uno::Exception & /* e */ ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir storeCommandInfo(0, uno::Reference< ucb::XCommandProcessor > ()); 520cdf0e10cSrcweir 521cdf0e10cSrcweir uno::Reference< ucb::XCommandProcessor2 > xCommandProcessor2(xCommandProcessor, uno::UNO_QUERY); 522cdf0e10cSrcweir if( xCommandProcessor2.is() ) 523cdf0e10cSrcweir xCommandProcessor2->releaseCommandIdentifier(nCommandId); 524cdf0e10cSrcweir 525cdf0e10cSrcweir throw; 526cdf0e10cSrcweir } 527cdf0e10cSrcweir storeCommandInfo(0, uno::Reference< ucb::XCommandProcessor > ()); 528cdf0e10cSrcweir 529cdf0e10cSrcweir uno::Reference< ucb::XCommandProcessor2 > xCommandProcessor2(xCommandProcessor, uno::UNO_QUERY); 530cdf0e10cSrcweir if( xCommandProcessor2.is() ) 531cdf0e10cSrcweir xCommandProcessor2->releaseCommandIdentifier(nCommandId); 532cdf0e10cSrcweir 533cdf0e10cSrcweir return INPUT_STREAM(aSink->getInputStream()); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir //------------------------------------------------------------------------------ 537cdf0e10cSrcweir 538cdf0e10cSrcweir // TODO: docu content node 539cdf0e10cSrcweir 540cdf0e10cSrcweir uno::Reference< xml::dom::XElement > 541cdf0e10cSrcweir UpdateInformationProvider::getDocumentRoot(const uno::Reference< xml::dom::XNode >& rxNode) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir OSL_ASSERT(m_xDocumentBuilder.is()); 544cdf0e10cSrcweir 545cdf0e10cSrcweir uno::Reference< xml::dom::XElement > xElement(rxNode, uno::UNO_QUERY_THROW); 546cdf0e10cSrcweir 547cdf0e10cSrcweir // load the document referenced in 'src' attribute .. 548cdf0e10cSrcweir if( xElement->hasAttribute( UNISTRING("src") ) ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir uno::Reference< xml::dom::XDocument > xUpdateXML = 551cdf0e10cSrcweir m_xDocumentBuilder->parse(load(xElement->getAttribute( UNISTRING("src") ))); 552cdf0e10cSrcweir 553cdf0e10cSrcweir OSL_ASSERT( xUpdateXML.is() ); 554cdf0e10cSrcweir 555cdf0e10cSrcweir if( xUpdateXML.is() ) 556cdf0e10cSrcweir return xUpdateXML->getDocumentElement(); 557cdf0e10cSrcweir } 558cdf0e10cSrcweir // .. or return the (single) child element 559cdf0e10cSrcweir else 560cdf0e10cSrcweir { 561cdf0e10cSrcweir uno::Reference< xml::dom::XNodeList> xChildNodes = rxNode->getChildNodes(); 562cdf0e10cSrcweir 563cdf0e10cSrcweir // ignore possible #text nodes 564cdf0e10cSrcweir sal_Int32 nmax = xChildNodes->getLength(); 565cdf0e10cSrcweir for(sal_Int32 n=0; n < nmax; n++) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir uno::Reference< xml::dom::XElement > xChildElement(xChildNodes->item(n), uno::UNO_QUERY); 568cdf0e10cSrcweir if( xChildElement.is() ) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir /* Copy the content to a dedicated document since XXPathAPI->selectNodeList 571cdf0e10cSrcweir * seems to evaluate expression always relative to the root node. 572cdf0e10cSrcweir */ 573cdf0e10cSrcweir uno::Reference< xml::dom::XDocument > xUpdateXML = m_xDocumentBuilder->newDocument(); 574cdf0e10cSrcweir xUpdateXML->appendChild( xUpdateXML->importNode(xChildElement.get(), sal_True ) ); 575cdf0e10cSrcweir return xUpdateXML->getDocumentElement(); 576cdf0e10cSrcweir } 577cdf0e10cSrcweir } 578cdf0e10cSrcweir } 579cdf0e10cSrcweir 580cdf0e10cSrcweir return uno::Reference< xml::dom::XElement > (); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir 583cdf0e10cSrcweir //------------------------------------------------------------------------------ 584cdf0e10cSrcweir 585cdf0e10cSrcweir uno::Reference< xml::dom::XNode > 586cdf0e10cSrcweir UpdateInformationProvider::getChildNode(const uno::Reference< xml::dom::XNode >& rxNode, 587cdf0e10cSrcweir const rtl::OUString& rName) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir OSL_ASSERT(m_xXPathAPI.is()); 590cdf0e10cSrcweir try { 591cdf0e10cSrcweir return m_xXPathAPI->selectSingleNode(rxNode, UNISTRING( "./atom:" ) + rName); 592cdf0e10cSrcweir } catch (xml::xpath::XPathException &) { 593cdf0e10cSrcweir // ignore 594cdf0e10cSrcweir return 0; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir } 597cdf0e10cSrcweir 598cdf0e10cSrcweir //------------------------------------------------------------------------------ 599cdf0e10cSrcweir 600cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL 601cdf0e10cSrcweir UpdateInformationProvider::getUpdateInformationEnumeration( 602cdf0e10cSrcweir uno::Sequence< rtl::OUString > const & repositories, 603cdf0e10cSrcweir rtl::OUString const & extensionId 604cdf0e10cSrcweir ) throw (uno::Exception, uno::RuntimeException) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir OSL_ASSERT(m_xDocumentBuilder.is()); 607cdf0e10cSrcweir 608cdf0e10cSrcweir // reset cancelled flag 609cdf0e10cSrcweir m_bCancelled.reset(); 610cdf0e10cSrcweir 611cdf0e10cSrcweir for(sal_Int32 n=0; n<repositories.getLength(); n++) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir try 614cdf0e10cSrcweir { 615cdf0e10cSrcweir uno::Reference< xml::dom::XDocument > xDocument = m_xDocumentBuilder->parse(load(repositories[n])); 616cdf0e10cSrcweir uno::Reference< xml::dom::XElement > xElement; 617cdf0e10cSrcweir 618cdf0e10cSrcweir if( xDocument.is() ) 619cdf0e10cSrcweir xElement = xDocument->getDocumentElement(); 620cdf0e10cSrcweir 621cdf0e10cSrcweir if( xElement.is() ) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir if( xElement->getNodeName().equalsAsciiL("feed", 4) ) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir rtl::OUString aXPathExpression; 626cdf0e10cSrcweir 627cdf0e10cSrcweir if( extensionId.getLength() > 0 ) 628cdf0e10cSrcweir aXPathExpression = UNISTRING("//atom:entry/atom:category[@term=\'") + extensionId + UNISTRING("\']/.."); 629cdf0e10cSrcweir else 630cdf0e10cSrcweir aXPathExpression = UNISTRING("//atom:entry"); 631cdf0e10cSrcweir 632cdf0e10cSrcweir uno::Reference< xml::dom::XNodeList > xNodeList; 633cdf0e10cSrcweir try { 634cdf0e10cSrcweir xNodeList = m_xXPathAPI->selectNodeList(xDocument.get(), 635cdf0e10cSrcweir aXPathExpression); 636cdf0e10cSrcweir } catch (xml::xpath::XPathException &) { 637cdf0e10cSrcweir // ignore 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir return new UpdateInformationEnumeration(xNodeList, this); 641cdf0e10cSrcweir } 642cdf0e10cSrcweir else 643cdf0e10cSrcweir { 644cdf0e10cSrcweir return new SingleUpdateInformationEnumeration(xElement); 645cdf0e10cSrcweir } 646cdf0e10cSrcweir } 647cdf0e10cSrcweir 648cdf0e10cSrcweir if( m_bCancelled.check() ) 649cdf0e10cSrcweir break; 650cdf0e10cSrcweir } 65183b92653SHerbert Dürr catch( uno::RuntimeException const& /*e*/) 65283b92653SHerbert Dürr { 65383b92653SHerbert Dürr // #i118675# ignore runtime exceptions for now 65483b92653SHerbert Dürr // especially the "unsatisfied query for interface of type com.sun.star.ucb.XCommandProcessor!" exception 65583b92653SHerbert Dürr } 656cdf0e10cSrcweir 657cdf0e10cSrcweir // rethrow only if last url in the list 658cdf0e10cSrcweir catch( uno::Exception const & ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir if( n+1 >= repositories.getLength() ) 661cdf0e10cSrcweir throw; 662cdf0e10cSrcweir } 663cdf0e10cSrcweir } 664cdf0e10cSrcweir 665cdf0e10cSrcweir return uno::Reference< container::XEnumeration >(); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir 668cdf0e10cSrcweir //------------------------------------------------------------------------------ 669cdf0e10cSrcweir 670cdf0e10cSrcweir uno::Sequence< uno::Reference< xml::dom::XElement > > SAL_CALL 671cdf0e10cSrcweir UpdateInformationProvider::getUpdateInformation( 672cdf0e10cSrcweir uno::Sequence< rtl::OUString > const & repositories, 673cdf0e10cSrcweir rtl::OUString const & extensionId 674cdf0e10cSrcweir ) throw (uno::Exception, uno::RuntimeException) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir uno::Reference< container::XEnumeration > xEnumeration( 677cdf0e10cSrcweir getUpdateInformationEnumeration(repositories, extensionId) 678cdf0e10cSrcweir ); 679cdf0e10cSrcweir 680cdf0e10cSrcweir uno::Sequence< uno::Reference< xml::dom::XElement > > aRet; 681cdf0e10cSrcweir 682cdf0e10cSrcweir if( xEnumeration.is() ) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir while( xEnumeration->hasMoreElements() ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir try 687cdf0e10cSrcweir { 688cdf0e10cSrcweir deployment::UpdateInformationEntry aEntry; 689cdf0e10cSrcweir if( (xEnumeration->nextElement() >>= aEntry ) && aEntry.UpdateDocument.is() ) 690cdf0e10cSrcweir { 691cdf0e10cSrcweir sal_Int32 n = aRet.getLength(); 692cdf0e10cSrcweir aRet.realloc(n + 1); 693cdf0e10cSrcweir aRet[n] = aEntry.UpdateDocument; 694cdf0e10cSrcweir } 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir catch( const lang::WrappedTargetException& e ) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir // command aborted, return what we have got so far 700cdf0e10cSrcweir if( e.TargetException.isExtractableTo( ::cppu::UnoType< ::com::sun::star::ucb::CommandAbortedException >::get() ) ) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir break; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir // ignore files that can't be loaded 706cdf0e10cSrcweir } 707cdf0e10cSrcweir } 708cdf0e10cSrcweir } 709cdf0e10cSrcweir 710cdf0e10cSrcweir return aRet; 711cdf0e10cSrcweir } 712cdf0e10cSrcweir 713cdf0e10cSrcweir //------------------------------------------------------------------------------ 714cdf0e10cSrcweir 715cdf0e10cSrcweir void SAL_CALL 716cdf0e10cSrcweir UpdateInformationProvider::cancel() throw (uno::RuntimeException) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir m_bCancelled.set(); 719cdf0e10cSrcweir 720cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 721cdf0e10cSrcweir if( m_xCommandProcessor.is() ) 722cdf0e10cSrcweir m_xCommandProcessor->abort(m_nCommandId); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir //------------------------------------------------------------------------------ 726cdf0e10cSrcweir 727cdf0e10cSrcweir void SAL_CALL 728cdf0e10cSrcweir UpdateInformationProvider::setInteractionHandler( 729cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > const & handler ) 730cdf0e10cSrcweir throw (uno::RuntimeException) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 733cdf0e10cSrcweir m_xInteractionHandler = handler; 734cdf0e10cSrcweir } 735cdf0e10cSrcweir 736cdf0e10cSrcweir //------------------------------------------------------------------------------ 737cdf0e10cSrcweir 738cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > SAL_CALL 739cdf0e10cSrcweir UpdateInformationProvider::getInteractionHandler() 740cdf0e10cSrcweir throw ( uno::RuntimeException ) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 743cdf0e10cSrcweir 744cdf0e10cSrcweir if ( m_xInteractionHandler.is() ) 745cdf0e10cSrcweir return m_xInteractionHandler; 746cdf0e10cSrcweir else 747cdf0e10cSrcweir { 748cdf0e10cSrcweir try 749cdf0e10cSrcweir { 750cdf0e10cSrcweir // Supply an interaction handler that uses the password container 751cdf0e10cSrcweir // service to obtain credentials without displaying a password gui. 752cdf0e10cSrcweir 753cdf0e10cSrcweir if ( !m_xPwContainerInteractionHandler.is() ) 754cdf0e10cSrcweir m_xPwContainerInteractionHandler 755cdf0e10cSrcweir = task::PasswordContainerInteractionHandler::create( 756cdf0e10cSrcweir m_xContext ); 757cdf0e10cSrcweir } 758cdf0e10cSrcweir catch ( uno::RuntimeException const & ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir throw; 761cdf0e10cSrcweir } 762cdf0e10cSrcweir catch ( uno::Exception const & ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir } 765cdf0e10cSrcweir return m_xPwContainerInteractionHandler; 766cdf0e10cSrcweir } 767cdf0e10cSrcweir } 768cdf0e10cSrcweir //------------------------------------------------------------------------------ 769cdf0e10cSrcweir 770cdf0e10cSrcweir uno::Sequence< rtl::OUString > 771cdf0e10cSrcweir UpdateInformationProvider::getServiceNames() 772cdf0e10cSrcweir { 773cdf0e10cSrcweir uno::Sequence< rtl::OUString > aServiceList(1); 774cdf0e10cSrcweir aServiceList[0] = UNISTRING( "com.sun.star.deployment.UpdateInformationProvider"); 775cdf0e10cSrcweir return aServiceList; 776cdf0e10cSrcweir }; 777cdf0e10cSrcweir 778cdf0e10cSrcweir //------------------------------------------------------------------------------ 779cdf0e10cSrcweir 780cdf0e10cSrcweir rtl::OUString 781cdf0e10cSrcweir UpdateInformationProvider::getImplName() 782cdf0e10cSrcweir { 783cdf0e10cSrcweir return UNISTRING( "vnd.sun.UpdateInformationProvider"); 784cdf0e10cSrcweir } 785cdf0e10cSrcweir 786cdf0e10cSrcweir //------------------------------------------------------------------------------ 787cdf0e10cSrcweir 788cdf0e10cSrcweir rtl::OUString SAL_CALL 789cdf0e10cSrcweir UpdateInformationProvider::getImplementationName() throw (uno::RuntimeException) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir return getImplName(); 792cdf0e10cSrcweir } 793cdf0e10cSrcweir 794cdf0e10cSrcweir //------------------------------------------------------------------------------ 795cdf0e10cSrcweir 796cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL 797cdf0e10cSrcweir UpdateInformationProvider::getSupportedServiceNames() throw (uno::RuntimeException) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir return getServiceNames(); 800cdf0e10cSrcweir } 801cdf0e10cSrcweir 802cdf0e10cSrcweir //------------------------------------------------------------------------------ 803cdf0e10cSrcweir 804cdf0e10cSrcweir sal_Bool SAL_CALL 805cdf0e10cSrcweir UpdateInformationProvider::supportsService( rtl::OUString const & serviceName ) throw (uno::RuntimeException) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir uno::Sequence< rtl::OUString > aServiceNameList = getServiceNames(); 808cdf0e10cSrcweir 809cdf0e10cSrcweir for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ ) 810cdf0e10cSrcweir if( aServiceNameList[n].equals(serviceName) ) 811cdf0e10cSrcweir return sal_True; 812cdf0e10cSrcweir 813cdf0e10cSrcweir return sal_False; 814cdf0e10cSrcweir } 815cdf0e10cSrcweir 816cdf0e10cSrcweir } // anonymous namespace 817cdf0e10cSrcweir 818cdf0e10cSrcweir //------------------------------------------------------------------------------ 819cdf0e10cSrcweir 820cdf0e10cSrcweir static uno::Reference<uno::XInterface> SAL_CALL 821cdf0e10cSrcweir createInstance(uno::Reference<uno::XComponentContext> const & xContext) 822cdf0e10cSrcweir { 823cdf0e10cSrcweir return UpdateInformationProvider::createInstance(xContext); 824cdf0e10cSrcweir } 825cdf0e10cSrcweir 826cdf0e10cSrcweir //------------------------------------------------------------------------------ 827cdf0e10cSrcweir 828cdf0e10cSrcweir static const cppu::ImplementationEntry kImplementations_entries[] = 829cdf0e10cSrcweir { 830cdf0e10cSrcweir { 831cdf0e10cSrcweir createInstance, 832cdf0e10cSrcweir UpdateInformationProvider::getImplName, 833cdf0e10cSrcweir UpdateInformationProvider::getServiceNames, 834cdf0e10cSrcweir cppu::createSingleComponentFactory, 835cdf0e10cSrcweir NULL, 836cdf0e10cSrcweir 0 837cdf0e10cSrcweir }, 838cdf0e10cSrcweir { NULL, NULL, NULL, NULL, NULL, 0 } 839cdf0e10cSrcweir } ; 840cdf0e10cSrcweir 841cdf0e10cSrcweir //------------------------------------------------------------------------------ 842cdf0e10cSrcweir 843cdf0e10cSrcweir extern "C" void SAL_CALL 844cdf0e10cSrcweir component_getImplementationEnvironment( const sal_Char **aEnvTypeName, uno_Environment **) 845cdf0e10cSrcweir { 846cdf0e10cSrcweir *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; 847cdf0e10cSrcweir } 848cdf0e10cSrcweir 849cdf0e10cSrcweir //------------------------------------------------------------------------------ 850cdf0e10cSrcweir 851cdf0e10cSrcweir extern "C" void * 852cdf0e10cSrcweir component_getFactory(const sal_Char *pszImplementationName, void *pServiceManager, void *pRegistryKey) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir return cppu::component_getFactoryHelper( 855cdf0e10cSrcweir pszImplementationName, 856cdf0e10cSrcweir pServiceManager, 857cdf0e10cSrcweir pRegistryKey, 858cdf0e10cSrcweir kImplementations_entries) ; 859cdf0e10cSrcweir } 860cdf0e10cSrcweir 861