2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 19:49:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 16:47:38 +00:00
|
|
|
|
2017-04-11 19:10:23 +02:00
|
|
|
#include <sal/config.h>
|
2018-08-05 00:50:24 +02:00
|
|
|
#include <sal/log.hxx>
|
2017-04-11 19:10:23 +02:00
|
|
|
|
|
|
|
#include <cassert>
|
2017-04-13 12:08:05 +02:00
|
|
|
#include <memory>
|
2017-04-11 19:10:23 +02:00
|
|
|
|
2017-10-23 22:38:59 +02:00
|
|
|
#include <elements.hxx>
|
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#include <fwkutil.hxx>
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
#include <fwkbase.hxx>
|
2004-11-09 12:59:48 +00:00
|
|
|
#include "framework.hxx"
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
#include <libxmlutil.hxx>
|
2004-04-21 08:30:36 +00:00
|
|
|
#include <algorithm>
|
2017-10-23 22:38:59 +02:00
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/xpath.h>
|
|
|
|
#include <libxml/xpathInternals.h>
|
2020-02-21 07:26:06 +01:00
|
|
|
#include <optional>
|
2008-02-04 12:46:18 +00:00
|
|
|
#include <string.h>
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2020-05-15 20:09:43 +02:00
|
|
|
// For backwards compatibility, the nRequirements flag word is
|
|
|
|
// read/written as potentially signed hexadecimal number (though that has no
|
|
|
|
// practical relevance given that it has only one flag with value 0x01
|
2013-06-12 15:58:17 +02:00
|
|
|
// defined).
|
2004-05-05 09:14:01 +00:00
|
|
|
|
|
|
|
using namespace osl;
|
2004-04-19 14:57:02 +00:00
|
|
|
namespace jfw
|
|
|
|
{
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static OString getElement(OString const & docPath,
|
2017-10-31 09:07:27 +02:00
|
|
|
xmlChar const * pathExpression)
|
2004-04-26 10:20:34 +00:00
|
|
|
{
|
|
|
|
//Prepare the xml document and context
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(!docPath.isEmpty());
|
2019-02-08 13:18:51 +02:00
|
|
|
jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr()));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (doc == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
2017-05-29 09:48:54 +02:00
|
|
|
"[Java framework] Error in function getElement (elements.cxx)");
|
2004-11-09 12:59:48 +00:00
|
|
|
|
2004-04-27 14:22:15 +00:00
|
|
|
jfw::CXPathContextPtr context(xmlXPathNewContext(doc));
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlXPathRegisterNs(context, reinterpret_cast<xmlChar const *>("jf"),
|
|
|
|
reinterpret_cast<xmlChar const *>(NS_JAVA_FRAMEWORK)) == -1)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
2017-05-29 09:48:54 +02:00
|
|
|
"[Java framework] Error in function getElement (elements.cxx)");
|
2010-09-15 10:00:35 +02:00
|
|
|
|
2019-04-13 14:54:59 +02:00
|
|
|
CXPathObjectPtr pathObj = xmlXPathEvalExpression(pathExpression, context);
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sValue;
|
2004-04-26 10:20:34 +00:00
|
|
|
if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
|
2010-09-15 10:00:35 +02:00
|
|
|
{
|
2017-10-31 09:07:27 +02:00
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
|
|
|
"[Java framework] Error in function getElement (elements.cxx)");
|
2010-09-15 10:00:35 +02:00
|
|
|
}
|
2019-12-19 09:46:58 +02:00
|
|
|
sValue = reinterpret_cast<char*>(pathObj->nodesetval->nodeTab[0]->content);
|
2004-11-09 12:59:48 +00:00
|
|
|
return sValue;
|
2004-04-26 10:20:34 +00:00
|
|
|
}
|
2004-11-09 12:59:48 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OString getElementUpdated()
|
2010-09-15 10:00:35 +02:00
|
|
|
{
|
|
|
|
return getElement(jfw::getVendorSettingsPath(),
|
2017-10-31 09:07:27 +02:00
|
|
|
reinterpret_cast<xmlChar const *>("/jf:javaSelection/jf:updated/text()"));
|
2010-09-15 10:00:35 +02:00
|
|
|
}
|
|
|
|
|
2004-11-09 12:59:48 +00:00
|
|
|
void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
|
2004-04-26 10:20:34 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sExcMsg("[Java framework] Error in function createSettingsStructure "
|
2004-11-09 12:59:48 +00:00
|
|
|
"(elements.cxx).");
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlNode * root = xmlDocGetRootElement(document);
|
2015-11-10 10:18:19 +01:00
|
|
|
if (root == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-26 10:20:34 +00:00
|
|
|
bool bFound = false;
|
|
|
|
xmlNode * cur = root->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (cur != nullptr)
|
2004-04-26 10:20:34 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("enabled")) == 0)
|
2004-04-26 10:20:34 +00:00
|
|
|
{
|
|
|
|
bFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
if (bFound)
|
|
|
|
{
|
2011-09-12 07:35:47 +02:00
|
|
|
*bNeedsSave = false;
|
2004-11-09 12:59:48 +00:00
|
|
|
return;
|
2004-04-26 10:20:34 +00:00
|
|
|
}
|
|
|
|
//We will modify this document
|
|
|
|
*bNeedsSave = true;
|
|
|
|
// Now we create the child elements ------------------
|
|
|
|
//Get xsi:nil namespace
|
|
|
|
xmlNs* nsXsi = xmlSearchNsByHref(
|
2015-01-17 18:48:45 +01:00
|
|
|
document, root, reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2004-04-26 10:20:34 +00:00
|
|
|
|
|
|
|
//<enabled xsi:nil="true"
|
|
|
|
xmlNode * nodeEn = xmlNewTextChild(
|
2015-11-10 10:18:19 +01:00
|
|
|
root, nullptr, reinterpret_cast<xmlChar const *>("enabled"), reinterpret_cast<xmlChar const *>(""));
|
|
|
|
if (nodeEn == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(nodeEn, nsXsi, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>("true"));
|
2004-04-26 10:20:34 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlAddChild(root, nodeCrLf);
|
|
|
|
|
|
|
|
//<userClassPath xsi:nil="true">
|
|
|
|
xmlNode * nodeUs = xmlNewTextChild(
|
2015-11-10 10:18:19 +01:00
|
|
|
root, nullptr, reinterpret_cast<xmlChar const *>("userClassPath"), reinterpret_cast<xmlChar const *>(""));
|
|
|
|
if (nodeUs == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(nodeUs, nsXsi, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>("true"));
|
2004-04-26 10:20:34 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlAddChild(root, nodeCrLf);
|
|
|
|
|
|
|
|
//<vmParameters xsi:nil="true">
|
|
|
|
xmlNode * nodeVm = xmlNewTextChild(
|
2015-11-10 10:18:19 +01:00
|
|
|
root, nullptr, reinterpret_cast<xmlChar const *>("vmParameters"), reinterpret_cast<xmlChar const *>(""));
|
|
|
|
if (nodeVm == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(nodeVm, nsXsi, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>("true"));
|
2004-04-26 10:20:34 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlAddChild(root, nodeCrLf);
|
|
|
|
|
|
|
|
//<jreLocations xsi:nil="true">
|
|
|
|
xmlNode * nodeJre = xmlNewTextChild(
|
2015-11-10 10:18:19 +01:00
|
|
|
root, nullptr, reinterpret_cast<xmlChar const *>("jreLocations"), reinterpret_cast<xmlChar const *>(""));
|
|
|
|
if (nodeJre == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(nodeJre, nsXsi, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>("true"));
|
2004-04-26 10:20:34 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlAddChild(root, nodeCrLf);
|
|
|
|
|
2011-03-04 01:41:18 +09:00
|
|
|
//<javaInfo xsi:nil="true">
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlNode * nodeJava = xmlNewTextChild(
|
2015-11-10 10:18:19 +01:00
|
|
|
root, nullptr, reinterpret_cast<xmlChar const *>("javaInfo"), reinterpret_cast<xmlChar const *>(""));
|
|
|
|
if (nodeJava == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(nodeJava, nsXsi, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>("true"));
|
2004-04-26 10:20:34 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-26 10:20:34 +00:00
|
|
|
xmlAddChild(root, nodeCrLf);
|
|
|
|
}
|
|
|
|
|
2007-06-13 06:57:18 +00:00
|
|
|
NodeJava::NodeJava(Layer layer):
|
|
|
|
m_layer(layer)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
//This class reads and write to files which should only be done in
|
|
|
|
//application mode
|
|
|
|
if (getMode() == JFW_MODE_DIRECT)
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_DIRECT_MODE,
|
|
|
|
"[Java framework] Trying to access settings files in direct mode.");
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-13 06:57:18 +00:00
|
|
|
void NodeJava::load()
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString sExcMsg("[Java framework] Error in function NodeJava::load"
|
2004-11-09 12:59:48 +00:00
|
|
|
"(elements.cxx).");
|
2007-06-13 06:57:18 +00:00
|
|
|
if (SHARED == m_layer)
|
|
|
|
{
|
|
|
|
//we do not support yet to write into the shared installation
|
|
|
|
|
|
|
|
//check if shared settings exist at all.
|
2012-11-15 12:40:40 +01:00
|
|
|
OUString sURL(BootParams::getSharedData());
|
|
|
|
jfw::FileStatus s = sURL.isEmpty()
|
|
|
|
? FILE_DOES_NOT_EXIST : checkFileURL(sURL);
|
2007-06-13 06:57:18 +00:00
|
|
|
if (s == FILE_INVALID)
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
|
|
|
"[Java framework] Invalid file for shared Java settings.");
|
|
|
|
else if (s == FILE_DOES_NOT_EXIST)
|
|
|
|
//Writing shared data is not supported yet.
|
|
|
|
return;
|
|
|
|
}
|
2012-08-10 15:52:22 +02:00
|
|
|
else if (USER == m_layer)
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2012-11-15 12:40:40 +01:00
|
|
|
if (!prepareSettingsDocument())
|
|
|
|
{
|
2013-03-04 15:25:02 +01:00
|
|
|
SAL_INFO("jfw.level1", "no path to load user settings document from");
|
2012-11-15 12:40:40 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-26 10:32:31 +01:00
|
|
|
OSL_FAIL("[Java framework] Unknown enum used.");
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
|
2004-04-26 13:47:39 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
//Read the user elements
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sSettingsPath = getSettingsPath();
|
2004-04-19 14:57:02 +00:00
|
|
|
//There must not be a share settings file
|
2007-06-13 06:57:18 +00:00
|
|
|
CXmlDocPtr docUser(xmlParseFile(sSettingsPath.getStr()));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (docUser == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
xmlNode * cur = xmlDocGetRootElement(docUser);
|
2015-11-10 10:18:19 +01:00
|
|
|
if (cur == nullptr || cur->children == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2004-04-27 14:22:15 +00:00
|
|
|
CXmlCharPtr sNil;
|
2004-04-19 14:57:02 +00:00
|
|
|
cur = cur->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (cur != nullptr)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("enabled")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
//only overwrite share settings if xsi:nil="false"
|
2004-04-27 14:22:15 +00:00
|
|
|
sNil = xmlGetNsProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
cur, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (sNil == nullptr)
|
2016-01-09 22:55:28 +01:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
CXmlCharPtr sEnabled( xmlNodeListGetString(
|
|
|
|
docUser, cur->children, 1));
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sEnabled, reinterpret_cast<xmlChar const *>("true")) == 0)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_enabled = std::optional<sal_Bool>(true);
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(sEnabled, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_enabled = std::optional<sal_Bool>(false);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("userClassPath")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-04-27 14:22:15 +00:00
|
|
|
sNil = xmlGetNsProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
cur, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (sNil == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
CXmlCharPtr sUser(xmlNodeListGetString(
|
|
|
|
docUser, cur->children, 1));
|
2020-02-21 07:26:06 +01:00
|
|
|
m_userClassPath = std::optional<OUString>(OUString(sUser));
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("javaInfo")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-04-27 14:22:15 +00:00
|
|
|
sNil = xmlGetNsProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
cur, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (sNil == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
if (! m_javaInfo)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_javaInfo = std::optional<CNodeJavaInfo>(CNodeJavaInfo());
|
2007-06-13 06:57:18 +00:00
|
|
|
m_javaInfo->loadFromNode(docUser, cur);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("vmParameters")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-04-27 14:22:15 +00:00
|
|
|
sNil = xmlGetNsProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
cur, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (sNil == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
if ( ! m_vmParameters)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_vmParameters = std::optional<std::vector<OUString> >(
|
2013-04-07 12:06:47 +02:00
|
|
|
std::vector<OUString> ());
|
2007-06-13 06:57:18 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlNode * pOpt = cur->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (pOpt != nullptr)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(pOpt->name, reinterpret_cast<xmlChar const *>("param")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr sOpt = xmlNodeListGetString(
|
2004-04-19 14:57:02 +00:00
|
|
|
docUser, pOpt->children, 1);
|
2007-06-13 06:57:18 +00:00
|
|
|
m_vmParameters->push_back(sOpt);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
pOpt = pOpt->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("jreLocations")) == 0)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2004-04-27 14:22:15 +00:00
|
|
|
sNil = xmlGetNsProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
cur, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (sNil == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
if (! m_JRELocations)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_JRELocations = std::optional<std::vector<OUString> >(
|
2013-04-07 12:06:47 +02:00
|
|
|
std::vector<OUString>());
|
2007-06-13 06:57:18 +00:00
|
|
|
|
2004-04-21 08:30:36 +00:00
|
|
|
xmlNode * pLoc = cur->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (pLoc != nullptr)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(pLoc->name, reinterpret_cast<xmlChar const *>("location")) == 0)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr sLoc = xmlNodeListGetString(
|
2004-04-21 08:30:36 +00:00
|
|
|
docUser, pLoc->children, 1);
|
2007-06-13 06:57:18 +00:00
|
|
|
m_JRELocations->push_back(sLoc);
|
2004-04-21 08:30:36 +00:00
|
|
|
}
|
|
|
|
pLoc = pLoc->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OString NodeJava::getSettingsPath() const
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OString ret;
|
2007-06-13 06:57:18 +00:00
|
|
|
switch (m_layer)
|
|
|
|
{
|
|
|
|
case USER: ret = getUserSettingsPath(); break;
|
|
|
|
case SHARED: ret = getSharedSettingsPath(); break;
|
|
|
|
default:
|
2011-02-26 10:32:31 +01:00
|
|
|
OSL_FAIL("[Java framework] NodeJava::getSettingsPath()");
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2004-11-09 12:59:48 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString NodeJava::getSettingsURL() const
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString ret;
|
2007-06-13 06:57:18 +00:00
|
|
|
switch (m_layer)
|
|
|
|
{
|
|
|
|
case USER: ret = BootParams::getUserData(); break;
|
|
|
|
case SHARED: ret = BootParams::getSharedData(); break;
|
|
|
|
default:
|
2011-02-26 10:32:31 +01:00
|
|
|
OSL_FAIL("[Java framework] NodeJava::getSettingsURL()");
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2012-11-15 12:40:40 +01:00
|
|
|
bool NodeJava::prepareSettingsDocument() const
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sExcMsg(
|
2007-06-13 06:57:18 +00:00
|
|
|
"[Java framework] Error in function prepareSettingsDocument"
|
|
|
|
" (elements.cxx).");
|
2012-11-15 12:40:40 +01:00
|
|
|
if (!createSettingsDocument())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sSettings = getSettingsPath();
|
2007-06-13 06:57:18 +00:00
|
|
|
CXmlDocPtr doc(xmlParseFile(sSettings.getStr()));
|
|
|
|
if (!doc)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
2007-06-13 06:57:18 +00:00
|
|
|
bool bNeedsSave = false;
|
|
|
|
createSettingsStructure(doc, & bNeedsSave);
|
|
|
|
if (bNeedsSave)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
if (xmlSaveFormatFileEnc(
|
|
|
|
sSettings.getStr(), doc,"UTF-8", 1) == -1)
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2012-11-15 12:40:40 +01:00
|
|
|
return true;
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2007-06-13 06:57:18 +00:00
|
|
|
void NodeJava::write() const
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sExcMsg("[Java framework] Error in function NodeJava::writeSettings "
|
2004-11-09 12:59:48 +00:00
|
|
|
"(elements.cxx).");
|
2004-04-19 14:57:02 +00:00
|
|
|
CXmlDocPtr docUser;
|
|
|
|
CXPathContextPtr contextUser;
|
|
|
|
CXPathObjectPtr pathObj;
|
|
|
|
|
2012-11-15 12:40:40 +01:00
|
|
|
if (!prepareSettingsDocument())
|
|
|
|
{
|
2013-03-04 15:25:02 +01:00
|
|
|
SAL_INFO("jfw.level1", "no path to write settings document to");
|
2012-11-15 12:40:40 +01:00
|
|
|
return;
|
|
|
|
}
|
2004-05-20 07:50:59 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
//Read the user elements
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sSettingsPath = getSettingsPath();
|
2004-04-19 14:57:02 +00:00
|
|
|
docUser = xmlParseFile(sSettingsPath.getStr());
|
2015-11-10 10:18:19 +01:00
|
|
|
if (docUser == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
contextUser = xmlXPathNewContext(docUser);
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlXPathRegisterNs(contextUser, reinterpret_cast<xmlChar const *>("jf"),
|
|
|
|
reinterpret_cast<xmlChar const *>(NS_JAVA_FRAMEWORK)) == -1)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
xmlNode * root = xmlDocGetRootElement(docUser);
|
|
|
|
//Get xsi:nil namespace
|
|
|
|
xmlNs* nsXsi = xmlSearchNsByHref(docUser,
|
|
|
|
root,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
//set the <enabled> element
|
|
|
|
//The element must exist
|
2007-06-13 06:57:18 +00:00
|
|
|
if (m_enabled)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-07-27 21:08:23 +02:00
|
|
|
pathObj = xmlXPathEvalExpression(reinterpret_cast<xmlChar const *>("/jf:java/jf:enabled"),
|
2004-04-19 14:57:02 +00:00
|
|
|
contextUser);
|
|
|
|
if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
xmlNode * nodeEnabled = pathObj->nodesetval->nodeTab[0];
|
|
|
|
xmlSetNsProp(nodeEnabled,
|
|
|
|
nsXsi,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>("nil"),
|
|
|
|
reinterpret_cast<xmlChar const *>("false"));
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2020-02-21 07:26:06 +01:00
|
|
|
if (m_enabled == std::optional<sal_Bool>(true))
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNodeSetContent(nodeEnabled,reinterpret_cast<xmlChar const *>("true"));
|
2004-04-19 14:57:02 +00:00
|
|
|
else
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNodeSetContent(nodeEnabled,reinterpret_cast<xmlChar const *>("false"));
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//set the <userClassPath> element
|
|
|
|
//The element must exist
|
2007-06-13 06:57:18 +00:00
|
|
|
if (m_userClassPath)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-07-27 21:08:23 +02:00
|
|
|
pathObj = xmlXPathEvalExpression(reinterpret_cast<xmlChar const *>("/jf:java/jf:userClassPath"),
|
2004-04-19 14:57:02 +00:00
|
|
|
contextUser);
|
|
|
|
if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
xmlNode * nodeEnabled = pathObj->nodesetval->nodeTab[0];
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(nodeEnabled, nsXsi, reinterpret_cast<xmlChar const *>("nil"),reinterpret_cast<xmlChar const *>("false"));
|
2015-06-08 16:25:58 +02:00
|
|
|
xmlNodeSetContent(nodeEnabled,static_cast<xmlChar*>(CXmlCharPtr(*m_userClassPath)));
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//set <javaInfo> element
|
2007-06-13 06:57:18 +00:00
|
|
|
if (m_javaInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-07-27 21:08:23 +02:00
|
|
|
pathObj = xmlXPathEvalExpression(reinterpret_cast<xmlChar const *>("/jf:java/jf:javaInfo"),
|
2004-04-19 14:57:02 +00:00
|
|
|
contextUser);
|
|
|
|
if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2007-06-13 06:57:18 +00:00
|
|
|
m_javaInfo->writeToNode(
|
2004-04-19 14:57:02 +00:00
|
|
|
docUser, pathObj->nodesetval->nodeTab[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//set <vmParameters> element
|
2007-06-13 06:57:18 +00:00
|
|
|
if (m_vmParameters)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-07-27 21:08:23 +02:00
|
|
|
pathObj = xmlXPathEvalExpression(reinterpret_cast<xmlChar const *>("/jf:java/jf:vmParameters"),
|
2004-04-19 14:57:02 +00:00
|
|
|
contextUser);
|
|
|
|
if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlNode* vmParameters = pathObj->nodesetval->nodeTab[0];
|
|
|
|
//set xsi:nil = false;
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(vmParameters, nsXsi,reinterpret_cast<xmlChar const *>("nil"),
|
|
|
|
reinterpret_cast<xmlChar const *>("false"));
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
//remove option elements
|
|
|
|
xmlNode* cur = vmParameters->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (cur != nullptr)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
xmlNode* lastNode = cur;
|
|
|
|
cur = cur->next;
|
|
|
|
xmlUnlinkNode(lastNode);
|
|
|
|
xmlFreeNode(lastNode);
|
|
|
|
}
|
|
|
|
//add a new line after <vmParameters>
|
2018-10-19 08:12:17 +02:00
|
|
|
if (!m_vmParameters->empty())
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(vmParameters, nodeCrLf);
|
|
|
|
}
|
|
|
|
|
2017-10-12 20:32:17 +02:00
|
|
|
for (auto const & vmParameter : *m_vmParameters)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(vmParameters, nullptr, reinterpret_cast<xmlChar const *>("param"),
|
2017-10-12 20:32:17 +02:00
|
|
|
CXmlCharPtr(vmParameter));
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(vmParameters, nodeCrLf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-21 08:30:36 +00:00
|
|
|
//set <jreLocations> element
|
2007-06-13 06:57:18 +00:00
|
|
|
if (m_JRELocations)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2019-07-27 21:08:23 +02:00
|
|
|
pathObj = xmlXPathEvalExpression(reinterpret_cast<xmlChar const *>("/jf:java/jf:jreLocations"),
|
2004-04-21 08:30:36 +00:00
|
|
|
contextUser);
|
|
|
|
if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-21 08:30:36 +00:00
|
|
|
xmlNode* jreLocationsNode = pathObj->nodesetval->nodeTab[0];
|
|
|
|
//set xsi:nil = false;
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetNsProp(jreLocationsNode, nsXsi,reinterpret_cast<xmlChar const *>("nil"),
|
|
|
|
reinterpret_cast<xmlChar const *>("false"));
|
2004-04-21 08:30:36 +00:00
|
|
|
|
|
|
|
//remove option elements
|
|
|
|
xmlNode* cur = jreLocationsNode->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (cur != nullptr)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
|
|
|
xmlNode* lastNode = cur;
|
|
|
|
cur = cur->next;
|
|
|
|
xmlUnlinkNode(lastNode);
|
|
|
|
xmlFreeNode(lastNode);
|
|
|
|
}
|
|
|
|
//add a new line after <vmParameters>
|
2018-10-19 08:12:17 +02:00
|
|
|
if (!m_JRELocations->empty())
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-21 08:30:36 +00:00
|
|
|
xmlAddChild(jreLocationsNode, nodeCrLf);
|
|
|
|
}
|
|
|
|
|
2017-10-12 20:32:17 +02:00
|
|
|
for (auto const & JRELocation : *m_JRELocations)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(jreLocationsNode, nullptr, reinterpret_cast<xmlChar const *>("location"),
|
2017-10-12 20:32:17 +02:00
|
|
|
CXmlCharPtr(JRELocation));
|
2004-04-21 08:30:36 +00:00
|
|
|
//add a new line
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-21 08:30:36 +00:00
|
|
|
xmlAddChild(jreLocationsNode, nodeCrLf);
|
|
|
|
}
|
|
|
|
}
|
2010-09-15 10:00:35 +02:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
if (xmlSaveFormatFile(sSettingsPath.getStr(), docUser, 1) == -1)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 12:01:43 +01:00
|
|
|
void NodeJava::setEnabled(bool bEnabled)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2020-02-21 07:26:06 +01:00
|
|
|
m_enabled = std::optional<sal_Bool>(bEnabled);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void NodeJava::setUserClassPath(const OUString & sClassPath)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2020-02-21 07:26:06 +01:00
|
|
|
m_userClassPath = std::optional<OUString>(sClassPath);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2007-06-13 06:57:18 +00:00
|
|
|
void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
if (!m_javaInfo)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_javaInfo = std::optional<CNodeJavaInfo>(CNodeJavaInfo());
|
2007-06-13 06:57:18 +00:00
|
|
|
m_javaInfo->bAutoSelect = bAutoSelect;
|
|
|
|
m_javaInfo->bNil = false;
|
2004-04-26 10:20:34 +00:00
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
if (pInfo != nullptr)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
m_javaInfo->m_bEmptyNode = false;
|
|
|
|
m_javaInfo->sVendor = pInfo->sVendor;
|
|
|
|
m_javaInfo->sLocation = pInfo->sLocation;
|
|
|
|
m_javaInfo->sVersion = pInfo->sVersion;
|
|
|
|
m_javaInfo->nRequirements = pInfo->nRequirements;
|
|
|
|
m_javaInfo->arVendorData = pInfo->arVendorData;
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
m_javaInfo->m_bEmptyNode = true;
|
2015-08-26 22:59:12 +02:00
|
|
|
m_javaInfo->sVendor.clear();
|
|
|
|
m_javaInfo->sLocation.clear();
|
|
|
|
m_javaInfo->sVersion.clear();
|
2007-06-13 06:57:18 +00:00
|
|
|
m_javaInfo->nRequirements = 0;
|
|
|
|
m_javaInfo->arVendorData = rtl::ByteSequence();
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-11 22:25:23 +02:00
|
|
|
void NodeJava::setVmParameters(std::vector<OUString> const & arOptions)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2020-02-21 07:26:06 +01:00
|
|
|
m_vmParameters = std::optional<std::vector<OUString> >(arOptions);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-11 21:38:46 +02:00
|
|
|
void NodeJava::addJRELocation(OUString const & sLocation)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2007-06-13 06:57:18 +00:00
|
|
|
if (!m_JRELocations)
|
2020-02-21 07:26:06 +01:00
|
|
|
m_JRELocations = std::optional<std::vector<OUString> >(
|
2013-04-07 12:06:47 +02:00
|
|
|
std::vector<OUString> ());
|
2007-06-13 06:57:18 +00:00
|
|
|
//only add the path if not already present
|
2013-04-07 12:06:47 +02:00
|
|
|
std::vector<OUString>::const_iterator it =
|
2017-04-11 21:38:46 +02:00
|
|
|
std::find(m_JRELocations->begin(), m_JRELocations->end(), sLocation);
|
2007-06-13 06:57:18 +00:00
|
|
|
if (it == m_JRELocations->end())
|
2017-04-11 21:38:46 +02:00
|
|
|
m_JRELocations->push_back(sLocation);
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
2004-04-21 08:30:36 +00:00
|
|
|
|
2015-03-27 10:50:38 +02:00
|
|
|
jfw::FileStatus NodeJava::checkSettingsFileStatus(OUString const & sURL)
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
|
|
|
jfw::FileStatus ret = FILE_DOES_NOT_EXIST;
|
|
|
|
|
|
|
|
//check the file time
|
|
|
|
::osl::DirectoryItem item;
|
|
|
|
File::RC rc = ::osl::DirectoryItem::get(sURL, item);
|
|
|
|
if (File::E_None == rc)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2012-08-10 15:52:22 +02:00
|
|
|
::osl::FileStatus stat(osl_FileStatus_Mask_Validate);
|
2007-06-13 06:57:18 +00:00
|
|
|
File::RC rc_stat = item.getFileStatus(stat);
|
|
|
|
if (File::E_None == rc_stat)
|
|
|
|
{
|
2012-08-10 15:52:22 +02:00
|
|
|
ret = FILE_OK;
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
else if (File::E_NOENT == rc_stat)
|
|
|
|
{
|
|
|
|
ret = FILE_DOES_NOT_EXIST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = FILE_INVALID;
|
|
|
|
}
|
2004-04-21 08:30:36 +00:00
|
|
|
}
|
2007-06-13 06:57:18 +00:00
|
|
|
else if(File::E_NOENT == rc)
|
|
|
|
{
|
|
|
|
ret = FILE_DOES_NOT_EXIST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = FILE_INVALID;
|
|
|
|
}
|
|
|
|
return ret;
|
2004-04-21 08:30:36 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 12:40:40 +01:00
|
|
|
bool NodeJava::createSettingsDocument() const
|
2004-05-13 10:15:02 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString sURL = getSettingsURL();
|
2012-11-15 12:40:40 +01:00
|
|
|
if (sURL.isEmpty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-13 06:57:18 +00:00
|
|
|
//make sure there is a user directory
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sExcMsg("[Java framework] Error in function createSettingsDocument "
|
2007-06-13 06:57:18 +00:00
|
|
|
"(elements.cxx).");
|
|
|
|
// check if javasettings.xml already exist
|
2012-11-15 12:40:40 +01:00
|
|
|
if (FILE_OK == checkSettingsFileStatus(sURL))
|
|
|
|
return true;
|
2007-06-13 06:57:18 +00:00
|
|
|
|
|
|
|
//make sure that the directories are created in case they do not exist
|
|
|
|
FileBase::RC rcFile = Directory::createPath(getDirFromFile(sURL));
|
|
|
|
if (rcFile != FileBase::E_EXIST && rcFile != FileBase::E_None)
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
|
|
|
//javasettings.xml does not exist yet
|
2015-01-17 18:48:45 +01:00
|
|
|
CXmlDocPtr doc(xmlNewDoc(reinterpret_cast<xmlChar const *>("1.0")));
|
2007-06-13 06:57:18 +00:00
|
|
|
if (! doc)
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
|
|
|
//Create the root element and name spaces
|
|
|
|
xmlNodePtr root = xmlNewDocNode(
|
2015-11-10 10:18:19 +01:00
|
|
|
doc, nullptr, reinterpret_cast<xmlChar const *>("java"), reinterpret_cast<xmlChar const *>("\n"));
|
2007-06-13 06:57:18 +00:00
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
if (root == nullptr)
|
2007-06-13 06:57:18 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
if (xmlNewNs(root, reinterpret_cast<xmlChar const *>(NS_JAVA_FRAMEWORK),nullptr) == nullptr)
|
2007-06-13 06:57:18 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-11-10 10:18:19 +01:00
|
|
|
if (xmlNewNs(root,reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE),reinterpret_cast<xmlChar const *>("xsi")) == nullptr)
|
2007-06-13 06:57:18 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
xmlDocSetRootElement(doc, root);
|
|
|
|
|
|
|
|
//Create a comment
|
|
|
|
xmlNodePtr com = xmlNewComment(
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>("This is a generated file. Do not alter this file!"));
|
2015-11-10 10:18:19 +01:00
|
|
|
if (com == nullptr)
|
2007-06-13 06:57:18 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
if (xmlAddPrevSibling(root, com) == nullptr)
|
2007-06-13 06:57:18 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString path = getSettingsPath();
|
2007-06-13 06:57:18 +00:00
|
|
|
if (xmlSaveFormatFileEnc(path.getStr(), doc,"UTF-8", 1) == -1)
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2012-11-15 12:40:40 +01:00
|
|
|
return true;
|
2004-05-13 10:15:02 +00:00
|
|
|
}
|
2007-06-13 06:57:18 +00:00
|
|
|
|
2014-02-25 19:15:10 +01:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
CNodeJavaInfo::CNodeJavaInfo() :
|
2006-06-19 23:10:45 +00:00
|
|
|
m_bEmptyNode(false), bNil(true), bAutoSelect(true),
|
2020-05-15 20:09:43 +02:00
|
|
|
nRequirements(0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-11-09 12:59:48 +00:00
|
|
|
void CNodeJavaInfo::loadFromNode(xmlDoc * pDoc, xmlNode * pJavaInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sExcMsg("[Java framework] Error in function NodeJavaInfo::loadFromNode "
|
2004-11-09 12:59:48 +00:00
|
|
|
"(elements.cxx).");
|
|
|
|
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(pJavaInfo && pDoc);
|
2015-11-10 10:18:19 +01:00
|
|
|
if (pJavaInfo->children == nullptr)
|
2004-11-09 12:59:48 +00:00
|
|
|
return;
|
2004-04-19 14:57:02 +00:00
|
|
|
//Get the xsi:nil attribute;
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr sNil = xmlGetNsProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
pJavaInfo, reinterpret_cast<xmlChar const *>("nil"), reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2004-04-19 14:57:02 +00:00
|
|
|
if ( ! sNil)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-05-13 10:15:02 +00:00
|
|
|
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("true")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
bNil = true;
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
bNil = false;
|
|
|
|
else
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2015-04-27 15:28:09 +02:00
|
|
|
if (bNil)
|
2004-11-09 12:59:48 +00:00
|
|
|
return;
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2004-05-13 10:15:02 +00:00
|
|
|
//Get javaInfo@manuallySelected attribute
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr sAutoSelect = xmlGetProp(
|
2015-01-17 18:48:45 +01:00
|
|
|
pJavaInfo, reinterpret_cast<xmlChar const *>("autoSelect"));
|
2004-05-13 10:15:02 +00:00
|
|
|
if ( ! sAutoSelect)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-05-13 10:15:02 +00:00
|
|
|
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(sAutoSelect, reinterpret_cast<xmlChar const *>("true")) == 0)
|
2004-05-13 10:15:02 +00:00
|
|
|
bAutoSelect = true;
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(sAutoSelect, reinterpret_cast<xmlChar const *>("false")) == 0)
|
2004-05-13 10:15:02 +00:00
|
|
|
bAutoSelect = false;
|
|
|
|
else
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-05-13 10:15:02 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlNode * cur = pJavaInfo->children;
|
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
while (cur != nullptr)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("vendor")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr xmlVendor = xmlNodeListGetString(
|
2004-04-19 14:57:02 +00:00
|
|
|
pDoc, cur->children, 1);
|
|
|
|
if (! xmlVendor)
|
2004-11-09 12:59:48 +00:00
|
|
|
return;
|
2004-04-19 14:57:02 +00:00
|
|
|
sVendor = xmlVendor;
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("location")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr xmlLocation = xmlNodeListGetString(
|
2004-04-19 14:57:02 +00:00
|
|
|
pDoc, cur->children, 1);
|
|
|
|
sLocation = xmlLocation;
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("version")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr xmlVersion = xmlNodeListGetString(
|
2004-04-19 14:57:02 +00:00
|
|
|
pDoc, cur->children, 1);
|
|
|
|
sVersion = xmlVersion;
|
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("requirements")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr xmlRequire = xmlNodeListGetString(
|
2004-04-19 14:57:02 +00:00
|
|
|
pDoc, cur->children, 1);
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sRequire = xmlRequire;
|
2004-04-19 14:57:02 +00:00
|
|
|
nRequirements = sRequire.toInt64(16);
|
2010-10-26 12:28:33 +02:00
|
|
|
#ifdef MACOSX
|
|
|
|
//javaldx is not used anymore in the mac build. In case the Java
|
|
|
|
//corresponding to the saved settings does not exist anymore the
|
|
|
|
//javavm services will look for an existing Java after creation of
|
|
|
|
//the JVM failed. See stoc/source/javavm/javavm.cxx. Only if
|
|
|
|
//nRequirements does not have the flag JFW_REQUIRE_NEEDRESTART the
|
|
|
|
//jvm of the new selected JRE will be started. Old settings (before
|
|
|
|
//OOo 3.3) still contain the flag which can be safely ignored.
|
2010-10-27 14:33:45 +02:00
|
|
|
nRequirements &= ~JFW_REQUIRE_NEEDRESTART;
|
2010-10-26 12:28:33 +02:00
|
|
|
#endif
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2015-01-17 18:48:45 +01:00
|
|
|
else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("vendorData")) == 0)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr xmlData = xmlNodeListGetString(
|
2004-04-19 14:57:02 +00:00
|
|
|
pDoc, cur->children, 1);
|
2015-06-08 16:25:58 +02:00
|
|
|
xmlChar* _data = static_cast<xmlChar*>(xmlData);
|
2004-04-19 14:57:02 +00:00
|
|
|
if (_data)
|
|
|
|
{
|
2015-01-17 18:48:45 +01:00
|
|
|
rtl::ByteSequence seq(reinterpret_cast<sal_Int8*>(_data), strlen(reinterpret_cast<char*>(_data)));
|
2004-04-19 14:57:02 +00:00
|
|
|
arVendorData = decodeBase16(seq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
|
2012-01-04 11:38:41 -02:00
|
|
|
if (sVendor.isEmpty())
|
2004-05-13 07:10:46 +00:00
|
|
|
m_bEmptyNode = true;
|
2004-04-19 14:57:02 +00:00
|
|
|
//Get the javainfo attributes
|
2019-04-13 14:54:59 +02:00
|
|
|
CXmlCharPtr sVendorUpdate = xmlGetProp(pJavaInfo,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>("vendorUpdate"));
|
2004-04-19 14:57:02 +00:00
|
|
|
if ( ! sVendorUpdate)
|
2004-11-09 12:59:48 +00:00
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
2004-04-19 14:57:02 +00:00
|
|
|
sAttrVendorUpdate = sVendorUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-09 12:59:48 +00:00
|
|
|
void CNodeJavaInfo::writeToNode(xmlDoc* pDoc,
|
|
|
|
xmlNode* pJavaInfoNode) const
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
{
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(pJavaInfoNode && pDoc);
|
2004-04-19 14:57:02 +00:00
|
|
|
//write the attribute vendorSettings
|
2004-04-26 10:20:34 +00:00
|
|
|
|
2004-05-13 10:15:02 +00:00
|
|
|
//javaInfo@vendorUpdate
|
2004-04-19 14:57:02 +00:00
|
|
|
//creates the attribute if necessary
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sUpdated = getElementUpdated();
|
2004-11-09 12:59:48 +00:00
|
|
|
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetProp(pJavaInfoNode, reinterpret_cast<xmlChar const *>("vendorUpdate"),
|
|
|
|
reinterpret_cast<xmlChar const *>(sUpdated.getStr()));
|
2004-05-13 10:15:02 +00:00
|
|
|
|
|
|
|
//javaInfo@autoSelect
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlSetProp(pJavaInfoNode, reinterpret_cast<xmlChar const *>("autoSelect"),
|
2015-04-27 15:28:09 +02:00
|
|
|
reinterpret_cast<xmlChar const *>(bAutoSelect ? "true" : "false"));
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
//Set xsi:nil in javaInfo element to false
|
|
|
|
//the xmlNs pointer must not be destroyed
|
2015-05-11 12:49:56 +02:00
|
|
|
xmlNs* nsXsi = xmlSearchNsByHref(pDoc,
|
2004-04-19 14:57:02 +00:00
|
|
|
pJavaInfoNode,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>(NS_SCHEMA_INSTANCE));
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
xmlSetNsProp(pJavaInfoNode,
|
|
|
|
nsXsi,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>("nil"),
|
|
|
|
reinterpret_cast<xmlChar const *>("false"));
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2004-04-21 08:30:36 +00:00
|
|
|
//Delete the children of JavaInfo
|
|
|
|
xmlNode* cur = pJavaInfoNode->children;
|
2015-11-10 10:18:19 +01:00
|
|
|
while (cur != nullptr)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-04-21 08:30:36 +00:00
|
|
|
xmlNode* lastNode = cur;
|
|
|
|
cur = cur->next;
|
|
|
|
xmlUnlinkNode(lastNode);
|
|
|
|
xmlFreeNode(lastNode);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2004-04-21 08:30:36 +00:00
|
|
|
//If the JavaInfo was set with an empty value,
|
|
|
|
//then we are done.
|
|
|
|
if (m_bEmptyNode)
|
2004-11-09 12:59:48 +00:00
|
|
|
return;
|
2004-04-21 08:30:36 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line after <javaInfo>
|
2015-01-17 18:48:45 +01:00
|
|
|
xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
|
|
|
|
//Create the vendor element
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast<xmlChar const *>("vendor"),
|
2008-11-28 10:06:48 +00:00
|
|
|
CXmlCharPtr(sVendor));
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line for better readability
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
|
|
|
|
//Create the location element
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast<xmlChar const *>("location"),
|
2008-11-28 10:06:48 +00:00
|
|
|
CXmlCharPtr(sLocation));
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line for better readability
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
|
|
|
|
//Create the version element
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast<xmlChar const *>("version"),
|
2008-11-28 10:06:48 +00:00
|
|
|
CXmlCharPtr(sVersion));
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line for better readability
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
|
2020-05-15 20:09:43 +02:00
|
|
|
//Create the features element, for backwards compatibility (it used to support one flag
|
|
|
|
// JFW_FEATURE_ACCESSBRIDGE = 0x01, but is ignored and always written as zero now)
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast<xmlChar const *>("features"),
|
2020-05-15 20:09:43 +02:00
|
|
|
reinterpret_cast<xmlChar const *>("0"));
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line for better readability
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
|
|
|
|
|
|
|
|
//Create the requirements element
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString sRequirements = OUString::number(
|
|
|
|
nRequirements, 16);
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast<xmlChar const *>("requirements"),
|
2008-11-28 10:06:48 +00:00
|
|
|
CXmlCharPtr(sRequirements));
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line for better readability
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
|
|
|
|
|
2020-05-15 12:09:15 +02:00
|
|
|
//Create the vendorData element
|
2004-04-19 14:57:02 +00:00
|
|
|
rtl::ByteSequence data = encodeBase16(arVendorData);
|
2015-11-10 10:18:19 +01:00
|
|
|
xmlNode* dataNode = xmlNewChild(pJavaInfoNode, nullptr,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar const *>("vendorData"),
|
|
|
|
reinterpret_cast<xmlChar const *>(""));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlNodeSetContentLen(dataNode,
|
2015-01-17 18:48:45 +01:00
|
|
|
reinterpret_cast<xmlChar*>(data.getArray()), data.getLength());
|
2004-04-19 14:57:02 +00:00
|
|
|
//add a new line for better readability
|
2015-01-17 18:48:45 +01:00
|
|
|
nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n"));
|
2004-04-19 14:57:02 +00:00
|
|
|
xmlAddChild(pJavaInfoNode, nodeCrLf);
|
|
|
|
}
|
|
|
|
|
2017-04-13 12:08:05 +02:00
|
|
|
std::unique_ptr<JavaInfo> CNodeJavaInfo::makeJavaInfo() const
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2015-04-27 15:28:09 +02:00
|
|
|
if (bNil || m_bEmptyNode)
|
2017-04-13 12:08:05 +02:00
|
|
|
return std::unique_ptr<JavaInfo>();
|
|
|
|
return std::unique_ptr<JavaInfo>(
|
|
|
|
new JavaInfo{
|
2020-05-15 20:09:43 +02:00
|
|
|
sVendor, sLocation, sVersion, nRequirements,
|
2017-04-13 12:08:05 +02:00
|
|
|
arVendorData});
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2007-06-13 06:57:18 +00:00
|
|
|
|
2014-02-25 19:15:10 +01:00
|
|
|
|
2007-06-13 06:57:18 +00:00
|
|
|
MergedSettings::MergedSettings():
|
2021-08-31 18:06:01 +02:00
|
|
|
m_bEnabled(false)
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2012-08-10 15:52:22 +02:00
|
|
|
NodeJava settings(NodeJava::USER);
|
2007-06-13 06:57:18 +00:00
|
|
|
settings.load();
|
2012-08-10 15:52:22 +02:00
|
|
|
NodeJava sharedSettings(NodeJava::SHARED);
|
|
|
|
sharedSettings.load();
|
|
|
|
merge(sharedSettings, settings);
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MergedSettings::~MergedSettings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MergedSettings::merge(const NodeJava & share, const NodeJava & user)
|
|
|
|
{
|
|
|
|
if (user.getEnabled())
|
|
|
|
m_bEnabled = * user.getEnabled();
|
|
|
|
else if (share.getEnabled())
|
|
|
|
m_bEnabled = * share.getEnabled();
|
|
|
|
else
|
2014-01-28 20:01:36 +01:00
|
|
|
m_bEnabled = true;
|
2007-06-13 06:57:18 +00:00
|
|
|
|
|
|
|
if (user.getUserClassPath())
|
|
|
|
m_sClassPath = * user.getUserClassPath();
|
|
|
|
else if (share.getUserClassPath())
|
|
|
|
m_sClassPath = * share.getUserClassPath();
|
|
|
|
|
|
|
|
if (user.getJavaInfo())
|
|
|
|
m_javaInfo = * user.getJavaInfo();
|
|
|
|
else if (share.getJavaInfo())
|
|
|
|
m_javaInfo = * share.getJavaInfo();
|
|
|
|
|
|
|
|
if (user.getVmParameters())
|
|
|
|
m_vmParams = * user.getVmParameters();
|
|
|
|
else if (share.getVmParameters())
|
|
|
|
m_vmParams = * share.getVmParameters();
|
|
|
|
|
|
|
|
if (user.getJRELocations())
|
|
|
|
m_JRELocations = * user.getJRELocations();
|
|
|
|
else if (share.getJRELocations())
|
|
|
|
m_JRELocations = * share.getJRELocations();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
::std::vector< OString> MergedSettings::getVmParametersUtf8() const
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
::std::vector< OString> ret;
|
2017-10-12 20:32:17 +02:00
|
|
|
for (auto const & vmParam : m_vmParams)
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2017-10-12 20:32:17 +02:00
|
|
|
ret.push_back( OUStringToOString(vmParam, RTL_TEXTENCODING_UTF8));
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-13 12:08:05 +02:00
|
|
|
std::unique_ptr<JavaInfo> MergedSettings::createJavaInfo() const
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
|
|
|
return m_javaInfo.makeJavaInfo();
|
|
|
|
}
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2007-06-13 06:57:18 +00:00
|
|
|
bool MergedSettings::getJavaInfoAttrAutoSelect() const
|
|
|
|
{
|
|
|
|
return m_javaInfo.bAutoSelect;
|
|
|
|
}
|
2008-06-06 07:37:17 +00:00
|
|
|
#endif
|
2017-04-11 22:25:23 +02:00
|
|
|
void MergedSettings::getVmParametersArray(std::vector<OUString> * parParams)
|
|
|
|
const
|
2007-06-13 06:57:18 +00:00
|
|
|
{
|
2017-04-11 22:25:23 +02:00
|
|
|
assert(parParams != nullptr);
|
2021-11-15 21:44:42 +02:00
|
|
|
osl::MutexGuard guard(FwkMutex());
|
2007-06-13 06:57:18 +00:00
|
|
|
|
2017-04-11 22:25:23 +02:00
|
|
|
*parParams = m_vmParams;
|
2007-06-13 06:57:18 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2010-10-14 08:30:07 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|