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

Generated by: LCOV version 1.10