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