diff options
Diffstat (limited to 'remotebridges')
-rw-r--r-- | remotebridges/source/bridge/bridge_provider.cxx | 69 | ||||
-rw-r--r-- | remotebridges/source/bridge/remote_bridge.cxx | 87 | ||||
-rw-r--r-- | remotebridges/source/bridge/remote_bridge.hxx | 14 | ||||
-rw-r--r-- | remotebridges/source/factory/bridgeimpl.cxx | 97 |
4 files changed, 189 insertions, 78 deletions
diff --git a/remotebridges/source/bridge/bridge_provider.cxx b/remotebridges/source/bridge/bridge_provider.cxx index 10b1b6806718..54b964ac874f 100644 --- a/remotebridges/source/bridge/bridge_provider.cxx +++ b/remotebridges/source/bridge/bridge_provider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bridge_provider.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jbu $ $Date: 2000-09-28 08:47:30 $ + * last change: $Author: jbu $ $Date: 2001-05-02 14:13:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,9 +91,6 @@ namespace remotebridges_bridge OInstanceProviderWrapper::~OInstanceProviderWrapper() { -#ifdef VERBOSE - printf( "Instance Provider Wrapper dies\n" ); -#endif } void OInstanceProviderWrapper::thisAcquire( remote_InstanceProvider *p ) @@ -111,12 +108,41 @@ namespace remotebridges_bridge } } + static convertToRemoteRuntimeException ( uno_Any **ppException, + const ::rtl::OUString &sMessage, + const Reference< XInterface > &rContext, + Mapping &map ) + { + + uno_type_any_construct( *ppException , + 0 , + getCppuType( (RuntimeException *)0 ).getTypeLibType() , + 0 ); + + typelib_CompoundTypeDescription * pCompType = 0 ; + getCppuType( (Exception*)0 ).getDescription( (typelib_TypeDescription **) &pCompType ); + if( ! ((typelib_TypeDescription *)pCompType)->bComplete ) + { + typelib_typedescription_complete( (typelib_TypeDescription**) &pCompType ); + } + + char *pValue = (char*) (*ppException)->pData; + rtl_uString_assign( (rtl_uString ** ) pValue , sMessage.pData ); + + *((remote_Interface**) pValue+pCompType->pMemberOffsets[1]) = + (remote_Interface*) map.mapInterface( + rContext.get(), getCppuType( &rContext) ); + + typelib_typedescription_release( (typelib_TypeDescription *) pCompType ); + } + void OInstanceProviderWrapper::thisGetInstance( remote_InstanceProvider * pProvider , uno_Environment *pEnvRemote, remote_Interface **ppRemoteI, rtl_uString *pInstanceName, - typelib_InterfaceTypeDescription *pType + typelib_InterfaceTypeDescription *pType, + uno_Any **ppException ) { OInstanceProviderWrapper * m = (OInstanceProviderWrapper *)pProvider; @@ -131,35 +157,42 @@ namespace remotebridges_bridge if( OUString( pType->aBase.pTypeName ) == getCppuType( (Reference<XInterface>*)0).getTypeName() ) { + OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); + + uno_Environment *pEnvThis = 0; + uno_getEnvironment( &pEnvThis , + sCppuName.pData , + 0 ); + Mapping map( pEnvThis , pEnvRemote ); + pEnvThis->release( pEnvThis ); + try { Reference< XInterface > r = m->m_rProvider->getInstance( OUString( pInstanceName ) ); - OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); - uno_Environment *pEnvThis = 0; - uno_getEnvironment( &pEnvThis , - sCppuName.pData , - 0 ); - - Mapping map( pEnvThis , pEnvRemote ); - *ppRemoteI = (remote_Interface*) map.mapInterface ( r.get(), getCppuType( (Reference< XInterface > *) 0 ) ); - pEnvThis->release( pEnvThis ); - if( *ppRemoteI && m->m_pBridgeCallback ) { m->m_pBridgeCallback->objectMappedSuccesfully(); m->m_pBridgeCallback = 0; } + *ppException = 0; + } + catch( ::com::sun::star::container::NoSuchElementException &e ) + { + // NoSuchElementException not specified, so convert it to a runtime exception + convertToRemoteRuntimeException( + ppException , e.Message.pData , e.Context.get(), map ); } - catch( ::com::sun::star::container::NoSuchElementException & ) + catch( ::com::sun::star::uno::RuntimeException &e ) { - // simply pass a null reference + convertToRemoteRuntimeException( + ppException , e.Message.pData , e.Context.get(), map ); } } diff --git a/remotebridges/source/bridge/remote_bridge.cxx b/remotebridges/source/bridge/remote_bridge.cxx index a76af0c22284..64e54d044361 100644 --- a/remotebridges/source/bridge/remote_bridge.cxx +++ b/remotebridges/source/bridge/remote_bridge.cxx @@ -2,9 +2,9 @@ * * $RCSfile: remote_bridge.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jl $ $Date: 2001-03-12 16:16:37 $ + * last change: $Author: jbu $ $Date: 2001-05-02 14:13:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -225,50 +225,89 @@ namespace remotebridges_bridge { Reference < XInterface > rReturn; - if( m_pContext && m_pContext->getRemoteInstance ) + remote_Context *pContext = 0; + { + MutexGuard guard( m_mutex ); + if( m_pContext && m_pContext->getRemoteInstance ) + { + pContext = m_pContext; + pContext->aBase.acquire( (uno_Context*)pContext ); + } + } + if( pContext ) { // get the appropriate remote environment uno_Environment *pEnvRemote = 0; - uno_getEnvironment( &pEnvRemote , m_sProtocol.pData , m_pContext ); + uno_getEnvironment( &pEnvRemote , m_sProtocol.pData , pContext ); if( ! pEnvRemote ) { - return Reference< XInterface > (); + pContext->aBase.release( (uno_Context*) pContext ); + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed" ) ), + Reference< XInterface > () ); } Type type = getCppuType( (Reference < XInterface > * ) 0 ); remote_Interface *pRemoteI = 0; - m_pContext->getRemoteInstance( + uno_Any exception; + uno_Any *pException = &exception; + + pContext->getRemoteInstance( pEnvRemote, &pRemoteI, sInstanceName.pData, - type.getTypeLibType() ); + type.getTypeLibType(), + &pException ); + pContext->aBase.release( (uno_Context*) pContext ); + pContext = 0; + + uno_Environment *pEnvCpp =0; + OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); + uno_getEnvironment( &pEnvCpp , + sCppuName.pData , + 0 ); + Mapping map( pEnvRemote , pEnvCpp ); + + pEnvCpp->release( pEnvCpp ); + pEnvRemote->release( pEnvRemote ); - if( pRemoteI ) + if( pException ) { - // got an interface ! - uno_Environment *pEnvCpp =0; - OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); - uno_getEnvironment( &pEnvCpp , - sCppuName.pData , - 0 ); - - Mapping map( pEnvRemote , pEnvCpp ); + typelib_CompoundTypeDescription * pCompType = 0 ; + getCppuType( (Exception*)0 ).getDescription( (typelib_TypeDescription **) &pCompType ); + if( ! ((typelib_TypeDescription *)pCompType)->bComplete ) + { + typelib_typedescription_complete( (typelib_TypeDescription**) &pCompType ); + } + XInterface *pXInterface = (XInterface *) map.mapInterface( + *(remote_Interface**) ( ((char*)pException->pData)+pCompType->pMemberOffsets[1] ), + getCppuType( (Reference< XInterface > *)0 ) ); + RuntimeException myException( + *((rtl_uString **)pException->pData), + Reference< XInterface > ( pXInterface , SAL_NO_ACQUIRE) ); + uno_any_destruct( pException , 0 ); + + throw myException; + } + else if( pRemoteI ) + { + // got an interface ! XInterface * pCppI = ( XInterface * ) map.mapInterface( pRemoteI, type ); - - rReturn = Reference<XInterface > ( pCppI ); - - pCppI->release( ); - + rReturn = Reference<XInterface > ( pCppI, SAL_NO_ACQUIRE ); pRemoteI->release( pRemoteI ); - pEnvCpp->release( pEnvCpp ); objectMappedSuccesfully(); } - - pEnvRemote->release( pEnvRemote ); } + else + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed." ) ), + Reference< XInterface > () ); + } + return rReturn; } diff --git a/remotebridges/source/bridge/remote_bridge.hxx b/remotebridges/source/bridge/remote_bridge.hxx index d0ab56c1adf6..06cf8d0ae0cf 100644 --- a/remotebridges/source/bridge/remote_bridge.hxx +++ b/remotebridges/source/bridge/remote_bridge.hxx @@ -2,9 +2,9 @@ * * $RCSfile: remote_bridge.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jbu $ $Date: 2000-09-28 08:47:31 $ + * last change: $Author: jbu $ $Date: 2001-05-02 14:13:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -162,11 +162,11 @@ namespace remotebridges_bridge static void SAL_CALL thisAcquire( remote_InstanceProvider * ); static void SAL_CALL thisRelease( remote_InstanceProvider * ); static void SAL_CALL thisGetInstance( remote_InstanceProvider * pProvider , - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pInstanceName, - typelib_InterfaceTypeDescription *pType - ); + uno_Environment *pEnvRemote, + remote_Interface **ppRemoteI, + rtl_uString *pInstanceName, + typelib_InterfaceTypeDescription *pType, + uno_Any **ppException ); private: ::com::sun::star::uno::Reference < diff --git a/remotebridges/source/factory/bridgeimpl.cxx b/remotebridges/source/factory/bridgeimpl.cxx index 9af8cf966add..8ecc08f3ccff 100644 --- a/remotebridges/source/factory/bridgeimpl.cxx +++ b/remotebridges/source/factory/bridgeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bridgeimpl.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jbu $ $Date: 2000-09-29 08:44:08 $ + * last change: $Author: jbu $ $Date: 2001-05-02 14:14:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -140,53 +140,92 @@ namespace remotebridges_factory { Reference< XInterface > OBridge::getInstance( const ::rtl::OUString& sInstanceName ) throw(::com::sun::star::uno::RuntimeException) { - Reference < XInterface > rReturn; - if( m_pContext && m_pContext->getRemoteInstance ) + remote_Context *pContext = 0; { - // get the appropriate remote environment - OUString sRemote( m_pContext->m_pProtocol ); - if( sRemote.indexOf( ',' ) != -1 ) + MutexGuard guard( m_mutex ); + if( m_pContext && m_pContext->getRemoteInstance ) { - sRemote = sRemote.copy( 0, sRemote.indexOf( ',' ) ); + pContext = m_pContext; + pContext->aBase.acquire( (uno_Context*)pContext ); } + } + if( pContext ) + { + OUString sProtocol = OUString( m_pContext->m_pProtocol ).getToken( 0 , ',' ); + + // get the appropriate remote environment uno_Environment *pEnvRemote = 0; - uno_getEnvironment( &pEnvRemote , sRemote.pData , m_pContext ); + uno_getEnvironment( &pEnvRemote , sProtocol.pData , pContext ); - OSL_ASSERT( pEnvRemote ); + if( ! pEnvRemote ) + { + pContext->aBase.release( (uno_Context*) pContext ); + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed" ) ), + Reference< XInterface > () ); + } Type type = getCppuType( (Reference < XInterface > * ) 0 ); remote_Interface *pRemoteI = 0; - m_pContext->getRemoteInstance( + uno_Any exception; + uno_Any *pException = &exception; + + pContext->getRemoteInstance( pEnvRemote, &pRemoteI, sInstanceName.pData, - type.getTypeLibType() ); - + type.getTypeLibType(), + &pException ); + pContext->aBase.release( (uno_Context*) pContext ); + pContext = 0; + + uno_Environment *pEnvCpp =0; + OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); + uno_getEnvironment( &pEnvCpp , + sCppuName.pData , + 0 ); + Mapping map( pEnvRemote , pEnvCpp ); + + pEnvCpp->release( pEnvCpp ); + pEnvRemote->release( pEnvRemote ); - if( pRemoteI ) + if( pException ) + { + typelib_CompoundTypeDescription * pCompType = 0 ; + getCppuType( (Exception*)0 ).getDescription( (typelib_TypeDescription **) &pCompType ); + + if( ! ((typelib_TypeDescription *)pCompType)->bComplete ) + { + typelib_typedescription_complete( (typelib_TypeDescription**) &pCompType ); + } + XInterface *pXInterface = (XInterface *) map.mapInterface( + *(remote_Interface**) ( ((char*)pException->pData)+pCompType->pMemberOffsets[1] ), + getCppuType( (Reference< XInterface > *)0 ) ); + RuntimeException myException( + *((rtl_uString **)pException->pData), + Reference< XInterface > ( pXInterface , SAL_NO_ACQUIRE) ); + uno_any_destruct( pException , 0 ); + + throw myException; + } + else if( pRemoteI ) { // got an interface ! - OUString sCppu ( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME )); - uno_Environment *pEnvCpp =0; - uno_getEnvironment( &pEnvCpp , sCppu.pData , 0 ); - - Mapping map( pEnvRemote , pEnvCpp ); - - XInterface * pCppI = ( XInterface * ) map.mapInterface( pRemoteI,type ); - - rReturn = Reference<XInterface > ( pCppI ); - - pCppI->release( ); - + XInterface * pCppI = ( XInterface * ) map.mapInterface( pRemoteI, type ); + rReturn = Reference<XInterface > ( pCppI, SAL_NO_ACQUIRE ); pRemoteI->release( pRemoteI ); - pEnvCpp->release( pEnvCpp ); } - - pEnvRemote->release( pEnvRemote ); } + else + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed." ) ), + Reference< XInterface > () ); + } + return rReturn; } |