Line data Source code
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 : #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_UPDATE_HXX
21 : #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_UPDATE_HXX
22 :
23 :
24 : #include <com/sun/star/deployment/XPackage.hpp>
25 : #include <com/sun/star/deployment/XExtensionManager.hpp>
26 : #include <com/sun/star/deployment/XUpdateInformationProvider.hpp>
27 : #include <com/sun/star/uno/XComponentContext.hpp>
28 : #include <com/sun/star/xml/dom/XNode.hpp>
29 :
30 : #include <rtl/ustrbuf.hxx>
31 : #include "dp_misc_api.hxx"
32 :
33 : #include <map>
34 : #include <vector>
35 :
36 : namespace dp_misc {
37 :
38 : /** returns the default update URL (for the update information) which
39 : is used when an extension does not provide its own URL.
40 : */
41 : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
42 : OUString getExtensionDefaultUpdateURL();
43 :
44 : enum UPDATE_SOURCE
45 : {
46 : UPDATE_SOURCE_NONE,
47 : UPDATE_SOURCE_SHARED,
48 : UPDATE_SOURCE_BUNDLED,
49 : UPDATE_SOURCE_ONLINE
50 : };
51 :
52 : /* determine if an update is available which is installed in the
53 : user repository.
54 :
55 : If the return value is UPDATE_SOURCE_NONE, then no update is
56 : available, otherwise the return value determine from which the
57 : repository the update is used.
58 : */
59 : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
60 : UPDATE_SOURCE isUpdateUserExtension(
61 : bool bReadOnlyShared,
62 : OUString const & userVersion,
63 : OUString const & sharedVersion,
64 : OUString const & bundledVersion,
65 : OUString const & onlineVersion);
66 :
67 : /* determine if an update is available which is installed in the
68 : shared repository.
69 :
70 : If the return value is UPDATE_SOURCE_NONE, then no update is
71 : available, otherwise the return value determine from which the
72 : repository the update is used.
73 : */
74 : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
75 : UPDATE_SOURCE isUpdateSharedExtension(
76 : bool bReadOnlyShared,
77 : OUString const & sharedVersion,
78 : OUString const & bundledVersion,
79 : OUString const & onlineVersion);
80 :
81 : /* determines the extension with the highest identifier and returns it
82 :
83 : */
84 : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
85 : ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>
86 : getExtensionWithHighestVersion(
87 : ::com::sun::star::uno::Sequence<
88 : ::com::sun::star::uno::Reference<
89 : ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId);
90 :
91 :
92 0 : struct UpdateInfo
93 : {
94 : UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext);
95 : ::com::sun::star::uno::Reference<
96 : ::com::sun::star::deployment::XPackage> extension;
97 : //version of the update
98 : OUString version;
99 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info;
100 : };
101 :
102 : typedef std::map< OUString, UpdateInfo > UpdateInfoMap;
103 :
104 : /*
105 : @param extensionList
106 : List of extension for which online update information are to be obtained. If NULL, then
107 : for update information are obtained for all installed extension. There may be only one extension
108 : with a particular identifier contained in the list. If one extension is installed
109 : in several repositories, then the one with the highest version must be used, because it contains
110 : the more recent URLs for getting the update information (if at all).
111 : @param out_errors
112 : the first member of the pair is the extension and the second the exception that was produced
113 : when processing the extension.
114 :
115 : @return
116 : A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains
117 : at only information for those extensions.
118 : */
119 : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
120 : UpdateInfoMap getOnlineUpdateInfos(
121 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext,
122 : ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr,
123 : ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation,
124 : std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList,
125 : ::std::vector< ::std::pair< ::com::sun::star::uno::Reference<
126 : ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors);
127 :
128 : /* retunrs the highest version from the provided arguments.
129 : */
130 : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
131 : OUString getHighestVersion(
132 : OUString const & userVersion,
133 : OUString const & sharedVersion,
134 : OUString const & bundledVersion,
135 : OUString const & onlineVersion);
136 :
137 : }
138 :
139 : #endif
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|