1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski #if ! defined INCLUDED_DP_UPDATE_HXX
25*b1cdbd2cSJim Jagielski #define INCLUDED_DP_UPDATE_HXX
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski 
28*b1cdbd2cSJim Jagielski #include "com/sun/star/deployment/XPackage.hpp"
29*b1cdbd2cSJim Jagielski #include "com/sun/star/deployment/XExtensionManager.hpp"
30*b1cdbd2cSJim Jagielski #include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
31*b1cdbd2cSJim Jagielski #include "com/sun/star/uno/XComponentContext.hpp"
32*b1cdbd2cSJim Jagielski #include "com/sun/star/xml/dom/XNode.hpp"
33*b1cdbd2cSJim Jagielski 
34*b1cdbd2cSJim Jagielski #include "rtl/ustrbuf.hxx"
35*b1cdbd2cSJim Jagielski #include "dp_misc_api.hxx"
36*b1cdbd2cSJim Jagielski 
37*b1cdbd2cSJim Jagielski #include <map>
38*b1cdbd2cSJim Jagielski #include <vector>
39*b1cdbd2cSJim Jagielski 
40*b1cdbd2cSJim Jagielski namespace dp_misc {
41*b1cdbd2cSJim Jagielski 
42*b1cdbd2cSJim Jagielski /** returns the default update URL (for the update information) which
43*b1cdbd2cSJim Jagielski     is used when an extension does not provide its own URL.
44*b1cdbd2cSJim Jagielski */
45*b1cdbd2cSJim Jagielski DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
46*b1cdbd2cSJim Jagielski ::rtl::OUString getExtensionDefaultUpdateURL();
47*b1cdbd2cSJim Jagielski 
48*b1cdbd2cSJim Jagielski enum UPDATE_SOURCE
49*b1cdbd2cSJim Jagielski {
50*b1cdbd2cSJim Jagielski     UPDATE_SOURCE_NONE,
51*b1cdbd2cSJim Jagielski     UPDATE_SOURCE_SHARED,
52*b1cdbd2cSJim Jagielski     UPDATE_SOURCE_BUNDLED,
53*b1cdbd2cSJim Jagielski     UPDATE_SOURCE_ONLINE
54*b1cdbd2cSJim Jagielski };
55*b1cdbd2cSJim Jagielski 
56*b1cdbd2cSJim Jagielski /* determine if an update is available which is installed in the
57*b1cdbd2cSJim Jagielski    user repository.
58*b1cdbd2cSJim Jagielski 
59*b1cdbd2cSJim Jagielski    If the return value is UPDATE_SOURCE_NONE, then no update is
60*b1cdbd2cSJim Jagielski    available, otherwise the return value determine from which the
61*b1cdbd2cSJim Jagielski    repository the update is used.
62*b1cdbd2cSJim Jagielski */
63*b1cdbd2cSJim Jagielski DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
64*b1cdbd2cSJim Jagielski UPDATE_SOURCE isUpdateUserExtension(
65*b1cdbd2cSJim Jagielski     bool bReadOnlyShared,
66*b1cdbd2cSJim Jagielski     ::rtl::OUString const & userVersion,
67*b1cdbd2cSJim Jagielski     ::rtl::OUString const & sharedVersion,
68*b1cdbd2cSJim Jagielski     ::rtl::OUString const & bundledVersion,
69*b1cdbd2cSJim Jagielski     ::rtl::OUString const & onlineVersion);
70*b1cdbd2cSJim Jagielski 
71*b1cdbd2cSJim Jagielski /* determine if an update is available which is installed in the
72*b1cdbd2cSJim Jagielski    shared repository.
73*b1cdbd2cSJim Jagielski 
74*b1cdbd2cSJim Jagielski    If the return value is UPDATE_SOURCE_NONE, then no update is
75*b1cdbd2cSJim Jagielski    available, otherwise the return value determine from which the
76*b1cdbd2cSJim Jagielski    repository the update is used.
77*b1cdbd2cSJim Jagielski */
78*b1cdbd2cSJim Jagielski DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
79*b1cdbd2cSJim Jagielski UPDATE_SOURCE isUpdateSharedExtension(
80*b1cdbd2cSJim Jagielski     bool bReadOnlyShared,
81*b1cdbd2cSJim Jagielski     ::rtl::OUString const & sharedVersion,
82*b1cdbd2cSJim Jagielski     ::rtl::OUString const & bundledVersion,
83*b1cdbd2cSJim Jagielski     ::rtl::OUString const & onlineVersion);
84*b1cdbd2cSJim Jagielski 
85*b1cdbd2cSJim Jagielski /* determines the extension with the highest identifier and returns it
86*b1cdbd2cSJim Jagielski 
87*b1cdbd2cSJim Jagielski  */
88*b1cdbd2cSJim Jagielski DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
89*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>
90*b1cdbd2cSJim Jagielski getExtensionWithHighestVersion(
91*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Sequence<
92*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference<
93*b1cdbd2cSJim Jagielski     ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId);
94*b1cdbd2cSJim Jagielski 
95*b1cdbd2cSJim Jagielski 
96*b1cdbd2cSJim Jagielski struct UpdateInfo
97*b1cdbd2cSJim Jagielski {
98*b1cdbd2cSJim Jagielski     UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext);
99*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference<
100*b1cdbd2cSJim Jagielski         ::com::sun::star::deployment::XPackage> extension;
101*b1cdbd2cSJim Jagielski //version of the update
102*b1cdbd2cSJim Jagielski     ::rtl::OUString version;
103*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info;
104*b1cdbd2cSJim Jagielski };
105*b1cdbd2cSJim Jagielski 
106*b1cdbd2cSJim Jagielski typedef std::map< ::rtl::OUString, UpdateInfo > UpdateInfoMap;
107*b1cdbd2cSJim Jagielski 
108*b1cdbd2cSJim Jagielski /*
109*b1cdbd2cSJim Jagielski   @param extensionList
110*b1cdbd2cSJim Jagielski   List of extension for which online update information are to be obtained. If NULL, then
111*b1cdbd2cSJim Jagielski   for update information are obtained for all installed extension. There may be only one extension
112*b1cdbd2cSJim Jagielski   with a particular identifier contained in the list. If one extension is installed
113*b1cdbd2cSJim Jagielski   in several repositories, then the one with the highest version must be used, because it contains
114*b1cdbd2cSJim Jagielski   the more recent URLs for getting the update information (if at all).
115*b1cdbd2cSJim Jagielski   @param out_errors
116*b1cdbd2cSJim Jagielski   the first member of the pair is the extension  and the second the exception that was produced
117*b1cdbd2cSJim Jagielski   when processing the extension.
118*b1cdbd2cSJim Jagielski 
119*b1cdbd2cSJim Jagielski   @return
120*b1cdbd2cSJim Jagielski   A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains
121*b1cdbd2cSJim Jagielski   at only information for those extensions.
122*b1cdbd2cSJim Jagielski  */
123*b1cdbd2cSJim Jagielski DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
124*b1cdbd2cSJim Jagielski UpdateInfoMap getOnlineUpdateInfos(
125*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext,
126*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr,
127*b1cdbd2cSJim Jagielski     ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation,
128*b1cdbd2cSJim Jagielski     std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList,
129*b1cdbd2cSJim Jagielski     ::std::vector< ::std::pair< ::com::sun::star::uno::Reference<
130*b1cdbd2cSJim Jagielski     ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors);
131*b1cdbd2cSJim Jagielski 
132*b1cdbd2cSJim Jagielski /* retunrs the highest version from the provided arguments.
133*b1cdbd2cSJim Jagielski */
134*b1cdbd2cSJim Jagielski DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
135*b1cdbd2cSJim Jagielski ::rtl::OUString getHighestVersion(
136*b1cdbd2cSJim Jagielski     ::rtl::OUString const & userVersion,
137*b1cdbd2cSJim Jagielski     ::rtl::OUString const & sharedVersion,
138*b1cdbd2cSJim Jagielski     ::rtl::OUString const & bundledVersion,
139*b1cdbd2cSJim Jagielski     ::rtl::OUString const & onlineVersion);
140*b1cdbd2cSJim Jagielski 
141*b1cdbd2cSJim Jagielski }
142*b1cdbd2cSJim Jagielski 
143*b1cdbd2cSJim Jagielski #endif
144