1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include <comphelper/processfactory.hxx>
27 
28 #include <cppuhelper/servicefactory.hxx>
29 #include <cppuhelper/bootstrap.hxx>
30 
31 #include <com/sun/star/lang/XInitialization.hpp>
32 
33 
34 #include <com/sun/star/deployment/UpdateInformationProvider.hpp>
35 
36 #include <sal/main.h>
37 #include <osl/process.h>
38 #include <stdio.h>
39 
40 namespace deployment = ::com::sun::star::deployment;
41 namespace lang = ::com::sun::star::lang;
42 namespace uno = ::com::sun::star::uno;
43 namespace xml = ::com::sun::star::xml;
44 
45 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
46 
47 // -----------------------------------------------------------------------
48 
SAL_IMPLEMENT_MAIN()49 SAL_IMPLEMENT_MAIN()
50 {
51     (void) argv;
52 	(void) argc;
53 
54     if( osl_getCommandArgCount() != 1 )
55     {
56         fprintf(stderr, "Usage: updatefeedtest <url>\n");
57         return -1;
58     }
59 
60     // create the initial component context
61     uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext();
62 
63     // initialize UCB
64     uno::Sequence< uno::Any > theArguments(2);
65     theArguments[0] = uno::makeAny( UNISTRING( "Local") );
66     theArguments[1] = uno::makeAny( UNISTRING( "Office") );
67 
68     uno::Reference< uno::XInterface > xUCB =
69         rComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
70             UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ),
71             theArguments,
72             rComponentContext );
73 
74     // retrieve the update information provider
75     uno::Reference< deployment::XUpdateInformationProvider > rUpdateInformationProvider =
76         deployment::UpdateInformationProvider::create( rComponentContext );
77 
78     uno::Sequence< rtl::OUString > theURLs(1);
79     osl_getCommandArg( 0, &theURLs[0].pData );
80     // theURLs[0] = UNISTRING( "http://localhost/~olli/atomfeed.xml" );
81 
82     rtl::OUString aExtension = UNISTRING( "MyExtension" );
83 
84     try
85     {
86         uno::Sequence< uno::Reference< xml::dom::XElement > > theUpdateInfo =
87             rUpdateInformationProvider->getUpdateInformation( theURLs, aExtension );
88 
89         OSL_TRACE( "getUpdateInformation returns %d element(s)", theUpdateInfo.getLength() );
90     }
91     catch( const uno::Exception & e )
92     {
93         OSL_TRACE( "exception caught: %s", rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr());
94     }
95     catch( ... )
96     {
97         OSL_TRACE( "exception of undetermined type caught" );
98     }
99 
100 
101     return 0;
102 }
103