LibreOffice Module extensions (master) 1
updateprotocoltest.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
22
23#include "updateprotocol.hxx"
24#include <com/sun/star/ucb/UniversalContentBroker.hpp>
25
26#include <sal/main.h>
27#include <osl/process.h>
28#include <stdio.h>
29#include "sal/log.hxx"
30
31namespace task = ::com::sun::star::task;
32namespace uno = ::com::sun::star::uno;
33
34
36{
37 (void) argv;
38 (void) argc;
39
40 if( osl_getCommandArgCount() != 0 )
41 {
42 fprintf(stderr, "Usage: updateprotocoltest\n");
43 return -1;
44 }
45
46 // create the initial component context
47 uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext();
48
49 // initialize UCB (for backwards compatibility, in case some code still uses
50 // plain createInstance w/o args directly to obtain an instance):
51 css::ucb::UniversalContentBroker::create(rComponentContext);
52
53
54 OUString aURL;
55 OUString aVersion;
56
57 try
58 {
59 if( checkForUpdates(rComponentContext, uno::Reference< task::XInteractionHandler > (), aURL, aVersion) )
60 {
61 SAL_INFO("extensions.update", "Update found: " << aVersion << " on " << aURL);
62 }
63 else
64 {
65 SAL_INFO("extensions.update", "no updates found" );
66 }
67 }
68 catch( ... )
69 {
70 SAL_INFO("extensions.update", "unhandled exception caught" );
71 }
72
73 return 0;
74}
75
76/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
URL aURL
#define SAL_INFO(area, stream)
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
bool checkForUpdates(UpdateInfo &o_rUpdateInfo, uno::Reference< uno::XComponentContext > const &rxContext, uno::Reference< task::XInteractionHandler > const &rxInteractionHandler, const uno::Reference< deployment::XUpdateInformationProvider > &rUpdateInfoProvider)
SAL_IMPLEMENT_MAIN()