Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_DESCRIPTIONINFOSET_HXX
30 : : #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_DESCRIPTIONINFOSET_HXX
31 : :
32 : : #include "sal/config.h"
33 : :
34 : : #include "boost/optional.hpp"
35 : : #include "com/sun/star/uno/Reference.hxx"
36 : : #include "com/sun/star/uno/Sequence.hxx"
37 : : #include "sal/types.h"
38 : : #include "dp_misc_api.hxx"
39 : :
40 : : /// @HTML
41 : :
42 : : namespace com { namespace sun { namespace star {
43 : : namespace lang { struct Locale; }
44 : : namespace uno { class XComponentContext; }
45 : : namespace xml {
46 : : namespace dom {
47 : : class XNode;
48 : : class XNodeList;
49 : : }
50 : : namespace xpath { class XXPathAPI; }
51 : : }
52 : : } } }
53 : : namespace rtl { class OUString; }
54 : :
55 : : namespace dp_misc {
56 : :
57 : 0 : struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SimpleLicenseAttributes
58 : : {
59 : : ::rtl::OUString acceptBy;
60 : : //Attribute suppress-on-update. Default is false.
61 : : bool suppressOnUpdate;
62 : : //Attribute suppress-if-required. Default is false.
63 : : bool suppressIfRequired;
64 : : };
65 : :
66 : :
67 : : /**
68 : : Access to the content of an XML <code>description</code> element.
69 : :
70 : : <p>This works for <code>description</code> elements in both the
71 : : <code>description.xml</code> file and online update information formats.</p>
72 : : */
73 : : class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DescriptionInfoset {
74 : : public:
75 : : /**
76 : : Create an instance.
77 : :
78 : : @param context
79 : : a non-null component context
80 : :
81 : : @param element
82 : : a <code>description</code> element; may be null (equivalent to an element
83 : : with no content)
84 : : */
85 : : DescriptionInfoset(
86 : : ::com::sun::star::uno::Reference<
87 : : ::com::sun::star::uno::XComponentContext > const & context,
88 : : ::com::sun::star::uno::Reference<
89 : : ::com::sun::star::xml::dom::XNode > const & element);
90 : :
91 : : ~DescriptionInfoset();
92 : :
93 : : /**
94 : : Return the identifier.
95 : :
96 : : @return
97 : : the identifier, or an empty <code>optional</code> if none is specified
98 : : */
99 : : ::boost::optional< ::rtl::OUString > getIdentifier() const;
100 : :
101 : : /**
102 : : Return the textual version representation.
103 : :
104 : : @return
105 : : textual version representation
106 : : */
107 : : ::rtl::OUString getVersion() const;
108 : :
109 : : /**
110 : : Returns a list of supported platforms.
111 : :
112 : : If the extension does not specify a platform by leaving out the platform element
113 : : then we assume that the extension supports all platforms. In this case the returned
114 : : sequence will have one element, which is "all".
115 : : If the platform element is present but does not specify a platform then an empty
116 : : sequence is returned. Examples for invalid platform elements:
117 : : <pre>
118 : : <platform />, <platform value="" />, <platfrom value=",">
119 : : </pre>
120 : :
121 : : The value attribute can contain various platform tokens. They must be separated by
122 : : commas.Each token will be stripped from leading and trailing white space (trim()).
123 : : */
124 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedPlaforms() const;
125 : :
126 : : /**
127 : : Returns the localized publisher name and the corresponding URL.
128 : :
129 : : In case there is no publisher element then a pair of two empty strings is returned.
130 : : */
131 : : ::std::pair< ::rtl::OUString, ::rtl::OUString > getLocalizedPublisherNameAndURL() const;
132 : :
133 : : /**
134 : : Returns the URL for the release notes corresponding to the office's locale.
135 : :
136 : : In case there is no release-notes element then an empty string is returned.
137 : : */
138 : : ::rtl::OUString getLocalizedReleaseNotesURL() const;
139 : :
140 : : /** returns the relative path to the license file.
141 : :
142 : : In case there is no simple-license element then an empty string is returned.
143 : : */
144 : : ::rtl::OUString getLocalizedLicenseURL() const;
145 : :
146 : : /** returns the attributes of the simple-license element
147 : :
148 : : As long as there is a simple-license element, the function will return
149 : : the structure. If it does not exist, then the optional object is uninitialized.
150 : : */
151 : : ::boost::optional<SimpleLicenseAttributes> getSimpleLicenseAttributes() const;
152 : :
153 : : /** returns the localized display name of the extensions.
154 : :
155 : : In case there is no localized display-name then an empty string is returned.
156 : : */
157 : : ::rtl::OUString getLocalizedDisplayName() const;
158 : :
159 : : /**
160 : : returns the download website URL from the update information.
161 : :
162 : : There can be multiple URLs where each is assigned to a particular locale.
163 : : The function returs the URL which locale matches best the one used in the office.
164 : :
165 : : The return value is an optional because it may be necessary to find out if there
166 : : was a value provided or not. This is necessary to flag the extension in the update dialog
167 : : properly as "browser based update". The return value will only then not be initialized
168 : : if there is no <code><update-website></code>. If the element exists, then it must
169 : : have at least one child element containing an URL.
170 : :
171 : : The <code><update-website></code> and <code><update-download></code>
172 : : elements are mutually exclusiv.
173 : :
174 : : @return
175 : : the download website URL, or an empty <code>optional</code> if none is
176 : : specified
177 : : */
178 : : ::boost::optional< ::rtl::OUString > getLocalizedUpdateWebsiteURL() const;
179 : :
180 : : /** returns the relative URL to the description.
181 : :
182 : : The URL is relative to the root directory of the extensions.
183 : : */
184 : : ::rtl::OUString getLocalizedDescriptionURL() const;
185 : : /**
186 : : Return the dependencies.
187 : :
188 : : @return
189 : : dependencies; will never be null
190 : : */
191 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNodeList >
192 : : getDependencies() const;
193 : :
194 : : /**
195 : : Return the update information URLs.
196 : :
197 : : @return
198 : : update information URLs
199 : : */
200 : : ::com::sun::star::uno::Sequence< ::rtl::OUString >
201 : : getUpdateInformationUrls() const;
202 : :
203 : : /**
204 : : Return the download URLs from the update information.
205 : :
206 : : Because the <code><update-download></code> and the <code><update-website></code>
207 : : elements are mutually exclusive one may need to determine exacty if the element
208 : : was provided.
209 : :
210 : : @return
211 : : download URLs
212 : : */
213 : : ::com::sun::star::uno::Sequence< ::rtl::OUString >
214 : : getUpdateDownloadUrls() const;
215 : :
216 : : /**
217 : : Returns the URL for the icon image.
218 : : */
219 : : ::rtl::OUString getIconURL( sal_Bool bHighContrast ) const;
220 : :
221 : : bool hasDescription() const;
222 : :
223 : : private:
224 : : SAL_DLLPRIVATE ::boost::optional< ::rtl::OUString > getOptionalValue(
225 : : ::rtl::OUString const & expression) const;
226 : :
227 : : SAL_DLLPRIVATE ::com::sun::star::uno::Sequence< ::rtl::OUString > getUrls(
228 : : ::rtl::OUString const & expression) const;
229 : :
230 : : /** Retrieves a child element which as lang attribute which matches the office locale.
231 : :
232 : : Only top-level children are taken into account. It is also assumed that they are all
233 : : of the same element type and have a lang attribute. The matching algoritm is according
234 : : to RFC 3066, with the exception that only one variant is allowed.
235 : : @param parent
236 : : the expression used to obtain the parent of the localized children. It can be null.
237 : : Then a null reference is returned.
238 : : */
239 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode >
240 : : getLocalizedChild( ::rtl::OUString const & sParent) const;
241 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode>
242 : : matchFullLocale(::com::sun::star::uno::Reference<
243 : : ::com::sun::star::xml::dom::XNode > const & xParent, ::rtl::OUString const & sLocale) const;
244 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode>
245 : : matchCountryAndLanguage(::com::sun::star::uno::Reference<
246 : : ::com::sun::star::xml::dom::XNode > const & xParent,
247 : : ::com::sun::star::lang::Locale const & officeLocale) const;
248 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode>
249 : : matchLanguage(
250 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & xParent,
251 : : ::com::sun::star::lang::Locale const & officeLocale) const;
252 : :
253 : : /** If there is no child element with a locale matching the office locale, then we use
254 : : the first child. In the case of the simple-license we also use the former default locale, which
255 : : was determined by the default-license-id (/description/registration/simple-license/@default-license-id)
256 : : and the license-id attributes (/description/registration/simple-license/license-text/@license-id).
257 : : However, since OOo 2.4 we use also the first child as default for the license
258 : : unless the two attributes are present.
259 : : */
260 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode>
261 : : getChildWithDefaultLocale(
262 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & xParent) const;
263 : : /**
264 : : @param out_bParentExists
265 : : indicates if the element node specified in sXPathParent exists.
266 : : */
267 : : SAL_DLLPRIVATE ::rtl::OUString getLocalizedHREFAttrFromChild(
268 : : ::rtl::OUString const & sXPathParent, bool * out_bParentExists) const;
269 : :
270 : : static SAL_DLLPRIVATE ::rtl::OUString
271 : : localeToString(::com::sun::star::lang::Locale const & locale);
272 : :
273 : : /** Gets the node value for a given expression. The expression is used in
274 : : m_xpath-selectSingleNode. The value of the returned node is return value
275 : : of this function.
276 : : */
277 : : SAL_DLLPRIVATE ::rtl::OUString
278 : : getNodeValueFromExpression(::rtl::OUString const & expression) const;
279 : :
280 : : ::com::sun::star::uno::Reference<
281 : : ::com::sun::star::xml::dom::XNode > m_element;
282 : : ::com::sun::star::uno::Reference<
283 : : ::com::sun::star::xml::xpath::XXPathAPI > m_xpath;
284 : : };
285 : :
286 : 500 : inline bool DescriptionInfoset::hasDescription() const
287 : : {
288 : 500 : return m_element.is();
289 : : }
290 : :
291 : : /** creates a DescriptionInfoset object.
292 : :
293 : : The argument sExtensionFolderURL is a file URL to extension folder containing
294 : : the description.xml.
295 : : */
296 : : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
297 : : DescriptionInfoset getDescriptionInfoset(::rtl::OUString const & sExtensionFolderURL);
298 : : }
299 : :
300 : : #endif
301 : :
302 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|