masterfix DEV300: #i10000# build fix
[LibreOffice.git] / extensions / source / update / feed / test / updatefeedtest.cxx
blob025a16dbcd76425e622ca7f779ce65aece215e0c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include <comphelper/processfactory.hxx>
32 #include <cppuhelper/servicefactory.hxx>
33 #include <cppuhelper/bootstrap.hxx>
35 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/deployment/UpdateInformationProvider.hpp>
40 #include <sal/main.h>
41 #include <osl/process.h>
42 #include <stdio.h>
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;
49 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
51 // -----------------------------------------------------------------------
53 SAL_IMPLEMENT_MAIN()
55 (void) argv;
56 (void) argc;
58 if( osl_getCommandArgCount() != 1 )
60 fprintf(stderr, "Usage: updatefeedtest <url>\n");
61 return -1;
64 // create the initial component context
65 uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext();
67 // initialize UCB
68 uno::Sequence< uno::Any > theArguments(2);
69 theArguments[0] = uno::makeAny( UNISTRING( "Local") );
70 theArguments[1] = uno::makeAny( UNISTRING( "Office") );
72 uno::Reference< uno::XInterface > xUCB =
73 rComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
74 UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ),
75 theArguments,
76 rComponentContext );
78 // retrieve the update information provider
79 uno::Reference< deployment::XUpdateInformationProvider > rUpdateInformationProvider =
80 deployment::UpdateInformationProvider::create( rComponentContext );
82 uno::Sequence< rtl::OUString > theURLs(1);
83 osl_getCommandArg( 0, &theURLs[0].pData );
84 // theURLs[0] = UNISTRING( "http://localhost/~olli/atomfeed.xml" );
86 rtl::OUString aExtension = UNISTRING( "MyExtension" );
88 try
90 uno::Sequence< uno::Reference< xml::dom::XElement > > theUpdateInfo =
91 rUpdateInformationProvider->getUpdateInformation( theURLs, aExtension );
93 OSL_TRACE( "getUpdateInformation returns %d element(s)", theUpdateInfo.getLength() );
95 catch( const uno::Exception & e )
97 OSL_TRACE( "exception caught: %s", rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr());
99 catch( ... )
101 OSL_TRACE( "exception of undetermined type caught" );
105 return 0;