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