LCOV - code coverage report
Current view: top level - javaunohelper/source - javaunohelper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 85 0.0 %
Date: 2014-04-11 Functions: 0 2 0.0 %
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 "sal/config.h"
      21             : 
      22             : #include <osl/diagnose.h>
      23             : #include <osl/module.h>
      24             : 
      25             : #include <uno/environment.hxx>
      26             : #include <uno/lbnames.h>
      27             : #include <uno/mapping.hxx>
      28             : 
      29             : #include <cppuhelper/factory.hxx>
      30             : 
      31             : #include <com/sun/star/beans/XPropertySet.hpp>
      32             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      33             : #include <com/sun/star/lang/XServiceInfo.hpp>
      34             : #include <com/sun/star/registry/XRegistryKey.hpp>
      35             : 
      36             : #include "jni.h"
      37             : #include "jvmaccess/virtualmachine.hxx"
      38             : #include "jvmaccess/unovirtualmachine.hxx"
      39             : 
      40             : #include "juhx-export-functions.hxx"
      41             : #include "vm.hxx"
      42             : 
      43             : using namespace ::com::sun::star;
      44             : using namespace ::com::sun::star::uno;
      45             : 
      46             : /*
      47             :  * Class:     com_sun_star_comp_helper_SharedLibraryLoader
      48             :  * Method:    component_writeInfo
      49             :  * Signature: (Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Z
      50             :  */
      51           0 : jboolean Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
      52             :     JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jLibName, jobject jSMgr,
      53             :     jobject jRegKey, jobject loader )
      54             : {
      55           0 :     sal_Bool bRet = sal_False;
      56             : 
      57           0 :     const jchar* pJLibName = pJEnv->GetStringChars( jLibName, NULL );
      58           0 :     OUString aLibName( pJLibName );
      59           0 :     pJEnv->ReleaseStringChars( jLibName, pJLibName);
      60             : 
      61             : #ifdef DISABLE_DYNLOADING
      62             :     (void) jSMgr;
      63             :     (void) jRegKey;
      64             :     (void) loader;
      65             : 
      66             :     fprintf(stderr, "Hmm, %s called for %s\n", __PRETTY_FUNCTION__, OUStringToOString(pJLibName, RTL_TEXTENCODING_JAVA_UTF8).getStr());
      67             : #else
      68           0 :     oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
      69           0 :     if (lib)
      70             :     {
      71             :         // ========================= LATEST VERSION =========================
      72           0 :         OUString aGetEnvName( COMPONENT_GETENV );
      73             :         oslGenericFunction pSym =
      74           0 :             osl_getFunctionSymbol( lib, aGetEnvName.pData );
      75           0 :         if (pSym)
      76             :         {
      77           0 :             Environment java_env, loader_env;
      78             : 
      79           0 :             const sal_Char * pEnvTypeName = 0;
      80             :             (*((component_getImplementationEnvironmentFunc)pSym))(
      81           0 :                 &pEnvTypeName, (uno_Environment **)&loader_env );
      82           0 :             if (! loader_env.is())
      83             :             {
      84           0 :                 OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
      85           0 :                 uno_getEnvironment( (uno_Environment **)&loader_env, aEnvTypeName.pData, 0 );
      86             :             }
      87             : 
      88             :             // create vm access
      89             :             ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
      90           0 :                 ::javaunohelper::create_vm_access( pJEnv, loader ) );
      91           0 :             OUString java_env_name = UNO_LB_JAVA;
      92             :             uno_getEnvironment(
      93           0 :                 (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
      94             : 
      95           0 :             OUString aWriteInfoName( COMPONENT_WRITEINFO );
      96           0 :             pSym = osl_getFunctionSymbol( lib, aWriteInfoName.pData );
      97           0 :             if (pSym)
      98             :             {
      99           0 :                 if (loader_env.is() && java_env.is())
     100             :                 {
     101           0 :                     Mapping java2dest(java_env.get(), loader_env.get());
     102             : 
     103           0 :                     if ( java2dest.is() )
     104             :                     {
     105             :                         void * pSMgr =
     106             :                             java2dest.mapInterface(
     107           0 :                                 jSMgr, getCppuType((Reference< lang::XMultiServiceFactory > *) 0) );
     108             :                         void * pKey =
     109             :                             java2dest.mapInterface(
     110           0 :                                 jRegKey, getCppuType((Reference< registry::XRegistryKey > *) 0) );
     111             : 
     112           0 :                         uno_ExtEnvironment * env = loader_env.get()->pExtEnv;
     113           0 :                         if (pKey)
     114             :                         {
     115           0 :                             bRet = (*((component_writeInfoFunc)pSym))( pSMgr, pKey );
     116             : 
     117           0 :                             if (env)
     118           0 :                                 (*env->releaseInterface)( env, pKey );
     119             :                         }
     120             : 
     121           0 :                         if (pSMgr && env)
     122           0 :                             (*env->releaseInterface)( env, pSMgr );
     123           0 :                     }
     124             :                 }
     125           0 :             }
     126           0 :         }
     127             :     }
     128             : #endif
     129           0 :     return bRet == sal_False? JNI_FALSE : JNI_TRUE;
     130             : }
     131             : 
     132             : /*
     133             :  * Class:     com_sun_star_comp_helper_SharedLibraryLoader
     134             :  * Method:    component_getFactory
     135             :  * Signature: (Ljava/lang/String;Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Ljava/lang/Object;
     136             :  */
     137           0 : jobject Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
     138             :     JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jLibName, jstring jImplName,
     139             :     jobject jSMgr, jobject jRegKey, jobject loader )
     140             : {
     141           0 :     const jchar* pJLibName = pJEnv->GetStringChars(jLibName, NULL);
     142             : 
     143             : #ifdef DISABLE_DYNLOADING
     144             :     (void) jImplName;
     145             :     (void) jSMgr;
     146             :     (void) jRegKey;
     147             :     (void) loader;
     148             : 
     149             :     fprintf(stderr, "Hmm, %s called for %s\n", __PRETTY_FUNCTION__, OUStringToOString(pJLibName, RTL_TEXTENCODING_JAVA_UTF8).getStr());
     150             : #endif
     151             : 
     152           0 :     OUString aLibName( pJLibName );
     153           0 :     pJEnv->ReleaseStringChars( jLibName, pJLibName);
     154             : 
     155           0 :     aLibName += OUString( SAL_DLLEXTENSION );
     156             : 
     157           0 :     jobject joSLL_cpp = 0;
     158             : 
     159             : #ifndef DISABLE_DYNLOADING
     160           0 :     oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
     161           0 :     if (lib)
     162             :     {
     163             :         // ========================= LATEST VERSION =========================
     164           0 :         OUString aGetEnvName( COMPONENT_GETENV );
     165             :         oslGenericFunction pSym =
     166           0 :             osl_getFunctionSymbol( lib, aGetEnvName.pData );
     167           0 :         if (pSym)
     168             :         {
     169           0 :             Environment java_env, loader_env;
     170             : 
     171           0 :             const sal_Char * pEnvTypeName = 0;
     172             :             (*((component_getImplementationEnvironmentFunc)pSym))(
     173           0 :                 &pEnvTypeName, (uno_Environment **)&loader_env );
     174             : 
     175           0 :             if (! loader_env.is())
     176             :             {
     177           0 :                 OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
     178           0 :                 uno_getEnvironment( (uno_Environment **)&loader_env, aEnvTypeName.pData, 0 );
     179             :             }
     180             : 
     181             :             // create vm access
     182             :             ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
     183           0 :                 ::javaunohelper::create_vm_access( pJEnv, loader ) );
     184           0 :             OUString java_env_name = UNO_LB_JAVA;
     185             :             uno_getEnvironment(
     186           0 :                 (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
     187             : 
     188           0 :             OUString aGetFactoryName( COMPONENT_GETFACTORY );
     189           0 :             pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData );
     190           0 :             if (pSym)
     191             :             {
     192           0 :                 if (loader_env.is() && java_env.is())
     193             :                 {
     194           0 :                     Mapping java2dest( java_env.get(), loader_env.get() );
     195           0 :                     Mapping dest2java( loader_env.get(), java_env.get() );
     196             : 
     197           0 :                     if (dest2java.is() && java2dest.is())
     198             :                     {
     199             :                         void * pSMgr =
     200             :                             java2dest.mapInterface(
     201           0 :                                 jSMgr, ::getCppuType((Reference< lang::XMultiServiceFactory > *) 0) );
     202             :                         void * pKey =
     203             :                             java2dest.mapInterface(
     204           0 :                                 jRegKey, ::getCppuType((Reference< registry::XRegistryKey > *) 0) );
     205             : 
     206           0 :                         const char* pImplName = pJEnv->GetStringUTFChars( jImplName, NULL );
     207             : 
     208             :                         void * pSSF = (*((component_getFactoryFunc)pSym))(
     209           0 :                             pImplName, pSMgr, pKey );
     210             : 
     211           0 :                         pJEnv->ReleaseStringUTFChars( jImplName, pImplName );
     212             : 
     213           0 :                         uno_ExtEnvironment * env = loader_env.get()->pExtEnv;
     214             : 
     215           0 :                         if (pKey && env)
     216           0 :                             (*env->releaseInterface)( env, pKey );
     217           0 :                         if (pSMgr && env)
     218           0 :                             (*env->releaseInterface)( env, pSMgr );
     219             : 
     220           0 :                         if (pSSF)
     221             :                         {
     222             :                             jobject jglobal = (jobject) dest2java.mapInterface(
     223           0 :                                 pSSF, getCppuType((Reference< XInterface > *) 0) );
     224           0 :                             joSLL_cpp = pJEnv->NewLocalRef( jglobal );
     225           0 :                             pJEnv->DeleteGlobalRef( jglobal );
     226           0 :                             if (env)
     227           0 :                                 (*env->releaseInterface)( env, pSSF );
     228             :                         }
     229           0 :                     }
     230             :                 }
     231           0 :             }
     232           0 :         }
     233             :     }
     234             : #endif
     235           0 :     return joSLL_cpp;
     236             : }
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10