1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_JVMFWK_SOURCE_ELEMENTS_HXX
20 #define INCLUDED_JVMFWK_SOURCE_ELEMENTS_HXX
23 #include "jvmfwk/framework.h"
24 #include "fwkutil.hxx"
25 #include "rtl/ustring.hxx"
26 #include "rtl/byteseq.hxx"
27 #include "libxml/parser.h"
28 #include "boost/optional.hpp"
30 #define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
31 #define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
36 /** gets the value of the updated element from the javavendors.xml.
38 OString
getElementUpdated();
40 /** create the child elements within the root structure for each platform.
43 [out]If true then the respective structure of elements was added and the
44 document needs to be saved.
46 void createSettingsStructure(
47 xmlDoc
* document
, bool * bNeedsSave
);
50 /** represents the settings saved in the /java/javaInfo element.
51 It is used within class NodeJava which determines the settings
60 /** if true, then javaInfo is empty. When writeToNode is called
61 then all child elements are deleted.
64 /** Contains the value of the <updated> element of
65 the javavendors.xml after loadFromNode was called.
66 It is not used, when the javaInfo node is written.
69 OString sAttrVendorUpdate
;
70 /** contains the nil value of the /java/javaInfo@xsi:nil attribute.
74 /** contains the value of the /java/javaInfo@autoSelect attribute.
75 Default is true. If it is false then the user has modified the JRE
76 selection by actively choosing a JRE from the options dialog. That is,
77 the function jfw_setSelectedJRE was called. Contrary, the function
78 jfw_findAndSelectJRE sets the attribute to true.
85 sal_uInt64 nRequirements
;
86 ::rtl::ByteSequence arVendorData
;
88 /** reads the node /java/javaInfo.
89 If javaInfo@xsi:nil = true then member bNil is set to true
90 an no further elements are read.
92 void loadFromNode(xmlDoc
* pDoc
,xmlNode
* pJavaInfo
);
93 /** The attribute nil will be set to false. The function gets the value
94 javaSettings/updated from the javavendors.xml and writes it to
95 javaInfo@vendorUpdate in javasettings.xml
97 void writeToNode(xmlDoc
* pDoc
, xmlNode
* pJavaInfo
) const;
99 /** returns NULL if javaInfo is nil.
101 JavaInfo
* makeJavaInfo() const;
104 /** this class represents the java settings based on a particular
107 Which settings file is used is determined by the value passed into the
108 constructor and the values of the bootstrap parameters
109 UNO_JAVA_JFW_USER_DATA and UNO_JAVA_JFW_SHARED_DATA.
111 The method load reads the data from the settings file.
112 The method write stores the data into the settings file.
117 enum Layer
{ USER
, SHARED
};
120 /** creates settings file and fills it with default values.
122 When this function is called then it creates the
123 settings file at the possition determined by the bootstrap parameters
124 (UNO_JAVA_JFW_USER_DATA, UNO_JAVA_JFW_SHARED_DATA) and m_layer, unless
125 the file already exists (see createSettingsDocument).
128 JFW_E_CONFIG_READWRITE
130 bool prepareSettingsDocument() const;
132 /** helper function for prepareSettingsDocument.
134 bool createSettingsDocument() const;
136 /** returns the system path to the data file which is to be used. The value
137 depends on the member m_layer and the bootstrap parameters
138 UNO_JAVA_JFW_USER_DATA and UNO_JAVA_JFW_SHARED_DATA.
140 OString
getSettingsPath() const;
142 /** returns the file URL to the data file which is to be used. See getSettingsPath.
144 OUString
getSettingsURL() const;
146 /** Verifies if the respective settings file exist.
148 jfw::FileStatus
checkSettingsFileStatus(OUString
const & sURL
) const;
150 /** Determines the layer for which the instance the loads and writes the
155 /** User configurable option. /java/enabled
156 If /java/enabled@xsi:nil == true then the value will be uninitialized
157 after a call to load().
159 boost::optional
<sal_Bool
> m_enabled
;
161 /** User configurable option. /java/userClassPath
162 If /java/userClassPath@xsi:nil == true then the value is uninitialized
163 after a call to load().
165 boost::optional
< OUString
> m_userClassPath
;
166 /** User configurable option. /java/javaInfo
167 If /java/javaInfo@xsi:nil == true then the value is uninitialized
168 after a call to load.
170 boost::optional
<CNodeJavaInfo
> m_javaInfo
;
171 /** User configurable option. /java/vmParameters
172 If /java/vmParameters@xsi:nil == true then the value is uninitialized
173 after a call to load.
175 boost::optional
< ::std::vector
< OUString
> > m_vmParameters
;
176 /** User configurable option. /java/jreLocations
177 If /java/jreLocaltions@xsi:nil == true then the value is uninitialized
178 after a call to load.
180 boost::optional
< ::std::vector
< OUString
> > m_JRELocations
;
184 explicit NodeJava(Layer theLayer
);
187 /java/enabled@xsi:nil will be set to false when write is called.
189 void setEnabled(bool bEnabled
);
191 /** sets m_sUserClassPath. See setEnabled.
193 void setUserClassPath(const OUString
& sClassPath
);
195 /** sets m_aInfo. See setEnabled.
197 true- called by jfw_setSelectedJRE
198 false called by jfw_findAndSelectJRE
200 void setJavaInfo(const JavaInfo
* pInfo
, bool bAutoSelect
);
202 /** sets the /java/vmParameters/param elements.
203 When this method all previous values are removed and replaced
204 by those in arParameters.
205 /java/vmParameters@xsi:nil will be set to true when write() is
208 void setVmParameters(rtl_uString
* * arParameters
, sal_Int32 size
);
210 /** sets the /java/jreLocations/location elements.
211 When this method is called then all previous values are removed
212 and replaced by those in arParamters.
213 /java/jreLocations@xsi:nil will be set to true write() is called.
215 void setJRELocations(rtl_uString
* * arParameters
, sal_Int32 size
);
217 /** adds a location to the already existing locations.
218 Note: call load() before, then add the location and then call write().
220 void addJRELocation(rtl_uString
* sLocation
);
222 /** writes the data to user settings.
226 /** load the values of the settings file.
230 /** returns the value of the element /java/enabled
232 const boost::optional
<sal_Bool
> & getEnabled() const;
233 /** returns the value of the element /java/userClassPath.
235 const boost::optional
< OUString
> & getUserClassPath() const;
237 /** returns the value of the element /java/javaInfo.
239 const boost::optional
<CNodeJavaInfo
> & getJavaInfo() const;
241 /** returns the parameters from the element /java/vmParameters/param.
243 const boost::optional
< ::std::vector
< OUString
> > & getVmParameters() const;
245 /** returns the parameters from the element /java/jreLocations/location.
247 const boost::optional
< ::std::vector
< OUString
> > & getJRELocations() const;
250 /** merges the settings for shared, user and installation during construction.
251 The class uses a simple merge mechanism for the javasettings.xml files in share and
252 user. The following elements completely overwrite the corresponding elements
260 In case of an installation, the shared and user settings are completely
263 The locations of the different settings files is obtained through the
265 UNO_JAVA_JFW_USER_DATA
266 UNO_JAVA_JFW_SHARED_DATA
268 The class also determines useful default values for settings which have not been made.
273 const MergedSettings
& operator = (MergedSettings
&);
274 MergedSettings(MergedSettings
&);
276 void merge(const NodeJava
& share
, const NodeJava
& user
);
280 OUString m_sClassPath
;
282 ::std::vector
< OUString
> m_vmParams
;
284 ::std::vector
< OUString
> m_JRELocations
;
286 CNodeJavaInfo m_javaInfo
;
290 virtual ~MergedSettings();
292 /** the default is true.
294 bool getEnabled() const;
296 const OUString
& getUserClassPath() const;
298 ::std::vector
< OString
> getVmParametersUtf8() const;
299 /** returns a JavaInfo structure representing the node
300 /java/javaInfo. Every time a new JavaInfo structure is created
301 which needs to be freed by the caller.
302 If both, user and share settings are nil, then NULL is returned.
304 JavaInfo
* createJavaInfo() const;
306 /** returns the value of the attribute /java/javaInfo[@vendorUpdate].
308 OString
const & getJavaInfoAttrVendorUpdate() const;
311 /** returns the javaInfo@autoSelect attribute.
312 Before calling this function loadFromSettings must be called.
313 It uses the javaInfo@autoSelect attribute to determine
316 bool getJavaInfoAttrAutoSelect() const;
319 /** returns an array.
320 Caller must free the strings and the array.
322 void getVmParametersArray(rtl_uString
*** parParameters
, sal_Int32
* size
) const;
324 /** returns an array.
325 Caller must free the strings and the array.
327 void getJRELocations(rtl_uString
*** parLocations
, sal_Int32
* size
) const;
329 const ::std::vector
< OUString
> & getJRELocations() const;
335 ::std::vector
< OUString
> vecExcludeVersions
;
336 rtl_uString
** arVersions
;
342 void addExcludeVersion(const OUString
& sVersion
);
344 OUString sMinVersion
;
345 OUString sMaxVersion
;
347 /** The caller DOES NOT get ownership of the strings. That is he
348 does not need to release the strings.
349 The array exists as long as this object exists.
352 rtl_uString
** getExcludeVersions();
353 sal_Int32
getExcludeVersionSize();
361 PluginLibrary(const OUString
& vendor
, const OUString
& path
) :
362 sVendor(vendor
), sPath(path
)
365 /** contains the vendor string which is later userd in the xml API
368 /** File URL the plug-in library
376 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */