Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "elements.hxx"
21 : #include "osl/mutex.hxx"
22 : #include "osl/file.hxx"
23 : #include "fwkutil.hxx"
24 : #include "fwkbase.hxx"
25 : #include "framework.hxx"
26 : #include "libxmlutil.hxx"
27 : #include "osl/thread.hxx"
28 : #include <algorithm>
29 : #include "libxml/parser.h"
30 : #include "libxml/xpath.h"
31 : #include "libxml/xpathInternals.h"
32 : #include "rtl/bootstrap.hxx"
33 : #include "boost/optional.hpp"
34 : #include <string.h>
35 :
36 : // For backwards compatibility, the nFeatures and nRequirements flag words are
37 : // read/written as potentially signed hexadecimal numbers (though that has no
38 : // practical relevance given that each has only one flag with value 0x01
39 : // defined).
40 :
41 : using namespace osl;
42 : namespace jfw
43 : {
44 :
45 42505 : OString getElement(OString const & docPath,
46 : xmlChar const * pathExpression, bool bThrowIfEmpty)
47 : {
48 : //Prepare the xml document and context
49 : OSL_ASSERT(!docPath.isEmpty());
50 42505 : jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr()));
51 42505 : if (doc == NULL)
52 : throw FrameworkException(
53 : JFW_E_ERROR,
54 : OString("[Java framework] Error in function getElement "
55 0 : "(elements.cxx)"));
56 :
57 85010 : jfw::CXPathContextPtr context(xmlXPathNewContext(doc));
58 42505 : if (xmlXPathRegisterNs(context, (xmlChar*) "jf",
59 42505 : (xmlChar*) NS_JAVA_FRAMEWORK) == -1)
60 : throw FrameworkException(
61 : JFW_E_ERROR,
62 : OString("[Java framework] Error in function getElement "
63 0 : "(elements.cxx)"));
64 :
65 85010 : CXPathObjectPtr pathObj;
66 42505 : pathObj = xmlXPathEvalExpression(pathExpression, context);
67 42505 : OString sValue;
68 42505 : if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
69 : {
70 0 : if (bThrowIfEmpty)
71 : throw FrameworkException(
72 : JFW_E_ERROR,
73 : OString("[Java framework] Error in function getElement "
74 0 : "(elements.cxx)"));
75 : }
76 : else
77 : {
78 42505 : sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content;
79 : }
80 85010 : return sValue;
81 : }
82 :
83 42505 : OString getElementUpdated()
84 : {
85 : return getElement(jfw::getVendorSettingsPath(),
86 42505 : (xmlChar*)"/jf:javaSelection/jf:updated/text()", true);
87 : }
88 :
89 85011 : void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
90 : {
91 : OString sExcMsg("[Java framework] Error in function createSettingsStructure "
92 85011 : "(elements.cxx).");
93 85011 : xmlNode * root = xmlDocGetRootElement(document);
94 85011 : if (root == NULL)
95 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
96 85011 : bool bFound = false;
97 85011 : xmlNode * cur = root->children;
98 255033 : while (cur != NULL)
99 : {
100 170021 : if (xmlStrcmp(cur->name, (xmlChar*) "enabled") == 0)
101 : {
102 85010 : bFound = true;
103 85010 : break;
104 : }
105 85011 : cur = cur->next;
106 : }
107 85011 : if (bFound)
108 : {
109 85010 : *bNeedsSave = false;
110 170021 : return;
111 : }
112 : //We will modify this document
113 1 : *bNeedsSave = true;
114 : // Now we create the child elements ------------------
115 : //Get xsi:nil namespace
116 : xmlNs* nsXsi = xmlSearchNsByHref(
117 1 : document, root,(xmlChar*) NS_SCHEMA_INSTANCE);
118 :
119 : //<enabled xsi:nil="true"
120 : xmlNode * nodeEn = xmlNewTextChild(
121 1 : root,NULL, (xmlChar*) "enabled", (xmlChar*) "");
122 1 : if (nodeEn == NULL)
123 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
124 1 : xmlSetNsProp(nodeEn,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
125 : //add a new line
126 1 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
127 1 : xmlAddChild(root, nodeCrLf);
128 :
129 : //<userClassPath xsi:nil="true">
130 : xmlNode * nodeUs = xmlNewTextChild(
131 1 : root,NULL, (xmlChar*) "userClassPath", (xmlChar*) "");
132 1 : if (nodeUs == NULL)
133 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
134 1 : xmlSetNsProp(nodeUs,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
135 : //add a new line
136 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
137 1 : xmlAddChild(root, nodeCrLf);
138 :
139 : //<vmParameters xsi:nil="true">
140 : xmlNode * nodeVm = xmlNewTextChild(
141 1 : root,NULL, (xmlChar*) "vmParameters", (xmlChar*) "");
142 1 : if (nodeVm == NULL)
143 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
144 1 : xmlSetNsProp(nodeVm,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
145 : //add a new line
146 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
147 1 : xmlAddChild(root, nodeCrLf);
148 :
149 : //<jreLocations xsi:nil="true">
150 : xmlNode * nodeJre = xmlNewTextChild(
151 1 : root,NULL, (xmlChar*) "jreLocations", (xmlChar*) "");
152 1 : if (nodeJre == NULL)
153 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
154 1 : xmlSetNsProp(nodeJre,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
155 : //add a new line
156 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
157 1 : xmlAddChild(root, nodeCrLf);
158 :
159 : //<javaInfo xsi:nil="true">
160 : xmlNode * nodeJava = xmlNewTextChild(
161 1 : root,NULL, (xmlChar*) "javaInfo", (xmlChar*) "");
162 1 : if (nodeJava == NULL)
163 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
164 1 : xmlSetNsProp(nodeJava,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
165 : //add a new line
166 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
167 1 : xmlAddChild(root, nodeCrLf);
168 : }
169 :
170 :
171 :
172 2 : VersionInfo::VersionInfo(): arVersions(NULL)
173 : {
174 2 : }
175 :
176 4 : VersionInfo::~VersionInfo()
177 : {
178 2 : delete [] arVersions;
179 2 : }
180 :
181 0 : void VersionInfo::addExcludeVersion(const OUString& sVersion)
182 : {
183 0 : vecExcludeVersions.push_back(sVersion);
184 0 : }
185 :
186 2 : rtl_uString** VersionInfo::getExcludeVersions()
187 : {
188 2 : osl::MutexGuard guard(FwkMutex::get());
189 2 : if (arVersions != NULL)
190 0 : return arVersions;
191 :
192 2 : arVersions = new rtl_uString*[vecExcludeVersions.size()];
193 2 : int j=0;
194 : typedef std::vector<OUString>::const_iterator it;
195 2 : for (it i = vecExcludeVersions.begin(); i != vecExcludeVersions.end();
196 : ++i, ++j)
197 : {
198 0 : arVersions[j] = vecExcludeVersions[j].pData;
199 : }
200 2 : return arVersions;
201 : }
202 :
203 2 : sal_Int32 VersionInfo::getExcludeVersionSize()
204 : {
205 2 : return vecExcludeVersions.size();
206 : }
207 :
208 :
209 170021 : NodeJava::NodeJava(Layer layer):
210 170021 : m_layer(layer)
211 : {
212 : //This class reads and write to files which should only be done in
213 : //application mode
214 170021 : if (getMode() == JFW_MODE_DIRECT)
215 : throw FrameworkException(
216 : JFW_E_DIRECT_MODE,
217 0 : "[Java framework] Trying to access settings files in direct mode.");
218 170021 : }
219 :
220 :
221 170020 : void NodeJava::load()
222 : {
223 : const OString sExcMsg("[Java framework] Error in function NodeJava::load"
224 170020 : "(elements.cxx).");
225 170020 : if (SHARED == m_layer)
226 : {
227 : //we do not support yet to write into the shared installation
228 :
229 : //check if shared settings exist at all.
230 85010 : OUString sURL(BootParams::getSharedData());
231 85010 : jfw::FileStatus s = sURL.isEmpty()
232 85010 : ? FILE_DOES_NOT_EXIST : checkFileURL(sURL);
233 85010 : if (s == FILE_INVALID)
234 : throw FrameworkException(
235 : JFW_E_ERROR,
236 0 : "[Java framework] Invalid file for shared Java settings.");
237 85010 : else if (s == FILE_DOES_NOT_EXIST)
238 : //Writing shared data is not supported yet.
239 85010 : return;
240 : }
241 85010 : else if (USER == m_layer)
242 : {
243 85010 : if (!prepareSettingsDocument())
244 : {
245 : SAL_INFO("jfw.level1", "no path to load user settings document from");
246 0 : return;
247 : }
248 : }
249 : else
250 : {
251 : OSL_FAIL("[Java framework] Unknown enum used.");
252 : }
253 :
254 :
255 : //Read the user elements
256 170020 : OString sSettingsPath = getSettingsPath();
257 : //There must not be a share settings file
258 170020 : CXmlDocPtr docUser(xmlParseFile(sSettingsPath.getStr()));
259 85010 : if (docUser == NULL)
260 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
261 :
262 85010 : xmlNode * cur = xmlDocGetRootElement(docUser);
263 85010 : if (cur == NULL || cur->children == NULL)
264 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
265 :
266 170020 : CXmlCharPtr sNil;
267 85010 : cur = cur->children;
268 1105130 : while (cur != NULL)
269 : {
270 935110 : if (xmlStrcmp(cur->name, (xmlChar*) "enabled") == 0)
271 : {
272 : //only overwrite share settings if xsi:nil="false"
273 85010 : sNil = xmlGetNsProp(
274 85010 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
275 85010 : if (sNil == NULL)
276 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);;
277 85010 : if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
278 : {
279 : CXmlCharPtr sEnabled( xmlNodeListGetString(
280 0 : docUser, cur->children, 1));
281 0 : if (xmlStrcmp(sEnabled, (xmlChar*) "true") == 0)
282 0 : m_enabled = boost::optional<sal_Bool>(sal_True);
283 0 : else if (xmlStrcmp(sEnabled, (xmlChar*) "false") == 0)
284 0 : m_enabled = boost::optional<sal_Bool>(sal_False);
285 : }
286 : }
287 850100 : else if (xmlStrcmp(cur->name, (xmlChar*) "userClassPath") == 0)
288 : {
289 85010 : sNil = xmlGetNsProp(
290 85010 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
291 85010 : if (sNil == NULL)
292 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
293 85010 : if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
294 : {
295 : CXmlCharPtr sUser(xmlNodeListGetString(
296 0 : docUser, cur->children, 1));
297 0 : m_userClassPath = boost::optional<OUString>(OUString(sUser));
298 : }
299 : }
300 765090 : else if (xmlStrcmp(cur->name, (xmlChar*) "javaInfo") == 0)
301 : {
302 85010 : sNil = xmlGetNsProp(
303 85010 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
304 85010 : if (sNil == NULL)
305 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
306 :
307 85010 : if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
308 : {
309 85008 : if (! m_javaInfo)
310 85008 : m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
311 85008 : m_javaInfo->loadFromNode(docUser, cur);
312 : }
313 : }
314 680080 : else if (xmlStrcmp(cur->name, (xmlChar*) "vmParameters") == 0)
315 : {
316 85010 : sNil = xmlGetNsProp(
317 85010 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
318 85010 : if (sNil == NULL)
319 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
320 85010 : if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
321 : {
322 0 : if ( ! m_vmParameters)
323 0 : m_vmParameters = boost::optional<std::vector<OUString> >(
324 0 : std::vector<OUString> ());
325 :
326 0 : xmlNode * pOpt = cur->children;
327 0 : while (pOpt != NULL)
328 : {
329 0 : if (xmlStrcmp(pOpt->name, (xmlChar*) "param") == 0)
330 : {
331 0 : CXmlCharPtr sOpt;
332 0 : sOpt = xmlNodeListGetString(
333 0 : docUser, pOpt->children, 1);
334 0 : m_vmParameters->push_back(sOpt);
335 : }
336 0 : pOpt = pOpt->next;
337 : }
338 : }
339 : }
340 595070 : else if (xmlStrcmp(cur->name, (xmlChar*) "jreLocations") == 0)
341 : {
342 85010 : sNil = xmlGetNsProp(
343 85010 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
344 85010 : if (sNil == NULL)
345 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
346 85010 : if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
347 : {
348 0 : if (! m_JRELocations)
349 0 : m_JRELocations = boost::optional<std::vector<OUString> >(
350 0 : std::vector<OUString>());
351 :
352 0 : xmlNode * pLoc = cur->children;
353 0 : while (pLoc != NULL)
354 : {
355 0 : if (xmlStrcmp(pLoc->name, (xmlChar*) "location") == 0)
356 : {
357 0 : CXmlCharPtr sLoc;
358 0 : sLoc = xmlNodeListGetString(
359 0 : docUser, pLoc->children, 1);
360 0 : m_JRELocations->push_back(sLoc);
361 : }
362 0 : pLoc = pLoc->next;
363 : }
364 : }
365 : }
366 935110 : cur = cur->next;
367 85010 : }
368 : }
369 :
370 170023 : OString NodeJava::getSettingsPath() const
371 : {
372 170023 : OString ret;
373 170023 : switch (m_layer)
374 : {
375 170023 : case USER: ret = getUserSettingsPath(); break;
376 0 : case SHARED: ret = getSharedSettingsPath(); break;
377 : default:
378 : OSL_FAIL("[Java framework] NodeJava::getSettingsPath()");
379 : }
380 170023 : return ret;
381 : }
382 :
383 85011 : OUString NodeJava::getSettingsURL() const
384 : {
385 85011 : OUString ret;
386 85011 : switch (m_layer)
387 : {
388 85011 : case USER: ret = BootParams::getUserData(); break;
389 0 : case SHARED: ret = BootParams::getSharedData(); break;
390 : default:
391 : OSL_FAIL("[Java framework] NodeJava::getSettingsURL()");
392 : }
393 85011 : return ret;
394 : }
395 :
396 85011 : bool NodeJava::prepareSettingsDocument() const
397 : {
398 : OString sExcMsg(
399 : "[Java framework] Error in function prepareSettingsDocument"
400 85011 : " (elements.cxx).");
401 85011 : if (!createSettingsDocument())
402 : {
403 0 : return false;
404 : }
405 170022 : OString sSettings = getSettingsPath();
406 170022 : CXmlDocPtr doc(xmlParseFile(sSettings.getStr()));
407 85011 : if (!doc)
408 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
409 :
410 85011 : bool bNeedsSave = false;
411 85011 : createSettingsStructure(doc, & bNeedsSave);
412 85011 : if (bNeedsSave)
413 : {
414 1 : if (xmlSaveFormatFileEnc(
415 1 : sSettings.getStr(), doc,"UTF-8", 1) == -1)
416 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
417 : }
418 170022 : return true;
419 : }
420 :
421 1 : void NodeJava::write() const
422 : {
423 : OString sExcMsg("[Java framework] Error in function NodeJava::writeSettings "
424 1 : "(elements.cxx).");
425 2 : CXmlDocPtr docUser;
426 2 : CXPathContextPtr contextUser;
427 2 : CXPathObjectPtr pathObj;
428 :
429 1 : if (!prepareSettingsDocument())
430 : {
431 : SAL_INFO("jfw.level1", "no path to write settings document to");
432 1 : return;
433 : }
434 :
435 : //Read the user elements
436 2 : OString sSettingsPath = getSettingsPath();
437 1 : docUser = xmlParseFile(sSettingsPath.getStr());
438 1 : if (docUser == NULL)
439 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
440 1 : contextUser = xmlXPathNewContext(docUser);
441 1 : if (xmlXPathRegisterNs(contextUser, (xmlChar*) "jf",
442 1 : (xmlChar*) NS_JAVA_FRAMEWORK) == -1)
443 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
444 :
445 1 : xmlNode * root = xmlDocGetRootElement(docUser);
446 : //Get xsi:nil namespace
447 : xmlNs* nsXsi = xmlSearchNsByHref(docUser,
448 : root,
449 1 : (xmlChar*) NS_SCHEMA_INSTANCE);
450 :
451 : //set the <enabled> element
452 : //The element must exist
453 1 : if (m_enabled)
454 : {
455 : OString sExpression= OString(
456 0 : "/jf:java/jf:enabled");
457 0 : pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
458 0 : contextUser);
459 0 : if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
460 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
461 :
462 0 : xmlNode * nodeEnabled = pathObj->nodesetval->nodeTab[0];
463 : xmlSetNsProp(nodeEnabled,
464 : nsXsi,
465 : (xmlChar*) "nil",
466 0 : (xmlChar*) "false");
467 :
468 0 : if (m_enabled == boost::optional<sal_Bool>(sal_True))
469 0 : xmlNodeSetContent(nodeEnabled,(xmlChar*) "true");
470 : else
471 0 : xmlNodeSetContent(nodeEnabled,(xmlChar*) "false");
472 : }
473 :
474 : //set the <userClassPath> element
475 : //The element must exist
476 1 : if (m_userClassPath)
477 : {
478 : OString sExpression= OString(
479 0 : "/jf:java/jf:userClassPath");
480 0 : pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
481 0 : contextUser);
482 0 : if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
483 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
484 :
485 0 : xmlNode * nodeEnabled = pathObj->nodesetval->nodeTab[0];
486 0 : xmlSetNsProp(nodeEnabled, nsXsi, (xmlChar*) "nil",(xmlChar*) "false");
487 0 : xmlNodeSetContent(nodeEnabled,(xmlChar*) CXmlCharPtr(*m_userClassPath));
488 : }
489 :
490 : //set <javaInfo> element
491 1 : if (m_javaInfo)
492 : {
493 : OString sExpression= OString(
494 1 : "/jf:java/jf:javaInfo");
495 1 : pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
496 1 : contextUser);
497 1 : if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
498 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
499 : m_javaInfo->writeToNode(
500 1 : docUser, pathObj->nodesetval->nodeTab[0]);
501 : }
502 :
503 : //set <vmParameters> element
504 1 : if (m_vmParameters)
505 : {
506 : OString sExpression= OString(
507 0 : "/jf:java/jf:vmParameters");
508 0 : pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
509 0 : contextUser);
510 0 : if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
511 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
512 0 : xmlNode* vmParameters = pathObj->nodesetval->nodeTab[0];
513 : //set xsi:nil = false;
514 : xmlSetNsProp(vmParameters, nsXsi,(xmlChar*) "nil",
515 0 : (xmlChar*) "false");
516 :
517 : //remove option elements
518 0 : xmlNode* cur = vmParameters->children;
519 0 : while (cur != NULL)
520 : {
521 0 : xmlNode* lastNode = cur;
522 0 : cur = cur->next;
523 0 : xmlUnlinkNode(lastNode);
524 0 : xmlFreeNode(lastNode);
525 : }
526 : //add a new line after <vmParameters>
527 0 : if (m_vmParameters->size() > 0)
528 : {
529 0 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
530 0 : xmlAddChild(vmParameters, nodeCrLf);
531 : }
532 :
533 : typedef std::vector<OUString>::const_iterator cit;
534 0 : for (cit i = m_vmParameters->begin(); i != m_vmParameters->end(); ++i)
535 : {
536 : xmlNewTextChild(vmParameters, NULL, (xmlChar*) "param",
537 0 : CXmlCharPtr(*i));
538 : //add a new line
539 0 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
540 0 : xmlAddChild(vmParameters, nodeCrLf);
541 0 : }
542 : }
543 :
544 : //set <jreLocations> element
545 1 : if (m_JRELocations)
546 : {
547 : OString sExpression= OString(
548 0 : "/jf:java/jf:jreLocations");
549 0 : pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
550 0 : contextUser);
551 0 : if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
552 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
553 0 : xmlNode* jreLocationsNode = pathObj->nodesetval->nodeTab[0];
554 : //set xsi:nil = false;
555 : xmlSetNsProp(jreLocationsNode, nsXsi,(xmlChar*) "nil",
556 0 : (xmlChar*) "false");
557 :
558 : //remove option elements
559 0 : xmlNode* cur = jreLocationsNode->children;
560 0 : while (cur != NULL)
561 : {
562 0 : xmlNode* lastNode = cur;
563 0 : cur = cur->next;
564 0 : xmlUnlinkNode(lastNode);
565 0 : xmlFreeNode(lastNode);
566 : }
567 : //add a new line after <vmParameters>
568 0 : if (m_JRELocations->size() > 0)
569 : {
570 0 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
571 0 : xmlAddChild(jreLocationsNode, nodeCrLf);
572 : }
573 :
574 : typedef std::vector<OUString>::const_iterator cit;
575 0 : for (cit i = m_JRELocations->begin(); i != m_JRELocations->end(); ++i)
576 : {
577 : xmlNewTextChild(jreLocationsNode, NULL, (xmlChar*) "location",
578 0 : CXmlCharPtr(*i));
579 : //add a new line
580 0 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
581 0 : xmlAddChild(jreLocationsNode, nodeCrLf);
582 0 : }
583 : }
584 :
585 1 : if (xmlSaveFormatFile(sSettingsPath.getStr(), docUser, 1) == -1)
586 1 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
587 : }
588 :
589 0 : void NodeJava::setEnabled(bool bEnabled)
590 : {
591 0 : m_enabled = boost::optional<sal_Bool>(bEnabled);
592 0 : }
593 :
594 :
595 0 : void NodeJava::setUserClassPath(const OUString & sClassPath)
596 : {
597 0 : m_userClassPath = boost::optional<OUString>(sClassPath);
598 0 : }
599 :
600 1 : void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect)
601 : {
602 1 : if (!m_javaInfo)
603 1 : m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
604 1 : m_javaInfo->bAutoSelect = bAutoSelect;
605 1 : m_javaInfo->bNil = false;
606 :
607 1 : if (pInfo != NULL)
608 : {
609 1 : m_javaInfo->m_bEmptyNode = false;
610 1 : m_javaInfo->sVendor = pInfo->sVendor;
611 1 : m_javaInfo->sLocation = pInfo->sLocation;
612 1 : m_javaInfo->sVersion = pInfo->sVersion;
613 1 : m_javaInfo->nFeatures = pInfo->nFeatures;
614 1 : m_javaInfo->nRequirements = pInfo->nRequirements;
615 1 : m_javaInfo->arVendorData = pInfo->arVendorData;
616 : }
617 : else
618 : {
619 0 : m_javaInfo->m_bEmptyNode = true;
620 0 : OUString sEmpty;
621 0 : m_javaInfo->sVendor = sEmpty;
622 0 : m_javaInfo->sLocation = sEmpty;
623 0 : m_javaInfo->sVersion = sEmpty;
624 0 : m_javaInfo->nFeatures = 0;
625 0 : m_javaInfo->nRequirements = 0;
626 0 : m_javaInfo->arVendorData = rtl::ByteSequence();
627 : }
628 1 : }
629 :
630 0 : void NodeJava::setVmParameters(rtl_uString * * arOptions, sal_Int32 size)
631 : {
632 : OSL_ASSERT( !(arOptions == 0 && size != 0));
633 0 : if ( ! m_vmParameters)
634 0 : m_vmParameters = boost::optional<std::vector<OUString> >(
635 0 : std::vector<OUString>());
636 0 : m_vmParameters->clear();
637 0 : if (arOptions != NULL)
638 : {
639 0 : for (int i = 0; i < size; i++)
640 : {
641 0 : const OUString sOption(static_cast<rtl_uString*>(arOptions[i]));
642 0 : m_vmParameters->push_back(sOption);
643 0 : }
644 : }
645 0 : }
646 :
647 0 : void NodeJava::setJRELocations(rtl_uString * * arLocations, sal_Int32 size)
648 : {
649 : OSL_ASSERT( !(arLocations == 0 && size != 0));
650 0 : if (! m_JRELocations)
651 0 : m_JRELocations = boost::optional<std::vector<OUString> > (
652 0 : std::vector<OUString>());
653 0 : m_JRELocations->clear();
654 0 : if (arLocations != NULL)
655 : {
656 0 : for (int i = 0; i < size; i++)
657 : {
658 0 : const OUString & sLocation = static_cast<rtl_uString*>(arLocations[i]);
659 :
660 : //only add the path if not already present
661 : std::vector<OUString>::const_iterator it =
662 : std::find(m_JRELocations->begin(), m_JRELocations->end(),
663 0 : sLocation);
664 0 : if (it == m_JRELocations->end())
665 0 : m_JRELocations->push_back(sLocation);
666 0 : }
667 : }
668 0 : }
669 :
670 0 : void NodeJava::addJRELocation(rtl_uString * sLocation)
671 : {
672 : OSL_ASSERT( sLocation);
673 0 : if (!m_JRELocations)
674 0 : m_JRELocations = boost::optional<std::vector<OUString> >(
675 0 : std::vector<OUString> ());
676 : //only add the path if not already present
677 : std::vector<OUString>::const_iterator it =
678 : std::find(m_JRELocations->begin(), m_JRELocations->end(),
679 0 : OUString(sLocation));
680 0 : if (it == m_JRELocations->end())
681 0 : m_JRELocations->push_back(OUString(sLocation));
682 0 : }
683 :
684 170020 : const boost::optional<sal_Bool> & NodeJava::getEnabled() const
685 : {
686 170020 : return m_enabled;
687 : }
688 :
689 : const boost::optional<std::vector<OUString> >&
690 170020 : NodeJava::getJRELocations() const
691 : {
692 170020 : return m_JRELocations;
693 : }
694 :
695 170020 : const boost::optional<OUString> & NodeJava::getUserClassPath() const
696 : {
697 170020 : return m_userClassPath;
698 : }
699 :
700 170020 : const boost::optional<std::vector<OUString> > & NodeJava::getVmParameters() const
701 : {
702 170020 : return m_vmParameters;
703 : }
704 :
705 170020 : const boost::optional<CNodeJavaInfo> & NodeJava::getJavaInfo() const
706 : {
707 170020 : return m_javaInfo;
708 : }
709 :
710 85011 : jfw::FileStatus NodeJava::checkSettingsFileStatus(OUString const & sURL) const
711 : {
712 85011 : jfw::FileStatus ret = FILE_DOES_NOT_EXIST;
713 :
714 : //check the file time
715 85011 : ::osl::DirectoryItem item;
716 85011 : File::RC rc = ::osl::DirectoryItem::get(sURL, item);
717 85011 : if (File::E_None == rc)
718 : {
719 85010 : ::osl::FileStatus stat(osl_FileStatus_Mask_Validate);
720 85010 : File::RC rc_stat = item.getFileStatus(stat);
721 85010 : if (File::E_None == rc_stat)
722 : {
723 85010 : ret = FILE_OK;
724 : }
725 0 : else if (File::E_NOENT == rc_stat)
726 : {
727 0 : ret = FILE_DOES_NOT_EXIST;
728 : }
729 : else
730 : {
731 0 : ret = FILE_INVALID;
732 85010 : }
733 : }
734 1 : else if(File::E_NOENT == rc)
735 : {
736 1 : ret = FILE_DOES_NOT_EXIST;
737 : }
738 : else
739 : {
740 0 : ret = FILE_INVALID;
741 : }
742 85011 : return ret;
743 : }
744 :
745 85011 : bool NodeJava::createSettingsDocument() const
746 : {
747 85011 : const OUString sURL = getSettingsURL();
748 85011 : if (sURL.isEmpty())
749 : {
750 0 : return false;
751 : }
752 : //make sure there is a user directory
753 : OString sExcMsg("[Java framework] Error in function createSettingsDocument "
754 170022 : "(elements.cxx).");
755 : // check if javasettings.xml already exist
756 85011 : if (FILE_OK == checkSettingsFileStatus(sURL))
757 85010 : return true;
758 :
759 : //make sure that the directories are created in case they do not exist
760 1 : FileBase::RC rcFile = Directory::createPath(getDirFromFile(sURL));
761 1 : if (rcFile != FileBase::E_EXIST && rcFile != FileBase::E_None)
762 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
763 :
764 : //javasettings.xml does not exist yet
765 2 : CXmlDocPtr doc(xmlNewDoc((xmlChar *)"1.0"));
766 1 : if (! doc)
767 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
768 : //Create a comment
769 : xmlNewDocComment(
770 1 : doc, (xmlChar *) "This is a generated file. Do not alter this file!");
771 :
772 : //Create the root element and name spaces
773 : xmlNodePtr root = xmlNewDocNode(
774 1 : doc, NULL, (xmlChar *) "java", (xmlChar *) "\n");
775 :
776 1 : if (root == NULL)
777 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
778 :
779 1 : if (xmlNewNs(root, (xmlChar *) NS_JAVA_FRAMEWORK,NULL) == NULL)
780 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
781 1 : if (xmlNewNs(root,(xmlChar*) NS_SCHEMA_INSTANCE,(xmlChar*)"xsi") == NULL)
782 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
783 1 : xmlDocSetRootElement(doc, root);
784 :
785 : //Create a comment
786 : xmlNodePtr com = xmlNewComment(
787 1 : (xmlChar *) "This is a generated file. Do not alter this file!");
788 1 : if (com == NULL)
789 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
790 :
791 1 : if (xmlAddPrevSibling(root, com) == NULL)
792 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
793 :
794 2 : const OString path = getSettingsPath();
795 1 : if (xmlSaveFormatFileEnc(path.getStr(), doc,"UTF-8", 1) == -1)
796 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
797 85012 : return true;
798 : }
799 :
800 :
801 170019 : CNodeJavaInfo::CNodeJavaInfo() :
802 : m_bEmptyNode(false), bNil(true), bAutoSelect(true),
803 170019 : nFeatures(0), nRequirements(0)
804 : {
805 170019 : }
806 :
807 340037 : CNodeJavaInfo::~CNodeJavaInfo()
808 : {
809 340037 : }
810 :
811 85008 : void CNodeJavaInfo::loadFromNode(xmlDoc * pDoc, xmlNode * pJavaInfo)
812 : {
813 : OString sExcMsg("[Java framework] Error in function NodeJavaInfo::loadFromNode "
814 85008 : "(elements.cxx).");
815 :
816 : OSL_ASSERT(pJavaInfo && pDoc);
817 85008 : if (pJavaInfo->children == NULL)
818 0 : return;
819 : //Get the xsi:nil attribute;
820 170016 : CXmlCharPtr sNil;
821 85008 : sNil = xmlGetNsProp(
822 85008 : pJavaInfo, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
823 85008 : if ( ! sNil)
824 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
825 :
826 85008 : if (xmlStrcmp(sNil, (xmlChar*) "true") == 0)
827 0 : bNil = true;
828 85008 : else if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
829 85008 : bNil = false;
830 : else
831 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
832 85008 : if (bNil == true)
833 0 : return;
834 :
835 : //Get javaInfo@manuallySelected attribute
836 170016 : CXmlCharPtr sAutoSelect;
837 85008 : sAutoSelect = xmlGetProp(
838 85008 : pJavaInfo, (xmlChar*) "autoSelect");
839 85008 : if ( ! sAutoSelect)
840 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
841 :
842 85008 : if (xmlStrcmp(sAutoSelect, (xmlChar*) "true") == 0)
843 85008 : bAutoSelect = true;
844 0 : else if (xmlStrcmp(sAutoSelect, (xmlChar*) "false") == 0)
845 0 : bAutoSelect = false;
846 : else
847 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
848 :
849 85008 : xmlNode * cur = pJavaInfo->children;
850 :
851 1275120 : while (cur != NULL)
852 : {
853 1105104 : if (xmlStrcmp(cur->name, (xmlChar*) "vendor") == 0)
854 : {
855 85008 : CXmlCharPtr xmlVendor;
856 85008 : xmlVendor = xmlNodeListGetString(
857 85008 : pDoc, cur->children, 1);
858 85008 : if (! xmlVendor)
859 0 : return;
860 85008 : sVendor = xmlVendor;
861 : }
862 1020096 : else if (xmlStrcmp(cur->name, (xmlChar*) "location") == 0)
863 : {
864 85008 : CXmlCharPtr xmlLocation;
865 85008 : xmlLocation = xmlNodeListGetString(
866 85008 : pDoc, cur->children, 1);
867 85008 : sLocation = xmlLocation;
868 : }
869 935088 : else if (xmlStrcmp(cur->name, (xmlChar*) "version") == 0)
870 : {
871 85008 : CXmlCharPtr xmlVersion;
872 85008 : xmlVersion = xmlNodeListGetString(
873 85008 : pDoc, cur->children, 1);
874 85008 : sVersion = xmlVersion;
875 : }
876 850080 : else if (xmlStrcmp(cur->name, (xmlChar*) "features")== 0)
877 : {
878 85008 : CXmlCharPtr xmlFeatures;
879 85008 : xmlFeatures = xmlNodeListGetString(
880 85008 : pDoc, cur->children, 1);
881 170016 : OUString sFeatures = xmlFeatures;
882 170016 : nFeatures = sFeatures.toInt64(16);
883 : }
884 765072 : else if (xmlStrcmp(cur->name, (xmlChar*) "requirements") == 0)
885 : {
886 85008 : CXmlCharPtr xmlRequire;
887 85008 : xmlRequire = xmlNodeListGetString(
888 85008 : pDoc, cur->children, 1);
889 170016 : OUString sRequire = xmlRequire;
890 170016 : nRequirements = sRequire.toInt64(16);
891 : #ifdef MACOSX
892 : //javaldx is not used anymore in the mac build. In case the Java
893 : //corresponding to the saved settings does not exist anymore the
894 : //javavm services will look for an existing Java after creation of
895 : //the JVM failed. See stoc/source/javavm/javavm.cxx. Only if
896 : //nRequirements does not have the flag JFW_REQUIRE_NEEDRESTART the
897 : //jvm of the new selected JRE will be started. Old settings (before
898 : //OOo 3.3) still contain the flag which can be safely ignored.
899 : nRequirements &= ~JFW_REQUIRE_NEEDRESTART;
900 : #endif
901 : }
902 680064 : else if (xmlStrcmp(cur->name, (xmlChar*) "vendorData") == 0)
903 : {
904 85008 : CXmlCharPtr xmlData;
905 85008 : xmlData = xmlNodeListGetString(
906 85008 : pDoc, cur->children, 1);
907 85008 : xmlChar* _data = (xmlChar*) xmlData;
908 85008 : if (_data)
909 : {
910 85008 : rtl::ByteSequence seq((sal_Int8*) _data, strlen((char*)_data));
911 85008 : arVendorData = decodeBase16(seq);
912 85008 : }
913 : }
914 1105104 : cur = cur->next;
915 : }
916 :
917 85008 : if (sVendor.isEmpty())
918 0 : m_bEmptyNode = true;
919 : //Get the javainfo attributes
920 170016 : CXmlCharPtr sVendorUpdate;
921 85008 : sVendorUpdate = xmlGetProp(pJavaInfo,
922 85008 : (xmlChar*) "vendorUpdate");
923 85008 : if ( ! sVendorUpdate)
924 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
925 170016 : sAttrVendorUpdate = sVendorUpdate;
926 : }
927 :
928 :
929 1 : void CNodeJavaInfo::writeToNode(xmlDoc* pDoc,
930 : xmlNode* pJavaInfoNode) const
931 :
932 : {
933 : OSL_ASSERT(pJavaInfoNode && pDoc);
934 : //write the attribute vendorSettings
935 :
936 : //javaInfo@vendorUpdate
937 : //creates the attribute if necessary
938 1 : OString sUpdated = getElementUpdated();
939 :
940 : xmlSetProp(pJavaInfoNode, (xmlChar*)"vendorUpdate",
941 1 : (xmlChar*) sUpdated.getStr());
942 :
943 : //javaInfo@autoSelect
944 : xmlSetProp(pJavaInfoNode, (xmlChar*)"autoSelect",
945 1 : (xmlChar*) (bAutoSelect == true ? "true" : "false"));
946 :
947 : //Set xsi:nil in javaInfo element to false
948 : //the xmlNs pointer must not be destroyed
949 : xmlNs* nsXsi = xmlSearchNsByHref((xmlDoc*) pDoc,
950 : pJavaInfoNode,
951 1 : (xmlChar*) NS_SCHEMA_INSTANCE);
952 :
953 : xmlSetNsProp(pJavaInfoNode,
954 : nsXsi,
955 : (xmlChar*) "nil",
956 1 : (xmlChar*) "false");
957 :
958 : //Delete the children of JavaInfo
959 1 : xmlNode* cur = pJavaInfoNode->children;
960 2 : while (cur != NULL)
961 : {
962 0 : xmlNode* lastNode = cur;
963 0 : cur = cur->next;
964 0 : xmlUnlinkNode(lastNode);
965 0 : xmlFreeNode(lastNode);
966 : }
967 :
968 : //If the JavaInfo was set with an empty value,
969 : //then we are done.
970 1 : if (m_bEmptyNode)
971 1 : return;
972 :
973 : //add a new line after <javaInfo>
974 1 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
975 1 : xmlAddChild(pJavaInfoNode, nodeCrLf);
976 :
977 : //Create the vendor element
978 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "vendor",
979 1 : CXmlCharPtr(sVendor));
980 : //add a new line for better readability
981 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
982 1 : xmlAddChild(pJavaInfoNode, nodeCrLf);
983 :
984 : //Create the location element
985 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "location",
986 1 : CXmlCharPtr(sLocation));
987 : //add a new line for better readability
988 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
989 1 : xmlAddChild(pJavaInfoNode, nodeCrLf);
990 :
991 : //Create the version element
992 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "version",
993 1 : CXmlCharPtr(sVersion));
994 : //add a new line for better readability
995 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
996 1 : xmlAddChild(pJavaInfoNode, nodeCrLf);
997 :
998 : //Create the features element
999 : OUString sFeatures = OUString::number(
1000 2 : nFeatures, 16);
1001 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "features",
1002 1 : CXmlCharPtr(sFeatures));
1003 : //add a new line for better readability
1004 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
1005 1 : xmlAddChild(pJavaInfoNode, nodeCrLf);
1006 :
1007 :
1008 : //Create the requirements element
1009 : OUString sRequirements = OUString::number(
1010 2 : nRequirements, 16);
1011 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "requirements",
1012 1 : CXmlCharPtr(sRequirements));
1013 : //add a new line for better readability
1014 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
1015 1 : xmlAddChild(pJavaInfoNode, nodeCrLf);
1016 :
1017 :
1018 : //Create the features element
1019 2 : rtl::ByteSequence data = encodeBase16(arVendorData);
1020 : xmlNode* dataNode = xmlNewChild(pJavaInfoNode, NULL,
1021 : (xmlChar*) "vendorData",
1022 1 : (xmlChar*) "");
1023 : xmlNodeSetContentLen(dataNode,
1024 1 : (xmlChar*) data.getArray(), data.getLength());
1025 : //add a new line for better readability
1026 1 : nodeCrLf = xmlNewText((xmlChar*) "\n");
1027 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
1028 : }
1029 :
1030 42505 : JavaInfo * CNodeJavaInfo::makeJavaInfo() const
1031 : {
1032 42505 : if (bNil == true || m_bEmptyNode == true)
1033 1 : return NULL;
1034 42504 : JavaInfo * pInfo = (JavaInfo*) rtl_allocateMemory(sizeof(JavaInfo));
1035 42504 : if (pInfo == NULL)
1036 0 : return NULL;
1037 42504 : memset(pInfo, 0, sizeof(JavaInfo));
1038 42504 : pInfo->sVendor = sVendor.pData;
1039 42504 : rtl_uString_acquire(pInfo->sVendor);
1040 42504 : pInfo->sLocation = sLocation.pData;
1041 42504 : rtl_uString_acquire(pInfo->sLocation);
1042 42504 : pInfo->sVersion = sVersion.pData;
1043 42504 : rtl_uString_acquire(pInfo->sVersion);
1044 42504 : pInfo->nFeatures = nFeatures;
1045 42504 : pInfo->nRequirements = nRequirements;
1046 42504 : pInfo->arVendorData = arVendorData.getHandle();
1047 42504 : rtl_byte_sequence_acquire(pInfo->arVendorData);
1048 42504 : return pInfo;
1049 : }
1050 :
1051 :
1052 85010 : MergedSettings::MergedSettings():
1053 : m_bEnabled(false),
1054 : m_sClassPath(),
1055 : m_vmParams(),
1056 : m_JRELocations(),
1057 85010 : m_javaInfo()
1058 : {
1059 85010 : NodeJava settings(NodeJava::USER);
1060 85010 : settings.load();
1061 170020 : NodeJava sharedSettings(NodeJava::SHARED);
1062 85010 : sharedSettings.load();
1063 170020 : merge(sharedSettings, settings);
1064 85010 : }
1065 :
1066 85010 : MergedSettings::~MergedSettings()
1067 : {
1068 85010 : }
1069 :
1070 85010 : void MergedSettings::merge(const NodeJava & share, const NodeJava & user)
1071 : {
1072 85010 : if (user.getEnabled())
1073 0 : m_bEnabled = * user.getEnabled();
1074 85010 : else if (share.getEnabled())
1075 0 : m_bEnabled = * share.getEnabled();
1076 : else
1077 85010 : m_bEnabled = true;
1078 :
1079 85010 : if (user.getUserClassPath())
1080 0 : m_sClassPath = * user.getUserClassPath();
1081 85010 : else if (share.getUserClassPath())
1082 0 : m_sClassPath = * share.getUserClassPath();
1083 :
1084 85010 : if (user.getJavaInfo())
1085 85008 : m_javaInfo = * user.getJavaInfo();
1086 2 : else if (share.getJavaInfo())
1087 0 : m_javaInfo = * share.getJavaInfo();
1088 :
1089 85010 : if (user.getVmParameters())
1090 0 : m_vmParams = * user.getVmParameters();
1091 85010 : else if (share.getVmParameters())
1092 0 : m_vmParams = * share.getVmParameters();
1093 :
1094 85010 : if (user.getJRELocations())
1095 0 : m_JRELocations = * user.getJRELocations();
1096 85010 : else if (share.getJRELocations())
1097 0 : m_JRELocations = * share.getJRELocations();
1098 85010 : }
1099 :
1100 42505 : bool MergedSettings::getEnabled() const
1101 : {
1102 42505 : return m_bEnabled;
1103 : }
1104 0 : const OUString& MergedSettings::getUserClassPath() const
1105 : {
1106 0 : return m_sClassPath;
1107 : }
1108 :
1109 0 : ::std::vector< OString> MergedSettings::getVmParametersUtf8() const
1110 : {
1111 0 : ::std::vector< OString> ret;
1112 : typedef ::std::vector< OUString>::const_iterator cit;
1113 0 : for (cit i = m_vmParams.begin(); i != m_vmParams.end(); ++i)
1114 : {
1115 0 : ret.push_back( OUStringToOString(*i, RTL_TEXTENCODING_UTF8));
1116 : }
1117 0 : return ret;
1118 : }
1119 :
1120 42504 : const OString & MergedSettings::getJavaInfoAttrVendorUpdate() const
1121 : {
1122 42504 : return m_javaInfo.sAttrVendorUpdate;
1123 : }
1124 :
1125 :
1126 42505 : JavaInfo * MergedSettings::createJavaInfo() const
1127 : {
1128 42505 : return m_javaInfo.makeJavaInfo();
1129 : }
1130 : #ifdef WNT
1131 : bool MergedSettings::getJavaInfoAttrAutoSelect() const
1132 : {
1133 : return m_javaInfo.bAutoSelect;
1134 : }
1135 : #endif
1136 0 : void MergedSettings::getVmParametersArray(
1137 : rtl_uString *** parParams, sal_Int32 * size) const
1138 : {
1139 0 : osl::MutexGuard guard(FwkMutex::get());
1140 : OSL_ASSERT(parParams != NULL && size != NULL);
1141 :
1142 : *parParams = (rtl_uString **)
1143 0 : rtl_allocateMemory(sizeof(rtl_uString*) * m_vmParams.size());
1144 0 : if (*parParams == NULL)
1145 0 : return;
1146 :
1147 0 : int j=0;
1148 : typedef std::vector<OUString>::const_iterator it;
1149 0 : for (it i = m_vmParams.begin(); i != m_vmParams.end();
1150 : ++i, ++j)
1151 : {
1152 0 : (*parParams)[j] = i->pData;
1153 0 : rtl_uString_acquire(i->pData);
1154 : }
1155 0 : *size = m_vmParams.size();
1156 : }
1157 :
1158 0 : void MergedSettings::getJRELocations(
1159 : rtl_uString *** parLocations, sal_Int32 * size) const
1160 : {
1161 0 : osl::MutexGuard guard(FwkMutex::get());
1162 : OSL_ASSERT(parLocations != NULL && size != NULL);
1163 :
1164 : *parLocations = (rtl_uString **)
1165 0 : rtl_allocateMemory(sizeof(rtl_uString*) * m_JRELocations.size());
1166 0 : if (*parLocations == NULL)
1167 0 : return;
1168 :
1169 0 : int j=0;
1170 : typedef std::vector<OUString>::const_iterator it;
1171 0 : for (it i = m_JRELocations.begin(); i != m_JRELocations.end();
1172 : ++i, ++j)
1173 : {
1174 0 : (*parLocations)[j] = i->pData;
1175 0 : rtl_uString_acquire(i->pData);
1176 : }
1177 0 : *size = m_JRELocations.size();
1178 : }
1179 0 : const std::vector<OUString> & MergedSettings::getJRELocations() const
1180 : {
1181 0 : return m_JRELocations;
1182 : }
1183 : }
1184 :
1185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|