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 2 : 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 2 : jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr()));
51 2 : if (doc == NULL)
52 : throw FrameworkException(
53 : JFW_E_ERROR,
54 : OString("[Java framework] Error in function getElement "
55 0 : "(elements.cxx)"));
56 :
57 4 : jfw::CXPathContextPtr context(xmlXPathNewContext(doc));
58 2 : if (xmlXPathRegisterNs(context, (xmlChar*) "jf",
59 2 : (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 4 : CXPathObjectPtr pathObj;
66 2 : pathObj = xmlXPathEvalExpression(pathExpression, context);
67 2 : OString sValue;
68 2 : 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 2 : sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content;
79 : }
80 4 : return sValue;
81 : }
82 :
83 2 : OString getElementUpdated()
84 : {
85 : return getElement(jfw::getVendorSettingsPath(),
86 2 : (xmlChar*)"/jf:javaSelection/jf:updated/text()", true);
87 : }
88 :
89 20 : void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
90 : {
91 : OString sExcMsg("[Java framework] Error in function createSettingsStructure "
92 20 : "(elements.cxx).");
93 20 : xmlNode * root = xmlDocGetRootElement(document);
94 20 : if (root == NULL)
95 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
96 20 : bool bFound = false;
97 20 : xmlNode * cur = root->children;
98 60 : while (cur != NULL)
99 : {
100 38 : if (xmlStrcmp(cur->name, (xmlChar*) "enabled") == 0)
101 : {
102 18 : bFound = true;
103 18 : break;
104 : }
105 20 : cur = cur->next;
106 : }
107 20 : if (bFound)
108 : {
109 18 : *bNeedsSave = false;
110 38 : return;
111 : }
112 : //We will modify this document
113 2 : *bNeedsSave = true;
114 : // Now we create the child elements ------------------
115 : //Get xsi:nil namespace
116 : xmlNs* nsXsi = xmlSearchNsByHref(
117 2 : document, root,(xmlChar*) NS_SCHEMA_INSTANCE);
118 :
119 : //<enabled xsi:nil="true"
120 : xmlNode * nodeEn = xmlNewTextChild(
121 2 : root,NULL, (xmlChar*) "enabled", (xmlChar*) "");
122 2 : if (nodeEn == NULL)
123 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
124 2 : xmlSetNsProp(nodeEn,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
125 : //add a new line
126 2 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
127 2 : xmlAddChild(root, nodeCrLf);
128 :
129 : //<userClassPath xsi:nil="true">
130 : xmlNode * nodeUs = xmlNewTextChild(
131 2 : root,NULL, (xmlChar*) "userClassPath", (xmlChar*) "");
132 2 : if (nodeUs == NULL)
133 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
134 2 : xmlSetNsProp(nodeUs,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
135 : //add a new line
136 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
137 2 : xmlAddChild(root, nodeCrLf);
138 :
139 : //<vmParameters xsi:nil="true">
140 : xmlNode * nodeVm = xmlNewTextChild(
141 2 : root,NULL, (xmlChar*) "vmParameters", (xmlChar*) "");
142 2 : if (nodeVm == NULL)
143 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
144 2 : xmlSetNsProp(nodeVm,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
145 : //add a new line
146 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
147 2 : xmlAddChild(root, nodeCrLf);
148 :
149 : //<jreLocations xsi:nil="true">
150 : xmlNode * nodeJre = xmlNewTextChild(
151 2 : root,NULL, (xmlChar*) "jreLocations", (xmlChar*) "");
152 2 : if (nodeJre == NULL)
153 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
154 2 : xmlSetNsProp(nodeJre,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
155 : //add a new line
156 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
157 2 : xmlAddChild(root, nodeCrLf);
158 :
159 : //<javaInfo xsi:nil="true">
160 : xmlNode * nodeJava = xmlNewTextChild(
161 2 : root,NULL, (xmlChar*) "javaInfo", (xmlChar*) "");
162 2 : if (nodeJava == NULL)
163 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
164 2 : xmlSetNsProp(nodeJava,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
165 : //add a new line
166 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
167 2 : xmlAddChild(root, nodeCrLf);
168 : }
169 :
170 :
171 :
172 232 : VersionInfo::VersionInfo(): arVersions(NULL)
173 : {
174 232 : }
175 :
176 464 : VersionInfo::~VersionInfo()
177 : {
178 232 : delete [] arVersions;
179 232 : }
180 :
181 0 : void VersionInfo::addExcludeVersion(const OUString& sVersion)
182 : {
183 0 : vecExcludeVersions.push_back(sVersion);
184 0 : }
185 :
186 232 : rtl_uString** VersionInfo::getExcludeVersions()
187 : {
188 232 : osl::MutexGuard guard(FwkMutex::get());
189 232 : if (arVersions != NULL)
190 0 : return arVersions;
191 :
192 232 : arVersions = new rtl_uString*[vecExcludeVersions.size()];
193 232 : int j=0;
194 : typedef std::vector<OUString>::const_iterator it;
195 232 : for (it i = vecExcludeVersions.begin(); i != vecExcludeVersions.end();
196 : ++i, ++j)
197 : {
198 0 : arVersions[j] = vecExcludeVersions[j].pData;
199 : }
200 232 : return arVersions;
201 : }
202 :
203 232 : sal_Int32 VersionInfo::getExcludeVersionSize()
204 : {
205 232 : return vecExcludeVersions.size();
206 : }
207 :
208 :
209 106 : NodeJava::NodeJava(Layer layer):
210 106 : m_layer(layer)
211 : {
212 : //This class reads and write to files which should only be done in
213 : //application mode
214 106 : 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 106 : }
219 :
220 :
221 92 : void NodeJava::load()
222 : {
223 : const OString sExcMsg("[Java framework] Error in function NodeJava::load"
224 92 : "(elements.cxx).");
225 92 : 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 46 : OUString sURL(BootParams::getSharedData());
231 46 : jfw::FileStatus s = sURL.isEmpty()
232 46 : ? FILE_DOES_NOT_EXIST : checkFileURL(sURL);
233 46 : if (s == FILE_INVALID)
234 : throw FrameworkException(
235 : JFW_E_ERROR,
236 0 : "[Java framework] Invalid file for shared Java settings.");
237 46 : else if (s == FILE_DOES_NOT_EXIST)
238 : //Writing shared data is not supported yet.
239 46 : return;
240 : }
241 46 : else if (USER == m_layer)
242 : {
243 46 : if (!prepareSettingsDocument())
244 : {
245 : SAL_INFO("jfw.level1", "no path to load user settings document from");
246 28 : return;
247 : }
248 : }
249 : else
250 : {
251 : OSL_FAIL("[Java framework] Unknown enum used.");
252 : }
253 :
254 :
255 : //Read the user elements
256 36 : OString sSettingsPath = getSettingsPath();
257 : //There must not be a share settings file
258 36 : CXmlDocPtr docUser(xmlParseFile(sSettingsPath.getStr()));
259 18 : if (docUser == NULL)
260 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
261 :
262 18 : xmlNode * cur = xmlDocGetRootElement(docUser);
263 18 : if (cur == NULL || cur->children == NULL)
264 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
265 :
266 36 : CXmlCharPtr sNil;
267 18 : cur = cur->children;
268 234 : while (cur != NULL)
269 : {
270 198 : if (xmlStrcmp(cur->name, (xmlChar*) "enabled") == 0)
271 : {
272 : //only overwrite share settings if xsi:nil="false"
273 18 : sNil = xmlGetNsProp(
274 18 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
275 18 : if (sNil == NULL)
276 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);;
277 18 : 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 180 : else if (xmlStrcmp(cur->name, (xmlChar*) "userClassPath") == 0)
288 : {
289 18 : sNil = xmlGetNsProp(
290 18 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
291 18 : if (sNil == NULL)
292 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
293 18 : 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 162 : else if (xmlStrcmp(cur->name, (xmlChar*) "javaInfo") == 0)
301 : {
302 18 : sNil = xmlGetNsProp(
303 18 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
304 18 : if (sNil == NULL)
305 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
306 :
307 18 : if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
308 : {
309 16 : if (! m_javaInfo)
310 16 : m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
311 16 : m_javaInfo->loadFromNode(docUser, cur);
312 : }
313 : }
314 144 : else if (xmlStrcmp(cur->name, (xmlChar*) "vmParameters") == 0)
315 : {
316 18 : sNil = xmlGetNsProp(
317 18 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
318 18 : if (sNil == NULL)
319 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
320 18 : 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 126 : else if (xmlStrcmp(cur->name, (xmlChar*) "jreLocations") == 0)
341 : {
342 18 : sNil = xmlGetNsProp(
343 18 : cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
344 18 : if (sNil == NULL)
345 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
346 18 : 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 198 : cur = cur->next;
367 18 : }
368 : }
369 :
370 42 : OString NodeJava::getSettingsPath() const
371 : {
372 42 : OString ret;
373 42 : switch (m_layer)
374 : {
375 42 : case USER: ret = getUserSettingsPath(); break;
376 0 : case SHARED: ret = getSharedSettingsPath(); break;
377 : default:
378 : OSL_FAIL("[Java framework] NodeJava::getSettingsPath()");
379 : }
380 42 : return ret;
381 : }
382 :
383 60 : OUString NodeJava::getSettingsURL() const
384 : {
385 60 : OUString ret;
386 60 : switch (m_layer)
387 : {
388 60 : 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 60 : return ret;
394 : }
395 :
396 60 : bool NodeJava::prepareSettingsDocument() const
397 : {
398 : OString sExcMsg(
399 : "[Java framework] Error in function prepareSettingsDocument"
400 60 : " (elements.cxx).");
401 60 : if (!createSettingsDocument())
402 : {
403 40 : return false;
404 : }
405 40 : OString sSettings = getSettingsPath();
406 40 : CXmlDocPtr doc(xmlParseFile(sSettings.getStr()));
407 20 : if (!doc)
408 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
409 :
410 20 : bool bNeedsSave = false;
411 20 : createSettingsStructure(doc, & bNeedsSave);
412 20 : if (bNeedsSave)
413 : {
414 2 : if (xmlSaveFormatFileEnc(
415 2 : sSettings.getStr(), doc,"UTF-8", 1) == -1)
416 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
417 : }
418 80 : return true;
419 : }
420 :
421 14 : void NodeJava::write() const
422 : {
423 : OString sExcMsg("[Java framework] Error in function NodeJava::writeSettings "
424 14 : "(elements.cxx).");
425 16 : CXmlDocPtr docUser;
426 16 : CXPathContextPtr contextUser;
427 16 : CXPathObjectPtr pathObj;
428 :
429 14 : if (!prepareSettingsDocument())
430 : {
431 : SAL_INFO("jfw.level1", "no path to write settings document to");
432 26 : return;
433 : }
434 :
435 : //Read the user elements
436 4 : OString sSettingsPath = getSettingsPath();
437 2 : docUser = xmlParseFile(sSettingsPath.getStr());
438 2 : if (docUser == NULL)
439 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
440 2 : contextUser = xmlXPathNewContext(docUser);
441 2 : if (xmlXPathRegisterNs(contextUser, (xmlChar*) "jf",
442 2 : (xmlChar*) NS_JAVA_FRAMEWORK) == -1)
443 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
444 :
445 2 : xmlNode * root = xmlDocGetRootElement(docUser);
446 : //Get xsi:nil namespace
447 : xmlNs* nsXsi = xmlSearchNsByHref(docUser,
448 : root,
449 2 : (xmlChar*) NS_SCHEMA_INSTANCE);
450 :
451 : //set the <enabled> element
452 : //The element must exist
453 2 : 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 2 : 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 2 : if (m_javaInfo)
492 : {
493 : OString sExpression= OString(
494 2 : "/jf:java/jf:javaInfo");
495 2 : pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
496 2 : contextUser);
497 2 : if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
498 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
499 : m_javaInfo->writeToNode(
500 2 : docUser, pathObj->nodesetval->nodeTab[0]);
501 : }
502 :
503 : //set <vmParameters> element
504 2 : 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 2 : 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 2 : if (xmlSaveFormatFile(sSettingsPath.getStr(), docUser, 1) == -1)
586 2 : 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 14 : void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect)
601 : {
602 14 : if (!m_javaInfo)
603 14 : m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
604 14 : m_javaInfo->bAutoSelect = bAutoSelect;
605 14 : m_javaInfo->bNil = false;
606 :
607 14 : if (pInfo != NULL)
608 : {
609 14 : m_javaInfo->m_bEmptyNode = false;
610 14 : m_javaInfo->sVendor = pInfo->sVendor;
611 14 : m_javaInfo->sLocation = pInfo->sLocation;
612 14 : m_javaInfo->sVersion = pInfo->sVersion;
613 14 : m_javaInfo->nFeatures = pInfo->nFeatures;
614 14 : m_javaInfo->nRequirements = pInfo->nRequirements;
615 14 : 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 14 : }
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 :
685 :
686 :
687 :
688 :
689 20 : jfw::FileStatus NodeJava::checkSettingsFileStatus(OUString const & sURL) const
690 : {
691 20 : jfw::FileStatus ret = FILE_DOES_NOT_EXIST;
692 :
693 : //check the file time
694 20 : ::osl::DirectoryItem item;
695 20 : File::RC rc = ::osl::DirectoryItem::get(sURL, item);
696 20 : if (File::E_None == rc)
697 : {
698 18 : ::osl::FileStatus stat(osl_FileStatus_Mask_Validate);
699 18 : File::RC rc_stat = item.getFileStatus(stat);
700 18 : if (File::E_None == rc_stat)
701 : {
702 18 : ret = FILE_OK;
703 : }
704 0 : else if (File::E_NOENT == rc_stat)
705 : {
706 0 : ret = FILE_DOES_NOT_EXIST;
707 : }
708 : else
709 : {
710 0 : ret = FILE_INVALID;
711 18 : }
712 : }
713 2 : else if(File::E_NOENT == rc)
714 : {
715 2 : ret = FILE_DOES_NOT_EXIST;
716 : }
717 : else
718 : {
719 0 : ret = FILE_INVALID;
720 : }
721 20 : return ret;
722 : }
723 :
724 60 : bool NodeJava::createSettingsDocument() const
725 : {
726 60 : const OUString sURL = getSettingsURL();
727 60 : if (sURL.isEmpty())
728 : {
729 40 : return false;
730 : }
731 : //make sure there is a user directory
732 : OString sExcMsg("[Java framework] Error in function createSettingsDocument "
733 40 : "(elements.cxx).");
734 : // check if javasettings.xml already exist
735 20 : if (FILE_OK == checkSettingsFileStatus(sURL))
736 18 : return true;
737 :
738 : //make sure that the directories are created in case they do not exist
739 2 : FileBase::RC rcFile = Directory::createPath(getDirFromFile(sURL));
740 2 : if (rcFile != FileBase::E_EXIST && rcFile != FileBase::E_None)
741 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
742 :
743 : //javasettings.xml does not exist yet
744 4 : CXmlDocPtr doc(xmlNewDoc((xmlChar *)"1.0"));
745 2 : if (! doc)
746 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
747 :
748 : //Create the root element and name spaces
749 : xmlNodePtr root = xmlNewDocNode(
750 2 : doc, NULL, (xmlChar *) "java", (xmlChar *) "\n");
751 :
752 2 : if (root == NULL)
753 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
754 :
755 2 : if (xmlNewNs(root, (xmlChar *) NS_JAVA_FRAMEWORK,NULL) == NULL)
756 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
757 2 : if (xmlNewNs(root,(xmlChar*) NS_SCHEMA_INSTANCE,(xmlChar*)"xsi") == NULL)
758 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
759 2 : xmlDocSetRootElement(doc, root);
760 :
761 : //Create a comment
762 : xmlNodePtr com = xmlNewComment(
763 2 : (xmlChar *) "This is a generated file. Do not alter this file!");
764 2 : if (com == NULL)
765 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
766 :
767 2 : if (xmlAddPrevSibling(root, com) == NULL)
768 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
769 :
770 4 : const OString path = getSettingsPath();
771 2 : if (xmlSaveFormatFileEnc(path.getStr(), doc,"UTF-8", 1) == -1)
772 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
773 62 : return true;
774 : }
775 :
776 :
777 76 : CNodeJavaInfo::CNodeJavaInfo() :
778 : m_bEmptyNode(false), bNil(true), bAutoSelect(true),
779 76 : nFeatures(0), nRequirements(0)
780 : {
781 76 : }
782 :
783 136 : CNodeJavaInfo::~CNodeJavaInfo()
784 : {
785 136 : }
786 :
787 16 : void CNodeJavaInfo::loadFromNode(xmlDoc * pDoc, xmlNode * pJavaInfo)
788 : {
789 : OString sExcMsg("[Java framework] Error in function NodeJavaInfo::loadFromNode "
790 16 : "(elements.cxx).");
791 :
792 : OSL_ASSERT(pJavaInfo && pDoc);
793 16 : if (pJavaInfo->children == NULL)
794 0 : return;
795 : //Get the xsi:nil attribute;
796 32 : CXmlCharPtr sNil;
797 16 : sNil = xmlGetNsProp(
798 16 : pJavaInfo, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE);
799 16 : if ( ! sNil)
800 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
801 :
802 16 : if (xmlStrcmp(sNil, (xmlChar*) "true") == 0)
803 0 : bNil = true;
804 16 : else if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
805 16 : bNil = false;
806 : else
807 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
808 16 : if (bNil == true)
809 0 : return;
810 :
811 : //Get javaInfo@manuallySelected attribute
812 32 : CXmlCharPtr sAutoSelect;
813 16 : sAutoSelect = xmlGetProp(
814 16 : pJavaInfo, (xmlChar*) "autoSelect");
815 16 : if ( ! sAutoSelect)
816 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
817 :
818 16 : if (xmlStrcmp(sAutoSelect, (xmlChar*) "true") == 0)
819 16 : bAutoSelect = true;
820 0 : else if (xmlStrcmp(sAutoSelect, (xmlChar*) "false") == 0)
821 0 : bAutoSelect = false;
822 : else
823 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
824 :
825 16 : xmlNode * cur = pJavaInfo->children;
826 :
827 240 : while (cur != NULL)
828 : {
829 208 : if (xmlStrcmp(cur->name, (xmlChar*) "vendor") == 0)
830 : {
831 16 : CXmlCharPtr xmlVendor;
832 16 : xmlVendor = xmlNodeListGetString(
833 16 : pDoc, cur->children, 1);
834 16 : if (! xmlVendor)
835 0 : return;
836 16 : sVendor = xmlVendor;
837 : }
838 192 : else if (xmlStrcmp(cur->name, (xmlChar*) "location") == 0)
839 : {
840 16 : CXmlCharPtr xmlLocation;
841 16 : xmlLocation = xmlNodeListGetString(
842 16 : pDoc, cur->children, 1);
843 16 : sLocation = xmlLocation;
844 : }
845 176 : else if (xmlStrcmp(cur->name, (xmlChar*) "version") == 0)
846 : {
847 16 : CXmlCharPtr xmlVersion;
848 16 : xmlVersion = xmlNodeListGetString(
849 16 : pDoc, cur->children, 1);
850 16 : sVersion = xmlVersion;
851 : }
852 160 : else if (xmlStrcmp(cur->name, (xmlChar*) "features")== 0)
853 : {
854 16 : CXmlCharPtr xmlFeatures;
855 16 : xmlFeatures = xmlNodeListGetString(
856 16 : pDoc, cur->children, 1);
857 32 : OUString sFeatures = xmlFeatures;
858 32 : nFeatures = sFeatures.toInt64(16);
859 : }
860 144 : else if (xmlStrcmp(cur->name, (xmlChar*) "requirements") == 0)
861 : {
862 16 : CXmlCharPtr xmlRequire;
863 16 : xmlRequire = xmlNodeListGetString(
864 16 : pDoc, cur->children, 1);
865 32 : OUString sRequire = xmlRequire;
866 32 : nRequirements = sRequire.toInt64(16);
867 : #ifdef MACOSX
868 : //javaldx is not used anymore in the mac build. In case the Java
869 : //corresponding to the saved settings does not exist anymore the
870 : //javavm services will look for an existing Java after creation of
871 : //the JVM failed. See stoc/source/javavm/javavm.cxx. Only if
872 : //nRequirements does not have the flag JFW_REQUIRE_NEEDRESTART the
873 : //jvm of the new selected JRE will be started. Old settings (before
874 : //OOo 3.3) still contain the flag which can be safely ignored.
875 : nRequirements &= ~JFW_REQUIRE_NEEDRESTART;
876 : #endif
877 : }
878 128 : else if (xmlStrcmp(cur->name, (xmlChar*) "vendorData") == 0)
879 : {
880 16 : CXmlCharPtr xmlData;
881 16 : xmlData = xmlNodeListGetString(
882 16 : pDoc, cur->children, 1);
883 16 : xmlChar* _data = (xmlChar*) xmlData;
884 16 : if (_data)
885 : {
886 16 : rtl::ByteSequence seq((sal_Int8*) _data, strlen((char*)_data));
887 16 : arVendorData = decodeBase16(seq);
888 16 : }
889 : }
890 208 : cur = cur->next;
891 : }
892 :
893 16 : if (sVendor.isEmpty())
894 0 : m_bEmptyNode = true;
895 : //Get the javainfo attributes
896 32 : CXmlCharPtr sVendorUpdate;
897 16 : sVendorUpdate = xmlGetProp(pJavaInfo,
898 16 : (xmlChar*) "vendorUpdate");
899 16 : if ( ! sVendorUpdate)
900 0 : throw FrameworkException(JFW_E_ERROR, sExcMsg);
901 32 : sAttrVendorUpdate = sVendorUpdate;
902 : }
903 :
904 :
905 2 : void CNodeJavaInfo::writeToNode(xmlDoc* pDoc,
906 : xmlNode* pJavaInfoNode) const
907 :
908 : {
909 : OSL_ASSERT(pJavaInfoNode && pDoc);
910 : //write the attribute vendorSettings
911 :
912 : //javaInfo@vendorUpdate
913 : //creates the attribute if necessary
914 2 : OString sUpdated = getElementUpdated();
915 :
916 : xmlSetProp(pJavaInfoNode, (xmlChar*)"vendorUpdate",
917 2 : (xmlChar*) sUpdated.getStr());
918 :
919 : //javaInfo@autoSelect
920 : xmlSetProp(pJavaInfoNode, (xmlChar*)"autoSelect",
921 2 : (xmlChar*) (bAutoSelect == true ? "true" : "false"));
922 :
923 : //Set xsi:nil in javaInfo element to false
924 : //the xmlNs pointer must not be destroyed
925 : xmlNs* nsXsi = xmlSearchNsByHref((xmlDoc*) pDoc,
926 : pJavaInfoNode,
927 2 : (xmlChar*) NS_SCHEMA_INSTANCE);
928 :
929 : xmlSetNsProp(pJavaInfoNode,
930 : nsXsi,
931 : (xmlChar*) "nil",
932 2 : (xmlChar*) "false");
933 :
934 : //Delete the children of JavaInfo
935 2 : xmlNode* cur = pJavaInfoNode->children;
936 4 : while (cur != NULL)
937 : {
938 0 : xmlNode* lastNode = cur;
939 0 : cur = cur->next;
940 0 : xmlUnlinkNode(lastNode);
941 0 : xmlFreeNode(lastNode);
942 : }
943 :
944 : //If the JavaInfo was set with an empty value,
945 : //then we are done.
946 2 : if (m_bEmptyNode)
947 2 : return;
948 :
949 : //add a new line after <javaInfo>
950 2 : xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
951 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
952 :
953 : //Create the vendor element
954 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "vendor",
955 2 : CXmlCharPtr(sVendor));
956 : //add a new line for better readability
957 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
958 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
959 :
960 : //Create the location element
961 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "location",
962 2 : CXmlCharPtr(sLocation));
963 : //add a new line for better readability
964 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
965 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
966 :
967 : //Create the version element
968 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "version",
969 2 : CXmlCharPtr(sVersion));
970 : //add a new line for better readability
971 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
972 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
973 :
974 : //Create the features element
975 : OUString sFeatures = OUString::number(
976 4 : nFeatures, 16);
977 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "features",
978 2 : CXmlCharPtr(sFeatures));
979 : //add a new line for better readability
980 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
981 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
982 :
983 :
984 : //Create the requirements element
985 : OUString sRequirements = OUString::number(
986 4 : nRequirements, 16);
987 : xmlNewTextChild(pJavaInfoNode, NULL, (xmlChar*) "requirements",
988 2 : CXmlCharPtr(sRequirements));
989 : //add a new line for better readability
990 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
991 2 : xmlAddChild(pJavaInfoNode, nodeCrLf);
992 :
993 :
994 : //Create the features element
995 4 : rtl::ByteSequence data = encodeBase16(arVendorData);
996 : xmlNode* dataNode = xmlNewChild(pJavaInfoNode, NULL,
997 : (xmlChar*) "vendorData",
998 2 : (xmlChar*) "");
999 : xmlNodeSetContentLen(dataNode,
1000 2 : (xmlChar*) data.getArray(), data.getLength());
1001 : //add a new line for better readability
1002 2 : nodeCrLf = xmlNewText((xmlChar*) "\n");
1003 4 : xmlAddChild(pJavaInfoNode, nodeCrLf);
1004 : }
1005 :
1006 14 : JavaInfo * CNodeJavaInfo::makeJavaInfo() const
1007 : {
1008 14 : if (bNil == true || m_bEmptyNode == true)
1009 14 : return NULL;
1010 0 : JavaInfo * pInfo = (JavaInfo*) rtl_allocateMemory(sizeof(JavaInfo));
1011 0 : if (pInfo == NULL)
1012 0 : return NULL;
1013 0 : memset(pInfo, 0, sizeof(JavaInfo));
1014 0 : pInfo->sVendor = sVendor.pData;
1015 0 : rtl_uString_acquire(pInfo->sVendor);
1016 0 : pInfo->sLocation = sLocation.pData;
1017 0 : rtl_uString_acquire(pInfo->sLocation);
1018 0 : pInfo->sVersion = sVersion.pData;
1019 0 : rtl_uString_acquire(pInfo->sVersion);
1020 0 : pInfo->nFeatures = nFeatures;
1021 0 : pInfo->nRequirements = nRequirements;
1022 0 : pInfo->arVendorData = arVendorData.getHandle();
1023 0 : rtl_byte_sequence_acquire(pInfo->arVendorData);
1024 0 : return pInfo;
1025 : }
1026 :
1027 :
1028 46 : MergedSettings::MergedSettings():
1029 : m_bEnabled(false),
1030 : m_sClassPath(),
1031 : m_vmParams(),
1032 : m_JRELocations(),
1033 46 : m_javaInfo()
1034 : {
1035 46 : NodeJava settings(NodeJava::USER);
1036 46 : settings.load();
1037 92 : NodeJava sharedSettings(NodeJava::SHARED);
1038 46 : sharedSettings.load();
1039 92 : merge(sharedSettings, settings);
1040 46 : }
1041 :
1042 46 : MergedSettings::~MergedSettings()
1043 : {
1044 46 : }
1045 :
1046 46 : void MergedSettings::merge(const NodeJava & share, const NodeJava & user)
1047 : {
1048 46 : if (user.getEnabled())
1049 0 : m_bEnabled = * user.getEnabled();
1050 46 : else if (share.getEnabled())
1051 0 : m_bEnabled = * share.getEnabled();
1052 : else
1053 46 : m_bEnabled = true;
1054 :
1055 46 : if (user.getUserClassPath())
1056 0 : m_sClassPath = * user.getUserClassPath();
1057 46 : else if (share.getUserClassPath())
1058 0 : m_sClassPath = * share.getUserClassPath();
1059 :
1060 46 : if (user.getJavaInfo())
1061 16 : m_javaInfo = * user.getJavaInfo();
1062 30 : else if (share.getJavaInfo())
1063 0 : m_javaInfo = * share.getJavaInfo();
1064 :
1065 46 : if (user.getVmParameters())
1066 0 : m_vmParams = * user.getVmParameters();
1067 46 : else if (share.getVmParameters())
1068 0 : m_vmParams = * share.getVmParameters();
1069 :
1070 46 : if (user.getJRELocations())
1071 0 : m_JRELocations = * user.getJRELocations();
1072 46 : else if (share.getJRELocations())
1073 0 : m_JRELocations = * share.getJRELocations();
1074 46 : }
1075 :
1076 :
1077 0 : ::std::vector< OString> MergedSettings::getVmParametersUtf8() const
1078 : {
1079 0 : ::std::vector< OString> ret;
1080 : typedef ::std::vector< OUString>::const_iterator cit;
1081 0 : for (cit i = m_vmParams.begin(); i != m_vmParams.end(); ++i)
1082 : {
1083 0 : ret.push_back( OUStringToOString(*i, RTL_TEXTENCODING_UTF8));
1084 : }
1085 0 : return ret;
1086 : }
1087 :
1088 :
1089 :
1090 14 : JavaInfo * MergedSettings::createJavaInfo() const
1091 : {
1092 14 : return m_javaInfo.makeJavaInfo();
1093 : }
1094 : #ifdef WNT
1095 : bool MergedSettings::getJavaInfoAttrAutoSelect() const
1096 : {
1097 : return m_javaInfo.bAutoSelect;
1098 : }
1099 : #endif
1100 0 : void MergedSettings::getVmParametersArray(
1101 : rtl_uString *** parParams, sal_Int32 * size) const
1102 : {
1103 0 : osl::MutexGuard guard(FwkMutex::get());
1104 : OSL_ASSERT(parParams != NULL && size != NULL);
1105 :
1106 : *parParams = (rtl_uString **)
1107 0 : rtl_allocateMemory(sizeof(rtl_uString*) * m_vmParams.size());
1108 0 : if (*parParams == NULL)
1109 0 : return;
1110 :
1111 0 : int j=0;
1112 : typedef std::vector<OUString>::const_iterator it;
1113 0 : for (it i = m_vmParams.begin(); i != m_vmParams.end();
1114 : ++i, ++j)
1115 : {
1116 0 : (*parParams)[j] = i->pData;
1117 0 : rtl_uString_acquire(i->pData);
1118 : }
1119 0 : *size = m_vmParams.size();
1120 : }
1121 :
1122 0 : void MergedSettings::getJRELocations(
1123 : rtl_uString *** parLocations, sal_Int32 * size) const
1124 : {
1125 0 : osl::MutexGuard guard(FwkMutex::get());
1126 : assert(parLocations != NULL && size != NULL);
1127 :
1128 : *parLocations = (rtl_uString **)
1129 0 : rtl_allocateMemory(sizeof(rtl_uString*) * m_JRELocations.size());
1130 0 : if (*parLocations == NULL)
1131 0 : return;
1132 :
1133 0 : int j=0;
1134 : typedef std::vector<OUString>::const_iterator it;
1135 0 : for (it i = m_JRELocations.begin(); i != m_JRELocations.end();
1136 : ++i, ++j)
1137 : {
1138 0 : (*parLocations)[j] = i->pData;
1139 0 : rtl_uString_acquire(i->pData);
1140 : }
1141 0 : *size = m_JRELocations.size();
1142 : }
1143 : }
1144 :
1145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|