1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
28 #if !defined INCLUDED_JVMFWK_ELEMENTS_HXX
29 #define INCLUDED_JVMFWK_ELEMENTS_HXX
32 #include "jvmfwk/framework.h"
33 #include "fwkutil.hxx"
34 #include "rtl/ustring.hxx"
35 #include "rtl/byteseq.hxx"
36 #include "libxml/parser.h"
37 #include "boost/optional.hpp"
39 #define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
40 #define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
45 /** gets the value of the updated element from the javavendors.xml.
47 rtl::OString
getElementUpdated();
49 /** create the child elements within the root structure for each platform.
52 [out]If true then the respective structure of elements was added and the
53 document needs to be saved.
55 void createSettingsStructure(
56 xmlDoc
* document
, bool * bNeedsSave
);
59 /** represents the settings saved in the /java/javaInfo element.
60 It is used within class NodeJava which determines the settings
69 /** if true, then javaInfo is empty. When writeToNode is called
70 then all child elements are deleted.
73 /** Contains the value of the <updated> element of
74 the javavendors.xml after loadFromNode was called.
75 It is not used, when the javaInfo node is written.
78 ::rtl::OString sAttrVendorUpdate
;
79 /** contains the nil value of the /java/javaInfo@xsi:nil attribute.
83 /** contains the value of the /java/javaInfo@autoSelect attribute.
84 Default is true. If it is false then the user has modified the JRE
85 selection by actively choosing a JRE from the options dialog. That is,
86 the function jfw_setSelectedJRE was called. Contrary, the function
87 jfw_findAndSelectJRE sets the attribute to true.
90 ::rtl::OUString sVendor
;
91 ::rtl::OUString sLocation
;
92 ::rtl::OUString sVersion
;
94 sal_uInt64 nRequirements
;
95 ::rtl::ByteSequence arVendorData
;
97 /** reads the node /java/javaInfo.
98 If javaInfo@xsi:nil = true then member bNil is set to true
99 an no further elements are read.
101 void loadFromNode(xmlDoc
* pDoc
,xmlNode
* pJavaInfo
);
102 /** The attribut nil will be set to false. The function gets the value
103 javaSettings/updated from the javavendors.xml and writes it to
104 javaInfo@vendorUpdate in javasettings.xml
106 void writeToNode(xmlDoc
* pDoc
, xmlNode
* pJavaInfo
) const;
108 /** returns NULL if javaInfo is nil.
110 JavaInfo
* makeJavaInfo() const;
113 /** this class represents the java settings based on a particular
116 Which settings file is used is determined by the value passed into the
117 constructor and the values of the bootstrap parameters
118 UNO_JAVA_JFW_USER_DATA and UNO_JAVA_JFW_SHARED_DATA.
120 The method load reads the data from the settings file.
121 The method write stores the data into the settings file.
126 enum Layer
{ USER
, SHARED
};
129 /** creates settings file and fills it with default values.
131 When this function is called then it creates the
132 settings file at the possition determined by the bootstrap parameters
133 (UNO_JAVA_JFW_USER_DATA, UNO_JAVA_JFW_SHARED_DATA) and m_layer, unless
134 the file already exists (see createSettingsDocument).
137 JFW_E_CONFIG_READWRITE
139 void prepareSettingsDocument() const;
141 /** helper function for prepareSettingsDocument.
143 void createSettingsDocument() const;
145 /** returns the system path to the data file which is to be used. The value
146 depends on the the member m_layer and the bootstrap parameters
147 UNO_JAVA_JFW_USER_DATA and UNO_JAVA_JFW_SHARED_DATA.
149 ::rtl::OString
getSettingsPath() const;
151 /** returns the file URL to the data file which is to be used. See getSettingsPath.
153 ::rtl::OUString
getSettingsURL() const;
155 /** Verifies if the respective settings file exist.
157 jfw::FileStatus
checkSettingsFileStatus() const;
159 /** Determines the layer for which the instance the loads and writes the
164 /** User configurable option. /java/enabled
165 If /java/enabled@xsi:nil == true then the value will be uninitialized
166 after a call to load().
168 boost::optional
<sal_Bool
> m_enabled
;
170 /** User configurable option. /java/userClassPath
171 If /java/userClassPath@xsi:nil == true then the value is uninitialized
172 after a call to load().
174 boost::optional
< ::rtl::OUString
> m_userClassPath
;
175 /** User configurable option. /java/javaInfo
176 If /java/javaInfo@xsi:nil == true then the value is uninitialized
177 after a call to load.
179 boost::optional
<CNodeJavaInfo
> m_javaInfo
;
180 /** User configurable option. /java/vmParameters
181 If /java/vmParameters@xsi:nil == true then the value is uninitialized
182 after a call to load.
184 boost::optional
< ::std::vector
< ::rtl::OUString
> > m_vmParameters
;
185 /** User configurable option. /java/jreLocations
186 If /java/jreLocaltions@xsi:nil == true then the value is uninitialized
187 after a call to load.
189 boost::optional
< ::std::vector
< ::rtl::OUString
> > m_JRELocations
;
193 explicit NodeJava(Layer theLayer
);
196 /java/enabled@xsi:nil will be set to false when write is called.
198 void setEnabled(sal_Bool bEnabled
);
200 /** sets m_sUserClassPath. See setEnabled.
202 void setUserClassPath(const ::rtl::OUString
& sClassPath
);
204 /** sets m_aInfo. See setEnabled.
206 true- called by jfw_setSelectedJRE
207 false called by jfw_findAndSelectJRE
209 void setJavaInfo(const JavaInfo
* pInfo
, bool bAutoSelect
);
211 /** sets the /java/vmParameters/param elements.
212 When this method all previous values are removed and replaced
213 by those in arParameters.
214 /java/vmParameters@xsi:nil will be set to true when write() is
217 void setVmParameters(rtl_uString
* * arParameters
, sal_Int32 size
);
219 /** sets the /java/jreLocations/location elements.
220 When this method is called then all previous values are removed
221 and replaced by those in arParamters.
222 /java/jreLocations@xsi:nil will be set to true write() is called.
224 void setJRELocations(rtl_uString
* * arParameters
, sal_Int32 size
);
226 /** adds a location to the already existing locations.
227 Note: call load() before, then add the location and then call write().
229 void addJRELocation(rtl_uString
* sLocation
);
231 /** writes the data to user settings.
235 /** load the values of the settings file.
239 /** returns the value of the element /java/enabled
241 const boost::optional
<sal_Bool
> & getEnabled() const;
242 /** returns the value of the element /java/userClassPath.
244 const boost::optional
< ::rtl::OUString
> & getUserClassPath() const;
246 /** returns the value of the element /java/javaInfo.
248 const boost::optional
<CNodeJavaInfo
> & getJavaInfo() const;
250 /** returns the parameters from the element /java/vmParameters/param.
252 const boost::optional
< ::std::vector
< ::rtl::OUString
> > & getVmParameters() const;
254 /** returns the parameters from the element /java/jreLocations/location.
256 const boost::optional
< ::std::vector
< ::rtl::OUString
> > & getJRELocations() const;
259 /** merges the settings for shared, user and installation during construction.
260 The class uses a simple merge mechanism for the javasettings.xml files in share and
261 user. The following elements completly overwrite the corresponding elements
269 In case of an installation, the shared and user settings are completely
272 The locations of the different settings files is obtained through the
274 UNO_JAVA_JFW_USER_DATA
275 UNO_JAVA_JFW_SHARED_DATA
277 The class also determines useful default values for settings which have not been made.
282 const MergedSettings
& operator = (MergedSettings
&);
283 MergedSettings(MergedSettings
&);
285 void merge(const NodeJava
& share
, const NodeJava
& user
);
289 ::rtl::OUString m_sClassPath
;
291 ::std::vector
< ::rtl::OUString
> m_vmParams
;
293 ::std::vector
< ::rtl::OUString
> m_JRELocations
;
295 CNodeJavaInfo m_javaInfo
;
299 virtual ~MergedSettings();
301 /** the default is true.
303 sal_Bool
getEnabled() const;
305 const ::rtl::OUString
& getUserClassPath() const;
307 ::std::vector
< ::rtl::OString
> getVmParametersUtf8() const;
308 /** returns a JavaInfo structure representing the node
309 /java/javaInfo. Every time a new JavaInfo structure is created
310 which needs to be freed by the caller.
311 If both, user and share settings are nil, then NULL is returned.
313 JavaInfo
* createJavaInfo() const;
315 /** returns the value of the attribute /java/javaInfo[@vendorUpdate].
317 ::rtl::OString
const & getJavaInfoAttrVendorUpdate() const;
320 /** returns the javaInfo@autoSelect attribute.
321 Before calling this function loadFromSettings must be called.
322 It uses the javaInfo@autoSelect attribute to determine
325 bool getJavaInfoAttrAutoSelect() const;
328 /** returns an array.
329 Caller must free the strings and the array.
331 void getVmParametersArray(rtl_uString
*** parParameters
, sal_Int32
* size
) const;
333 /** returns an array.
334 Caller must free the strings and the array.
336 void getJRELocations(rtl_uString
*** parLocations
, sal_Int32
* size
) const;
338 const ::std::vector
< ::rtl::OUString
> & getJRELocations() const;
344 ::std::vector
< ::rtl::OUString
> vecExcludeVersions
;
345 rtl_uString
** arVersions
;
351 void addExcludeVersion(const ::rtl::OUString
& sVersion
);
353 ::rtl::OUString sMinVersion
;
354 ::rtl::OUString sMaxVersion
;
356 /** The caller DOES NOT get ownership of the strings. That is he
357 does not need to release the strings.
358 The array exists as long as this object exists.
361 rtl_uString
** getExcludeVersions();
362 sal_Int32
getExcludeVersionSize();
370 PluginLibrary(rtl::OUString vendor
,::rtl::OUString path
) :
371 sVendor(vendor
), sPath(path
)
374 /** contains the vendor string which is later userd in the xml API
376 ::rtl::OUString sVendor
;
377 /** File URL the plug-in library
379 ::rtl::OUString sPath
;
385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */