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 27 #include <cppuhelper/bootstrap.hxx> 28 29 #include "updateprotocol.hxx" 30 31 #include <sal/main.h> 32 #include <osl/process.h> 33 #include <stdio.h> 34 35 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 36 37 namespace task = ::com::sun::star::task; 38 namespace uno = ::com::sun::star::uno; 39 40 // ----------------------------------------------------------------------- 41 42 SAL_IMPLEMENT_MAIN() 43 { 44 (void) argv; 45 (void) argc; 46 47 if( osl_getCommandArgCount() != 0 ) 48 { 49 fprintf(stderr, "Usage: updateprotocoltest\n"); 50 return -1; 51 } 52 53 // create the initial component context 54 uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext(); 55 56 // initialize UCB 57 uno::Sequence< uno::Any > theArguments(2); 58 theArguments[0] = uno::makeAny( UNISTRING( "Local") ); 59 theArguments[1] = uno::makeAny( UNISTRING( "Office") ); 60 61 uno::Reference< uno::XInterface > xUCB = 62 rComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext( 63 UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ), 64 theArguments, 65 rComponentContext ); 66 67 68 rtl::OUString aURL; 69 rtl::OUString aVersion; 70 71 try 72 { 73 if( checkForUpdates(rComponentContext, uno::Reference< task::XInteractionHandler > (), aURL, aVersion) ) 74 { 75 OSL_TRACE( "Update found: %s on %s", 76 rtl::OUStringToOString( aVersion, RTL_TEXTENCODING_UTF8).getStr(), 77 rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8).getStr()); 78 } 79 else 80 { 81 OSL_TRACE( "no updates found" ); 82 } 83 } 84 catch( ... ) 85 { 86 OSL_TRACE( "unhandled exception caught" ); 87 } 88 89 return 0; 90 } 91