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 "boost/scoped_array.hpp" 27 #include "rtl/ustring.hxx" 28 #include "rtl/bootstrap.hxx" 29 #include "osl/thread.hxx" 30 #include "osl/file.hxx" 31 #include "osl/module.hxx" 32 #include "jvmfwk/framework.h" 33 #include "jvmfwk/vendorplugin.h" 34 #include <vector> 35 #include <functional> 36 #include <algorithm> 37 #include "framework.hxx" 38 #include "fwkutil.hxx" 39 #include "elements.hxx" 40 #include "fwkbase.hxx" 41 42 #ifdef WNT 43 /** The existence of the file useatjava.txt decides if a Java should be used 44 that supports accessibility tools. 45 */ 46 #define USE_ACCESSIBILITY_FILE "useatjava.txt" 47 #endif 48 49 #define UNO_JAVA_JFW_JREHOME "UNO_JAVA_JFW_JREHOME" 50 namespace { 51 JavaVM * g_pJavaVM = NULL; 52 53 bool g_bEnabledSwitchedOn = false; 54 55 sal_Bool areEqualJavaInfo( 56 JavaInfo const * pInfoA,JavaInfo const * pInfoB) 57 { 58 return jfw_areEqualJavaInfo(pInfoA, pInfoB); 59 } 60 } 61 62 javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSize) 63 { 64 javaFrameworkError retVal = JFW_E_NONE; 65 try 66 { 67 osl::MutexGuard guard(jfw::FwkMutex::get()); 68 javaFrameworkError errcode = JFW_E_NONE; 69 if (pparInfo == NULL || pSize == NULL) 70 return JFW_E_INVALID_ARG; 71 72 jfw::VendorSettings aVendorSettings; 73 //Get a list of plugins which provide Java information 74 std::vector<jfw::PluginLibrary> vecPlugins = 75 aVendorSettings.getPluginData(); 76 77 //Create a vector that holds the libraries, which will be later 78 //dynamically loaded; 79 boost::scoped_array<osl::Module> sarModules; 80 sarModules.reset(new osl::Module[vecPlugins.size()]); 81 osl::Module * arModules = sarModules.get(); 82 //Add the JavaInfos found by jfw_plugin_getAllJavaInfos to the vector 83 //Make sure that the contents are destroyed if this 84 //function returns with an error 85 std::vector<jfw::CJavaInfo> vecInfo; 86 //Add the JavaInfos found by jfw_plugin_getJavaInfoByPath to this vector 87 //Make sure that the contents are destroyed if this 88 //function returns with an error 89 std::vector<jfw::CJavaInfo> vecInfoManual; 90 typedef std::vector<jfw::CJavaInfo>::iterator it_info; 91 //get the list of paths to jre locations which have been 92 //added manually 93 const jfw::MergedSettings settings; 94 const std::vector<rtl::OUString>& vecJRELocations = 95 settings.getJRELocations(); 96 //Use every plug-in library to get Java installations. 97 typedef std::vector<jfw::PluginLibrary>::const_iterator ci_pl; 98 int cModule = 0; 99 for (ci_pl i = vecPlugins.begin(); i != vecPlugins.end(); i++, cModule++) 100 { 101 const jfw::PluginLibrary & library = *i; 102 jfw::VersionInfo versionInfo = 103 aVendorSettings.getVersionInformation(library.sVendor); 104 arModules[cModule].load(library.sPath); 105 osl::Module & pluginLib = arModules[cModule]; 106 107 if (pluginLib.is() == sal_False) 108 { 109 rtl::OString msg = rtl::OUStringToOString( 110 library.sPath, osl_getThreadTextEncoding()); 111 fprintf(stderr,"[jvmfwk] Could not load plugin %s\n" \ 112 "Modify the javavendors.xml accordingly!\n", msg.getStr()); 113 return JFW_E_NO_PLUGIN; 114 } 115 jfw_plugin_getAllJavaInfos_ptr getAllJavaFunc = 116 (jfw_plugin_getAllJavaInfos_ptr) pluginLib.getFunctionSymbol( 117 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getAllJavaInfos"))); 118 119 OSL_ASSERT(getAllJavaFunc); 120 if (getAllJavaFunc == NULL) 121 return JFW_E_ERROR; 122 123 //get all installations of one vendor according to minVersion, 124 //maxVersion and excludeVersions 125 sal_Int32 cInfos = 0; 126 JavaInfo** arInfos = NULL; 127 javaPluginError plerr = (*getAllJavaFunc)( 128 library.sVendor.pData, 129 versionInfo.sMinVersion.pData, 130 versionInfo.sMaxVersion.pData, 131 versionInfo.getExcludeVersions(), 132 versionInfo.getExcludeVersionSize(), 133 & arInfos, 134 & cInfos); 135 136 if (plerr != JFW_PLUGIN_E_NONE) 137 return JFW_E_ERROR; 138 139 for (int j = 0; j < cInfos; j++) 140 vecInfo.push_back(jfw::CJavaInfo::createWrapper(arInfos[j])); 141 142 rtl_freeMemory(arInfos); 143 144 //Check if the current plugin can detect JREs at the location 145 // of the paths added by jfw_setJRELocations or jfw_addJRELocation 146 //get the function from the plugin 147 jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc = 148 (jfw_plugin_getJavaInfoByPath_ptr) pluginLib.getFunctionSymbol( 149 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getJavaInfoByPath"))); 150 151 OSL_ASSERT(jfw_plugin_getJavaInfoByPathFunc); 152 if (jfw_plugin_getJavaInfoByPathFunc == NULL) 153 return JFW_E_ERROR; 154 155 typedef std::vector<rtl::OUString>::const_iterator citLoc; 156 //Check every manually added location 157 for (citLoc ii = vecJRELocations.begin(); 158 ii != vecJRELocations.end(); ii++) 159 { 160 // rtl::OUString sLocation = 161 // rtl::OStringToOUString(*ii, RTL_TEXTENCODING_UTF8); 162 jfw::CJavaInfo aInfo; 163 plerr = (*jfw_plugin_getJavaInfoByPathFunc)( 164 ii->pData, 165 library.sVendor.pData, 166 versionInfo.sMinVersion.pData, 167 versionInfo.sMaxVersion.pData, 168 versionInfo.getExcludeVersions(), 169 versionInfo.getExcludeVersionSize(), 170 & aInfo.pInfo); 171 if (plerr == JFW_PLUGIN_E_NO_JRE) 172 continue; 173 if (plerr == JFW_PLUGIN_E_FAILED_VERSION) 174 continue; 175 else if (plerr !=JFW_PLUGIN_E_NONE) 176 return JFW_E_ERROR; 177 178 if (aInfo) 179 { 180 //Was this JRE already added?. Different plugins could detect 181 //the same JRE 182 it_info it_duplicate = 183 std::find_if(vecInfoManual.begin(), vecInfoManual.end(), 184 std::bind2nd(std::ptr_fun(areEqualJavaInfo), aInfo)); 185 if (it_duplicate == vecInfoManual.end()) 186 vecInfoManual.push_back(aInfo); 187 } 188 } 189 } 190 //Make sure vecInfoManual contains only JavaInfos for the vendors for which 191 //there is a javaSelection/plugins/library entry in the javavendors.xml 192 //To obtain the JavaInfos for the manually added JRE locations the function 193 //jfw_getJavaInfoByPath is called which can return a JavaInfo of any vendor. 194 std::vector<jfw::CJavaInfo> vecInfoManual2; 195 for (it_info ivm = vecInfoManual.begin(); ivm != vecInfoManual.end(); ivm++) 196 { 197 for (ci_pl ii = vecPlugins.begin(); ii != vecPlugins.end(); ii++) 198 { 199 if ( ii->sVendor.equals((*ivm)->sVendor)) 200 { 201 vecInfoManual2.push_back(*ivm); 202 break; 203 } 204 } 205 } 206 //Check which JavaInfo from vector vecInfoManual2 is already 207 //contained in vecInfo. If it already exists then remove it from 208 //vecInfoManual2 209 for (it_info j = vecInfo.begin(); j != vecInfo.end(); j++) 210 { 211 it_info it_duplicate = 212 std::find_if(vecInfoManual2.begin(), vecInfoManual2.end(), 213 std::bind2nd(std::ptr_fun(areEqualJavaInfo), *j)); 214 if (it_duplicate != vecInfoManual2.end()) 215 vecInfoManual2.erase(it_duplicate); 216 } 217 //create an fill the array of JavaInfo* 218 sal_Int32 nSize = vecInfo.size() + vecInfoManual2.size(); 219 *pparInfo = (JavaInfo**) rtl_allocateMemory( 220 nSize * sizeof(JavaInfo*)); 221 if (*pparInfo == NULL) 222 return JFW_E_ERROR; 223 224 typedef std::vector<jfw::CJavaInfo>::iterator it; 225 int index = 0; 226 //Add the automatically detected JREs 227 for (it k = vecInfo.begin(); k != vecInfo.end(); k++) 228 (*pparInfo)[index++] = k->detach(); 229 //Add the manually detected JREs 230 for (it l = vecInfoManual2.begin(); l != vecInfoManual2.end(); l++) 231 (*pparInfo)[index++] = l->detach(); 232 233 *pSize = nSize; 234 return errcode; 235 } 236 catch (jfw::FrameworkException& e) 237 { 238 retVal = e.errorCode; 239 fprintf(stderr, "%s\n", e.message.getStr()); 240 OSL_ENSURE(0, e.message.getStr()); 241 } 242 return retVal; 243 } 244 245 javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOptions, 246 JavaVM **ppVM, JNIEnv **ppEnv) 247 { 248 #ifndef SOLAR_JAVA 249 return JFW_E_ERROR; 250 #else 251 javaFrameworkError errcode = JFW_E_NONE; 252 if (cOptions > 0 && arOptions == NULL) 253 return JFW_E_INVALID_ARG; 254 255 try 256 { 257 osl::MutexGuard guard(jfw::FwkMutex::get()); 258 259 //We keep this pointer so we can determine if a VM has already 260 //been created. 261 if (g_pJavaVM != NULL) 262 return JFW_E_RUNNING_JVM; 263 264 if (ppVM == NULL) 265 return JFW_E_INVALID_ARG; 266 267 std::vector<rtl::OString> vmParams; 268 rtl::OString sUserClassPath; 269 jfw::CJavaInfo aInfo; 270 jfw::JFW_MODE mode = jfw::getMode(); 271 if (mode == jfw::JFW_MODE_APPLICATION) 272 { 273 const jfw::MergedSettings settings; 274 if (sal_False == settings.getEnabled()) 275 return JFW_E_JAVA_DISABLED; 276 aInfo.attach(settings.createJavaInfo()); 277 //check if a Java has ever been selected 278 if (aInfo == NULL) 279 return JFW_E_NO_SELECT; 280 281 #ifdef WNT 282 //Because on Windows there is no system setting that we can use to determine 283 //if Assistive Technology Tool support is needed, we ship a .reg file that the 284 //user can use to create a registry setting. When the user forgets to set 285 //the key before he starts the office then a JRE may be selected without access bridge. 286 //When he later sets the key then we select a JRE with accessibility support but 287 //only if the user has not manually changed the selected JRE in the options dialog. 288 if (jfw::isAccessibilitySupportDesired()) 289 { 290 // If no JRE has been selected then we do not select one. This function shall then 291 //return JFW_E_NO_SELECT 292 if (aInfo != NULL && 293 (aInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE) == 0) 294 { 295 //has the user manually selected a JRE? 296 if (settings.getJavaInfoAttrAutoSelect() == true) 297 { 298 // if not then the automatism has previously selected a JRE 299 //without accessibility support. We return JFW_E_NO_SELECT 300 //to cause that we search for another JRE. The search code will 301 //then prefer a JRE with accessibility support. 302 return JFW_E_NO_SELECT; 303 } 304 } 305 } 306 #endif 307 //check if the javavendors.xml has changed after a Java was selected 308 rtl::OString sVendorUpdate = jfw::getElementUpdated(); 309 310 if (sVendorUpdate != settings.getJavaInfoAttrVendorUpdate()) 311 return JFW_E_INVALID_SETTINGS; 312 313 //check if JAVA is disabled 314 //If Java is enabled, but it was disabled when this process was started 315 // then no preparational work, such as setting the LD_LIBRARY_PATH, was 316 //done. Therefore if a JRE needs it it must not be started. 317 if (g_bEnabledSwitchedOn && 318 (aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART)) 319 return JFW_E_NEED_RESTART; 320 321 //Check if the selected Java was set in this process. If so it 322 //must not have the requirments flag JFW_REQUIRE_NEEDRESTART 323 if ((aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART) 324 && 325 (jfw::wasJavaSelectedInSameProcess() == true)) 326 return JFW_E_NEED_RESTART; 327 328 vmParams = settings.getVmParametersUtf8(); 329 sUserClassPath = jfw::makeClassPathOption(settings.getUserClassPath()); 330 } // end mode FWK_MODE_OFFICE 331 else if (mode == jfw::JFW_MODE_DIRECT) 332 { 333 errcode = jfw_getSelectedJRE(&aInfo.pInfo); 334 if (errcode != JFW_E_NONE) 335 return errcode; 336 //In direct mode the options are specified by bootstrap variables 337 //of the form UNO_JAVA_JFW_PARAMETER_1 .. UNO_JAVA_JFW_PARAMETER_n 338 vmParams = jfw::BootParams::getVMParameters(); 339 sUserClassPath = 340 "-Djava.class.path=" + jfw::BootParams::getClasspath(); 341 } 342 else 343 OSL_ASSERT(0); 344 345 //get the function jfw_plugin_startJavaVirtualMachine 346 jfw::VendorSettings aVendorSettings; 347 rtl::OUString sLibPath = aVendorSettings.getPluginLibrary(aInfo.getVendor()); 348 349 osl::Module modulePlugin(sLibPath); 350 if ( ! modulePlugin) 351 return JFW_E_NO_PLUGIN; 352 353 rtl::OUString sFunctionName( 354 RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_startJavaVirtualMachine")); 355 jfw_plugin_startJavaVirtualMachine_ptr pFunc = 356 (jfw_plugin_startJavaVirtualMachine_ptr) 357 osl_getFunctionSymbol(modulePlugin, sFunctionName.pData); 358 if (pFunc == NULL) 359 return JFW_E_ERROR; 360 361 // create JavaVMOptions array that is passed to the plugin 362 // it contains the classpath and all options set in the 363 //options dialog 364 boost::scoped_array<JavaVMOption> sarJOptions( 365 new JavaVMOption[cOptions + 2 + vmParams.size()]); 366 JavaVMOption * arOpt = sarJOptions.get(); 367 if (! arOpt) 368 return JFW_E_ERROR; 369 370 //The first argument is the classpath 371 arOpt[0].optionString= (char*) sUserClassPath.getStr(); 372 arOpt[0].extraInfo = NULL; 373 // Set a flag that this JVM has been created via the JNI Invocation API 374 // (used, for example, by UNO remote bridges to share a common thread pool 375 // factory among Java and native bridge implementations): 376 arOpt[1].optionString = (char *) "-Dorg.openoffice.native="; 377 arOpt[1].extraInfo = 0; 378 379 //add the options set by options dialog 380 int index = 2; 381 typedef std::vector<rtl::OString>::const_iterator cit; 382 for (cit i = vmParams.begin(); i != vmParams.end(); i ++) 383 { 384 arOpt[index].optionString = const_cast<sal_Char*>(i->getStr()); 385 arOpt[index].extraInfo = 0; 386 index ++; 387 } 388 //add all options of the arOptions argument 389 for (int ii = 0; ii < cOptions; ii++) 390 { 391 arOpt[index].optionString = arOptions[ii].optionString; 392 arOpt[index].extraInfo = arOptions[ii].extraInfo; 393 index++; 394 } 395 396 //start Java 397 JavaVM *pVm = NULL; 398 javaPluginError plerr = (*pFunc)(aInfo, arOpt, index, & pVm, ppEnv); 399 if (plerr == JFW_PLUGIN_E_VM_CREATION_FAILED) 400 { 401 errcode = JFW_E_VM_CREATION_FAILED; 402 } 403 else if (plerr != JFW_PLUGIN_E_NONE ) 404 { 405 errcode = JFW_E_ERROR; 406 } 407 else 408 { 409 g_pJavaVM = pVm; 410 *ppVM = pVm; 411 } 412 OSL_ASSERT(plerr != JFW_PLUGIN_E_WRONG_VENDOR); 413 } 414 catch (jfw::FrameworkException& e) 415 { 416 errcode = e.errorCode; 417 fprintf(stderr, "%s\n", e.message.getStr()); 418 OSL_ENSURE(0, e.message.getStr()); 419 } 420 421 return errcode; 422 #endif 423 } 424 425 /** We do not use here jfw_findAllJREs and then check if a JavaInfo 426 meets the requirements, because that means using all plug-ins, which 427 may take quite a while. The implementation uses one plug-in and if 428 it already finds a suitable JRE then it is done and does not need to 429 load another plug-in 430 */ 431 javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) 432 { 433 javaFrameworkError errcode = JFW_E_NONE; 434 try 435 { 436 osl::MutexGuard guard(jfw::FwkMutex::get()); 437 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 438 return JFW_E_DIRECT_MODE; 439 sal_uInt64 nFeatureFlags = 0; 440 jfw::CJavaInfo aCurrentInfo; 441 //Determine if accessibility support is needed 442 bool bSupportAccessibility = jfw::isAccessibilitySupportDesired(); 443 nFeatureFlags = bSupportAccessibility ? 444 JFW_FEATURE_ACCESSBRIDGE : 0L; 445 446 //Get a list of services which provide Java information 447 jfw::VendorSettings aVendorSettings; 448 std::vector<jfw::PluginLibrary> vecPlugins = 449 aVendorSettings.getPluginData(); 450 //Create a vector that holds the libraries, which will be later 451 //dynamically loaded; 452 boost::scoped_array<osl::Module> sarModules; 453 sarModules.reset(new osl::Module[vecPlugins.size()]); 454 osl::Module * arModules = sarModules.get(); 455 456 //Use every plug-in library to get Java installations. At the first usable 457 //Java the loop will break 458 typedef std::vector<jfw::PluginLibrary>::const_iterator ci_pl; 459 int cModule = 0; 460 for (ci_pl i = vecPlugins.begin(); i != vecPlugins.end(); i++, cModule++) 461 { 462 const jfw::PluginLibrary & library = *i; 463 jfw::VersionInfo versionInfo = 464 aVendorSettings.getVersionInformation(library.sVendor); 465 466 arModules[cModule].load(library.sPath); 467 osl::Module & pluginLib = arModules[cModule]; 468 if (pluginLib.is() == sal_False) 469 return JFW_E_NO_PLUGIN; 470 471 jfw_plugin_getAllJavaInfos_ptr getAllJavaFunc = 472 (jfw_plugin_getAllJavaInfos_ptr) pluginLib.getFunctionSymbol( 473 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getAllJavaInfos"))); 474 475 OSL_ASSERT(getAllJavaFunc); 476 if (getAllJavaFunc == NULL) 477 continue; 478 479 //get all installations of one vendor according to minVersion, 480 //maxVersion and excludeVersions 481 sal_Int32 cInfos = 0; 482 JavaInfo** arInfos = NULL; 483 javaPluginError plerr = (*getAllJavaFunc)( 484 library.sVendor.pData, 485 versionInfo.sMinVersion.pData, 486 versionInfo.sMaxVersion.pData, 487 versionInfo.getExcludeVersions(), 488 versionInfo.getExcludeVersionSize(), 489 & arInfos, 490 & cInfos); 491 492 if (plerr != JFW_PLUGIN_E_NONE) 493 continue; 494 //iterate over all installations to find the best which has 495 //all features 496 if (cInfos == 0) 497 { 498 rtl_freeMemory(arInfos); 499 continue; 500 } 501 bool bInfoFound = false; 502 for (int ii = 0; ii < cInfos; ii++) 503 { 504 JavaInfo* pJInfo = arInfos[ii]; 505 506 //We remember the very first installation in aCurrentInfo 507 if (aCurrentInfo.getLocation().getLength() == 0) 508 aCurrentInfo = pJInfo; 509 // compare features 510 // If the user does not require any features (nFeatureFlags = 0) 511 // then the first installation is used 512 if ((pJInfo->nFeatures & nFeatureFlags) == nFeatureFlags) 513 { 514 //the just found Java implements all required features 515 //currently there is only accessibility!!! 516 aCurrentInfo = pJInfo; 517 bInfoFound = true; 518 break; 519 } 520 } 521 //The array returned by jfw_plugin_getAllJavaInfos must be freed as well as 522 //its contents 523 for (int j = 0; j < cInfos; j++) 524 jfw_freeJavaInfo(arInfos[j]); 525 rtl_freeMemory(arInfos); 526 527 if (bInfoFound == true) 528 break; 529 //All Java installations found by the current plug-in lib 530 //do not provide the required features. Try the next plug-in 531 } 532 if ((JavaInfo*) aCurrentInfo == NULL) 533 {//The plug-ins did not find a suitable Java. Now try the paths which have been 534 //added manually. 535 //get the list of paths to jre locations which have been added manually 536 const jfw::MergedSettings settings; 537 //node.loadFromSettings(); 538 const std::vector<rtl::OUString> & vecJRELocations = 539 settings.getJRELocations(); 540 //use every plug-in to determine the JavaInfo objects 541 bool bInfoFound = false; 542 for (ci_pl i = vecPlugins.begin(); i != vecPlugins.end(); i++) 543 { 544 const jfw::PluginLibrary & library = *i; 545 jfw::VersionInfo versionInfo = 546 aVendorSettings.getVersionInformation(library.sVendor); 547 548 osl::Module pluginLib(library.sPath); 549 if (pluginLib.is() == sal_False) 550 return JFW_E_NO_PLUGIN; 551 //Check if the current plugin can detect JREs at the location 552 // of the paths added by jfw_setJRELocations or jfw_addJRELocation 553 //get the function from the plugin 554 jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc = 555 (jfw_plugin_getJavaInfoByPath_ptr) pluginLib.getFunctionSymbol( 556 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getJavaInfoByPath"))); 557 558 OSL_ASSERT(jfw_plugin_getJavaInfoByPathFunc); 559 if (jfw_plugin_getJavaInfoByPathFunc == NULL) 560 return JFW_E_ERROR; 561 562 typedef std::vector<rtl::OUString>::const_iterator citLoc; 563 for (citLoc it = vecJRELocations.begin(); 564 it != vecJRELocations.end(); it++) 565 { 566 jfw::CJavaInfo aInfo; 567 javaPluginError err = (*jfw_plugin_getJavaInfoByPathFunc)( 568 it->pData, 569 library.sVendor.pData, 570 versionInfo.sMinVersion.pData, 571 versionInfo.sMaxVersion.pData, 572 versionInfo.getExcludeVersions(), 573 versionInfo.getExcludeVersionSize(), 574 & aInfo.pInfo); 575 if (err == JFW_PLUGIN_E_NO_JRE) 576 continue; 577 if (err == JFW_PLUGIN_E_FAILED_VERSION) 578 continue; 579 else if (err !=JFW_PLUGIN_E_NONE) 580 return JFW_E_ERROR; 581 582 if (aInfo) 583 { 584 //We remember the very first installation in aCurrentInfo 585 if (aCurrentInfo.getLocation().getLength() == 0) 586 aCurrentInfo = aInfo; 587 // compare features 588 // If the user does not require any features (nFeatureFlags = 0) 589 // then the first installation is used 590 if ((aInfo.getFeatures() & nFeatureFlags) == nFeatureFlags) 591 { 592 //the just found Java implements all required features 593 //currently there is only accessibility!!! 594 aCurrentInfo = aInfo; 595 bInfoFound = true; 596 break; 597 } 598 } 599 }//end iterate over paths 600 if (bInfoFound == true) 601 break; 602 }// end iterate plug-ins 603 } 604 if ((JavaInfo*) aCurrentInfo) 605 { 606 jfw::NodeJava javaNode; 607 javaNode.setJavaInfo(aCurrentInfo,true); 608 javaNode.write(); 609 610 if (pInfo !=NULL) 611 { 612 //copy to out param 613 *pInfo = aCurrentInfo.cloneJavaInfo(); 614 //remember that this JRE was selected in this process 615 jfw::setJavaSelected(); 616 } 617 } 618 else 619 { 620 errcode = JFW_E_NO_JAVA_FOUND; 621 } 622 } 623 catch (jfw::FrameworkException& e) 624 { 625 errcode = e.errorCode; 626 fprintf(stderr, "%s\n", e.message.getStr()); 627 OSL_ENSURE(0, e.message.getStr()); 628 } 629 630 return errcode; 631 } 632 sal_Bool SAL_CALL jfw_areEqualJavaInfo( 633 JavaInfo const * pInfoA,JavaInfo const * pInfoB) 634 { 635 if (pInfoA == pInfoB) 636 return sal_True; 637 if (pInfoA == NULL || pInfoB == NULL) 638 return sal_False; 639 rtl::OUString sVendor(pInfoA->sVendor); 640 rtl::OUString sLocation(pInfoA->sLocation); 641 rtl::OUString sVersion(pInfoA->sVersion); 642 rtl::ByteSequence sData(pInfoA->arVendorData); 643 if (sVendor.equals(pInfoB->sVendor) == sal_True 644 && sLocation.equals(pInfoB->sLocation) == sal_True 645 && sVersion.equals(pInfoB->sVersion) == sal_True 646 && pInfoA->nFeatures == pInfoB->nFeatures 647 && pInfoA->nRequirements == pInfoB->nRequirements 648 && sData == pInfoB->arVendorData) 649 { 650 return sal_True; 651 } 652 return sal_False; 653 } 654 655 656 void SAL_CALL jfw_freeJavaInfo(JavaInfo *pInfo) 657 { 658 if (pInfo == NULL) 659 return; 660 rtl_uString_release(pInfo->sVendor); 661 rtl_uString_release(pInfo->sLocation); 662 rtl_uString_release(pInfo->sVersion); 663 rtl_byte_sequence_release(pInfo->arVendorData); 664 rtl_freeMemory(pInfo); 665 } 666 667 javaFrameworkError SAL_CALL jfw_getSelectedJRE(JavaInfo **ppInfo) 668 { 669 javaFrameworkError errcode = JFW_E_NONE; 670 try 671 { 672 osl::MutexGuard guard(jfw::FwkMutex::get()); 673 if (ppInfo == NULL) 674 return JFW_E_INVALID_ARG; 675 676 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 677 { 678 rtl::OUString sJRE = jfw::BootParams::getJREHome(); 679 680 jfw::CJavaInfo aInfo; 681 if ((errcode = jfw_getJavaInfoByPath(sJRE.pData, & aInfo.pInfo)) 682 != JFW_E_NONE) 683 throw jfw::FrameworkException( 684 JFW_E_CONFIGURATION, 685 rtl::OString( 686 "[Java framework] The JRE specified by the bootstrap " 687 "variable UNO_JAVA_JFW_JREHOME or UNO_JAVA_JFW_ENV_JREHOME " 688 " could not be recognized. Check the values and make sure that you " 689 "use a plug-in library that can recognize that JRE.")); 690 691 *ppInfo = aInfo.detach(); 692 return JFW_E_NONE; 693 } 694 695 const jfw::MergedSettings settings; 696 jfw::CJavaInfo aInfo; 697 aInfo.attach(settings.createJavaInfo()); 698 if (! aInfo) 699 { 700 *ppInfo = NULL; 701 return JFW_E_NONE; 702 } 703 //If the javavendors.xml has changed, then the current selected 704 //Java is not valid anymore 705 // /java/javaInfo/@vendorUpdate != javaSelection/updated (javavendors.xml) 706 rtl::OString sUpdated = jfw::getElementUpdated(); 707 708 if (sUpdated.equals(settings.getJavaInfoAttrVendorUpdate()) == sal_False) 709 return JFW_E_INVALID_SETTINGS; 710 *ppInfo = aInfo.detach(); 711 } 712 catch (jfw::FrameworkException& e) 713 { 714 errcode = e.errorCode; 715 fprintf(stderr, "%s\n", e.message.getStr()); 716 OSL_ENSURE(0, e.message.getStr()); 717 } 718 return errcode; 719 } 720 721 javaFrameworkError SAL_CALL jfw_isVMRunning(sal_Bool *bRunning) 722 { 723 osl::MutexGuard guard(jfw::FwkMutex::get()); 724 if (bRunning == NULL) 725 return JFW_E_INVALID_ARG; 726 if (g_pJavaVM == NULL) 727 *bRunning = sal_False; 728 else 729 *bRunning = sal_True; 730 return JFW_E_NONE; 731 } 732 733 javaFrameworkError SAL_CALL jfw_getJavaInfoByPath( 734 rtl_uString *pPath, JavaInfo **ppInfo) 735 { 736 javaFrameworkError errcode = JFW_E_NONE; 737 try 738 { 739 osl::MutexGuard guard(jfw::FwkMutex::get()); 740 if (pPath == NULL || ppInfo == NULL) 741 return JFW_E_INVALID_ARG; 742 743 jfw::VendorSettings aVendorSettings; 744 //Get a list of plugins which provide Java information 745 std::vector<jfw::PluginLibrary> vecPlugins = 746 aVendorSettings.getPluginData(); 747 //Create a vector that holds the libraries, which will be later 748 //dynamically loaded; 749 boost::scoped_array<osl::Module> sarModules; 750 sarModules.reset(new osl::Module[vecPlugins.size()]); 751 osl::Module * arModules = sarModules.get(); 752 753 typedef std::vector<rtl::OUString>::const_iterator CIT_VENDOR; 754 std::vector<rtl::OUString> vecVendors = 755 aVendorSettings.getSupportedVendors(); 756 757 //Use every plug-in library to determine if the path represents a 758 //JRE. If a plugin recognized it then the loop will break 759 typedef std::vector<jfw::PluginLibrary>::const_iterator ci_pl; 760 int cModule = 0; 761 for (ci_pl i = vecPlugins.begin(); i != vecPlugins.end(); 762 i++, cModule++) 763 { 764 const jfw::PluginLibrary & library = *i; 765 jfw::VersionInfo versionInfo = 766 aVendorSettings.getVersionInformation(library.sVendor); 767 arModules[cModule].load(library.sPath); 768 osl::Module & pluginLib = arModules[cModule]; 769 if (pluginLib.is() == sal_False) 770 { 771 rtl::OString msg = rtl::OUStringToOString( 772 library.sPath, osl_getThreadTextEncoding()); 773 fprintf(stderr,"[jvmfwk] Could not load plugin %s\n" \ 774 "Modify the javavendors.xml accordingly!\n", msg.getStr()); 775 return JFW_E_NO_PLUGIN; 776 } 777 778 jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc = 779 (jfw_plugin_getJavaInfoByPath_ptr) pluginLib.getFunctionSymbol( 780 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getJavaInfoByPath"))); 781 782 OSL_ASSERT(jfw_plugin_getJavaInfoByPathFunc); 783 if (jfw_plugin_getJavaInfoByPathFunc == NULL) 784 continue; 785 786 //ask the plugin if this is a JRE. 787 //If so check if it meets the version requirements. 788 //Only if it does return a JavaInfo 789 JavaInfo* pInfo = NULL; 790 javaPluginError plerr = (*jfw_plugin_getJavaInfoByPathFunc)( 791 pPath, 792 library.sVendor.pData, 793 versionInfo.sMinVersion.pData, 794 versionInfo.sMaxVersion.pData, 795 versionInfo.getExcludeVersions(), 796 versionInfo.getExcludeVersionSize(), 797 & pInfo); 798 799 if (plerr == JFW_PLUGIN_E_NONE) 800 { 801 //check if the vendor of the found JRE is supported 802 if (vecVendors.size() == 0) 803 { 804 //vendor does not matter 805 *ppInfo = pInfo; 806 break; 807 } 808 else 809 { 810 rtl::OUString sVendor(pInfo->sVendor); 811 CIT_VENDOR ivendor = std::find(vecVendors.begin(), vecVendors.end(), 812 sVendor); 813 if (ivendor != vecVendors.end()) 814 { 815 *ppInfo = pInfo; 816 } 817 else 818 { 819 *ppInfo = NULL; 820 errcode = JFW_E_NOT_RECOGNIZED; 821 } 822 break; 823 } 824 } 825 else if(plerr == JFW_PLUGIN_E_FAILED_VERSION) 826 {//found JRE but it has the wrong version 827 *ppInfo = NULL; 828 errcode = JFW_E_FAILED_VERSION; 829 break; 830 } 831 else if (plerr == JFW_PLUGIN_E_NO_JRE) 832 {// plugin does not recognize this path as belonging to JRE 833 continue; 834 } 835 OSL_ASSERT(0); 836 } 837 if (*ppInfo == NULL && errcode != JFW_E_FAILED_VERSION) 838 errcode = JFW_E_NOT_RECOGNIZED; 839 } 840 catch (jfw::FrameworkException& e) 841 { 842 errcode = e.errorCode; 843 fprintf(stderr, "%s\n", e.message.getStr()); 844 OSL_ENSURE(0, e.message.getStr()); 845 } 846 847 return errcode; 848 } 849 850 851 javaFrameworkError SAL_CALL jfw_setSelectedJRE(JavaInfo const *pInfo) 852 { 853 javaFrameworkError errcode = JFW_E_NONE; 854 try 855 { 856 osl::MutexGuard guard(jfw::FwkMutex::get()); 857 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 858 return JFW_E_DIRECT_MODE; 859 //check if pInfo is the selected JRE 860 JavaInfo *currentInfo = NULL; 861 errcode = jfw_getSelectedJRE( & currentInfo); 862 if (errcode != JFW_E_NONE && errcode != JFW_E_INVALID_SETTINGS) 863 return errcode; 864 865 if (jfw_areEqualJavaInfo(currentInfo, pInfo) == sal_False) 866 { 867 jfw::NodeJava node; 868 node.setJavaInfo(pInfo, false); 869 node.write(); 870 //remember that the JRE was selected in this process 871 jfw::setJavaSelected(); 872 } 873 } 874 catch (jfw::FrameworkException& e) 875 { 876 errcode = e.errorCode; 877 fprintf(stderr, "%s\n", e.message.getStr()); 878 OSL_ENSURE(0, e.message.getStr()); 879 } 880 return errcode; 881 } 882 javaFrameworkError SAL_CALL jfw_setEnabled(sal_Bool bEnabled) 883 { 884 javaFrameworkError errcode = JFW_E_NONE; 885 try 886 { 887 osl::MutexGuard guard(jfw::FwkMutex::get()); 888 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 889 return JFW_E_DIRECT_MODE; 890 891 if (g_bEnabledSwitchedOn == false && bEnabled == sal_True) 892 { 893 //When the process started then Enabled was false. 894 //This is first time enabled is set to true. 895 //That means, no preparational work has been done, such as setting the 896 //LD_LIBRARY_PATH, etc. 897 898 //check if Enabled is false; 899 const jfw::MergedSettings settings; 900 if (settings.getEnabled() == sal_False) 901 g_bEnabledSwitchedOn = true; 902 } 903 jfw::NodeJava node; 904 node.setEnabled(bEnabled); 905 node.write(); 906 } 907 catch (jfw::FrameworkException& e) 908 { 909 errcode = e.errorCode; 910 fprintf(stderr, "%s\n", e.message.getStr()); 911 OSL_ENSURE(0, e.message.getStr()); 912 } 913 return errcode; 914 } 915 916 javaFrameworkError SAL_CALL jfw_getEnabled(sal_Bool *pbEnabled) 917 { 918 javaFrameworkError errcode = JFW_E_NONE; 919 try 920 { 921 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 922 return JFW_E_DIRECT_MODE; 923 osl::MutexGuard guard(jfw::FwkMutex::get()); 924 if (pbEnabled == NULL) 925 return JFW_E_INVALID_ARG; 926 jfw::MergedSettings settings; 927 *pbEnabled = settings.getEnabled(); 928 } 929 catch (jfw::FrameworkException& e) 930 { 931 errcode = e.errorCode; 932 fprintf(stderr, "%s\n", e.message.getStr()); 933 OSL_ENSURE(0, e.message.getStr()); 934 } 935 return errcode; 936 } 937 938 939 javaFrameworkError SAL_CALL jfw_setVMParameters( 940 rtl_uString * * arOptions, sal_Int32 nLen) 941 { 942 javaFrameworkError errcode = JFW_E_NONE; 943 try 944 { 945 osl::MutexGuard guard(jfw::FwkMutex::get()); 946 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 947 return JFW_E_DIRECT_MODE; 948 jfw::NodeJava node; 949 if (arOptions == NULL && nLen != 0) 950 return JFW_E_INVALID_ARG; 951 node.setVmParameters(arOptions, nLen); 952 node.write(); 953 } 954 catch (jfw::FrameworkException& e) 955 { 956 errcode = e.errorCode; 957 fprintf(stderr, "%s\n", e.message.getStr()); 958 OSL_ENSURE(0, e.message.getStr()); 959 } 960 961 return errcode; 962 } 963 964 javaFrameworkError SAL_CALL jfw_getVMParameters( 965 rtl_uString *** parOptions, sal_Int32 * pLen) 966 { 967 javaFrameworkError errcode = JFW_E_NONE; 968 try 969 { 970 osl::MutexGuard guard(jfw::FwkMutex::get()); 971 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 972 return JFW_E_DIRECT_MODE; 973 974 if (parOptions == NULL || pLen == NULL) 975 return JFW_E_INVALID_ARG; 976 const jfw::MergedSettings settings; 977 settings.getVmParametersArray(parOptions, pLen); 978 } 979 catch (jfw::FrameworkException& e) 980 { 981 errcode = e.errorCode; 982 fprintf(stderr, "%s\n", e.message.getStr()); 983 OSL_ENSURE(0, e.message.getStr()); 984 } 985 return errcode; 986 } 987 988 javaFrameworkError SAL_CALL jfw_setUserClassPath(rtl_uString * pCp) 989 { 990 javaFrameworkError errcode = JFW_E_NONE; 991 try 992 { 993 osl::MutexGuard guard(jfw::FwkMutex::get()); 994 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 995 return JFW_E_DIRECT_MODE; 996 jfw::NodeJava node; 997 if (pCp == NULL) 998 return JFW_E_INVALID_ARG; 999 node.setUserClassPath(pCp); 1000 node.write(); 1001 } 1002 catch (jfw::FrameworkException& e) 1003 { 1004 errcode = e.errorCode; 1005 fprintf(stderr, "%s\n", e.message.getStr()); 1006 OSL_ENSURE(0, e.message.getStr()); 1007 } 1008 return errcode; 1009 } 1010 1011 javaFrameworkError SAL_CALL jfw_getUserClassPath(rtl_uString ** ppCP) 1012 { 1013 javaFrameworkError errcode = JFW_E_NONE; 1014 try 1015 { 1016 osl::MutexGuard guard(jfw::FwkMutex::get()); 1017 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 1018 return JFW_E_DIRECT_MODE; 1019 if (ppCP == NULL) 1020 return JFW_E_INVALID_ARG; 1021 const jfw::MergedSettings settings; 1022 *ppCP = settings.getUserClassPath().pData; 1023 rtl_uString_acquire(*ppCP); 1024 } 1025 catch (jfw::FrameworkException& e) 1026 { 1027 errcode = e.errorCode; 1028 fprintf(stderr, "%s\n", e.message.getStr()); 1029 OSL_ENSURE(0, e.message.getStr()); 1030 } 1031 return errcode; 1032 } 1033 1034 javaFrameworkError SAL_CALL jfw_addJRELocation(rtl_uString * sLocation) 1035 { 1036 javaFrameworkError errcode = JFW_E_NONE; 1037 try 1038 { 1039 osl::MutexGuard guard(jfw::FwkMutex::get()); 1040 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 1041 return JFW_E_DIRECT_MODE; 1042 jfw::NodeJava node; 1043 if (sLocation == NULL) 1044 return JFW_E_INVALID_ARG; 1045 node.load(); 1046 node.addJRELocation(sLocation); 1047 node.write(); 1048 } 1049 catch (jfw::FrameworkException& e) 1050 { 1051 errcode = e.errorCode; 1052 fprintf(stderr, "%s\n", e.message.getStr()); 1053 OSL_ENSURE(0, e.message.getStr()); 1054 } 1055 1056 return errcode; 1057 1058 } 1059 1060 javaFrameworkError SAL_CALL jfw_setJRELocations( 1061 rtl_uString ** arLocations, sal_Int32 nLen) 1062 { 1063 javaFrameworkError errcode = JFW_E_NONE; 1064 try 1065 { 1066 osl::MutexGuard guard(jfw::FwkMutex::get()); 1067 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 1068 return JFW_E_DIRECT_MODE; 1069 jfw::NodeJava node; 1070 if (arLocations == NULL && nLen != 0) 1071 return JFW_E_INVALID_ARG; 1072 node.setJRELocations(arLocations, nLen); 1073 node.write(); 1074 } 1075 catch (jfw::FrameworkException& e) 1076 { 1077 errcode = e.errorCode; 1078 fprintf(stderr, "%s\n", e.message.getStr()); 1079 OSL_ENSURE(0, e.message.getStr()); 1080 } 1081 return errcode; 1082 1083 } 1084 1085 javaFrameworkError SAL_CALL jfw_getJRELocations( 1086 rtl_uString *** parLocations, sal_Int32 *pLen) 1087 { 1088 javaFrameworkError errcode = JFW_E_NONE; 1089 try 1090 { 1091 osl::MutexGuard guard(jfw::FwkMutex::get()); 1092 if (jfw::getMode() == jfw::JFW_MODE_DIRECT) 1093 return JFW_E_DIRECT_MODE; 1094 1095 if (parLocations == NULL || pLen == NULL) 1096 return JFW_E_INVALID_ARG; 1097 const jfw::MergedSettings settings; 1098 settings.getJRELocations(parLocations, pLen); 1099 } 1100 catch (jfw::FrameworkException& e) 1101 { 1102 errcode = e.errorCode; 1103 fprintf(stderr, "%s\n", e.message.getStr()); 1104 OSL_ENSURE(0, e.message.getStr()); 1105 } 1106 1107 return errcode; 1108 } 1109 1110 1111 javaFrameworkError jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist) 1112 { 1113 //get the function jfw_plugin_existJRE 1114 jfw::VendorSettings aVendorSettings; 1115 jfw::CJavaInfo aInfo; 1116 aInfo = (const ::JavaInfo*) pInfo; //makes a copy of pInfo 1117 rtl::OUString sLibPath = aVendorSettings.getPluginLibrary(aInfo.getVendor()); 1118 osl::Module modulePlugin(sLibPath); 1119 if ( ! modulePlugin) 1120 return JFW_E_NO_PLUGIN; 1121 rtl::OUString sFunctionName( 1122 RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_existJRE")); 1123 jfw_plugin_existJRE_ptr pFunc = 1124 (jfw_plugin_existJRE_ptr) 1125 osl_getFunctionSymbol(modulePlugin, sFunctionName.pData); 1126 if (pFunc == NULL) 1127 return JFW_E_ERROR; 1128 1129 javaPluginError plerr = (*pFunc)(pInfo, exist); 1130 1131 javaFrameworkError ret = JFW_E_NONE; 1132 switch (plerr) 1133 { 1134 case JFW_PLUGIN_E_NONE: 1135 ret = JFW_E_NONE; 1136 break; 1137 case JFW_PLUGIN_E_INVALID_ARG: 1138 ret = JFW_E_INVALID_ARG; 1139 break; 1140 case JFW_PLUGIN_E_ERROR: 1141 ret = JFW_E_ERROR; 1142 break; 1143 default: 1144 ret = JFW_E_ERROR; 1145 } 1146 return ret; 1147 } 1148 1149 void SAL_CALL jfw_lock() 1150 { 1151 jfw::FwkMutex::get().acquire(); 1152 } 1153 1154 void SAL_CALL jfw_unlock() 1155 { 1156 jfw::FwkMutex::get().release(); 1157 } 1158 1159 1160 namespace jfw 1161 { 1162 CJavaInfo::CJavaInfo(): pInfo(0) 1163 { 1164 } 1165 1166 CJavaInfo::CJavaInfo(const CJavaInfo & info) 1167 { 1168 pInfo = copyJavaInfo(info.pInfo); 1169 } 1170 1171 CJavaInfo::CJavaInfo(::JavaInfo * info, _transfer_ownership) 1172 { 1173 pInfo = info; 1174 } 1175 CJavaInfo CJavaInfo::createWrapper(::JavaInfo* info) 1176 { 1177 return CJavaInfo(info, TRANSFER); 1178 } 1179 void CJavaInfo::attach(::JavaInfo * info) 1180 { 1181 jfw_freeJavaInfo(pInfo); 1182 pInfo = info; 1183 } 1184 ::JavaInfo * CJavaInfo::detach() 1185 { 1186 JavaInfo * tmp = pInfo; 1187 pInfo = NULL; 1188 return tmp; 1189 } 1190 1191 CJavaInfo::~CJavaInfo() 1192 { 1193 jfw_freeJavaInfo(pInfo); 1194 } 1195 1196 CJavaInfo::operator ::JavaInfo* () 1197 { 1198 return pInfo; 1199 } 1200 1201 JavaInfo * CJavaInfo::copyJavaInfo(const JavaInfo * pInfo) 1202 { 1203 if (pInfo == NULL) 1204 return NULL; 1205 JavaInfo* newInfo = 1206 (JavaInfo*) rtl_allocateMemory(sizeof(JavaInfo)); 1207 if (newInfo) 1208 { 1209 rtl_copyMemory(newInfo, pInfo, sizeof(JavaInfo)); 1210 rtl_uString_acquire(pInfo->sVendor); 1211 rtl_uString_acquire(pInfo->sLocation); 1212 rtl_uString_acquire(pInfo->sVersion); 1213 rtl_byte_sequence_acquire(pInfo->arVendorData); 1214 } 1215 return newInfo; 1216 } 1217 1218 1219 JavaInfo* CJavaInfo::cloneJavaInfo() const 1220 { 1221 if (pInfo == NULL) 1222 return NULL; 1223 return copyJavaInfo(pInfo); 1224 } 1225 1226 CJavaInfo & CJavaInfo::operator = (const CJavaInfo& info) 1227 { 1228 if (&info == this) 1229 return *this; 1230 1231 jfw_freeJavaInfo(pInfo); 1232 pInfo = copyJavaInfo(info.pInfo); 1233 return *this; 1234 } 1235 CJavaInfo & CJavaInfo::operator = (const ::JavaInfo* info) 1236 { 1237 if (info == pInfo) 1238 return *this; 1239 1240 jfw_freeJavaInfo(pInfo); 1241 pInfo = copyJavaInfo(info); 1242 return *this; 1243 } 1244 1245 const ::JavaInfo* CJavaInfo::operator ->() const 1246 { 1247 return pInfo; 1248 } 1249 1250 CJavaInfo::operator JavaInfo const * () const 1251 { 1252 return pInfo; 1253 } 1254 // ::JavaInfo** CJavaInfo::operator & () 1255 // { 1256 // return & pInfo; 1257 // } 1258 1259 rtl::OUString CJavaInfo::getVendor() const 1260 { 1261 if (pInfo) 1262 return rtl::OUString(pInfo->sVendor); 1263 else 1264 return rtl::OUString(); 1265 } 1266 1267 rtl::OUString CJavaInfo::getLocation() const 1268 { 1269 if (pInfo) 1270 return rtl::OUString(pInfo->sLocation); 1271 else 1272 return rtl::OUString(); 1273 } 1274 1275 sal_uInt64 CJavaInfo::getFeatures() const 1276 { 1277 if (pInfo) 1278 return pInfo->nFeatures; 1279 else 1280 return 0l; 1281 } 1282 1283 } 1284