2004-04-19 09:57:02 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* $RCSfile: elements.hxx,v $
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* $Revision: 1.9 $
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-07 19:34:08 $
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
2005-09-07 13:34:08 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-04-19 09:57:02 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#if !defined INCLUDED_JVMFWK_ELEMENTS_HXX
|
|
|
|
#define INCLUDED_JVMFWK_ELEMENTS_HXX
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "jvmfwk/framework.h"
|
|
|
|
#include "rtl/ustring.hxx"
|
|
|
|
#include "rtl/byteseq.hxx"
|
|
|
|
#include "libxml/parser.h"
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
#define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
|
|
|
|
#define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
|
2004-04-19 09:57:02 -05:00
|
|
|
namespace jfw
|
|
|
|
{
|
|
|
|
|
2004-04-26 05:20:34 -05:00
|
|
|
xmlNode* findChildNode(const xmlNode * pParent, const xmlChar* pName);
|
|
|
|
|
|
|
|
/** gets the value of the updated element from the javavendors.xml.
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
rtl::OString getElementUpdated();
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
/** creates the javasettings.xml in the users home directory.
|
|
|
|
|
|
|
|
If javasettings.xml does not exist then it creates the file
|
|
|
|
and inserts the root element with its namespaces.
|
|
|
|
The content should look like this:
|
|
|
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!--This is a generated file. Do not alter this file!-->
|
|
|
|
<java xmlns:="http://openoffice.org/2004/java/framework/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
|
|
</java>
|
|
|
|
|
2004-11-09 07:00:06 -06:00
|
|
|
|
2004-04-26 05:20:34 -05:00
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void createUserSettingsDocument();
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
/** create the child elements within the root structure for each platform.
|
|
|
|
|
|
|
|
@param bNeedsSave
|
|
|
|
[out]If true then the respective structure of elements was added and the
|
|
|
|
document needs to be saved.
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void createSettingsStructure(
|
2004-04-26 05:20:34 -05:00
|
|
|
xmlDoc * document, bool * bNeedsSave);
|
|
|
|
|
2004-11-09 07:00:06 -06:00
|
|
|
/** copies shared settings to user settings.
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
This must only occur the first time when the javasettings.xml is
|
2004-11-09 07:00:06 -06:00
|
|
|
prepared for the user. The shared settings shall be provided as bootstrap
|
|
|
|
parameters.
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
@param userParent
|
2004-11-09 07:00:06 -06:00
|
|
|
The node under which the values are to be copied.
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void copyShareSettings(xmlDoc * userDoc, xmlNode* userParent);
|
2004-04-26 05:20:34 -05:00
|
|
|
|
|
|
|
/** creates the structure of the documend.
|
|
|
|
|
|
|
|
When this function is called the first time for a user then it creates the
|
|
|
|
javasettings.xml in th ~/<office>/user/config/ unless it already exists
|
|
|
|
(see createUserSettingsDocument). Then
|
|
|
|
it creates a section for the current platform unless it already exist and
|
|
|
|
creates all children elements. If the respective platform section did not exist
|
|
|
|
then after creating the children, the values from the share/config/javasettings.xml
|
|
|
|
are copied.
|
|
|
|
|
|
|
|
@return
|
|
|
|
JFW_E_CONFIG_READWRITE
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void prepareSettingsDocument();
|
2004-04-26 05:20:34 -05:00
|
|
|
|
2004-04-19 09:57:02 -05:00
|
|
|
class CXmlCharPtr;
|
|
|
|
class CNodeJavaInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CNodeJavaInfo();
|
|
|
|
~CNodeJavaInfo();
|
|
|
|
/**
|
|
|
|
sUpdated is the value from the <updated> element from the
|
|
|
|
javavendors.xml.
|
|
|
|
*/
|
2004-04-26 05:20:34 -05:00
|
|
|
CNodeJavaInfo(const JavaInfo * pInfo);
|
2004-04-19 09:57:02 -05:00
|
|
|
|
|
|
|
/** if true, then javaInfo is empty. When writeToNode is called
|
|
|
|
then all child elements are deleted.
|
|
|
|
*/
|
|
|
|
bool m_bEmptyNode;
|
|
|
|
/** Contains the value of the <updated> element of
|
2004-04-26 05:20:34 -05:00
|
|
|
the javavendors.xml after loadFromNode was called.
|
|
|
|
It is not used, when the javaInfo node is written.
|
|
|
|
see writeToNode
|
2004-04-19 09:57:02 -05:00
|
|
|
*/
|
2004-04-26 05:20:34 -05:00
|
|
|
rtl::OString sAttrVendorUpdate;
|
2004-04-19 09:57:02 -05:00
|
|
|
/** contains the nil value of the /java/javaInfo@xsi:nil attribute.
|
|
|
|
Default is true;
|
|
|
|
*/
|
|
|
|
bool bNil;
|
2004-05-13 05:15:02 -05:00
|
|
|
/** contains the value of the /java/javaInfo@autoSelect attribute.
|
|
|
|
Default is true. If it is false then the user has modified the JRE
|
|
|
|
selection by actively choosing a JRE from the options dialog. That is,
|
|
|
|
the function jfw_setSelectedJRE was called. Contrary, the function
|
|
|
|
jfw_findAndSelectJRE sets the attribute to true.
|
|
|
|
*/
|
|
|
|
bool bAutoSelect;
|
2004-04-19 09:57:02 -05:00
|
|
|
rtl::OUString sVendor;
|
|
|
|
rtl::OUString sLocation;
|
|
|
|
rtl::OUString sVersion;
|
|
|
|
sal_uInt64 nFeatures;
|
|
|
|
sal_uInt64 nRequirements;
|
|
|
|
rtl::ByteSequence arVendorData;
|
|
|
|
|
|
|
|
/** reads the node /java/javaInfo.
|
|
|
|
If javaInfo@xsi:nil = true then member bNil is set to true
|
|
|
|
an no further elements are read.
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void loadFromNode(xmlDoc * pDoc,xmlNode * pJavaInfo);
|
2004-04-19 09:57:02 -05:00
|
|
|
/** Only writes user settings. The attribut nil always gets the value
|
2004-04-26 05:20:34 -05:00
|
|
|
false. The function gets the value javaSettings/updated from the
|
|
|
|
javavendors.xml and writes it to javaInfo@vendorUpdate in javasettings.xml
|
2004-04-19 09:57:02 -05:00
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void writeToNode(xmlDoc * pDoc, xmlNode * pJavaInfo) const;
|
2004-04-19 09:57:02 -05:00
|
|
|
|
|
|
|
/** returns NULL if javaInfo is nil in both, user and share, settings.
|
|
|
|
*/
|
|
|
|
JavaInfo * makeJavaInfo() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** this class represents the javasettings.xml file
|
|
|
|
*/
|
|
|
|
class CNodeJava
|
|
|
|
{
|
|
|
|
/** Share settings are a special case. Per default
|
2004-11-09 07:00:06 -06:00
|
|
|
there are only user settings. Currently there need not be
|
|
|
|
a share settings file. In that case the function returns
|
|
|
|
without throwing an exception.
|
2004-04-19 09:57:02 -05:00
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void loadShareSettings();
|
2004-04-19 09:57:02 -05:00
|
|
|
/** This function is called after loadShareSettings. Elements which have been
|
|
|
|
modified by the user, that is, the attribute xsi:nil = false, overwrite the
|
|
|
|
values which have been retrieved with loadShareSettings.
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void loadUserSettings();
|
2004-04-19 09:57:02 -05:00
|
|
|
|
|
|
|
/** User configurable option. /java/enabled
|
|
|
|
The value is valid after loadFromSettings has been called
|
|
|
|
successfully.
|
|
|
|
The value is that of the user setting. If it is nil
|
|
|
|
(/java/enabled[@xsi:nil = true]) then it represents the share setting.
|
|
|
|
If there are no share settings or the node is also nil then the default
|
|
|
|
is true.
|
|
|
|
*/
|
|
|
|
sal_Bool m_bEnabled;
|
|
|
|
/** Determines if m_bEnabled has been modified */
|
|
|
|
bool m_bEnabledModified;
|
|
|
|
/** User configurable option. /java/userClassPath
|
|
|
|
The value is valid after loadFromSettings has been called successfully.
|
|
|
|
The value is that of the user setting. If it is nil
|
|
|
|
(/java/userClassPath[@xsi:nil = true]) then it represents the share setting.
|
|
|
|
If there are no share settings or the node is also nil then the default
|
|
|
|
is an empty string.
|
|
|
|
*/
|
|
|
|
rtl::OUString m_sUserClassPath;
|
|
|
|
/** Determines if m_sUserClassPath has been modified */
|
|
|
|
bool m_bUserClassPathModified;
|
|
|
|
/** User configurable option. /java/javaInfo
|
|
|
|
The value is valid after loadFromSettings has been called successfully.
|
|
|
|
The value is that of the user setting. If it is nil
|
|
|
|
(/java/javaInfo[@xsi:nil = true]) then it represents the share setting.
|
|
|
|
If there are no share settings then the structure is regarded as empty.
|
|
|
|
*/
|
|
|
|
CNodeJavaInfo m_aInfo;
|
|
|
|
/** Determines if m_aInfo has been modified */
|
|
|
|
bool m_bJavaInfoModified;
|
|
|
|
|
|
|
|
/** User configurable option. /java/vmParameters
|
|
|
|
The value is valid after loadFromSettings has been called successfully.
|
|
|
|
The value is that of the user setting. If it is nil
|
|
|
|
(/java/vmParameters[@xsi:nil = true]) then it represents the share setting.
|
|
|
|
If there are no share settings then array is empty.
|
|
|
|
*/
|
|
|
|
std::vector<rtl::OString> m_arVmParameters;
|
|
|
|
bool m_bVmParametersModified;
|
2004-04-21 03:30:36 -05:00
|
|
|
|
|
|
|
/** User configurable option. /java/jreLocations
|
|
|
|
The value is valid after loadFromSettings has been called successfully.
|
|
|
|
The value is that of the user setting. If it is nil
|
|
|
|
(/java/jreLocations[@xsi:nil = true]) then it represents the share setting.
|
|
|
|
If there are no share settings then array is empty.
|
|
|
|
*/
|
|
|
|
std::vector<rtl::OString> m_arJRELocations;
|
|
|
|
bool m_bJRELocationsModified;
|
|
|
|
|
2004-04-19 09:57:02 -05:00
|
|
|
public:
|
|
|
|
CNodeJava();
|
|
|
|
/** sets m_bEnabled. It also sets a flag, that the value has been
|
|
|
|
modified. This will cause that /java/enabled[@xsi:nil] will be
|
|
|
|
set to false. The nil value and the value of enabled are only
|
|
|
|
written when write Settings is called.
|
|
|
|
*/
|
|
|
|
void setEnabled(sal_Bool bEnabled);
|
|
|
|
/** returns the value of the element /java/enabled
|
|
|
|
*/
|
|
|
|
sal_Bool getEnabled() const;
|
|
|
|
/** sets m_sUserClassPath. Analog to setEnabled.
|
|
|
|
*/
|
|
|
|
void setUserClassPath(const rtl::OUString & sClassPath);
|
|
|
|
/** returns the value of the element /java/userClassPath.
|
|
|
|
*/
|
|
|
|
rtl::OUString const & getUserClassPath() const;
|
|
|
|
/** sets m_aInfo. Analog to setEnabled.
|
2004-05-13 05:15:02 -05:00
|
|
|
@param bAutoSelect
|
|
|
|
true- called by jfw_setSelectedJRE
|
|
|
|
false called by jfw_findAndSelectJRE
|
2004-04-19 09:57:02 -05:00
|
|
|
*/
|
2004-05-13 05:15:02 -05:00
|
|
|
void setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect);
|
2004-04-19 09:57:02 -05:00
|
|
|
/** returns a JavaInfo structure representing the node
|
2004-11-09 07:00:06 -06:00
|
|
|
/java/javaInfo. Every time a new JavaInfo structure is created
|
|
|
|
which needs to be freed by the caller.
|
2004-04-19 09:57:02 -05:00
|
|
|
If both, user and share settings are nil, then NULL is returned.
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
JavaInfo * createJavaInfo() const;
|
2004-04-19 09:57:02 -05:00
|
|
|
/** returns the value of the attribute /java/javaInfo[@vendorUpdate].
|
|
|
|
*/
|
2004-04-26 05:20:34 -05:00
|
|
|
rtl::OString const & getJavaInfoAttrVendorUpdate() const;
|
2004-05-13 05:15:02 -05:00
|
|
|
|
|
|
|
/** returns the javaInfo@autoSelect attribute.
|
|
|
|
Before calling this function loadFromSettings must be called.
|
|
|
|
It uses the javaInfo@autoSelect attribute to determine
|
|
|
|
the return value;
|
|
|
|
*/
|
|
|
|
bool getJavaInfoAttrAutoSelect() const;
|
|
|
|
|
2004-04-19 09:57:02 -05:00
|
|
|
/** sets the /java/vmParameters/param elements.
|
|
|
|
The values are kept in a vector m_arVmParameters. When this method is
|
|
|
|
called then the vector is cleared and the new values are inserted.
|
|
|
|
The xsi:nil attribute of vmParameters will be set to true;
|
|
|
|
*/
|
|
|
|
void setVmParameters(rtl_uString * * arParameters, sal_Int32 size);
|
|
|
|
/** returns the parameters from the element /java/vmParameters/param.
|
|
|
|
*/
|
2004-04-21 03:30:36 -05:00
|
|
|
const std::vector<rtl::OString> & getVmParameters() const;
|
|
|
|
|
|
|
|
/** returns an array.
|
|
|
|
Caller must free the strings and the array.
|
|
|
|
*/
|
|
|
|
void getVmParametersArray(rtl_uString *** parParameters, sal_Int32 * size) const;
|
|
|
|
|
|
|
|
/** sets the /java/jreLocations/location elements.
|
|
|
|
The values are kept in a vector m_arJRELocations. When this method is
|
|
|
|
called then the vector is cleared and the new values are inserted.
|
|
|
|
The xsi:nil attribute of vmParameters will be set to true;
|
|
|
|
*/
|
|
|
|
void setJRELocations(rtl_uString * * arParameters, sal_Int32 size);
|
|
|
|
|
|
|
|
void addJRELocation(rtl_uString * sLocation);
|
|
|
|
/** returns the parameters from the element /java/jreLocations/location.
|
|
|
|
*/
|
|
|
|
const std::vector<rtl::OString> & getJRELocations() const;
|
|
|
|
|
|
|
|
|
|
|
|
/** returns an array.
|
|
|
|
Caller must free the strings and the array.
|
|
|
|
*/
|
|
|
|
void getJRELocations(rtl_uString *** parLocations, sal_Int32 * size) const;
|
2004-04-19 09:57:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
/** reads user and share settings. user data supersede
|
|
|
|
share data. These elements can be changed by the user:
|
|
|
|
<enabled>, <userClasspath>, <javaInfo>, <vmParameters>
|
|
|
|
If the user has not changed them then the nil attribute is
|
|
|
|
set to true;
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void loadFromSettings();
|
2004-04-19 09:57:02 -05:00
|
|
|
/** writes the data to user settings.
|
|
|
|
*/
|
2004-11-09 07:00:06 -06:00
|
|
|
void writeSettings() const;
|
2004-04-19 09:57:02 -05:00
|
|
|
|
2004-05-13 05:15:02 -05:00
|
|
|
|
2004-04-19 09:57:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VersionInfo
|
|
|
|
{
|
|
|
|
std::vector<rtl::OUString> vecExcludeVersions;
|
|
|
|
rtl_uString ** arVersions;
|
|
|
|
|
|
|
|
public:
|
|
|
|
VersionInfo();
|
|
|
|
~VersionInfo();
|
|
|
|
|
|
|
|
void addExcludeVersion(const rtl::OUString& sVersion);
|
|
|
|
|
|
|
|
rtl::OUString sMinVersion;
|
|
|
|
rtl::OUString sMaxVersion;
|
|
|
|
|
|
|
|
/** The caller DOES NOT get ownership of the strings. That is he
|
|
|
|
does not need to release the strings.
|
|
|
|
The array exists as long as this object exists.
|
|
|
|
*/
|
|
|
|
|
|
|
|
rtl_uString** getExcludeVersions();
|
|
|
|
sal_Int32 getExcludeVersionSize();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PluginLibrary
|
|
|
|
{
|
2004-11-09 07:00:06 -06:00
|
|
|
PluginLibrary()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
PluginLibrary(rtl::OUString vendor, rtl::OUString path) :
|
|
|
|
sVendor(vendor), sPath(path)
|
|
|
|
{
|
|
|
|
}
|
2004-04-19 09:57:02 -05:00
|
|
|
/** contains the vendor string which is later userd in the xml API
|
|
|
|
*/
|
2004-07-23 05:54:27 -05:00
|
|
|
rtl::OUString sVendor;
|
2004-04-19 09:57:02 -05:00
|
|
|
/** File URL the plug-in library
|
|
|
|
*/
|
|
|
|
rtl::OUString sPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
} //end namespace
|
|
|
|
#endif
|