xref: /aoo42x/main/jvmfwk/source/fwkbase.cxx (revision a21130c6)
136f55ffcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
336f55ffcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
436f55ffcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
536f55ffcSAndrew Rist  * distributed with this work for additional information
636f55ffcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
736f55ffcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
836f55ffcSAndrew Rist  * "License"); you may not use this file except in compliance
936f55ffcSAndrew Rist  * with the License.  You may obtain a copy of the License at
1036f55ffcSAndrew Rist  *
1136f55ffcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1236f55ffcSAndrew Rist  *
1336f55ffcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1436f55ffcSAndrew Rist  * software distributed under the License is distributed on an
1536f55ffcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1636f55ffcSAndrew Rist  * KIND, either express or implied.  See the License for the
1736f55ffcSAndrew Rist  * specific language governing permissions and limitations
1836f55ffcSAndrew Rist  * under the License.
1936f55ffcSAndrew Rist  *
2036f55ffcSAndrew Rist  *************************************************************/
2136f55ffcSAndrew Rist 
2236f55ffcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_jvmfwk.hxx"
26cdf0e10cSrcweir #include "rtl/ustring.hxx"
27cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
28cdf0e10cSrcweir #include "rtl/uri.hxx"
29cdf0e10cSrcweir #include "osl/thread.hxx"
30cdf0e10cSrcweir #include "osl/process.h"
31cdf0e10cSrcweir #include "libxml/xpathInternals.h"
32cdf0e10cSrcweir #include "osl/file.hxx"
33cdf0e10cSrcweir #include "osl/module.hxx"
34cdf0e10cSrcweir #include "framework.hxx"
35cdf0e10cSrcweir #include "fwkutil.hxx"
36cdf0e10cSrcweir #include "elements.hxx"
37cdf0e10cSrcweir #include "fwkbase.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using namespace osl;
40cdf0e10cSrcweir using namespace rtl;
41cdf0e10cSrcweir #define JAVASETTINGS "javasettings"
42cdf0e10cSrcweir #define JAVASETTINGS_XML "javasettings.xml"
43cdf0e10cSrcweir #define VENDORSETTINGS "javavendors.xml"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #define UNO_JAVA_JFW_PARAMETER "UNO_JAVA_JFW_PARAMETER_"
46cdf0e10cSrcweir #define UNO_JAVA_JFW_JREHOME "UNO_JAVA_JFW_JREHOME"
47cdf0e10cSrcweir #define UNO_JAVA_JFW_ENV_JREHOME "UNO_JAVA_JFW_ENV_JREHOME"
48cdf0e10cSrcweir #define UNO_JAVA_JFW_CLASSPATH "UNO_JAVA_JFW_CLASSPATH"
49cdf0e10cSrcweir #define UNO_JAVA_JFW_ENV_CLASSPATH "UNO_JAVA_JFW_ENV_CLASSPATH"
50cdf0e10cSrcweir #define UNO_JAVA_JFW_CLASSPATH_URLS "UNO_JAVA_JFW_CLASSPATH_URLS"
51cdf0e10cSrcweir #define UNO_JAVA_JFW_PARAMETERS "UNO_JAVA_JFW_PARAMETERS"
52cdf0e10cSrcweir #define UNO_JAVA_JFW_VENDOR_SETTINGS "UNO_JAVA_JFW_VENDOR_SETTINGS"
53cdf0e10cSrcweir #define UNO_JAVA_JFW_USER_DATA "UNO_JAVA_JFW_USER_DATA"
54cdf0e10cSrcweir #define UNO_JAVA_JFW_SHARED_DATA "UNO_JAVA_JFW_SHARED_DATA"
55cdf0e10cSrcweir #define UNO_JAVA_JFW_INSTALL_DATA "UNO_JAVA_JFW_INSTALL_DATA"
56cdf0e10cSrcweir #define UNO_JAVA_JFW_INSTALL_EXPIRE "UNO_JAVA_JFW_INSTALL_EXPIRE"
57cdf0e10cSrcweir #define DEFAULT_INSTALL_EXPIRATION 3600
58cdf0e10cSrcweir 
59cdf0e10cSrcweir namespace jfw
60cdf0e10cSrcweir {
61cdf0e10cSrcweir bool  g_bJavaSet = false;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir namespace {
64cdf0e10cSrcweir 
getVendorSettingsPath(rtl::OUString const & sURL)65cdf0e10cSrcweir rtl::OString getVendorSettingsPath(rtl::OUString const & sURL)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	if (sURL.getLength() == 0)
68cdf0e10cSrcweir 		return rtl::OString();
69cdf0e10cSrcweir     rtl::OUString sSystemPathSettings;
70cdf0e10cSrcweir     if (osl_getSystemPathFromFileURL(sURL.pData,
71cdf0e10cSrcweir         & sSystemPathSettings.pData) != osl_File_E_None)
72cdf0e10cSrcweir         throw FrameworkException(
73cdf0e10cSrcweir             JFW_E_ERROR,
74cdf0e10cSrcweir             rtl::OString("[Java framework] Error in function "
75cdf0e10cSrcweir                          "getVendorSettingsPath (fwkutil.cxx) "));
76cdf0e10cSrcweir     rtl::OString osSystemPathSettings =
77cdf0e10cSrcweir         rtl::OUStringToOString(sSystemPathSettings,osl_getThreadTextEncoding());
78cdf0e10cSrcweir     return osSystemPathSettings;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
getParam(const char * name)81cdf0e10cSrcweir rtl::OUString getParam(const char * name)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     rtl::OUString retVal;
84cdf0e10cSrcweir     if (Bootstrap::get()->getFrom(rtl::OUString::createFromAscii(name), retVal))
85cdf0e10cSrcweir     {
86cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
87cdf0e10cSrcweir         rtl::OString sValue = rtl::OUStringToOString(retVal, osl_getThreadTextEncoding());
88cdf0e10cSrcweir         fprintf(stderr,"[Java framework] Using bootstrap parameter %s = %s.\n",
89cdf0e10cSrcweir                 name, sValue.getStr());
90cdf0e10cSrcweir #endif
91cdf0e10cSrcweir     }
92cdf0e10cSrcweir     return retVal;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
getParamFirstUrl(const char * name)95cdf0e10cSrcweir rtl::OUString getParamFirstUrl(const char * name)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     // Some parameters can consist of multiple URLs (separated by space
98cdf0e10cSrcweir     // characters, although trim() harmlessly also removes other white-space),
99cdf0e10cSrcweir     // of which only the first is used:
100cdf0e10cSrcweir     sal_Int32 i = 0;
101cdf0e10cSrcweir     return getParam(name).trim().getToken(0, ' ', i);
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir }//blind namespace
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
VendorSettings()107cdf0e10cSrcweir VendorSettings::VendorSettings():
108cdf0e10cSrcweir     m_xmlDocVendorSettingsFileUrl(BootParams::getVendorSettings())
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     OString sMsgExc("[Java framework] Error in constructor "
111cdf0e10cSrcweir                          "VendorSettings::VendorSettings() (fwkbase.cxx)");
112cdf0e10cSrcweir     //Prepare the xml document and context
113cdf0e10cSrcweir     OString sSettingsPath = getVendorSettingsPath(m_xmlDocVendorSettingsFileUrl);
114cdf0e10cSrcweir     if (sSettingsPath.getLength() == 0)
115cdf0e10cSrcweir     {
116cdf0e10cSrcweir         OString sMsg("[Java framework] A vendor settings file was not specified."
117cdf0e10cSrcweir                "Check the bootstrap parameter " UNO_JAVA_JFW_VENDOR_SETTINGS ".");
118cdf0e10cSrcweir         OSL_ENSURE(0, sMsg.getStr());
119cdf0e10cSrcweir         throw FrameworkException(JFW_E_CONFIGURATION, sMsg);
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir     if (sSettingsPath.getLength() > 0)
122cdf0e10cSrcweir     {
123cdf0e10cSrcweir         m_xmlDocVendorSettings = xmlParseFile(sSettingsPath.getStr());
124cdf0e10cSrcweir         if (m_xmlDocVendorSettings == NULL)
125cdf0e10cSrcweir             throw FrameworkException(
126cdf0e10cSrcweir                 JFW_E_ERROR,
127cdf0e10cSrcweir                 OString("[Java framework] Error while parsing file: ")
128cdf0e10cSrcweir                 + sSettingsPath + OString("."));
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         m_xmlPathContextVendorSettings = xmlXPathNewContext(m_xmlDocVendorSettings);
131cdf0e10cSrcweir         int res = xmlXPathRegisterNs(
132cdf0e10cSrcweir             m_xmlPathContextVendorSettings, (xmlChar*) "jf",
133cdf0e10cSrcweir             (xmlChar*) NS_JAVA_FRAMEWORK);
134cdf0e10cSrcweir         if (res == -1)
135cdf0e10cSrcweir             throw FrameworkException(JFW_E_ERROR, sMsgExc);
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
getPluginData()139cdf0e10cSrcweir std::vector<PluginLibrary> VendorSettings::getPluginData()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     OString sExcMsg("[Java framework] Error in function VendorSettings::getVendorPluginURLs "
142cdf0e10cSrcweir                          "(fwkbase.cxx).");
143cdf0e10cSrcweir     std::vector<PluginLibrary> vecPlugins;
144cdf0e10cSrcweir 	CXPathObjectPtr result(xmlXPathEvalExpression(
145cdf0e10cSrcweir         (xmlChar*)"/jf:javaSelection/jf:plugins/jf:library",
146cdf0e10cSrcweir         m_xmlPathContextVendorSettings));
147cdf0e10cSrcweir     if (xmlXPathNodeSetIsEmpty(result->nodesetval))
148cdf0e10cSrcweir         throw FrameworkException(JFW_E_ERROR, sExcMsg);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     //get the values of the library elements + vendor attribute
151cdf0e10cSrcweir     xmlNode* cur = result->nodesetval->nodeTab[0];
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     while (cur != NULL)
154cdf0e10cSrcweir     {
155cdf0e10cSrcweir         //between library elements are also text elements
156cdf0e10cSrcweir         if (cur->type == XML_ELEMENT_NODE)
157cdf0e10cSrcweir         {
158cdf0e10cSrcweir             CXmlCharPtr sAttrVendor(xmlGetProp(cur, (xmlChar*) "vendor"));
159cdf0e10cSrcweir             CXmlCharPtr sTextLibrary(
160cdf0e10cSrcweir                 xmlNodeListGetString(m_xmlDocVendorSettings,
161cdf0e10cSrcweir                                      cur->xmlChildrenNode, 1));
162cdf0e10cSrcweir             PluginLibrary plugin;
163cdf0e10cSrcweir             OString osVendor((sal_Char*)(xmlChar*) sAttrVendor);
164cdf0e10cSrcweir             plugin.sVendor = OStringToOUString(osVendor, RTL_TEXTENCODING_UTF8);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir             //create the file URL to the library
167cdf0e10cSrcweir             OUString sUrl = findPlugin(
168cdf0e10cSrcweir                 m_xmlDocVendorSettingsFileUrl, sTextLibrary);
169cdf0e10cSrcweir             if (sUrl.getLength() == 0)
170cdf0e10cSrcweir             {
171cdf0e10cSrcweir                 OString sPlugin = OUStringToOString(
172cdf0e10cSrcweir                     sTextLibrary, osl_getThreadTextEncoding());
173cdf0e10cSrcweir                 throw FrameworkException(
174cdf0e10cSrcweir                     JFW_E_CONFIGURATION,
175cdf0e10cSrcweir                     "[Java framework] The file: " + sPlugin + " does not exist.");
176cdf0e10cSrcweir             }
177cdf0e10cSrcweir             plugin.sPath  = sUrl;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir             vecPlugins.push_back(plugin);
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir         cur = cur->next;
182cdf0e10cSrcweir     }
183cdf0e10cSrcweir     return vecPlugins;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
getVersionInformation(const rtl::OUString & sVendor)186cdf0e10cSrcweir VersionInfo VendorSettings::getVersionInformation(const rtl::OUString & sVendor)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     OSL_ASSERT(sVendor.getLength() > 0);
189cdf0e10cSrcweir     VersionInfo aVersionInfo;
190cdf0e10cSrcweir     OString osVendor = OUStringToOString(sVendor, RTL_TEXTENCODING_UTF8);
191cdf0e10cSrcweir     //Get minVersion
192cdf0e10cSrcweir     OString sExpresion = OString(
193cdf0e10cSrcweir         "/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
194cdf0e10cSrcweir         osVendor + OString("\"]/jf:minVersion");
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     CXPathObjectPtr xPathObjectMin;
197cdf0e10cSrcweir     xPathObjectMin =
198cdf0e10cSrcweir         xmlXPathEvalExpression((xmlChar*) sExpresion.getStr(),
199cdf0e10cSrcweir                                m_xmlPathContextVendorSettings);
200cdf0e10cSrcweir     if (xmlXPathNodeSetIsEmpty(xPathObjectMin->nodesetval))
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir         aVersionInfo.sMinVersion = OUString();
203cdf0e10cSrcweir     }
204cdf0e10cSrcweir     else
205cdf0e10cSrcweir     {
206cdf0e10cSrcweir         CXmlCharPtr sVersion;
207cdf0e10cSrcweir         sVersion = xmlNodeListGetString(
208cdf0e10cSrcweir             m_xmlDocVendorSettings,
209cdf0e10cSrcweir             xPathObjectMin->nodesetval->nodeTab[0]->xmlChildrenNode, 1);
210cdf0e10cSrcweir         OString osVersion((sal_Char*)(xmlChar*) sVersion);
211cdf0e10cSrcweir         aVersionInfo.sMinVersion = OStringToOUString(
212cdf0e10cSrcweir             osVersion, RTL_TEXTENCODING_UTF8);
213cdf0e10cSrcweir     }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     //Get maxVersion
216cdf0e10cSrcweir     sExpresion = OString("/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
217cdf0e10cSrcweir         osVendor + OString("\"]/jf:maxVersion");
218cdf0e10cSrcweir     CXPathObjectPtr xPathObjectMax;
219cdf0e10cSrcweir     xPathObjectMax = xmlXPathEvalExpression(
220cdf0e10cSrcweir         (xmlChar*) sExpresion.getStr(),
221cdf0e10cSrcweir         m_xmlPathContextVendorSettings);
222cdf0e10cSrcweir     if (xmlXPathNodeSetIsEmpty(xPathObjectMax->nodesetval))
223cdf0e10cSrcweir     {
224cdf0e10cSrcweir         aVersionInfo.sMaxVersion = OUString();
225cdf0e10cSrcweir     }
226cdf0e10cSrcweir     else
227cdf0e10cSrcweir     {
228cdf0e10cSrcweir         CXmlCharPtr sVersion;
229cdf0e10cSrcweir         sVersion = xmlNodeListGetString(
230cdf0e10cSrcweir             m_xmlDocVendorSettings,
231cdf0e10cSrcweir             xPathObjectMax->nodesetval->nodeTab[0]->xmlChildrenNode, 1);
232cdf0e10cSrcweir         OString osVersion((sal_Char*) (xmlChar*) sVersion);
233cdf0e10cSrcweir         aVersionInfo.sMaxVersion = OStringToOUString(
234cdf0e10cSrcweir             osVersion, RTL_TEXTENCODING_UTF8);
235cdf0e10cSrcweir     }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     //Get excludeVersions
238cdf0e10cSrcweir     sExpresion = OString("/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
239cdf0e10cSrcweir         osVendor + OString("\"]/jf:excludeVersions/jf:version");
240cdf0e10cSrcweir     CXPathObjectPtr xPathObjectVersions;
241cdf0e10cSrcweir     xPathObjectVersions =
242cdf0e10cSrcweir         xmlXPathEvalExpression((xmlChar*) sExpresion.getStr(),
243cdf0e10cSrcweir                                m_xmlPathContextVendorSettings);
244cdf0e10cSrcweir     if (!xmlXPathNodeSetIsEmpty(xPathObjectVersions->nodesetval))
245cdf0e10cSrcweir     {
246cdf0e10cSrcweir         xmlNode* cur = xPathObjectVersions->nodesetval->nodeTab[0];
247cdf0e10cSrcweir         while (cur != NULL)
248cdf0e10cSrcweir         {
249cdf0e10cSrcweir             if (cur->type == XML_ELEMENT_NODE )
250cdf0e10cSrcweir             {
251cdf0e10cSrcweir                 if (xmlStrcmp(cur->name, (xmlChar*) "version") == 0)
252cdf0e10cSrcweir                 {
253cdf0e10cSrcweir                     CXmlCharPtr sVersion;
254cdf0e10cSrcweir                     sVersion = xmlNodeListGetString(
255cdf0e10cSrcweir                         m_xmlDocVendorSettings, cur->xmlChildrenNode, 1);
256cdf0e10cSrcweir                     OString osVersion((sal_Char*)(xmlChar*) sVersion);
257cdf0e10cSrcweir                     OUString usVersion = OStringToOUString(
258cdf0e10cSrcweir                         osVersion, RTL_TEXTENCODING_UTF8);
259cdf0e10cSrcweir                     aVersionInfo.addExcludeVersion(usVersion);
260cdf0e10cSrcweir                 }
261cdf0e10cSrcweir             }
262cdf0e10cSrcweir             cur = cur->next;
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir     return aVersionInfo;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
getSupportedVendors()268cdf0e10cSrcweir std::vector<OUString> VendorSettings::getSupportedVendors()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     std::vector<rtl::OUString> vecVendors;
271cdf0e10cSrcweir     //get the nodeset for the library elements
272cdf0e10cSrcweir 	jfw::CXPathObjectPtr result;
273cdf0e10cSrcweir     result = xmlXPathEvalExpression(
274cdf0e10cSrcweir         (xmlChar*)"/jf:javaSelection/jf:plugins/jf:library",
275cdf0e10cSrcweir         m_xmlPathContextVendorSettings);
276cdf0e10cSrcweir     if (xmlXPathNodeSetIsEmpty(result->nodesetval))
277cdf0e10cSrcweir         throw FrameworkException(
278cdf0e10cSrcweir             JFW_E_ERROR,
279cdf0e10cSrcweir             rtl::OString("[Java framework] Error in function getSupportedVendors (fwkutil.cxx)."));
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     //get the values of the library elements + vendor attribute
282cdf0e10cSrcweir     xmlNode* cur = result->nodesetval->nodeTab[0];
283cdf0e10cSrcweir     while (cur != NULL)
284cdf0e10cSrcweir     {
285cdf0e10cSrcweir         //between library elements are also text elements
286cdf0e10cSrcweir         if (cur->type == XML_ELEMENT_NODE)
287cdf0e10cSrcweir         {
288cdf0e10cSrcweir             jfw::CXmlCharPtr sAttrVendor(xmlGetProp(cur, (xmlChar*) "vendor"));
289cdf0e10cSrcweir             vecVendors.push_back(sAttrVendor);
290cdf0e10cSrcweir         }
291cdf0e10cSrcweir         cur = cur->next;
292cdf0e10cSrcweir     }
293cdf0e10cSrcweir     return vecVendors;
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
getPluginLibrary(const OUString & sVendor)296cdf0e10cSrcweir OUString VendorSettings::getPluginLibrary(const OUString& sVendor)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     OSL_ASSERT(sVendor.getLength() > 0);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     OString sExcMsg("[Java framework] Error in function getPluginLibrary (fwkutil.cxx).");
301cdf0e10cSrcweir     OString sVendorsPath = getVendorSettingsPath(m_xmlDocVendorSettingsFileUrl);
302cdf0e10cSrcweir     OUStringBuffer usBuffer(256);
303cdf0e10cSrcweir     usBuffer.appendAscii("/jf:javaSelection/jf:plugins/jf:library[@vendor=\"");
304cdf0e10cSrcweir     usBuffer.append(sVendor);
305cdf0e10cSrcweir     usBuffer.appendAscii("\"]/text()");
306cdf0e10cSrcweir     OUString ouExpr = usBuffer.makeStringAndClear();
307cdf0e10cSrcweir     OString sExpression =
308cdf0e10cSrcweir         OUStringToOString(ouExpr, osl_getThreadTextEncoding());
309cdf0e10cSrcweir     CXPathObjectPtr pathObjVendor;
310cdf0e10cSrcweir     pathObjVendor = xmlXPathEvalExpression(
311cdf0e10cSrcweir         (xmlChar*) sExpression.getStr(), m_xmlPathContextVendorSettings);
312cdf0e10cSrcweir     if (xmlXPathNodeSetIsEmpty(pathObjVendor->nodesetval))
313cdf0e10cSrcweir         throw FrameworkException(JFW_E_ERROR, sExcMsg);
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     CXmlCharPtr xmlCharPlugin;
316cdf0e10cSrcweir     xmlCharPlugin =
317cdf0e10cSrcweir         xmlNodeListGetString(
318cdf0e10cSrcweir             m_xmlDocVendorSettings,pathObjVendor->nodesetval->nodeTab[0], 1);
319cdf0e10cSrcweir 
320cdf0e10cSrcweir     //make an absolute file url from the relativ plugin URL
321cdf0e10cSrcweir     OUString sUrl = findPlugin(m_xmlDocVendorSettingsFileUrl, xmlCharPlugin);
322cdf0e10cSrcweir     if (sUrl.getLength() == 0)
323cdf0e10cSrcweir     {
324cdf0e10cSrcweir         OString sPlugin = OUStringToOString(
325cdf0e10cSrcweir             xmlCharPlugin, osl_getThreadTextEncoding());
326cdf0e10cSrcweir         throw FrameworkException(
327cdf0e10cSrcweir                     JFW_E_CONFIGURATION,
328cdf0e10cSrcweir                     "[Java framework] The file: " + sPlugin + " does not exist.");
329cdf0e10cSrcweir     }
330cdf0e10cSrcweir     return sUrl;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
getVMParameters()333cdf0e10cSrcweir ::std::vector<OString> BootParams::getVMParameters()
334cdf0e10cSrcweir {
335cdf0e10cSrcweir     ::std::vector<OString> vecParams;
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     for (sal_Int32 i = 1; ; i++)
338cdf0e10cSrcweir     {
339cdf0e10cSrcweir         OUString sName =
340cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_PARAMETER)) +
341cdf0e10cSrcweir             OUString::valueOf(i);
342cdf0e10cSrcweir         OUString sValue;
343cdf0e10cSrcweir         if (Bootstrap::get()->getFrom(sName, sValue) == sal_True)
344cdf0e10cSrcweir         {
345cdf0e10cSrcweir             OString sParam =
346cdf0e10cSrcweir                 OUStringToOString(sValue, osl_getThreadTextEncoding());
347cdf0e10cSrcweir             vecParams.push_back(sParam);
348cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
349cdf0e10cSrcweir             rtl::OString sParamName = rtl::OUStringToOString(sName, osl_getThreadTextEncoding());
350cdf0e10cSrcweir             fprintf(stderr,"[Java framework] Using bootstrap parameter %s"
351cdf0e10cSrcweir                     " = %s.\n", sParamName.getStr(), sParam.getStr());
352cdf0e10cSrcweir #endif
353cdf0e10cSrcweir         }
354cdf0e10cSrcweir         else
355cdf0e10cSrcweir             break;
356cdf0e10cSrcweir     }
357cdf0e10cSrcweir     return vecParams;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
getUserData()360cdf0e10cSrcweir rtl::OUString BootParams::getUserData()
361cdf0e10cSrcweir {
362cdf0e10cSrcweir     return getParamFirstUrl(UNO_JAVA_JFW_USER_DATA);
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
getSharedData()365cdf0e10cSrcweir rtl::OUString BootParams::getSharedData()
366cdf0e10cSrcweir {
367cdf0e10cSrcweir     return getParamFirstUrl(UNO_JAVA_JFW_SHARED_DATA);
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
getInstallData()370cdf0e10cSrcweir rtl::OUString BootParams::getInstallData()
371cdf0e10cSrcweir {
372cdf0e10cSrcweir     return getParam(UNO_JAVA_JFW_INSTALL_DATA);
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 
getClasspath()376cdf0e10cSrcweir rtl::OString BootParams::getClasspath()
377cdf0e10cSrcweir {
378cdf0e10cSrcweir     rtl::OString sClassPath;
379cdf0e10cSrcweir     rtl::OUString sCP;
380cdf0e10cSrcweir     char szSep[] = {SAL_PATHSEPARATOR,0};
381cdf0e10cSrcweir     if (Bootstrap::get()->getFrom(
382cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH)),
383cdf0e10cSrcweir         sCP) == sal_True)
384cdf0e10cSrcweir     {
385cdf0e10cSrcweir         sClassPath = rtl::OUStringToOString(
386cdf0e10cSrcweir             sCP, osl_getThreadTextEncoding());
387cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
388cdf0e10cSrcweir         fprintf(stderr,"[Java framework] Using bootstrap parameter "
38953174aa6SArrigo Marchiori             UNO_JAVA_JFW_CLASSPATH " = \"%s\".\n", sClassPath.getStr());
390cdf0e10cSrcweir #endif
391cdf0e10cSrcweir     }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     rtl::OUString sEnvCP;
394cdf0e10cSrcweir     if (Bootstrap::get()->getFrom(
395cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_CLASSPATH)),
396cdf0e10cSrcweir         sEnvCP) == sal_True)
397cdf0e10cSrcweir     {
398cdf0e10cSrcweir         char * pCp = getenv("CLASSPATH");
399cdf0e10cSrcweir         if (pCp)
400cdf0e10cSrcweir         {
401*a21130c6SArrigo Marchiori             if (sClassPath.getLength()) {
402*a21130c6SArrigo Marchiori                 sClassPath += rtl::OString(szSep);
403*a21130c6SArrigo Marchiori             }
404*a21130c6SArrigo Marchiori             sClassPath += rtl::OString(pCp);
405cdf0e10cSrcweir         }
406cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
407cdf0e10cSrcweir         fprintf(stderr,"[Java framework] Using bootstrap parameter "
408cdf0e10cSrcweir             UNO_JAVA_JFW_ENV_CLASSPATH " and class path is:\n %s.\n", pCp ? pCp : "");
409cdf0e10cSrcweir #endif
410cdf0e10cSrcweir     }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     return sClassPath;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
getVendorSettings()415cdf0e10cSrcweir rtl::OUString BootParams::getVendorSettings()
416cdf0e10cSrcweir {
417cdf0e10cSrcweir     rtl::OUString sVendor;
418cdf0e10cSrcweir     rtl::OUString sName(
419cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_VENDOR_SETTINGS));
420cdf0e10cSrcweir     if (Bootstrap::get()->getFrom(sName ,sVendor) == sal_True)
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         //check the value of the bootstrap variable
423cdf0e10cSrcweir         jfw::FileStatus s = checkFileURL(sVendor);
424cdf0e10cSrcweir         if (s != FILE_OK)
425cdf0e10cSrcweir         {
426cdf0e10cSrcweir             //This bootstrap parameter can contain a relative URL
427cdf0e10cSrcweir             rtl::OUString sAbsoluteUrl;
428cdf0e10cSrcweir             rtl::OUString sBaseDir = getLibraryLocation();
429cdf0e10cSrcweir             if (File::getAbsoluteFileURL(sBaseDir, sVendor, sAbsoluteUrl)
430cdf0e10cSrcweir                 != File::E_None)
431cdf0e10cSrcweir                 throw FrameworkException(
432cdf0e10cSrcweir                     JFW_E_CONFIGURATION,
433cdf0e10cSrcweir                     rtl::OString("[Java framework] Invalid value for bootstrap variable: "
434cdf0e10cSrcweir                              UNO_JAVA_JFW_VENDOR_SETTINGS));
435cdf0e10cSrcweir             sVendor = sAbsoluteUrl;
436cdf0e10cSrcweir             s = checkFileURL(sVendor);
437cdf0e10cSrcweir             if (s == jfw::FILE_INVALID || s == jfw::FILE_DOES_NOT_EXIST)
438cdf0e10cSrcweir             {
439cdf0e10cSrcweir                 throw FrameworkException(
440cdf0e10cSrcweir                     JFW_E_CONFIGURATION,
441cdf0e10cSrcweir                     rtl::OString("[Java framework] Invalid value for bootstrap variable: "
442cdf0e10cSrcweir                                  UNO_JAVA_JFW_VENDOR_SETTINGS));
443cdf0e10cSrcweir             }
444cdf0e10cSrcweir         }
445cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
446cdf0e10cSrcweir     rtl::OString sValue = rtl::OUStringToOString(sVendor, osl_getThreadTextEncoding());
447cdf0e10cSrcweir     fprintf(stderr,"[Java framework] Using bootstrap parameter "
448cdf0e10cSrcweir             UNO_JAVA_JFW_VENDOR_SETTINGS" = %s.\n", sValue.getStr());
449cdf0e10cSrcweir #endif
450cdf0e10cSrcweir     }
451cdf0e10cSrcweir     return sVendor;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
getJREHome()454cdf0e10cSrcweir rtl::OUString BootParams::getJREHome()
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     rtl::OUString sJRE;
457cdf0e10cSrcweir     rtl::OUString sEnvJRE;
458cdf0e10cSrcweir     sal_Bool bJRE = Bootstrap::get()->getFrom(
459cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_JREHOME)) ,sJRE);
460cdf0e10cSrcweir     sal_Bool bEnvJRE = Bootstrap::get()->getFrom(
461cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_JREHOME)) ,sEnvJRE);
462cdf0e10cSrcweir 
463cdf0e10cSrcweir     if (bJRE == sal_True && bEnvJRE == sal_True)
464cdf0e10cSrcweir     {
465cdf0e10cSrcweir         throw FrameworkException(
466cdf0e10cSrcweir             JFW_E_CONFIGURATION,
467cdf0e10cSrcweir             rtl::OString("[Java framework] Both bootstrap parameter "
468cdf0e10cSrcweir                          UNO_JAVA_JFW_JREHOME" and "
469cdf0e10cSrcweir                          UNO_JAVA_JFW_ENV_JREHOME" are set. However only one of them can be set."
470cdf0e10cSrcweir                              "Check bootstrap parameters: environment variables, command line "
471cdf0e10cSrcweir                              "arguments, rc/ini files for executable and java framework library."));
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir     else if (bEnvJRE == sal_True)
474cdf0e10cSrcweir     {
475cdf0e10cSrcweir         const char * pJRE = getenv("JAVA_HOME");
476cdf0e10cSrcweir         if (pJRE == NULL)
477cdf0e10cSrcweir         {
478cdf0e10cSrcweir             throw FrameworkException(
479cdf0e10cSrcweir             JFW_E_CONFIGURATION,
480cdf0e10cSrcweir             rtl::OString("[Java framework] Both bootstrap parameter "
481cdf0e10cSrcweir                          UNO_JAVA_JFW_ENV_JREHOME" is set, but the environment variable "
482cdf0e10cSrcweir                          "JAVA_HOME is not set."));
483cdf0e10cSrcweir         }
484cdf0e10cSrcweir         rtl::OString osJRE(pJRE);
485cdf0e10cSrcweir         rtl::OUString usJRE = rtl::OStringToOUString(osJRE, osl_getThreadTextEncoding());
486cdf0e10cSrcweir         if (File::getFileURLFromSystemPath(usJRE, sJRE) != File::E_None)
487cdf0e10cSrcweir             throw FrameworkException(
488cdf0e10cSrcweir                 JFW_E_ERROR,
489cdf0e10cSrcweir                 rtl::OString("[Java framework] Error in function BootParams::getJREHome() "
490cdf0e10cSrcweir                              "(fwkbase.cxx)."));
491cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
492cdf0e10cSrcweir     fprintf(stderr,"[Java framework] Using bootstrap parameter "
493cdf0e10cSrcweir             UNO_JAVA_JFW_ENV_JREHOME" with JAVA_HOME = %s.\n", pJRE);
494cdf0e10cSrcweir #endif
495cdf0e10cSrcweir     }
496cdf0e10cSrcweir     else if (getMode() == JFW_MODE_DIRECT
497cdf0e10cSrcweir         && bEnvJRE == sal_False
498cdf0e10cSrcweir         && bJRE == sal_False)
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         throw FrameworkException(
501cdf0e10cSrcweir             JFW_E_CONFIGURATION,
502cdf0e10cSrcweir             rtl::OString("[Java framework] The bootstrap parameter "
503cdf0e10cSrcweir                          UNO_JAVA_JFW_ENV_JREHOME" or " UNO_JAVA_JFW_JREHOME
504cdf0e10cSrcweir                          " must be set in direct mode."));
505cdf0e10cSrcweir     }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
508cdf0e10cSrcweir     if (bJRE == sal_True)
509cdf0e10cSrcweir     {
510cdf0e10cSrcweir         rtl::OString sValue = rtl::OUStringToOString(sJRE, osl_getThreadTextEncoding());
511cdf0e10cSrcweir         fprintf(stderr,"[Java framework] Using bootstrap parameter "
512cdf0e10cSrcweir             UNO_JAVA_JFW_JREHOME" = %s.\n", sValue.getStr());
513cdf0e10cSrcweir     }
514cdf0e10cSrcweir #endif
515cdf0e10cSrcweir     return sJRE;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
getClasspathUrls()518cdf0e10cSrcweir rtl::OUString BootParams::getClasspathUrls()
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     rtl::OUString sParams;
521cdf0e10cSrcweir     Bootstrap::get()->getFrom(
522cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH_URLS)),
523cdf0e10cSrcweir         sParams);
524cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
525cdf0e10cSrcweir     rtl::OString sValue = rtl::OUStringToOString(sParams, osl_getThreadTextEncoding());
526cdf0e10cSrcweir     fprintf(stderr,"[Java framework] Using bootstrap parameter "
52753174aa6SArrigo Marchiori             UNO_JAVA_JFW_CLASSPATH_URLS " = \"%s\".\n", sValue.getStr());
528cdf0e10cSrcweir #endif
529cdf0e10cSrcweir     return sParams;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
getInstallDataExpiration()532cdf0e10cSrcweir ::sal_uInt32 BootParams::getInstallDataExpiration()
533cdf0e10cSrcweir {
534cdf0e10cSrcweir     rtl::OUString sValue;
535cdf0e10cSrcweir     Bootstrap::get()->getFrom(
536cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_INSTALL_EXPIRE)),
537cdf0e10cSrcweir         sValue);
538cdf0e10cSrcweir 
539cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
540cdf0e10cSrcweir     rtl::OString osValue = rtl::OUStringToOString(sValue, osl_getThreadTextEncoding());
541cdf0e10cSrcweir     fprintf(stderr,"[Java framework] Using bootstrap parameter "
542cdf0e10cSrcweir             UNO_JAVA_JFW_INSTALL_EXPIRE " = %s.\n", osValue.getStr());
543cdf0e10cSrcweir #endif
544cdf0e10cSrcweir 
545cdf0e10cSrcweir     sal_Int64 nVal = sValue.toInt64();
546cdf0e10cSrcweir     if (0 == nVal)
547cdf0e10cSrcweir     {
548cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2
549cdf0e10cSrcweir         fprintf(stderr,"[Java framework] Using default value for "
550cdf0e10cSrcweir                 "UNO_JAVA_JFW_INSTALL_EXPIRE: %d  \n", DEFAULT_INSTALL_EXPIRATION);
551cdf0e10cSrcweir #endif
552cdf0e10cSrcweir         return DEFAULT_INSTALL_EXPIRATION;
553cdf0e10cSrcweir     }
554cdf0e10cSrcweir     else
555cdf0e10cSrcweir     {
556cdf0e10cSrcweir         return static_cast<sal_uInt32>(nVal);
557cdf0e10cSrcweir     }
558cdf0e10cSrcweir }
559cdf0e10cSrcweir 
getMode()560cdf0e10cSrcweir JFW_MODE getMode()
561cdf0e10cSrcweir {
562cdf0e10cSrcweir     static bool g_bMode = false;
563cdf0e10cSrcweir     static JFW_MODE g_mode = JFW_MODE_APPLICATION;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     if (g_bMode == false)
566cdf0e10cSrcweir     {
567cdf0e10cSrcweir         //check if either of the "direct mode" bootstrap variables is set
568cdf0e10cSrcweir         bool bDirectMode = true;
569cdf0e10cSrcweir         rtl::OUString sValue;
570cdf0e10cSrcweir         const rtl::Bootstrap * aBoot = Bootstrap::get();
571cdf0e10cSrcweir         rtl::OUString sJREHome(
572cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_JREHOME));
573cdf0e10cSrcweir         if (aBoot->getFrom(sJREHome, sValue) == sal_False)
574cdf0e10cSrcweir         {
575cdf0e10cSrcweir             rtl::OUString sEnvJRE(
576cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_JREHOME));
577cdf0e10cSrcweir             if (aBoot->getFrom(sEnvJRE, sValue) == sal_False)
578cdf0e10cSrcweir             {
579cdf0e10cSrcweir                 rtl::OUString sClasspath(
580cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH));
581cdf0e10cSrcweir                 if (aBoot->getFrom(sClasspath, sValue) == sal_False)
582cdf0e10cSrcweir                 {
583cdf0e10cSrcweir                     rtl::OUString sEnvClasspath(
584cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_CLASSPATH));
585cdf0e10cSrcweir                     if (aBoot->getFrom(sEnvClasspath, sValue) == sal_False)
586cdf0e10cSrcweir                     {
587cdf0e10cSrcweir                         rtl::OUString sParams = rtl::OUString(
588cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_PARAMETER)) +
589cdf0e10cSrcweir                             rtl::OUString::valueOf((sal_Int32)1);
590cdf0e10cSrcweir                         if (aBoot->getFrom(sParams, sValue) == sal_False)
591cdf0e10cSrcweir                         {
592cdf0e10cSrcweir                             bDirectMode = false;
593cdf0e10cSrcweir                         }
594cdf0e10cSrcweir                     }
595cdf0e10cSrcweir                 }
596cdf0e10cSrcweir             }
597cdf0e10cSrcweir         }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir         if (bDirectMode)
600cdf0e10cSrcweir             g_mode = JFW_MODE_DIRECT;
601cdf0e10cSrcweir         else
602cdf0e10cSrcweir             g_mode = JFW_MODE_APPLICATION;
603cdf0e10cSrcweir         g_bMode = true;
604cdf0e10cSrcweir     }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir     return g_mode;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
getApplicationClassPath()609cdf0e10cSrcweir rtl::OUString getApplicationClassPath()
610cdf0e10cSrcweir {
611cdf0e10cSrcweir     OSL_ASSERT(getMode() == JFW_MODE_APPLICATION);
612cdf0e10cSrcweir     rtl::OUString retVal;
613cdf0e10cSrcweir     rtl::OUString sParams = BootParams::getClasspathUrls();
614cdf0e10cSrcweir     if (sParams.getLength() == 0)
615cdf0e10cSrcweir         return retVal;
616cdf0e10cSrcweir 
617cdf0e10cSrcweir     rtl::OUStringBuffer buf;
618cdf0e10cSrcweir     sal_Int32 index = 0;
619cdf0e10cSrcweir     char szClassPathSep[] = {SAL_PATHSEPARATOR,0};
620cdf0e10cSrcweir     do
621cdf0e10cSrcweir     {
622cdf0e10cSrcweir         ::rtl::OUString token( sParams.getToken( 0, ' ', index ).trim() );
623cdf0e10cSrcweir         if (token.getLength())
624cdf0e10cSrcweir         {
625cdf0e10cSrcweir             ::rtl::OUString systemPathElement;
626cdf0e10cSrcweir             oslFileError rc = osl_getSystemPathFromFileURL(
627cdf0e10cSrcweir                 token.pData, &systemPathElement.pData );
628cdf0e10cSrcweir             OSL_ASSERT( rc == osl_File_E_None );
629cdf0e10cSrcweir             if (rc == osl_File_E_None && systemPathElement.getLength() > 0)
630cdf0e10cSrcweir             {
631cdf0e10cSrcweir                 if (buf.getLength() > 0)
632cdf0e10cSrcweir                     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
633cdf0e10cSrcweir                                          szClassPathSep) );
634cdf0e10cSrcweir                 buf.append( systemPathElement );
635cdf0e10cSrcweir             }
636cdf0e10cSrcweir         }
637cdf0e10cSrcweir     }
638cdf0e10cSrcweir     while (index >= 0);
639cdf0e10cSrcweir     return buf.makeStringAndClear();
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
makeClassPathOption(OUString const & sUserClassPath)642cdf0e10cSrcweir rtl::OString makeClassPathOption(OUString const & sUserClassPath)
643cdf0e10cSrcweir {
644cdf0e10cSrcweir     //Compose the class path
645cdf0e10cSrcweir     rtl::OString sPaths;
646cdf0e10cSrcweir     rtl::OUStringBuffer sBufCP(4096);
647cdf0e10cSrcweir     char szSep[] = {SAL_PATHSEPARATOR,0};
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     // append all user selected jars to the class path
650cdf0e10cSrcweir     if (sUserClassPath.getLength() > 0)
651cdf0e10cSrcweir         sBufCP.append(sUserClassPath);
652cdf0e10cSrcweir 
653cdf0e10cSrcweir     //append all jar libraries and components to the class path
654cdf0e10cSrcweir     OUString sAppCP = getApplicationClassPath();
655cdf0e10cSrcweir     if (sAppCP.getLength())
656cdf0e10cSrcweir     {
657cdf0e10cSrcweir         if (sUserClassPath.getLength())
658cdf0e10cSrcweir             sBufCP.appendAscii(szSep);
659cdf0e10cSrcweir         sBufCP.append(sAppCP);
660cdf0e10cSrcweir     }
661cdf0e10cSrcweir 
662cdf0e10cSrcweir     sPaths = rtl::OUStringToOString(
663cdf0e10cSrcweir         sBufCP.makeStringAndClear(), osl_getThreadTextEncoding());
664cdf0e10cSrcweir 
665cdf0e10cSrcweir     rtl::OString sOptionClassPath("-Djava.class.path=");
666cdf0e10cSrcweir     sOptionClassPath += sPaths;
667cdf0e10cSrcweir     return sOptionClassPath;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
getUserSettingsPath()670cdf0e10cSrcweir rtl::OString getUserSettingsPath()
671cdf0e10cSrcweir {
672cdf0e10cSrcweir     return getSettingsPath(BootParams::getUserData());
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
getSharedSettingsPath()675cdf0e10cSrcweir rtl::OString getSharedSettingsPath()
676cdf0e10cSrcweir {
677cdf0e10cSrcweir     return getSettingsPath(BootParams::getSharedData());
678cdf0e10cSrcweir }
679cdf0e10cSrcweir 
getInstallSettingsPath()680cdf0e10cSrcweir rtl::OString getInstallSettingsPath()
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     return getSettingsPath(BootParams::getInstallData());
683cdf0e10cSrcweir }
684cdf0e10cSrcweir 
getSettingsPath(const rtl::OUString & sURL)685cdf0e10cSrcweir rtl::OString getSettingsPath( const rtl::OUString & sURL)
686cdf0e10cSrcweir {
687cdf0e10cSrcweir     if (sURL.getLength() == 0)
688cdf0e10cSrcweir 		return rtl::OString();
689cdf0e10cSrcweir     rtl::OUString sPath;
690cdf0e10cSrcweir     if (osl_getSystemPathFromFileURL(sURL.pData,
691cdf0e10cSrcweir         & sPath.pData) != osl_File_E_None)
692cdf0e10cSrcweir         throw FrameworkException(
693cdf0e10cSrcweir             JFW_E_ERROR, rtl::OString(
694cdf0e10cSrcweir                 "[Java framework] Error in function ::getSettingsPath (fwkbase.cxx)."));
695cdf0e10cSrcweir     return rtl::OUStringToOString(sPath,osl_getThreadTextEncoding());
696cdf0e10cSrcweir }
697cdf0e10cSrcweir 
getVendorSettingsPath()698cdf0e10cSrcweir rtl::OString getVendorSettingsPath()
699cdf0e10cSrcweir {
700cdf0e10cSrcweir     return getVendorSettingsPath(BootParams::getVendorSettings());
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
setJavaSelected()703cdf0e10cSrcweir void setJavaSelected()
704cdf0e10cSrcweir {
705cdf0e10cSrcweir     g_bJavaSet = true;
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
wasJavaSelectedInSameProcess()708cdf0e10cSrcweir bool wasJavaSelectedInSameProcess()
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     //g_setJavaProcId not set means no Java selected
711cdf0e10cSrcweir     if (g_bJavaSet == true)
712cdf0e10cSrcweir         return true;
713cdf0e10cSrcweir     return false;
714cdf0e10cSrcweir }
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 
717cdf0e10cSrcweir }
718