LCOV - code coverage report
Current view: top level - jvmfwk/source - framework.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 184 521 35.3 %
Date: 2014-11-03 Functions: 15 35 42.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10