1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_extensions.hxx" 30 #include <comphelper/processfactory.hxx> 31 32 #include <cppuhelper/servicefactory.hxx> 33 #include <cppuhelper/bootstrap.hxx> 34 35 #include <com/sun/star/lang/XInitialization.hpp> 36 37 38 #include <com/sun/star/deployment/UpdateInformationProvider.hpp> 39 40 #include <sal/main.h> 41 #include <osl/process.h> 42 #include <stdio.h> 43 44 namespace deployment = ::com::sun::star::deployment; 45 namespace lang = ::com::sun::star::lang; 46 namespace uno = ::com::sun::star::uno; 47 namespace xml = ::com::sun::star::xml; 48 49 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 50 51 // ----------------------------------------------------------------------- 52 53 SAL_IMPLEMENT_MAIN() 54 { 55 (void) argv; 56 (void) argc; 57 58 if( osl_getCommandArgCount() != 1 ) 59 { 60 fprintf(stderr, "Usage: updatefeedtest <url>\n"); 61 return -1; 62 } 63 64 // create the initial component context 65 uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext(); 66 67 // initialize UCB 68 uno::Sequence< uno::Any > theArguments(2); 69 theArguments[0] = uno::makeAny( UNISTRING( "Local") ); 70 theArguments[1] = uno::makeAny( UNISTRING( "Office") ); 71 72 uno::Reference< uno::XInterface > xUCB = 73 rComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext( 74 UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ), 75 theArguments, 76 rComponentContext ); 77 78 // retrieve the update information provider 79 uno::Reference< deployment::XUpdateInformationProvider > rUpdateInformationProvider = 80 deployment::UpdateInformationProvider::create( rComponentContext ); 81 82 uno::Sequence< rtl::OUString > theURLs(1); 83 osl_getCommandArg( 0, &theURLs[0].pData ); 84 // theURLs[0] = UNISTRING( "http://localhost/~olli/atomfeed.xml" ); 85 86 rtl::OUString aExtension = UNISTRING( "MyExtension" ); 87 88 try 89 { 90 uno::Sequence< uno::Reference< xml::dom::XElement > > theUpdateInfo = 91 rUpdateInformationProvider->getUpdateInformation( theURLs, aExtension ); 92 93 OSL_TRACE( "getUpdateInformation returns %d element(s)", theUpdateInfo.getLength() ); 94 } 95 catch( const uno::Exception & e ) 96 { 97 OSL_TRACE( "exception caught: %s", rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr()); 98 } 99 catch( ... ) 100 { 101 OSL_TRACE( "exception of undetermined type caught" ); 102 } 103 104 105 return 0; 106 } 107