LCOV - code coverage report
Current view: top level - javaunohelper/source - javaunohelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 87 0.0 %
Date: 2014-11-03 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.hxx>
      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 :     bool bRet = 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 :     osl::Module lib(aLibName, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
      69           0 :     if (lib.is())
      70             :     {
      71           0 :         lib.release();
      72             : 
      73             :         // ========================= LATEST VERSION =========================
      74           0 :         OUString aGetEnvName( COMPONENT_GETENV );
      75           0 :         oslGenericFunction pSym = lib.getFunctionSymbol(aGetEnvName);
      76           0 :         if (pSym)
      77             :         {
      78           0 :             Environment java_env, loader_env;
      79             : 
      80           0 :             const sal_Char * pEnvTypeName = 0;
      81             :             (*((component_getImplementationEnvironmentFunc)pSym))(
      82           0 :                 &pEnvTypeName, (uno_Environment **)&loader_env );
      83           0 :             if (! loader_env.is())
      84             :             {
      85           0 :                 OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
      86           0 :                 uno_getEnvironment( (uno_Environment **)&loader_env, aEnvTypeName.pData, 0 );
      87             :             }
      88             : 
      89             :             // create vm access
      90             :             ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
      91           0 :                 ::javaunohelper::create_vm_access( pJEnv, loader ) );
      92           0 :             OUString java_env_name = UNO_LB_JAVA;
      93             :             uno_getEnvironment(
      94           0 :                 (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
      95             : 
      96           0 :             OUString aWriteInfoName( COMPONENT_WRITEINFO );
      97           0 :             pSym = lib.getFunctionSymbol(aWriteInfoName);
      98           0 :             if (pSym)
      99             :             {
     100           0 :                 if (loader_env.is() && java_env.is())
     101             :                 {
     102           0 :                     Mapping java2dest(java_env.get(), loader_env.get());
     103             : 
     104           0 :                     if ( java2dest.is() )
     105             :                     {
     106             :                         void * pSMgr =
     107             :                             java2dest.mapInterface(
     108           0 :                                 jSMgr, cppu::UnoType<lang::XMultiServiceFactory>::get());
     109             :                         void * pKey =
     110             :                             java2dest.mapInterface(
     111           0 :                                 jRegKey, cppu::UnoType<registry::XRegistryKey>::get());
     112             : 
     113           0 :                         uno_ExtEnvironment * env = loader_env.get()->pExtEnv;
     114           0 :                         if (pKey)
     115             :                         {
     116           0 :                             bRet = (*((component_writeInfoFunc)pSym))( pSMgr, pKey );
     117             : 
     118           0 :                             if (env)
     119           0 :                                 (*env->releaseInterface)( env, pKey );
     120             :                         }
     121             : 
     122           0 :                         if (pSMgr && env)
     123           0 :                             (*env->releaseInterface)( env, pSMgr );
     124           0 :                     }
     125             :                 }
     126           0 :             }
     127           0 :         }
     128             :     }
     129             : #endif
     130           0 :     return bRet == false? JNI_FALSE : JNI_TRUE;
     131             : }
     132             : 
     133             : /*
     134             :  * Class:     com_sun_star_comp_helper_SharedLibraryLoader
     135             :  * Method:    component_getFactory
     136             :  * Signature: (Ljava/lang/String;Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Ljava/lang/Object;
     137             :  */
     138           0 : jobject Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
     139             :     JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jLibName, jstring jImplName,
     140             :     jobject jSMgr, jobject jRegKey, jobject loader )
     141             : {
     142           0 :     const jchar* pJLibName = pJEnv->GetStringChars(jLibName, NULL);
     143             : 
     144             : #ifdef DISABLE_DYNLOADING
     145             :     (void) jImplName;
     146             :     (void) jSMgr;
     147             :     (void) jRegKey;
     148             :     (void) loader;
     149             : 
     150             :     fprintf(stderr, "Hmm, %s called for %s\n", __PRETTY_FUNCTION__, OUStringToOString(pJLibName, RTL_TEXTENCODING_JAVA_UTF8).getStr());
     151             : #endif
     152             : 
     153           0 :     OUString aLibName( pJLibName );
     154           0 :     pJEnv->ReleaseStringChars( jLibName, pJLibName);
     155             : 
     156           0 :     aLibName += OUString( SAL_DLLEXTENSION );
     157             : 
     158           0 :     jobject joSLL_cpp = 0;
     159             : 
     160             : #ifndef DISABLE_DYNLOADING
     161           0 :     osl::Module lib(aLibName, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
     162           0 :     if (lib.is())
     163             :     {
     164           0 :         lib.release();
     165             : 
     166             :         // ========================= LATEST VERSION =========================
     167           0 :         OUString aGetEnvName( COMPONENT_GETENV );
     168           0 :         oslGenericFunction pSym = lib.getFunctionSymbol(aGetEnvName);
     169           0 :         if (pSym)
     170             :         {
     171           0 :             Environment java_env, loader_env;
     172             : 
     173           0 :             const sal_Char * pEnvTypeName = 0;
     174             :             (*((component_getImplementationEnvironmentFunc)pSym))(
     175           0 :                 &pEnvTypeName, (uno_Environment **)&loader_env );
     176             : 
     177           0 :             if (! loader_env.is())
     178             :             {
     179           0 :                 OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
     180           0 :                 uno_getEnvironment( (uno_Environment **)&loader_env, aEnvTypeName.pData, 0 );
     181             :             }
     182             : 
     183             :             // create vm access
     184             :             ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access(
     185           0 :                 ::javaunohelper::create_vm_access( pJEnv, loader ) );
     186           0 :             OUString java_env_name = UNO_LB_JAVA;
     187             :             uno_getEnvironment(
     188           0 :                 (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
     189             : 
     190           0 :             OUString aGetFactoryName( COMPONENT_GETFACTORY );
     191           0 :             pSym = lib.getFunctionSymbol(aGetFactoryName);
     192           0 :             if (pSym)
     193             :             {
     194           0 :                 if (loader_env.is() && java_env.is())
     195             :                 {
     196           0 :                     Mapping java2dest( java_env.get(), loader_env.get() );
     197           0 :                     Mapping dest2java( loader_env.get(), java_env.get() );
     198             : 
     199           0 :                     if (dest2java.is() && java2dest.is())
     200             :                     {
     201             :                         void * pSMgr =
     202             :                             java2dest.mapInterface(
     203           0 :                                 jSMgr, cppu::UnoType<lang::XMultiServiceFactory>::get());
     204             :                         void * pKey =
     205             :                             java2dest.mapInterface(
     206           0 :                                 jRegKey, cppu::UnoType<registry::XRegistryKey>::get());
     207             : 
     208           0 :                         const char* pImplName = pJEnv->GetStringUTFChars( jImplName, NULL );
     209             : 
     210             :                         void * pSSF = (*((component_getFactoryFunc)pSym))(
     211           0 :                             pImplName, pSMgr, pKey );
     212             : 
     213           0 :                         pJEnv->ReleaseStringUTFChars( jImplName, pImplName );
     214             : 
     215           0 :                         uno_ExtEnvironment * env = loader_env.get()->pExtEnv;
     216             : 
     217           0 :                         if (pKey && env)
     218           0 :                             (*env->releaseInterface)( env, pKey );
     219           0 :                         if (pSMgr && env)
     220           0 :                             (*env->releaseInterface)( env, pSMgr );
     221             : 
     222           0 :                         if (pSSF)
     223             :                         {
     224             :                             jobject jglobal = (jobject) dest2java.mapInterface(
     225           0 :                                 pSSF, cppu::UnoType<XInterface>::get());
     226           0 :                             joSLL_cpp = pJEnv->NewLocalRef( jglobal );
     227           0 :                             pJEnv->DeleteGlobalRef( jglobal );
     228           0 :                             if (env)
     229           0 :                                 (*env->releaseInterface)( env, pSSF );
     230             :                         }
     231           0 :                     }
     232             :                 }
     233           0 :             }
     234           0 :         }
     235             :     }
     236             : #endif
     237           0 :     return joSLL_cpp;
     238             : }
     239             : 
     240             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10