summaryrefslogtreecommitdiff
path: root/bridges/source/remote/urp
diff options
context:
space:
mode:
authorJörg Budischewski <jbu@openoffice.org>2000-09-29 07:42:07 +0000
committerJörg Budischewski <jbu@openoffice.org>2000-09-29 07:42:07 +0000
commit5d410afb731d39d63399b37708a75dc77ea81112 (patch)
treeb3c02ddb2a9a5e94f55fb714866a8579a632a51d /bridges/source/remote/urp
parent86a4267dd280e6ea6b73cef667fc58a5f02070c3 (diff)
incompatible urp modification, urp is now final :o)
Diffstat (limited to 'bridges/source/remote/urp')
-rw-r--r--bridges/source/remote/urp/makefile.mk10
-rw-r--r--bridges/source/remote/urp/urp_bridgeimpl.cxx133
-rw-r--r--bridges/source/remote/urp/urp_bridgeimpl.hxx20
-rw-r--r--bridges/source/remote/urp/urp_cache.h9
-rw-r--r--bridges/source/remote/urp/urp_cache.hxx67
-rw-r--r--bridges/source/remote/urp/urp_dispatch.cxx248
-rw-r--r--bridges/source/remote/urp/urp_dispatch.hxx24
-rw-r--r--bridges/source/remote/urp/urp_environment.cxx132
-rw-r--r--bridges/source/remote/urp/urp_job.cxx275
-rw-r--r--bridges/source/remote/urp/urp_job.hxx190
-rw-r--r--bridges/source/remote/urp/urp_log.hxx6
-rw-r--r--bridges/source/remote/urp/urp_marshal.cxx31
-rw-r--r--bridges/source/remote/urp/urp_marshal.hxx55
-rw-r--r--bridges/source/remote/urp/urp_marshal_decl.hxx21
-rw-r--r--bridges/source/remote/urp/urp_property.hxx103
-rw-r--r--bridges/source/remote/urp/urp_propertyobject.cxx682
-rw-r--r--bridges/source/remote/urp/urp_propertyobject.hxx165
-rw-r--r--bridges/source/remote/urp/urp_reader.cxx494
-rw-r--r--bridges/source/remote/urp/urp_reader.hxx11
-rw-r--r--bridges/source/remote/urp/urp_replycontainer.hxx12
-rw-r--r--bridges/source/remote/urp/urp_unmarshal.cxx191
-rw-r--r--bridges/source/remote/urp/urp_unmarshal.hxx43
-rw-r--r--bridges/source/remote/urp/urp_writer.cxx31
-rw-r--r--bridges/source/remote/urp/urp_writer.hxx7
24 files changed, 2127 insertions, 833 deletions
diff --git a/bridges/source/remote/urp/makefile.mk b/bridges/source/remote/urp/makefile.mk
index efad07ea8..1ebfbb019 100644
--- a/bridges/source/remote/urp/makefile.mk
+++ b/bridges/source/remote/urp/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1.1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+# last change: $Author: jbu $ $Date: 2000-09-29 08:42:05 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -88,7 +88,8 @@ INCPRE+=$(UNOUCROUT)
UNOTYPES= \
com.sun.star.uno.XInterface \
- com.sun.star.uno.TypeClass
+ com.sun.star.uno.TypeClass \
+ com.sun.star.bridge.XProtocolProperties
SLOFILES= \
@@ -100,7 +101,8 @@ SLOFILES= \
$(SLO)$/urp_reader.obj \
$(SLO)$/urp_writer.obj \
$(SLO)$/urp_log.obj \
- $(SLO)$/urp_bridgeimpl.obj
+ $(SLO)$/urp_bridgeimpl.obj \
+ $(SLO)$/urp_propertyobject.obj
SHL1TARGET= $(TARGET)
diff --git a/bridges/source/remote/urp/urp_bridgeimpl.cxx b/bridges/source/remote/urp/urp_bridgeimpl.cxx
index 730a302cd..3fa531854 100644
--- a/bridges/source/remote/urp/urp_bridgeimpl.cxx
+++ b/bridges/source/remote/urp/urp_bridgeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_bridgeimpl.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,12 @@ using namespace ::com::sun::star::uno;
namespace bridges_urp
{
+template < class t >
+inline t mymin( const t & val1, const t & val2 )
+{
+ return val1 < val2 ? val1 : val2;
+}
+
/***********
* urp_BridgeImpl
***********/
@@ -74,8 +80,8 @@ urp_BridgeImpl::urp_BridgeImpl( sal_Int32 nCacheSize , sal_uInt32 nInitialMarsha
m_oidCacheOut( nCacheSize ),
m_tidCacheOut( nCacheSize ),
m_typeCacheOut( nCacheSize ),
- m_nCacheSize( nCacheSize ),
- m_blockMarshaler( this , nInitialMarshalerSize , ::bridges_remote::remote_retrieveOidFromProxy)
+ m_blockMarshaler( this , nInitialMarshalerSize , ::bridges_remote::remote_retrieveOidFromProxy),
+ m_nMarshaledMessages( 0 )
{
m_pOidIn = new OUString[ nCacheSize ];
m_pTidIn = new ByteSequence[ nCacheSize ];
@@ -89,4 +95,123 @@ urp_BridgeImpl::~urp_BridgeImpl()
delete [] m_pTidIn;
delete [] m_pTypeIn;
}
+
+
+void urp_BridgeImpl::applyProtocolChanges( const Properties &props )
+{
+ if( m_properties.nTypeCacheSize != props.nTypeCacheSize )
+ {
+ if( props.nTypeCacheSize == 0 )
+ {
+ delete [] m_pTypeIn;
+ m_pTypeIn = 0;
+ }
+ else
+ {
+ Type *pNew = new Type[props.nTypeCacheSize];
+ sal_Int32 i;
+ sal_Int32 iMin = mymin( m_properties.nTypeCacheSize , props.nTypeCacheSize );
+ for( i = 0; i < iMin ; i ++ )
+ {
+ pNew[i] = m_pTypeIn[i];
+ }
+ delete [] m_pTypeIn;
+ m_pTypeIn = pNew;
+ }
+ m_properties.nTypeCacheSize = props.nTypeCacheSize;
+ m_typeCacheOut.resize( props.nTypeCacheSize );
+ }
+
+ if( m_properties.nOidCacheSize != props.nOidCacheSize )
+ {
+ if( 0 == props.nOidCacheSize )
+ {
+ delete [] m_pOidIn;
+ m_pOidIn = 0;
+ }
+ else
+ {
+ OUString *pNew = new OUString[props.nOidCacheSize];
+ sal_Int32 i;
+ sal_Int32 iMin = mymin( m_properties.nOidCacheSize , props.nOidCacheSize );
+ for( i = 0; i < iMin ; i ++ )
+ {
+ pNew[i] = m_pOidIn[i];
+ }
+ delete [] m_pOidIn;
+ m_pOidIn = pNew;
+ }
+ m_oidCacheOut.resize( props.nOidCacheSize );
+ m_properties.nOidCacheSize = props.nOidCacheSize;
+ }
+
+ if( m_properties.nTidCacheSize != props.nTidCacheSize )
+ {
+ if( 0 == props.nTidCacheSize )
+ {
+ delete [] m_pTidIn;
+ m_pOidIn = 0;
+ }
+ else
+ {
+ ByteSequence *pNew = new ByteSequence[props.nTidCacheSize];
+ sal_Int32 i;
+ sal_Int32 iMin = mymin( m_properties.nTidCacheSize , props.nTidCacheSize );
+ for( i = 0; i < iMin ; i ++ )
+ {
+ pNew[i] = m_pTidIn[i];
+ }
+ delete [] m_pTidIn;
+ m_pTidIn = pNew;
+ }
+ m_tidCacheOut.resize( props.nTidCacheSize );
+ m_properties.nTidCacheSize = props.nTidCacheSize;
+ }
+
+ if( m_properties.sVersion != props.sVersion )
+ {
+ m_properties.sVersion = props.sVersion;
+ }
+
+ if( m_properties.nFlushBlockSize != props.nFlushBlockSize )
+ {
+ m_properties.nFlushBlockSize = props.nFlushBlockSize;
+ }
+
+ if( m_properties.nOnewayTimeoutMUSEC != props.nOnewayTimeoutMUSEC )
+ {
+ m_properties.nOnewayTimeoutMUSEC = props.nOnewayTimeoutMUSEC;
+ }
+
+ if( props.bClearCache )
+ {
+ if( m_properties.nTypeCacheSize )
+ {
+ delete [] m_pTypeIn;
+ m_pTypeIn = new Type[m_properties.nTypeCacheSize];
+ m_typeCacheOut.clear();
+ }
+ m_lastInType = Type();
+ m_lastOutType = Type();
+
+ if( m_properties.nOidCacheSize )
+ {
+ delete [] m_pOidIn;
+ m_pOidIn = new OUString[ m_properties.nOidCacheSize];
+ m_oidCacheOut.clear();
+ }
+ m_lastOutOid = OUString();
+ m_lastInOid = OUString();
+
+ if( m_properties.nTidCacheSize )
+ {
+ delete [] m_pTidIn;
+ m_pTidIn = new ByteSequence[m_properties.nTidCacheSize];
+ m_tidCacheOut.clear();
+ }
+ m_lastInTid = ByteSequence();
+ m_lastOutTid = ByteSequence();
+ }
+}
+
}
diff --git a/bridges/source/remote/urp/urp_bridgeimpl.hxx b/bridges/source/remote/urp/urp_bridgeimpl.hxx
index a5ccfa43b..93f686554 100644
--- a/bridges/source/remote/urp/urp_bridgeimpl.hxx
+++ b/bridges/source/remote/urp/urp_bridgeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_bridgeimpl.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,11 +73,14 @@
#include "urp_cache.hxx"
#include "urp_marshal_decl.hxx"
#include "urp_replycontainer.hxx"
+#include "urp_property.hxx"
namespace bridges_urp
{
+class PropertyObject;
+
struct equalOUString
{
sal_Int32 operator() ( const ::rtl::OUString &s1, const ::rtl::OUString &s2 ) const
@@ -104,9 +107,15 @@ struct urp_BridgeImpl :
urp_BridgeImpl( sal_Int32 nCacheSize , sal_uInt32 nInitialMarshalerSize );
~urp_BridgeImpl();
+ void applyProtocolChanges( const Properties & );
+
+ void startBlockBridge();
+ void stopBlockBridge();
+
::osl::Mutex m_marshalingMutex;
::osl::Mutex m_disposingMutex;
Marshal m_blockMarshaler;
+ sal_Int32 m_nMarshaledMessages;
// Caches for vars, that go from local process to the remote process
Cache < ::rtl::OUString , equalOUString > m_oidCacheOut;
@@ -118,7 +127,6 @@ struct urp_BridgeImpl :
::rtl::OUString m_lastOutOid;
// Caches for vars, that come from the remote process to the local process
- sal_Int32 m_nCacheSize;
::rtl::OUString *m_pOidIn;
::rtl::ByteSequence *m_pTidIn;
::com::sun::star::uno::Type *m_pTypeIn;
@@ -127,15 +135,15 @@ struct urp_BridgeImpl :
::rtl::ByteSequence m_lastInTid;
::rtl::OUString m_lastInOid;
- sal_Int32 m_nTimeoutMUSEC;
- sal_Int32 m_nFlushBlockSize;
-
urp_ClientJobContainer m_clientJobContainer;
OWriterThread *m_pWriter;
OReaderThread *m_pReader;
FILE *m_pLogFile;
::osl::Condition m_cndWaitForThreads;
+
+ struct Properties m_properties;
+ class PropertyObject *m_pPropertyObject;
};
}
diff --git a/bridges/source/remote/urp/urp_cache.h b/bridges/source/remote/urp/urp_cache.h
index e60d70f8d..5382845f4 100644
--- a/bridges/source/remote/urp/urp_cache.h
+++ b/bridges/source/remote/urp/urp_cache.h
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_cache.h,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,6 +77,11 @@ namespace bridges_urp
// returns 0xffff, when value cannot be found in the list
inline sal_uInt16 seek( const t & );
+ // resizes the cache, conserving overlapping values
+ inline void resize( sal_Int32 nNewMaxEntries );
+
+ // empties the cache
+ inline void clear();
private:
t *m_pCache;
::std::list< sal_uInt16 > m_lstLeastRecentlyUsed;
diff --git a/bridges/source/remote/urp/urp_cache.hxx b/bridges/source/remote/urp/urp_cache.hxx
index 135c38ccc..83a1c629a 100644
--- a/bridges/source/remote/urp/urp_cache.hxx
+++ b/bridges/source/remote/urp/urp_cache.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_cache.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -89,6 +89,10 @@ namespace bridges_urp
template < class t , class tequals >
inline sal_uInt16 Cache< t , tequals >::put( const t & value )
{
+ if( ! m_nMaxEntries )
+ {
+ return 0xffff;
+ }
sal_uInt16 nEntry = 0xffff;
if( m_nEntries < m_nMaxEntries )
{
@@ -129,4 +133,63 @@ namespace bridges_urp
}
return 0xffff;
}
+
+ // helper predicate for element removal
+ template < class t >
+ struct PredicateOverMax
+ {
+ t m_;
+ inline PredicateOverMax( const t &value ) : m_(value)
+ {}
+ sal_Int32 operator () ( const t &value ) const
+ { return value >= m_; }
+ };
+
+ template < class t, class tequals >
+ inline void Cache < t , tequals >::resize( sal_Int32 nNewMaxEntries )
+ {
+ if( 0 == nNewMaxEntries )
+ {
+ m_lstLeastRecentlyUsed.clear();
+ delete [] m_pCache;
+ m_pCache = 0;
+ m_nMaxEntries = 0;
+ }
+ else
+ {
+ // allocate
+ t *pNew = new t[nNewMaxEntries];
+ sal_Int32 nMin = nNewMaxEntries < m_nMaxEntries ? nNewMaxEntries : m_nMaxEntries;
+
+ // copy
+ for( sal_Int32 i = 0; i < nMin ; i ++ )
+ {
+ pNew[i] = m_pCache[i];
+ }
+ // delete
+ delete [] m_pCache;
+
+ // assign
+ m_pCache = pNew;
+
+ // remove overlapping lru cache entries
+ ::std::remove_if(m_lstLeastRecentlyUsed.begin(),
+ m_lstLeastRecentlyUsed.end(),
+ PredicateOverMax< sal_Int32 > ( nMin ) );
+ }
+ m_nMaxEntries = nNewMaxEntries;
+ m_nEntries = m_nEntries < m_nMaxEntries ?
+ m_nEntries : m_nMaxEntries;
+ }
+
+ template < class t, class tequals >
+ inline void Cache < t, tequals >:: clear()
+ {
+ for( sal_Int32 i = 0; i < m_nMaxEntries ; i ++ )
+ {
+ m_pCache[i] = t();
+ }
+ m_lstLeastRecentlyUsed.clear();
+ m_nEntries = 0;
+ }
}
diff --git a/bridges/source/remote/urp/urp_dispatch.cxx b/bridges/source/remote/urp/urp_dispatch.cxx
index 7d4c6414d..6bd687249 100644
--- a/bridges/source/remote/urp/urp_dispatch.cxx
+++ b/bridges/source/remote/urp/urp_dispatch.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_dispatch.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,14 +94,6 @@ using namespace ::com::sun::star::uno;
namespace bridges_urp
{
-void prepareRuntimeExceptionClientSide( uno_Any **ppException , const OUString &s)
-{
-
- // TODO : add string to runtimeexception
- Type type = ::getCppuType( ( ::com::sun::star::uno::RuntimeException *) 0 );
- uno_type_any_construct( *ppException , 0 , type.getTypeLibType() , 0 );
-}
-
void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote )
{
remote_Context *pContext = (remote_Context *) pEnvRemote->pContext;
@@ -120,7 +112,6 @@ void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote )
pImpl->m_pWriter->sendEmptyMessage();
}
}
-
void SAL_CALL urp_sendRequest(
uno_Environment *pEnvRemote,
typelib_TypeDescription * pMemberType,
@@ -128,241 +119,18 @@ void SAL_CALL urp_sendRequest(
typelib_InterfaceTypeDescription *pInterfaceType,
void *pReturn,
void *ppArgs[],
- uno_Any **ppException
- )
-{
+ uno_Any **ppException )
+{
remote_Context *pContext = (remote_Context *) pEnvRemote->pContext;
urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl );
-
- uno_threadpool_Handle *pThreadpoolHandle = 0;
- sal_Bool bOneway = typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass ?
- (( typelib_InterfaceMethodTypeDescription * ) pMemberType)->bOneWay :
- sal_False;
- sal_Bool bReleaseForTypeDescriptionNecessary = sal_False;
-
- // get thread id
- sal_Sequence *pThreadId = 0;
- uno_getIdOfCurrentThread( &pThreadId );
- ByteSequence aThreadId = ByteSequence( pThreadId , BYTESEQ_NOACQUIRE );
-
- ClientJob clientJob = ClientJob( pEnvRemote, pImpl );
- {
- MutexGuard guard( pImpl->m_marshalingMutex );
-
- if( pImpl->m_bDisposed )
- {
- prepareRuntimeExceptionClientSide(
- ppException , OUString( RTL_CONSTASCII_USTRINGPARAM( "URP-Bridge: disposed" )) );
- return;
- }
-
- clientJob.m_ppArgs = ppArgs;
- clientJob.m_pReturn = pReturn;
- clientJob.m_ppException = ppException;
-
- if( typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass )
- {
- clientJob.m_pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pMemberType;
- }
-
- if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pMemberType->eTypeClass )
- {
- clientJob.m_pAttributeType =
- ( typelib_InterfaceAttributeTypeDescription * ) pMemberType;
- }
-
- // calculate method index
- sal_Int32 nMethodIndex = 0;
- if( ! pInterfaceType->aBase.bComplete )
- {
- // must be acquired because typedescription may be exchanged
- typelib_typedescription_acquire((typelib_TypeDescription*) pInterfaceType );
- bReleaseForTypeDescriptionNecessary = sal_True;
- typelib_typedescription_complete( (typelib_TypeDescription ** ) &pInterfaceType );
- }
- nMethodIndex = pInterfaceType->pMapMemberIndexToFunctionIndex[
- ((typelib_InterfaceMemberTypeDescription*)pMemberType)->nPosition ];
-
- if( clientJob.m_pAttributeType && clientJob.m_ppArgs )
- {
- // setter
- nMethodIndex ++;
- }
-
- // build up the flag byte
- sal_Bool bType = sal_False, bOid = sal_False, bTid = sal_False;
- sal_uInt8 nFlags = 0;
- if( pImpl->m_lastOutType.getTypeLibType() != pInterfaceType->aBase.pWeakRef &&
- ! typelib_typedescriptionreference_equals(
- pImpl->m_lastOutType.getTypeLibType(), pInterfaceType->aBase.pWeakRef ) )
- {
- //new type
- nFlags = nFlags | HDRFLAG_NEWTYPE;
- bType = sal_True;
- }
- if( pImpl->m_lastOutOid.pData != pOid &&
- rtl_ustr_compare_WithLength( pImpl->m_lastOutOid.pData->buffer,
- pImpl->m_lastOutOid.pData->length,
- pOid->buffer,
- pOid->length ) )
- {
- //new object id
- nFlags = nFlags | HDRFLAG_NEWOID;
- bOid = sal_True;
- }
- if( pImpl->m_lastOutTid.getHandle() != aThreadId.getHandle() &&
- !(pImpl->m_lastOutTid == aThreadId) )
- {
- // new threadid
- nFlags = nFlags | HDRFLAG_NEWTID;
- bTid = sal_True;
- }
-#ifdef BRIDGES_URP_PROT
- sal_Int32 nLogStart = pImpl->m_blockMarshaler.getPos();
-#endif
- if( nFlags )
- {
- // the flag byte is needed + request
- nFlags = nFlags | HDRFLAG_LONG | HDRFLAG_REQUEST; //
- if( nMethodIndex >= 0x100 )
- {
- nFlags = nFlags | HDRFLAG_LONGMETHODID;
- }
- if( clientJob.m_pMethodType && clientJob.m_pMethodType->bOneWay )
- {
- // oneway
- nFlags = nFlags | HDRFLAG_ONEWAY;
- }
- pImpl->m_blockMarshaler.packInt8( &nFlags );
-
- if( nFlags & HDRFLAG_LONGMETHODID )
- {
- sal_uInt16 nMethod = (sal_uInt16 ) nMethodIndex;
- pImpl->m_blockMarshaler.packInt16( &nMethod );
- }
- else
- {
- sal_uInt8 nMethod = (sal_uInt8) nMethodIndex;
- pImpl->m_blockMarshaler.packInt8( &nMethod );
- }
- }
- else
- {
- // no flag byte needed, simply marshal the method index
- if( nMethodIndex >= 64 )
- {
- sal_uInt16 nMethod = ( sal_uInt16 ) nMethodIndex;
- nMethod = nMethod | 0x4000;
- pImpl->m_blockMarshaler.packInt16( &nMethod );
- }
- else
- {
- sal_uInt8 nMethod = (sal_uInt8 ) nMethodIndex;
- pImpl->m_blockMarshaler.packInt8( &nMethod );
- }
- }
- // marshal type,oid,tid
- if( bType )
- {
- pImpl->m_lastOutType = pInterfaceType->aBase.pWeakRef;
- pImpl->m_blockMarshaler.packType( &(pImpl->m_lastOutType) );
- }
- if( bOid )
- {
- pImpl->m_lastOutOid = pOid;
- pImpl->m_blockMarshaler.packOid( pImpl->m_lastOutOid );
- }
- if( bTid )
- {
- pImpl->m_lastOutTid = aThreadId;
- pImpl->m_blockMarshaler.packTid( pImpl->m_lastOutTid );
- }
-
-
- // marshal arguments !
-#ifdef BRIDGES_URP_PROT
- sal_Int32 nLogHeader = pImpl->m_blockMarshaler.getPos();
-#endif
- if( clientJob.m_pMethodType )
- {
- sal_Int32 i;
- for( i = 0 ; i < clientJob.m_pMethodType->nParams ; i ++ )
- {
- if( clientJob.m_pMethodType->pParams[i].bIn )
- {
- typelib_TypeDescription *pType = 0;
- TYPELIB_DANGER_GET( &pType , clientJob.m_pMethodType->pParams[i].pTypeRef );
- pImpl->m_blockMarshaler.pack( ppArgs[i] , pType );
- TYPELIB_DANGER_RELEASE( pType );
- }
- }
- }
- else if( clientJob.m_pAttributeType && clientJob.m_pReturn )
- {
- // nothing to do !
- }
- else if( clientJob.m_pAttributeType && clientJob.m_ppArgs )
- {
- typelib_TypeDescription *pType = 0;
- TYPELIB_DANGER_GET( &pType , clientJob.m_pAttributeType->pAttributeTypeRef );
- pImpl->m_blockMarshaler.pack( clientJob.m_ppArgs[0] , pType );
- TYPELIB_DANGER_RELEASE( pType );
- }
- else
- {
- OSL_ASSERT( 0 );
- }
-
-#ifdef BRIDGES_URP_PROT
- urp_logCall( pImpl, pImpl->m_blockMarshaler.getPos() - nLogStart,
- pImpl->m_blockMarshaler.getPos() - nLogHeader, ! bOneway,
- ((typelib_InterfaceMemberTypeDescription*)pMemberType)->pMemberName );
-#endif
-
- if( ! bOneway )
- {
- pThreadpoolHandle = uno_threadpool_createHandle( (sal_Int64 ) pEnvRemote );
- pImpl->m_clientJobContainer.add( aThreadId , &clientJob );
- }
-
- //---------------------------
- // Inform the writer thread, that there is some work to do
- //---------------------------
- pImpl->m_pWriter->touch( !bOneway );
-
- // release the guard
- }
+ ClientJob job(pEnvRemote, pImpl, pOid, pMemberType, pInterfaceType, pReturn, ppArgs, ppException);
- if(! bOneway)
+ job.pack();
+ if( ! job.isOneway() )
{
- //---------------------------
- // Wait for the reply
- //---------------------------
- ClientJob * pData = 0;
- uno_threadpool_enter( pThreadpoolHandle, (void **) &pData );
-
- if( ! pData )
- {
- OSL_VERIFY( &clientJob ==
- pImpl->m_clientJobContainer.remove( aThreadId ) );
-
- prepareRuntimeExceptionClientSide(
- ppException, OUString( RTL_CONSTASCII_USTRINGPARAM( "URP_Bridge : disposed" ) ) );
- }
+ job.wait();
}
- else
- {
- //----------------
- // One way call
- //----------------
- *ppException = 0;
- }
-
- uno_releaseIdFromCurrentThread();
-
- if( bReleaseForTypeDescriptionNecessary )
- typelib_typedescription_release( (typelib_TypeDescription *) pInterfaceType );
}
}
diff --git a/bridges/source/remote/urp/urp_dispatch.hxx b/bridges/source/remote/urp/urp_dispatch.hxx
index 811274290..847bf8f7b 100644
--- a/bridges/source/remote/urp/urp_dispatch.hxx
+++ b/bridges/source/remote/urp/urp_dispatch.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_dispatch.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,14 +73,18 @@ struct remote_Interface;
namespace bridges_urp {
- const sal_uInt8 HDRFLAG_LONG = 0x80;
- const sal_uInt8 HDRFLAG_REQUEST = 0x40;
- const sal_uInt8 HDRFLAG_EXCEPTIONOCCURED = 0x20;
- const sal_uInt8 HDRFLAG_NEWTYPE = 0x20;
- const sal_uInt8 HDRFLAG_NEWOID = 0x10;
- const sal_uInt8 HDRFLAG_NEWTID = 0x08;
- const sal_uInt8 HDRFLAG_LONGMETHODID = 0x04;
- const sal_uInt8 HDRFLAG_ONEWAY = 0x02;
+ const sal_uInt8 HDRFLAG_LONGHEADER = 0x80;
+ const sal_uInt8 HDRFLAG_REQUEST = 0x40;
+ const sal_uInt8 HDRFLAG_NEWTYPE = 0x20;
+ const sal_uInt8 HDRFLAG_NEWOID = 0x10;
+ const sal_uInt8 HDRFLAG_NEWTID = 0x08;
+ const sal_uInt8 HDRFLAG_LONGMETHODID = 0x04;
+ const sal_uInt8 HDRFLAG_IGNORECACHE = 0x02;
+ const sal_uInt8 HDRFLAG_MOREFLAGS = 0x01;
+ const sal_uInt8 HDRFLAG_MUSTREPLY = 0x80;
+ const sal_uInt8 HDRFLAG_SYNCHRONOUS = 0x40;
+
+ const sal_uInt8 HDRFLAG_EXCEPTION = 0x20;
void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote );
diff --git a/bridges/source/remote/urp/urp_environment.cxx b/bridges/source/remote/urp/urp_environment.cxx
index c95421893..bfe8e6ce0 100644
--- a/bridges/source/remote/urp/urp_environment.cxx
+++ b/bridges/source/remote/urp/urp_environment.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_environment.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,16 +91,84 @@
#include "urp_reader.hxx"
#include "urp_dispatch.hxx"
#include "urp_log.hxx"
+#include "urp_propertyobject.hxx"
using namespace ::rtl;
using namespace ::com::sun::star::uno;
-
-#define UNO_LB_URP "urp"
-
namespace bridges_urp
{
+// static void dumpProperties( struct Properties *p )
+// {
+// fprintf( stderr , "FlushBlockSize : %d\n" , p->nFlushBlockSize );
+// fprintf( stderr , "OnewayTimeoutMUSEC : %d\n" , p->nOnewayTimeoutMUSEC );
+// fprintf( stderr , "OidCacheSize : %d\n" , p->nOidCacheSize );
+// fprintf( stderr , "TypeCacheSize : %d\n" , p->nTypeCacheSize );
+// fprintf( stderr , "TidCacheSize : %d\n" , p->nTidCacheSize );
+// OString o = OUStringToOString( p->sSupportedVersions , RTL_TEXTENCODING_ASCII_US );
+// fprintf( stderr , "SupportedVersions : %s\n" , o.pData->buffer );
+// o = OUStringToOString( p->sVersion , RTL_TEXTENCODING_ASCII_US );
+// fprintf( stderr , "Version : %s\n" , o.pData->buffer );
+// fprintf( stderr , "SupportsMultipleSynchronous : %d\n" , p->bSupportsMultipleSynchronous );
+// fprintf( stderr , "SupportsMustReply : %d\n" , p->bSupportsMustReply );
+// fprintf( stderr , "SupportsSynchronous : %d\n" , p->bSupportsSynchronous );
+// }
+
+// PropertySetterThread
+//------------------------------------
+class PropertySetterThread : public ::vos::OThread
+{
+ urp_BridgeImpl *m_pImpl;
+ ::rtl::OUString m_sProps;
+ uno_Environment *m_pEnvRemote;
+public:
+ PropertySetterThread( uno_Environment *pEnvRemote,
+ urp_BridgeImpl *pImpl,
+ const ::rtl::OUString & props )
+ : m_pImpl( pImpl )
+ , m_sProps( props )
+ , m_pEnvRemote( pEnvRemote )
+ {
+ // hold the environment in case all references are released before this
+ // thread terminates
+ m_pEnvRemote->acquire( pEnvRemote );
+ }
+ ~PropertySetterThread()
+ {
+ m_pEnvRemote->release( m_pEnvRemote );
+ }
+
+ virtual void SAL_CALL run()
+ {
+ struct Properties props;
+ if( m_sProps.getLength() )
+ {
+ sal_Int32 nResult = m_pImpl->m_pPropertyObject->localRequestChange( );
+ if( 1 == nResult )
+ {
+ sal_Bool bExceptionThrown;
+ m_pImpl->m_pPropertyObject->localCommitChange( m_sProps , &bExceptionThrown );
+ OSL_ENSURE( !bExceptionThrown, "properties were not set\n" );
+ }
+ else if( 0 == nResult )
+ {
+ OSL_TRACE( "urp-bridge : remote-counterpart won the changing-the-protocol-race\n" );
+ }
+ else
+ {
+ OSL_ASSERT( !"urp-bridge : property setting failed because identical random numbers " );
+ }
+ }
+ }
+ virtual void SAL_CALL onTerminated()
+ {
+ delete this;
+ }
+};
+//------------------------------------
+
+
void test_cache()
{
OUString a = OUString( RTL_CONSTASCII_USTRINGPARAM( "a" ) );
@@ -296,6 +364,8 @@ void RemoteEnvironment::thisDisposing( uno_Environment *pEnvRemote )
thisDispose( pEnvRemote );
}
}
+ pImpl->m_pPropertyObject->thisRelease();
+ pImpl->m_pPropertyObject = 0;
uno_threadpool_stopDisposeThreads( (sal_Int64) pEnvRemote );
@@ -309,8 +379,7 @@ void RemoteEnvironment::thisComputeObjectIdentifier( uno_ExtEnvironment *pEnvRem
rtl_uString **ppOid ,
void *pInterface)
{
- assert( 0 );
- // should never be called
+ OSL_ENSURE( 0, "RemoteEnvironment::thisComputeObjectIdentifier should never be called" );
}
void RemoteEnvironment::thisAcquireInterface( uno_ExtEnvironment *pEnvRemote, void *pInterface )
@@ -326,6 +395,7 @@ void RemoteEnvironment::thisReleaseInterface( uno_ExtEnvironment *pEnvRemote, vo
} // end namespace bridges_urp
using namespace bridges_urp;
+
//##################################################################################################
extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pEnvRemote )
{
@@ -341,22 +411,35 @@ extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pE
pContext->getRemoteInstance = ::bridges_remote::remote_sendQueryInterface;
// Initialize impl struct urp_BridgeImpl
- sal_Int32 nCacheSize = 256;
- sal_Int32 nTimeoutMUSEC = 10000;
- sal_Int32 nFlushBlockSize = 4*1024;
-
- urp_BridgeImpl *pImpl = new ::bridges_urp::urp_BridgeImpl( nCacheSize, 8192 );
+ urp_BridgeImpl *pImpl = new ::bridges_urp::urp_BridgeImpl( 256, 8192 );
pContext->m_pBridgeImpl = pImpl;
- pImpl->m_cndWaitForThreads;
+ // take the bridgepointer as id
+ pImpl->m_properties.seqBridgeID = ByteSequence( (sal_Int8*)&pEnvRemote , sizeof( pEnvRemote ) );
+ pImpl->m_properties.nFlushBlockSize = 4*1024;
+ pImpl->m_properties.nTypeCacheSize = 256;
+ pImpl->m_properties.nOnewayTimeoutMUSEC = 10000;
+ pImpl->m_properties.nOidCacheSize = 256;
+ pImpl->m_properties.nTidCacheSize = 256;
+ pImpl->m_properties.sVersion = OUString( RTL_CONSTASCII_USTRINGPARAM( "1.0" ) );
+ pImpl->m_properties.sSupportedVersions = OUString( RTL_CONSTASCII_USTRINGPARAM( "1.0" ) );
+ pImpl->m_properties.bSupportsMultipleSynchronous = sal_False;
+ pImpl->m_properties.bSupportsMustReply = sal_False;
+ pImpl->m_properties.bSupportsSynchronous = sal_False;
+ pImpl->m_properties.bClearCache = sal_False;
+
+
+ pImpl->m_cndWaitForThreads.reset();
pImpl->m_allThreadsAreGone = allThreadsAreGone;
pImpl->m_sendRequest = urp_sendRequest;
- pImpl->m_nFlushBlockSize = nFlushBlockSize;
- pImpl->m_nTimeoutMUSEC = nTimeoutMUSEC;
pImpl->m_nRemoteThreads = 0;
pImpl->m_bDisposed = sal_False;
pImpl->m_bReleaseStubsCalled = sal_False;
+ pImpl->m_pPropertyObject = new PropertyObject( &(pImpl->m_properties ), pEnvRemote, pImpl );
+ pImpl->m_pPropertyObject->thisAcquire();
+
+ // start reader and writer threads
pImpl->m_pWriter = new ::bridges_urp::OWriterThread( pContext->m_pConnection , pImpl );
pImpl->m_pWriter->create();
@@ -364,7 +447,8 @@ extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pE
pEnvRemote,
pImpl->m_pWriter );
pImpl->m_pReader->create();
-
+
+ // create the properties object
#ifdef BRIDGES_URP_PROT
pImpl->m_pLogFile = 0;
char *p = getenv( "PROT_REMOTE" );
@@ -377,7 +461,19 @@ extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pE
counter++;
}
#endif
- // start reader and writer threads
+
+ // start the property-set-thread, if necessary
+ OUString sProtocolProperties;
+ if( pContext->m_pProtocol->length > 3 )
+ {
+ sProtocolProperties = OUString( pContext->m_pProtocol ).copy( 4, pContext->m_pProtocol->length-4);
+ }
+ if( sProtocolProperties.getLength() )
+ {
+ PropertySetterThread *pPropsSetterThread =
+ new PropertySetterThread( pEnvRemote, pImpl , sProtocolProperties );
+ pPropsSetterThread->create();
+ }
#ifdef DEBUG
thisCounter.acquire();
#endif
@@ -400,7 +496,7 @@ extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping(
::rtl::OUString sFromName = pFrom->pTypeName;
::rtl::OUString sToName = pTo->pTypeName;
::rtl::OUString sUno = OUString::createFromAscii( UNO_LB_UNO );
- ::rtl::OUString sRemote = OUString::createFromAscii( UNO_LB_URP );
+ ::rtl::OUString sRemote = OUString::createFromAscii( "urp" );
if ( sFromName.equalsIgnoreCase( sRemote ) &&
sToName.equalsIgnoreCase( sUno ) )
{
diff --git a/bridges/source/remote/urp/urp_job.cxx b/bridges/source/remote/urp/urp_job.cxx
index 193b2404c..941052d89 100644
--- a/bridges/source/remote/urp/urp_job.cxx
+++ b/bridges/source/remote/urp/urp_job.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_job.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,7 @@
#include "urp_dispatch.hxx"
#include "urp_log.hxx"
#include "urp_marshal.hxx"
+#include "urp_propertyobject.hxx"
using namespace ::std;
using namespace ::rtl;
@@ -88,12 +89,21 @@ using namespace ::com::sun::star::uno;
namespace bridges_urp
{
+ //--------------------------------------------------------------------------------------
+ static void prepareRuntimeExceptionClientSide( uno_Any **ppException , const OUString &s)
+ {
+ // TODO : add string to runtimeexception
+ RuntimeException exception;
+ exception.Message = s;
+ Type type = ::getCppuType( ( ::com::sun::star::uno::RuntimeException *) 0 );
+ uno_type_any_construct( *ppException , &exception , type.getTypeLibType() , 0 );
+ }
+
- Job::Job(
- uno_Environment *pEnvRemote,
- sal_Sequence *pTid,
- struct urp_BridgeImpl *pBridgeImpl,
- Unmarshal *pUnmarshal )
+ Job::Job( uno_Environment *pEnvRemote,
+ sal_Sequence *pTid,
+ struct urp_BridgeImpl *pBridgeImpl,
+ Unmarshal *pUnmarshal )
: m_pTid( pTid )
, m_counter( pEnvRemote )
, m_pBridgeImpl( pBridgeImpl )
@@ -109,23 +119,16 @@ namespace bridges_urp
rtl_byte_sequence_release( m_pTid );
}
- // static method
- void Job::doit( void *pThis )
- {
- Job *pJob = ( Job * ) pThis;
- pJob->execute();
- delete pJob;
- }
+
//--------------------------------------------------------------------------------------
sal_Bool ClientJob::extract( )
{
sal_Bool bReturn = sal_True;
-
- //--------------------------
- // Handle the reply, unpack data
- //--------------------------
+ //-------------------------------
+ // Handle the reply, unpack data
+ //-------------------------------
if( m_bExceptionOccured )
{
bReturn = m_pUnmarshal->unpackAny( *m_ppException );
@@ -182,26 +185,214 @@ namespace bridges_urp
return sal_True;
}
+ //-------------------------------------------------------------------------------------------
void ClientJob::initiate()
{
uno_threadpool_putReply( m_pTid , (sal_Int8*) this );
}
+ //--------------------------------------------------------------------------------------------
+ void ClientJob::pack()
+ {
+ MutexGuard guard( m_pBridgeImpl->m_marshalingMutex );
+
+ if( m_pBridgeImpl->m_bDisposed )
+ {
+ prepareRuntimeExceptionClientSide(
+ m_ppException , OUString( RTL_CONSTASCII_USTRINGPARAM( "URP-Bridge: disposed" )) );
+ return;
+ }
+
+ // build up the flag byte
+ sal_Bool bType = sal_False, bOid = sal_False, bTid = sal_False;
+ sal_uInt8 nFlags = 0;
+ if( m_pBridgeImpl->m_lastOutType.getTypeLibType() != m_pInterfaceType->aBase.pWeakRef &&
+ ! typelib_typedescriptionreference_equals(
+ m_pBridgeImpl->m_lastOutType.getTypeLibType(), m_pInterfaceType->aBase.pWeakRef ) )
+ {
+ //new type
+ nFlags = nFlags | HDRFLAG_NEWTYPE;
+ bType = sal_True;
+ }
+ if( m_pBridgeImpl->m_lastOutOid.pData != m_pOid &&
+ rtl_ustr_compare_WithLength( m_pBridgeImpl->m_lastOutOid.pData->buffer,
+ m_pBridgeImpl->m_lastOutOid.pData->length,
+ m_pOid->buffer,
+ m_pOid->length ) )
+ {
+ //new object id
+ nFlags = nFlags | HDRFLAG_NEWOID;
+ bOid = sal_True;
+ }
+ if( m_pBridgeImpl->m_lastOutTid.getHandle() != m_pTid &&
+ !(m_pBridgeImpl->m_lastOutTid == *(ByteSequence*) &(m_pTid) ) )
+ {
+ // new threadid
+ nFlags = nFlags | HDRFLAG_NEWTID;
+ bTid = sal_True;
+ }
+#ifdef BRIDGES_URP_PROT
+ sal_Int32 nLogStart = m_pBridgeImpl->m_blockMarshaler.getPos();
+#endif
+ if( nFlags )
+ {
+ // the flag byte is needed + request
+ nFlags = nFlags | HDRFLAG_LONGHEADER | HDRFLAG_REQUEST; //
+
+ // as long as we do not have customized calls, no MOREFLAGS must be set
+ if( m_nMethodIndex >= 0x100 )
+ {
+ nFlags = nFlags | HDRFLAG_LONGMETHODID;
+ }
+ m_pBridgeImpl->m_blockMarshaler.packInt8( &nFlags );
-
- //------------------------------------------------------------------------------------
+ if( nFlags & HDRFLAG_LONGMETHODID )
+ {
+ sal_uInt16 nMethod = (sal_uInt16 ) m_nMethodIndex;
+ m_pBridgeImpl->m_blockMarshaler.packInt16( &nMethod );
+ }
+ else
+ {
+ sal_uInt8 nMethod = (sal_uInt8) m_nMethodIndex;
+ m_pBridgeImpl->m_blockMarshaler.packInt8( &nMethod );
+ }
+ }
+ else
+ {
+ // no flag byte needed, simply marshal the method index
+ if( m_nMethodIndex >= 64 )
+ {
+ sal_uInt16 nMethod = ( sal_uInt16 ) m_nMethodIndex;
+ nMethod = nMethod | 0x4000;
+ m_pBridgeImpl->m_blockMarshaler.packInt16( &nMethod );
+ }
+ else
+ {
+ sal_uInt8 nMethod = (sal_uInt8 ) m_nMethodIndex;
+ m_pBridgeImpl->m_blockMarshaler.packInt8( &nMethod );
+ }
+ }
+
+ // marshal type,oid,tid
+ if( bType )
+ {
+ m_pBridgeImpl->m_lastOutType = m_pInterfaceType->aBase.pWeakRef;
+ m_pBridgeImpl->m_blockMarshaler.packType( &(m_pBridgeImpl->m_lastOutType) );
+ }
+ if( bOid )
+ {
+ m_pBridgeImpl->m_lastOutOid = *(OUString *)&m_pOid;
+ m_pBridgeImpl->m_blockMarshaler.packOid( m_pBridgeImpl->m_lastOutOid );
+ }
+ if( bTid )
+ {
+ m_pBridgeImpl->m_lastOutTid = *(ByteSequence*)&(m_pTid);
+ m_pBridgeImpl->m_blockMarshaler.packTid( m_pBridgeImpl->m_lastOutTid );
+ }
+
+ // marshal arguments !
+#ifdef BRIDGES_URP_PROT
+ sal_Int32 nLogHeader = m_pBridgeImpl->m_blockMarshaler.getPos();
+#endif
+ if( m_pMethodType )
+ {
+ sal_Int32 i;
+ for( i = 0 ; i < m_pMethodType->nParams ; i ++ )
+ {
+ if( m_pMethodType->pParams[i].bIn )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , m_pMethodType->pParams[i].pTypeRef );
+ m_pBridgeImpl->m_blockMarshaler.pack( m_ppArgs[i] , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+ }
+ }
+ else if( m_pAttributeType && m_pReturn )
+ {
+ // nothing to do !
+ }
+ else if( m_pAttributeType && m_ppArgs )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , m_pAttributeType->pAttributeTypeRef );
+ m_pBridgeImpl->m_blockMarshaler.pack( m_ppArgs[0] , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+ else
+ {
+ OSL_ASSERT( 0 );
+ }
+
+#ifdef BRIDGES_URP_PROT
+ urp_logCall( m_pBridgeImpl, m_pBridgeImpl->m_blockMarshaler.getPos() - nLogStart,
+ m_pBridgeImpl->m_blockMarshaler.getPos() - nLogHeader, ! m_bOneway,
+ m_pMethodType ? m_pMethodType->aBase.pMemberName :
+ m_pAttributeType->aBase.pMemberName );
+#endif
+
+ if( ! m_bOneway )
+ {
+ m_pThreadpoolHandle = uno_threadpool_createHandle( (sal_Int64 ) m_pEnvRemote );
+ m_pBridgeImpl->m_clientJobContainer.add( *(ByteSequence*)&(m_pTid), this );
+ }
+
+ m_pBridgeImpl->m_nMarshaledMessages ++;
+ //---------------------------
+ // Inform the writer thread, that there is some work to do
+ //---------------------------
+ m_pBridgeImpl->m_pWriter->touch( ! m_bOneway );
+
+ if( m_bOneway )
+ {
+ *m_ppException = 0;
+ }
+ // release the guard
+ }
+
+ //------------------------------------------------------------------------------------
+ void ClientJob::wait()
+ {
+ if(! m_bOneway)
+ {
+ //---------------------------
+ // Wait for the reply
+ //---------------------------
+ ClientJob * pData = 0;
+ uno_threadpool_enter( m_pThreadpoolHandle, (void **) &pData );
+
+ if( ! pData )
+ {
+ OSL_VERIFY( this ==
+ m_pBridgeImpl->m_clientJobContainer.remove( *(ByteSequence*) &m_pTid ) );
+
+ prepareRuntimeExceptionClientSide(
+ m_ppException, OUString( RTL_CONSTASCII_USTRINGPARAM( "URP_Bridge : disposed" ) ) );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------------------
+ // ServerMultiJob
+ //------------------------------------------------------------------------------------
ServerMultiJob::ServerMultiJob(
uno_Environment *pEnvRemote,
sal_Sequence *pTid,
struct urp_BridgeImpl *pBridgeImpl,
- Unmarshal *pUnmarshal )
+ Unmarshal *pUnmarshal,
+ sal_Int32 nMaxMessages )
: Job( pEnvRemote, pTid, pBridgeImpl , pUnmarshal )
, m_pEnvRemote( pEnvRemote )
- , m_pCurrentMem( (sal_Int8*)rtl_allocateMemory( g_nInitialMemorySize ) )
, m_nCurrentMemPosition( 0 )
, m_nCalls( 0 )
+ , m_nMaxMessages( nMaxMessages )
{
m_pEnvRemote->acquire( m_pEnvRemote );
+ m_nCurrentMemSize = MULTIJOB_STANDARD_MEMORY_SIZE + m_nMaxMessages * (
+ MULTIJOB_PER_CALL_MEMORY_SIZE + sizeof(ServerJobEntry) + sizeof(MemberTypeInfo) );
+ m_pCurrentMem = ( sal_Int8 * ) rtl_allocateMemory( m_nCurrentMemSize );
+ m_aEntries = ( ServerJobEntry * ) getHeap( m_nMaxMessages * sizeof( ServerJobEntry ) );
+ m_aTypeInfo = ( MemberTypeInfo * ) getHeap( m_nMaxMessages * sizeof( MemberTypeInfo ) );
}
ServerMultiJob::~ServerMultiJob()
@@ -244,9 +435,17 @@ namespace bridges_urp
if( m_pEnvRemote )
m_pEnvRemote->release( m_pEnvRemote );
+ }
+ //-------------------------------------------------------------------------------------
+ void ServerMultiJob::doit( void *pThis )
+ {
+ ServerMultiJob *pJob = ( ServerMultiJob * ) pThis;
+ pJob->execute();
+ delete pJob;
}
+ //-------------------------------------------------------------------------------------
void ServerMultiJob::execute()
{
for( sal_Int32 i = 0; i < m_nCalls ; i ++ )
@@ -263,6 +462,7 @@ namespace bridges_urp
// provokes an segfault. Make sure, the call
// is not a release call.
remote_Context *pRemoteC = ((remote_Context*)m_pEnvRemote->pContext);
+
if( ! pMTI->m_bIsReleaseCall && pRemoteC->m_pInstanceProvider )
{
pRemoteC->m_pInstanceProvider->getInstance(
@@ -337,9 +537,9 @@ namespace bridges_urp
MutexGuard guard( m_pBridgeImpl->m_marshalingMutex );
sal_Bool bTid = sal_False;
- sal_uInt8 nFlags = HDRFLAG_LONG;
+ sal_uInt8 nFlags = HDRFLAG_LONGHEADER;
ByteSequence tid = m_pTid;
- if( !( tid == m_pBridgeImpl->m_lastOutTid ) )
+ if( !( tid == m_pBridgeImpl->m_lastOutTid ) || pSJE->m_bIgnoreCache )
{
// new threadid
nFlags = nFlags | HDRFLAG_NEWTID;
@@ -348,7 +548,7 @@ namespace bridges_urp
if( pSJE->m_pException )
{
- nFlags = nFlags | HDRFLAG_EXCEPTIONOCCURED;
+ nFlags = nFlags | HDRFLAG_EXCEPTION;
}
#ifdef BRIDGES_URP_PROT
sal_Int32 nLogStart = m_pBridgeImpl->m_blockMarshaler.getPos();
@@ -357,9 +557,11 @@ namespace bridges_urp
if( bTid )
{
-
- m_pBridgeImpl->m_lastOutTid = tid;
- m_pBridgeImpl->m_blockMarshaler.packTid( tid );
+ if( ! pSJE->m_bIgnoreCache )
+ {
+ m_pBridgeImpl->m_lastOutTid = tid;
+ }
+ m_pBridgeImpl->m_blockMarshaler.packTid( tid , pSJE->m_bIgnoreCache );
}
#ifdef BRIDGES_URP_PROT
@@ -434,29 +636,28 @@ namespace bridges_urp
pSJE->m_pRemoteI = 0;
}
+ m_pBridgeImpl->m_nMarshaledMessages ++;
// put it on the wire
m_pBridgeImpl->m_pWriter->touch( sal_True );
} // MutexGuard marshalingMutex
}
}
+ //-------------------------------------------------------------------------------------
void ServerMultiJob::prepareRuntimeException( const OUString & sMessage , sal_Int32 nCall )
{
// -------------------------------
// Construct the RuntimeException
// -------------------------------
-
- typelib_TypeDescription *pType = 0;
- getCppuType( (RuntimeException * ) 0 ).getDescription(&pType );
-
- OSL_ENSURE( pType , "urp-bridge: couldn't get RuntimeException type" );
+ RuntimeException exception;
+ exception.Message = sMessage;
+ Type type = getCppuType( (RuntimeException * ) 0 );
m_aEntries[nCall].m_pException = &(m_aEntries[nCall].m_exception);
- uno_any_construct( m_aEntries[nCall].m_pException , 0 , pType , 0 );
-
- typelib_typedescription_release( pType );
+ uno_type_any_construct( m_aEntries[nCall].m_pException , &exception , type.getTypeLibType() , 0 );
}
+ //-------------------------------------------------------------------------------------
void ServerMultiJob::initiate()
{
uno_threadpool_putRequest(
@@ -465,7 +666,7 @@ namespace bridges_urp
}
- // this method is called by the dispatcher thread to unmarshal a request
+ //-------------------------------------------------------------------------------------
sal_Bool ServerMultiJob::extract()
{
sal_Bool bContinue = sal_True;
diff --git a/bridges/source/remote/urp/urp_job.hxx b/bridges/source/remote/urp/urp_job.hxx
index 6e866169a..9dd18b8cb 100644
--- a/bridges/source/remote/urp/urp_job.hxx
+++ b/bridges/source/remote/urp/urp_job.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_job.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,21 +58,24 @@
*
*
************************************************************************/
+#ifndef _URP_JOB_HXX_
+#define _URP_JOB_HXX_
#include <list>
#include <typelib/typedescription.hxx>
#include <uno/any2.h>
#include <uno/environment.h>
+#include <uno/threadpool.h>
#include "urp_threadid.hxx"
#include "urp_unmarshal.hxx"
#include <bridges/remote/bridgeimpl.hxx>
-const sal_Int32 MAX_ENTRIES_IN_MULTIJOB = 60;
-const sal_Int32 g_nInitialMemorySize = 6192;
-
namespace bridges_urp
{
+const sal_Int32 MULTIJOB_STANDARD_MEMORY_SIZE = 1024;
+const sal_Int32 MULTIJOB_PER_CALL_MEMORY_SIZE = 96;
+
class Unmarshal;
struct urp_BridgeImpl;
@@ -98,22 +101,12 @@ public:
, m_pTid( 0 )
{}
- virtual ~Job();
-
- // doit method is used only for ServerJobs, calls execute and pack
- static void SAL_CALL doit( void *pThreadSpecificData );
-
- // is called from the dispatcher thread
- virtual sal_Bool extract( ) = 0;
- virtual void initiate() = 0;
- virtual void execute() = 0;
+ ~Job();
- inline void setThreadId( sal_Sequence *pId )
- { rtl_byte_sequence_assign( &m_pTid , pId ); }
inline void setUnmarshal( Unmarshal *p )
{ m_pUnmarshal = p; }
-protected:
+public:
Unmarshal *m_pUnmarshal;
struct urp_BridgeImpl *m_pBridgeImpl;
sal_Sequence *m_pTid;
@@ -123,38 +116,57 @@ protected:
class ClientJob : public Job
{
public:
- ClientJob( uno_Environment *pEnvRemote, struct urp_BridgeImpl *pBridgeImpl )
- : Job( pEnvRemote , pBridgeImpl, ::bridges_remote::RTC_HOLDENVWEAK )
- , m_ppException( 0 )
- , m_ppArgs( 0 )
- , m_pReturn( 0 )
- , m_pMethodType( 0 )
- , m_pAttributeType( 0 )
- {}
+ inline ClientJob( uno_Environment *pEnvRemote, // weak !
+ struct urp_BridgeImpl *pBridgeImpl,
+ rtl_uString *pOid, // weak
+ typelib_TypeDescription * pMemberType, // weak
+ typelib_InterfaceTypeDescription *pInterfaceType, // weak
+ void *pReturn,
+ void *ppArgs[],
+ uno_Any **ppException );
// ~ClientJob
// no release for method type and attribute type necessary, because
// it was acquired by the caller of urp_sendRequest. The lifetime
// of the ClientJob object is always shorter than the urp_sendRequest call.
- ~ClientJob()
- {}
-
- virtual sal_Bool extract( );
- virtual void initiate();
- virtual void execute()
- {}
+ inline ~ClientJob()
+ {
+ if( m_bReleaseForTypeDescriptionNecessary )
+ typelib_typedescription_release( (typelib_TypeDescription*) m_pInterfaceType );
+ uno_releaseIdFromCurrentThread();
+ }
+
+ void pack();
+ void wait();
+ sal_Bool extract( );
+ void initiate();
+ inline void setBridgePropertyCall()
+ { m_bBridgePropertyCall = sal_True; }
+ inline sal_Bool isBridgePropertyCall()
+ { return m_bBridgePropertyCall; }
+ inline sal_Bool isOneway()
+ { return m_bOneway; }
public:
- void **m_ppArgs;
- void *m_pReturn;
typelib_InterfaceMethodTypeDescription *m_pMethodType;
typelib_InterfaceAttributeTypeDescription *m_pAttributeType;
+ sal_Bool m_bExceptionOccured;
+private:
+ void **m_ppArgs;
+ void *m_pReturn;
+ typelib_InterfaceTypeDescription *m_pInterfaceType;
+ sal_Bool m_bReleaseForTypeDescriptionNecessary;
+
+ uno_threadpool_Handle *m_pThreadpoolHandle;
uno_Any **m_ppException;
- sal_Bool m_bExceptionOccured;
+ sal_Bool m_bOneway;
+ sal_Bool m_bBridgePropertyCall;
+ sal_uInt16 m_nMethodIndex;
+ uno_Environment *m_pEnvRemote;
+ rtl_uString *m_pOid;
};
-
struct MemberTypeInfo
{
typelib_InterfaceTypeDescription *m_pInterfaceType;
@@ -178,7 +190,7 @@ struct ServerJobEntry
void *m_pReturn;
uno_Any m_exception;
uno_Any *m_pException;
-
+ sal_Bool m_bIgnoreCache;
};
class ServerMultiJob : public Job
@@ -187,12 +199,16 @@ public:
ServerMultiJob( uno_Environment *pEnvRemote,
sal_Sequence *pTid,
struct urp_BridgeImpl *pBridgeImpl,
- Unmarshal *pUnmarshal);
+ Unmarshal *pUnmarshal,
+ sal_Int32 nMaxMessages );
~ServerMultiJob();
public:
- virtual sal_Bool extract( );
- virtual void initiate();
- virtual void execute();
+ // doit method is used only for ServerJobs, calls execute and pack
+ static void SAL_CALL doit( void *pThreadSpecificData );
+
+ sal_Bool extract( );
+ void initiate();
+ void execute();
public:
// setMethodType or setAttributeType MUST be called before extract
@@ -212,18 +228,18 @@ public:
m_aTypeInfo[m_nCalls].m_bIsReleaseCall = sal_False;
}
- inline void setType( const ::com::sun::star::uno::Type &type )
+ inline void setType( typelib_TypeDescriptionReference *pTypeRef )
{
- m_aEntries[m_nCalls].m_pInterfaceTypeRef = type.getTypeLibType();
+ m_aEntries[m_nCalls].m_pInterfaceTypeRef = pTypeRef;
typelib_typedescriptionreference_acquire( m_aEntries[m_nCalls].m_pInterfaceTypeRef );
TYPELIB_DANGER_GET(
(typelib_TypeDescription ** )&(m_aTypeInfo[m_nCalls].m_pInterfaceType) ,
- type.getTypeLibType() );
+ pTypeRef );
}
// setOid or setInterface MUST be called before extract
- inline void setOid( const ::rtl::OUString & sOid )
+ inline void setOid( rtl_uString *pOid )
{
- m_aEntries[m_nCalls].m_pOid = sOid.pData;
+ m_aEntries[m_nCalls].m_pOid = pOid;
rtl_uString_acquire( m_aEntries[m_nCalls].m_pOid );
m_aEntries[m_nCalls].m_pRemoteI = 0;
}
@@ -236,16 +252,22 @@ public:
m_aEntries[m_nCalls].m_pOid = 0;
}
+ inline void setIgnoreCache( sal_Bool bIgnoreCache )
+ {
+ m_aEntries[m_nCalls].m_bIgnoreCache = bIgnoreCache;
+ }
+
inline sal_Bool isFull()
- { return m_nCalls >= MAX_ENTRIES_IN_MULTIJOB; }
+ { return m_nCalls >= m_nMaxMessages; }
inline sal_Int8 *getHeap( sal_Int32 nSizeToAlloc )
{
- if( nSizeToAlloc + m_nCurrentMemPosition > g_nInitialMemorySize )
+ if( nSizeToAlloc + m_nCurrentMemPosition > m_nCurrentMemSize )
{
m_lstMem.push_back( m_pCurrentMem );
- m_pCurrentMem = (sal_Int8*)
- rtl_allocateMemory( mymax( nSizeToAlloc , g_nInitialMemorySize ) );
+ m_nCurrentMemSize = mymax( nSizeToAlloc , MULTIJOB_STANDARD_MEMORY_SIZE ) +
+ (m_nMaxMessages -m_nCalls)*MULTIJOB_PER_CALL_MEMORY_SIZE;
+ m_pCurrentMem = (sal_Int8*) rtl_allocateMemory( m_nCurrentMemSize );
m_nCurrentMemPosition = 0;
}
sal_Int8 *pHeap = m_pCurrentMem + m_nCurrentMemPosition;
@@ -263,14 +285,78 @@ public:
private:
uno_Environment *m_pEnvRemote;
sal_Int32 m_nCalls;
- ServerJobEntry m_aEntries[MAX_ENTRIES_IN_MULTIJOB];
- MemberTypeInfo m_aTypeInfo[MAX_ENTRIES_IN_MULTIJOB];
+ sal_Int32 m_nMaxMessages;
+
+ ServerJobEntry *m_aEntries;
+ MemberTypeInfo *m_aTypeInfo;
sal_Int8 *m_pCurrentMem;
+ sal_Int32 m_nCurrentMemSize;
sal_Int32 m_nCurrentMemPosition;
// list of memory pointers, that must be freed
::std::list< sal_Int8 * > m_lstMem;
};
+
+
+//---------------------------------------------------------------------------------------------
+inline ClientJob::ClientJob(
+ uno_Environment *pEnvRemote,
+ struct urp_BridgeImpl *pBridgeImpl,
+ rtl_uString *pOid,
+ typelib_TypeDescription * pMemberType,
+ typelib_InterfaceTypeDescription *pInterfaceType,
+ void *pReturn,
+ void *ppArgs[],
+ uno_Any **ppException )
+ : Job( pEnvRemote , pBridgeImpl, ::bridges_remote::RTC_HOLDENVWEAK )
+ , m_pOid( pOid ) // weak
+ , m_pEnvRemote( pEnvRemote ) // weak
+ , m_ppArgs( ppArgs )
+ , m_pReturn( pReturn )
+ , m_ppException( ppException )
+ , m_pInterfaceType( pInterfaceType ) // weak
+ , m_bReleaseForTypeDescriptionNecessary( sal_False )
+ , m_bBridgePropertyCall( sal_False )
+{
+ uno_getIdOfCurrentThread( &m_pTid );
+
+ if( typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass )
+ {
+ m_pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pMemberType;
+ m_pAttributeType = 0;
+ }
+ else if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pMemberType->eTypeClass )
+ {
+ m_pAttributeType = ( typelib_InterfaceAttributeTypeDescription * ) pMemberType;
+ m_pMethodType = 0;
+ }
+ else
+ {
+ OSL_ASSERT( ! "wrong member type" );
+ }
+
+ // calculate method index
+ if( ! m_pInterfaceType->aBase.bComplete )
+ {
+ // must be acquired because typedescription may be exchanged
+ typelib_typedescription_acquire((typelib_TypeDescription*) m_pInterfaceType );
+ m_bReleaseForTypeDescriptionNecessary = sal_True;
+ typelib_typedescription_complete( (typelib_TypeDescription ** ) &m_pInterfaceType );
+ }
+ m_nMethodIndex = m_pInterfaceType->pMapMemberIndexToFunctionIndex[
+ ((typelib_InterfaceMemberTypeDescription*)pMemberType)->nPosition ];
+
+ if( m_pAttributeType && m_ppArgs )
+ {
+ // setter
+ m_nMethodIndex ++;
+ }
+ m_bOneway = typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass ?
+ (( typelib_InterfaceMethodTypeDescription * ) pMemberType)->bOneWay :
+ sal_False;
+}
+
}
+#endif
diff --git a/bridges/source/remote/urp/urp_log.hxx b/bridges/source/remote/urp/urp_log.hxx
index ec1ff05e3..84e94c1c7 100644
--- a/bridges/source/remote/urp/urp_log.hxx
+++ b/bridges/source/remote/urp/urp_log.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_log.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,7 +61,7 @@
namespace bridges_urp
{
#ifndef PRODUCT
-#define BRIDGES_URP_PROT
+//#define BRIDGES_URP_PROT
#endif
#ifdef BRIDGES_URP_PROT
diff --git a/bridges/source/remote/urp/urp_marshal.cxx b/bridges/source/remote/urp/urp_marshal.cxx
index 580cfbc24..170b32d5d 100644
--- a/bridges/source/remote/urp/urp_marshal.cxx
+++ b/bridges/source/remote/urp/urp_marshal.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_marshal.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,8 +83,7 @@ Marshal::Marshal( urp_BridgeImpl *pBridgeImpl,
m_callback( callback ),
m_nBufferSize( nBufferSize ),
m_base( (sal_Int8*)rtl_allocateMemory( nBufferSize ) ),
- m_pos( m_base + 5 ),
- m_nSizeOffset( 0 ),
+ m_pos( m_base + 2*sizeof( sal_Int32 ) ),
m_pBridgeImpl( pBridgeImpl )
{}
@@ -120,12 +119,21 @@ void Marshal::packOid( const ::rtl::OUString & oid )
packInt16( &nIndex );
}
-void Marshal::packTid( const ByteSequence & threadId )
+void Marshal::packTid( const ByteSequence & threadId, sal_Bool bIgnoreCache )
{
- sal_uInt16 nIndex = m_pBridgeImpl->m_tidCacheOut.seek( threadId );
+
+ sal_uInt16 nIndex = 0xffff;
+ if( ! bIgnoreCache )
+ {
+ nIndex = m_pBridgeImpl->m_tidCacheOut.seek( threadId );
+ }
+
if( 0xffff == nIndex )
{
- nIndex = m_pBridgeImpl->m_tidCacheOut.put( threadId );
+ if( ! bIgnoreCache )
+ {
+ nIndex = m_pBridgeImpl->m_tidCacheOut.put( threadId );
+ }
packByteSequence( (sal_Int8*) threadId.getConstArray() ,threadId.getLength());
}
else
@@ -142,9 +150,8 @@ void Marshal::packType( void *pSource )
*(typelib_TypeDescriptionReference ** ) pSource;
OSL_ASSERT( pRef );
- Type type( pRef );
- sal_uInt8 nTypeClass = type.getTypeClass();
+ sal_uInt8 nTypeClass = ( sal_uInt8 ) pRef->eTypeClass;
if( nTypeClass <= /* any*/ 14 )
{
@@ -155,12 +162,12 @@ void Marshal::packType( void *pSource )
OUString sTypeName;
sal_uInt16 nIndex = 0xffff;
- nIndex = m_pBridgeImpl->m_typeCacheOut.seek( type );
+ nIndex = m_pBridgeImpl->m_typeCacheOut.seek( *(Type*)&pRef );
if( 0xffff == nIndex )
{
// put it into the cache
- nIndex = m_pBridgeImpl->m_typeCacheOut.put( type );
- sTypeName = type.getTypeName();
+ nIndex = m_pBridgeImpl->m_typeCacheOut.put( *(Type*)&pRef );
+ sTypeName = pRef->pTypeName;
nTypeClass = nTypeClass | 0x80;
}
packInt8( &nTypeClass );
diff --git a/bridges/source/remote/urp/urp_marshal.hxx b/bridges/source/remote/urp/urp_marshal.hxx
index 4505309a1..83d4adaf7 100644
--- a/bridges/source/remote/urp/urp_marshal.hxx
+++ b/bridges/source/remote/urp/urp_marshal.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_marshal.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,16 +61,6 @@
#ifndef _URP_MARSHAL_HXX_
#define _URP_MARSHAL_HXX_
-/**************************************************************************
-#*
-#* last change $Author: hr $ $Date: 2000-09-18 15:28:50 $
-#* $Revision: 1.1.1.1 $
-#*
-#* $Logfile: $
-#*
-#* Copyright (c) 2000, Sun Microsystems
-#*
-#************************************************************************/
#include <rtl/ustring.hxx>
#include <rtl/byteseq.hxx>
@@ -81,48 +71,41 @@
struct remote_Interface;
-
namespace bridges_urp
{
// methods for accessing marshaling buffer
- inline void Marshal::finish()
+ inline void Marshal::finish( sal_Int32 nMessageCount )
{
- sal_Int32 nSize = ( ((sal_uInt32 )(m_pos - m_base)) -5 );
- OSL_ASSERT( nSize );
+ sal_Int32 nSize = getSize() - 2*sizeof( sal_Int32 );
+
+ // save the state
sal_Int8 *pos = m_pos;
m_pos = m_base;
- packCompressedSize( nSize );
- if( m_pos == m_base +1 )
- {
- ((sal_uInt8*)m_base)[4] = (sal_uInt8) ((sal_uInt8*)m_base)[0];
- m_nSizeOffset = 4;
- }
- else
- {
- m_nSizeOffset = 0;
- }
+ packInt32( &nSize );
+ packInt32( &nMessageCount );
+
+ // reset the state
m_pos = pos;
}
inline void Marshal::restart()
{
- m_pos = m_base +5;
- m_nSizeOffset = 0;
+ m_pos = m_base + 2*sizeof( sal_Int32 );
}
inline sal_Int8 *Marshal::getBuffer()
{
- return m_base + m_nSizeOffset;
+ return m_base;
}
inline sal_Bool Marshal::empty() const
{
- return ( m_pos -m_base ) == 5;
+ return ( m_pos - m_base ) == 2*sizeof( sal_Int32 );
}
inline sal_Int32 Marshal::getSize()
{
- return (sal_Int32)(m_pos - m_base) - m_nSizeOffset;
+ return ((sal_Int32) (m_pos - m_base));
}
inline void Marshal::ensureAdditionalMem( sal_Int32 nMemToAdd )
@@ -139,7 +122,6 @@ namespace bridges_urp
}
}
-
// marshaling methods
inline void Marshal::packInt8( void *pSource )
{
@@ -222,7 +204,6 @@ namespace bridges_urp
m_pos +=4;
}
-
inline void Marshal::packCompressedSize( sal_Int32 nSize )
{
ensureAdditionalMem( 5 );
@@ -240,7 +221,6 @@ namespace bridges_urp
}
}
-
inline void Marshal::pack( void *pSource , typelib_TypeDescription *pType )
{
switch( pType->eTypeClass )
@@ -265,6 +245,7 @@ namespace bridges_urp
packInt16( pSource );
break;
}
+ case typelib_TypeClass_ENUM:
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
case typelib_TypeClass_FLOAT:
@@ -318,12 +299,6 @@ namespace bridges_urp
packAny( pSource );
break;
}
- case typelib_TypeClass_ENUM:
- {
- sal_uInt32 nValue = *(sal_Int32*)pSource;
- packCompressedSize( nValue );
- break;
- }
case typelib_TypeClass_TYPEDEF:
{
OSL_ASSERT( 0 ); // should never occur
diff --git a/bridges/source/remote/urp/urp_marshal_decl.hxx b/bridges/source/remote/urp/urp_marshal_decl.hxx
index ffa81d287..75a4aae80 100644
--- a/bridges/source/remote/urp/urp_marshal_decl.hxx
+++ b/bridges/source/remote/urp/urp_marshal_decl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_marshal_decl.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* Copyright according the GNU Public License.
*
@@ -14,8 +14,8 @@
/**************************************************************************
#*
-#* last change $Author: hr $ $Date: 2000-09-18 15:28:50 $
-#* $Revision: 1.1.1.1 $
+#* last change $Author: jbu $ $Date: 2000-09-29 08:42:06 $
+#* $Revision: 1.2 $
#*
#* $Logfile: $
#*
@@ -31,9 +31,8 @@ namespace bridges_urp
{
struct urp_BridgeImpl;
- typedef void ( SAL_CALL * urp_extractOidCallback ) (
- remote_Interface *pRemoteI,
- rtl_uString **ppOid );
+ typedef void
+ ( SAL_CALL * urp_extractOidCallback )( remote_Interface *pRemoteI, rtl_uString **ppOid );
extern char g_bMarshalSystemIsLittleEndian;
class Marshal
@@ -49,7 +48,7 @@ namespace bridges_urp
void packRecursive( void *pSource, typelib_TypeDescription *pType );
- void packTid( const ::rtl::ByteSequence &id );
+ void packTid( const ::rtl::ByteSequence &id, sal_Bool bIgnoreCache = sal_False );
void packOid( const ::rtl::OUString &oid );
void packType( void *pSource );
@@ -68,7 +67,7 @@ namespace bridges_urp
// stops marshaling, inserts size in front of the buffer
// getStart and getSize can now be called
- inline void finish();
+ inline void finish( sal_Int32 nMessageCount );
// must be called after finish. After calling restart,
// a new marshalling session is started invalidating
@@ -92,10 +91,8 @@ namespace bridges_urp
private:
inline void ensureAdditionalMem( sal_Int32 nMemToAdd );
sal_Int32 m_nBufferSize;
- sal_Int8 *m_base;
-
+ sal_Int8 *m_base;
sal_Int8 *m_pos;
- sal_Int32 m_nSizeOffset;
struct urp_BridgeImpl *m_pBridgeImpl;
urp_extractOidCallback m_callback;
};
diff --git a/bridges/source/remote/urp/urp_property.hxx b/bridges/source/remote/urp/urp_property.hxx
new file mode 100644
index 000000000..7169617c5
--- /dev/null
+++ b/bridges/source/remote/urp/urp_property.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_property.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _URP_PROPERTY_HXX_
+#define _URP_PROPERTY_HXX_
+#include <bridges/remote/remote.h>
+
+#include <rtl/ustring.hxx>
+#include <rtl/byteseq.hxx>
+
+namespace bridges_urp
+{
+ struct Properties
+ {
+ ::rtl::ByteSequence seqBridgeID;
+ sal_Int32 nTypeCacheSize;
+ sal_Int32 nOidCacheSize;
+ sal_Int32 nTidCacheSize;
+ ::rtl::OUString sSupportedVersions;
+ ::rtl::OUString sVersion;
+ sal_Int32 nFlushBlockSize;
+ sal_Int32 nOnewayTimeoutMUSEC;
+ sal_Bool bSupportsMustReply;
+ sal_Bool bSupportsSynchronous;
+ sal_Bool bSupportsMultipleSynchronous;
+ sal_Bool bClearCache;
+
+ inline Properties & SAL_CALL operator = ( const Properties &props )
+ {
+ seqBridgeID = props.seqBridgeID;
+ nTypeCacheSize = props.nTypeCacheSize;
+ nOidCacheSize = props.nOidCacheSize;
+ nTidCacheSize = props.nTidCacheSize;
+ sSupportedVersions = props.sSupportedVersions;
+ sVersion = props.sVersion;
+ nFlushBlockSize = props.nFlushBlockSize;
+ nOnewayTimeoutMUSEC = props.nOnewayTimeoutMUSEC;
+ bSupportsMustReply = props.bSupportsMustReply;
+ bSupportsSynchronous = props.bSupportsSynchronous;
+ bSupportsMultipleSynchronous = props.bSupportsMultipleSynchronous;
+ bClearCache = props.bClearCache;
+ return *this;
+ }
+ };
+} // end namespace bridges_urp
+#endif
diff --git a/bridges/source/remote/urp/urp_propertyobject.cxx b/bridges/source/remote/urp/urp_propertyobject.cxx
new file mode 100644
index 000000000..58e0b6579
--- /dev/null
+++ b/bridges/source/remote/urp/urp_propertyobject.cxx
@@ -0,0 +1,682 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_propertyobject.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdlib.h>
+
+#include <osl/diagnose.h>
+
+#include <rtl/random.h>
+
+#include <uno/data.h>
+
+#include <com/sun/star/bridge/XProtocolProperties.hpp>
+
+#include "urp_propertyobject.hxx"
+#include "urp_dispatch.hxx"
+#include "urp_bridgeimpl.hxx"
+#include "urp_job.hxx"
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::uno;
+
+namespace bridges_urp
+{
+// some nice constants ....
+static const sal_Int32 METHOD_QUERY_INTERFACE = 0;
+static const sal_Int32 METHOD_GET_PROPERTIES = 3;
+static const sal_Int32 METHOD_REQUEST_CHANGE = 4;
+static const sal_Int32 METHOD_COMMIT_CHANGE = 5;
+
+static const sal_Int32 PROPERTY_BRIDGEID = 0;
+static const sal_Int32 PROPERTY_TYPECACHESIZE = 1;
+static const sal_Int32 PROPERTY_OIDCACHESIZE = 2;
+static const sal_Int32 PROPERTY_TIDCACHESIZE = 3;
+static const sal_Int32 PROPERTY_SUPPORTEDVERSIONS = 4;
+static const sal_Int32 PROPERTY_VERSION =5;
+static const sal_Int32 PROPERTY_FLUSHBLOCKSIZE = 6;
+static const sal_Int32 PROPERTY_ONEWAYTIMEOUT_MUSEC = 7;
+static const sal_Int32 PROPERTY_SUPPORTSMUSTREPLY = 8;
+static const sal_Int32 PROPERTY_SUPPERTSSYNCHRONOUS = 9;
+static const sal_Int32 PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS = 10;
+static const sal_Int32 PROPERTY_CLEARCACHE = 11;
+
+static const sal_Int32 MAX_PROPERTIES = PROPERTY_CLEARCACHE +1;
+
+const sal_Char *g_aPropertyName[] =
+{
+ "BridgeId",
+ "TypeCacheSize",
+ "OidCacheSize",
+ "TidCacheSize",
+ "SupportedVersion",
+ "Version",
+ "FlushBlockSize",
+ "OnewayTimeoutMUSEC",
+ "SupportsMustReply",
+ "SupportsSynchronous",
+ "SupportsMultipleSynchronous",
+ "ClearCache"
+};
+
+// nice little helper functions for conversion
+template< class t >
+void assignToIdl( ProtocolProperty *pIdl, sal_Int32 nIndex, const t &value )
+{
+ pIdl->Name = OUString::createFromAscii( g_aPropertyName[nIndex] );
+ ( *(::com::sun::star::uno::Any *)&(pIdl->Value) ) <<= value;
+}
+
+template< class t >
+void assignFromIdl( t * p, const ProtocolProperty & property )
+{
+ property.Value >>=*p;
+}
+
+static sal_Int32 getIndexFromIdl( const ProtocolProperty & property )
+{
+ sal_Int32 nResult = -1;
+ for( sal_Int32 i = 0 ; i < MAX_PROPERTIES ; i ++ )
+ {
+ if( 0 == property.Name.compareToAscii( g_aPropertyName[i] ) )
+ {
+ nResult = i;
+ break;
+ }
+ }
+ return nResult;
+}
+
+static sal_Int32 getIndexFromString( const OUString & property )
+{
+ sal_Int32 nResult = -1;
+ for( sal_Int32 i = 0 ; i < MAX_PROPERTIES ; i ++ )
+ {
+ if( 0 == property.compareToAscii( g_aPropertyName[i] ) )
+ {
+ nResult = i;
+ break;
+ }
+ }
+ return nResult;
+}
+
+static sal_Bool assignFromIdlToStruct( Properties *pProps, const ProtocolProperty &idl )
+{
+ sal_Bool bReturn = sal_True;
+
+ sal_Int32 nIndex = getIndexFromIdl( idl );
+ if( nIndex >= 0 )
+ {
+ switch( nIndex )
+ {
+ case PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS:
+ assignFromIdl( &(pProps->bSupportsMultipleSynchronous) , idl );
+ break;
+ case PROPERTY_SUPPERTSSYNCHRONOUS:
+ assignFromIdl( &(pProps->bSupportsMustReply) , idl );
+ break;
+ case PROPERTY_SUPPORTSMUSTREPLY:
+ assignFromIdl( &(pProps->bSupportsSynchronous) , idl );
+ break;
+ case PROPERTY_ONEWAYTIMEOUT_MUSEC:
+ assignFromIdl( &(pProps->nOnewayTimeoutMUSEC) , idl );
+ break;
+ case PROPERTY_BRIDGEID:
+ assignFromIdl( (Sequence< sal_Int8 > * )&(pProps->seqBridgeID), idl );
+ break;
+ case PROPERTY_TYPECACHESIZE:
+ assignFromIdl( &(pProps->nTypeCacheSize) , idl );
+ break;
+ case PROPERTY_OIDCACHESIZE:
+ assignFromIdl( &(pProps->nOidCacheSize) , idl );
+ break;
+ case PROPERTY_TIDCACHESIZE:
+ assignFromIdl( &(pProps->nTidCacheSize), idl );
+ break;
+ case PROPERTY_SUPPORTEDVERSIONS:
+ assignFromIdl( &(pProps->sSupportedVersions) , idl );
+ break;
+ case PROPERTY_VERSION:
+ assignFromIdl( &(pProps->sVersion) , idl );
+ break;
+ case PROPERTY_FLUSHBLOCKSIZE:
+ assignFromIdl( &(pProps->nFlushBlockSize) ,idl );
+ break;
+ case PROPERTY_CLEARCACHE:
+ assignFromIdl( &(pProps->bClearCache) ,idl );
+ break;
+ default:
+ bReturn = sal_False;
+ }
+ }
+ else
+ {
+ bReturn = sal_False;
+ }
+ return bReturn;
+}
+
+
+//----------------------------------------------------------------------------------------------
+// PropertyObject implementation
+PropertyObject::PropertyObject(
+ struct Properties *pLocalSetting , uno_Environment *pEnvRemote, urp_BridgeImpl *pImpl )
+ : m_pLocalSetting( pLocalSetting )
+ , m_nRefCount( 0 )
+ , m_pEnvRemote( pEnvRemote )
+ , m_bApplyProperties( sal_False )
+ , m_pBridgeImpl( pImpl )
+ , m_bClientWaitingForCommit( sal_False )
+ , m_bServerWaitingForCommit( sal_False )
+ , m_bRequestChangeHasBeenCalled( sal_False )
+ , m_commitChangeCondition( osl_createCondition() )
+{
+ acquire = staticAcquire;
+ release = staticRelease;
+ pDispatcher = staticDispatch;
+}
+
+PropertyObject::~PropertyObject()
+{
+ osl_destroyCondition( m_commitChangeCondition );
+}
+
+void SAL_CALL PropertyObject::thisDispatch(
+ typelib_TypeDescription * pMemberType, void * pReturn, void * ppArgs[],uno_Any ** ppException )
+{
+ OSL_ASSERT( pMemberType->eTypeClass == typelib_TypeClass_INTERFACE_METHOD );
+
+ typelib_InterfaceMethodTypeDescription *pMethodType =
+ ( typelib_InterfaceMethodTypeDescription * ) pMemberType;
+
+ switch( pMethodType->aBase.nPosition )
+ {
+ case METHOD_QUERY_INTERFACE:
+ OSL_ENSURE( 0 , "not implemented yet !" );
+ break;
+ case METHOD_GET_PROPERTIES:
+ {
+ implGetProperties( (uno_Sequence **) pReturn );
+ *ppException = 0;
+ break;
+ }
+ case METHOD_COMMIT_CHANGE:
+ {
+ implCommitChange( *(uno_Sequence ** ) ppArgs[0] , ppException );
+ break;
+ }
+ case METHOD_REQUEST_CHANGE:
+ {
+ *(sal_Int32 *) pReturn = implRequestChange( *(sal_Int32 *)ppArgs[0], ppException );
+ break;
+ }
+ default:
+ OSL_ENSURE( 0 , "unkown method !" );
+ }
+}
+
+void SAL_CALL PropertyObject::localGetPropertiesFromRemote( struct Properties *pR )
+{
+ OUString oid = OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject );
+
+ typelib_TypeDescription *pInterfaceType = 0;
+ getCppuType( (Reference< XProtocolProperties > *) 0 ).getDescription( &pInterfaceType );
+
+ if( !pInterfaceType->bComplete )
+ {
+ typelib_typedescription_complete( &pInterfaceType );
+ }
+
+ typelib_TypeDescription *pMethodType = 0;
+ typelib_typedescriptionreference_getDescription(
+ &pMethodType,
+ ((typelib_InterfaceTypeDescription*) pInterfaceType)->ppAllMembers[METHOD_GET_PROPERTIES] );
+
+
+ uno_Sequence *pResult = 0;
+ uno_Any exception;
+ uno_Any *pException = &exception;
+ urp_sendRequest( m_pEnvRemote,
+ pMethodType,
+ oid.pData,
+ (typelib_InterfaceTypeDescription*) pInterfaceType,
+ &pResult,
+ 0,
+ &pException );
+
+ if( pException )
+ {
+ OSL_ENSURE( 0 , "remote urp-bridge doesn't support property-object" );
+ uno_any_destruct( pException , 0 );
+ return;
+ }
+
+ ProtocolProperty *pP = (ProtocolProperty * ) pResult->elements;
+ for( sal_Int32 i = 0; i < pResult->nElements ; i ++ )
+ {
+ if( ! assignFromIdlToStruct( pR , pP[i] ) )
+ {
+ OSL_ENSURE( 0 , "unknown property !!!!" );
+ }
+ }
+
+ typelib_typedescription_release( pInterfaceType );
+ typelib_typedescription_release( pMethodType );
+}
+
+
+// implementation for call from remote
+void SAL_CALL PropertyObject::implGetProperties( uno_Sequence **ppReturnValue )
+{
+ typelib_TypeDescription *pElementType= 0;
+ getCppuType( (Sequence< ProtocolProperty > *)0).getDescription( &pElementType );
+
+ OSL_ENSURE( pElementType , "Couldn't get property type" );
+
+ *ppReturnValue = 0;
+ uno_sequence_construct( ppReturnValue , pElementType , 0, MAX_PROPERTIES , 0 );
+ ProtocolProperty *pElements = (ProtocolProperty * ) ( *ppReturnValue )->elements;
+ Properties *pP = m_pLocalSetting;
+
+ assignToIdl( &(pElements[PROPERTY_BRIDGEID]),PROPERTY_BRIDGEID, *(Sequence< sal_Int8 > *)&(pP->seqBridgeID) );
+ assignToIdl( &(pElements[PROPERTY_TYPECACHESIZE]),PROPERTY_TYPECACHESIZE,pP->nTypeCacheSize );
+ assignToIdl( &(pElements[PROPERTY_OIDCACHESIZE]),PROPERTY_OIDCACHESIZE, pP->nOidCacheSize );
+ assignToIdl( &(pElements[PROPERTY_TIDCACHESIZE]),PROPERTY_TIDCACHESIZE, pP->nTidCacheSize );
+ assignToIdl( &(pElements[PROPERTY_SUPPORTEDVERSIONS]),PROPERTY_SUPPORTEDVERSIONS, pP->sSupportedVersions );
+ assignToIdl( &(pElements[PROPERTY_VERSION]),PROPERTY_VERSION, pP->sVersion );
+ assignToIdl( &(pElements[PROPERTY_FLUSHBLOCKSIZE]), PROPERTY_FLUSHBLOCKSIZE,pP->nFlushBlockSize );
+ assignToIdl( &(pElements[PROPERTY_ONEWAYTIMEOUT_MUSEC]), PROPERTY_ONEWAYTIMEOUT_MUSEC, pP->nOnewayTimeoutMUSEC );
+ assignToIdl( &(pElements[PROPERTY_SUPPORTSMUSTREPLY]), PROPERTY_SUPPORTSMUSTREPLY, pP->bSupportsMustReply );
+ assignToIdl( &(pElements[PROPERTY_SUPPERTSSYNCHRONOUS]), PROPERTY_SUPPERTSSYNCHRONOUS, pP->bSupportsSynchronous );
+ assignToIdl( &(pElements[PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS]), PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS, pP->bSupportsMultipleSynchronous );
+ assignToIdl( &(pElements[PROPERTY_CLEARCACHE]), PROPERTY_CLEARCACHE, pP->bClearCache );
+
+ typelib_typedescription_release( pElementType );
+}
+
+//----------------------------------------------------------------------------------------------
+sal_Int32 SAL_CALL PropertyObject::localRequestChange( )
+{
+ sal_Int32 nResult = -1; // try again is default
+ sal_Bool bCall = sal_True;
+
+ // disallow marshaling NOW !
+ ClearableMutexGuard marshalingGuard( m_pBridgeImpl->m_marshalingMutex );
+ {
+ MutexGuard guard( m_mutex );
+ if( m_bRequestChangeHasBeenCalled || m_bClientWaitingForCommit || m_bServerWaitingForCommit )
+ {
+ // another transaction is already underway
+ // try again later !
+ bCall = sal_False;
+ }
+ m_bRequestChangeHasBeenCalled = sal_True;
+
+ if( bCall )
+ {
+ rtlRandomPool pool = rtl_random_createPool ();
+ rtl_random_getBytes( pool , &m_nRandomNumberOfRequest, sizeof( m_nRandomNumberOfRequest ) );
+ rtl_random_destroyPool( pool );
+ }
+ }
+
+ if( bCall )
+ {
+ OUString oid = OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject );
+
+ // gather types for calling
+ typelib_TypeDescription *pInterfaceType = 0;
+ getCppuType( (Reference< XProtocolProperties > *) 0 ).getDescription( &pInterfaceType );
+
+ if( !pInterfaceType->bComplete )
+ {
+ typelib_typedescription_complete( &pInterfaceType );
+ }
+
+ typelib_TypeDescription *pMethodType = 0;
+ typelib_typedescriptionreference_getDescription(
+ &pMethodType,
+ ((typelib_InterfaceTypeDescription*) pInterfaceType)->ppAllMembers[METHOD_REQUEST_CHANGE] );
+
+ void *pArg1 = &m_nRandomNumberOfRequest;
+ void **ppArgs = &pArg1;
+
+ uno_Sequence *pResult = 0;
+ uno_Any exception;
+ uno_Any *pException = &exception;
+
+ ClientJob job( m_pEnvRemote,
+ m_pBridgeImpl,
+ oid.pData,
+ pMethodType,
+ (typelib_InterfaceTypeDescription*) pInterfaceType,
+ &nResult,
+ ppArgs,
+ &pException );
+
+ // put the call on the line !
+ job.pack();
+
+ // now allow writing on wire again.
+ // NOTE : this has been locked, because it is inevitable to set m_bRequestChangeHasBeenCalled
+ // and call requestChange in an atomar operation. Otherwise, implRequestChange may be called
+ // inbetween and reply, before the request is put on the wire. This certainly would
+ // be confusing for the remote counterpart !
+ marshalingGuard.clear();
+
+ // wait for the reply ...
+ job.wait();
+
+ if( pException )
+ {
+ // the object is unknown on the other side.
+ uno_any_destruct( pException , 0 );
+ nResult = 0;
+ }
+ typelib_typedescription_release( pInterfaceType );
+ typelib_typedescription_release( pMethodType );
+ }
+
+ {
+ MutexGuard guard( m_mutex );
+ m_bRequestChangeHasBeenCalled = sal_False;
+ m_bClientWaitingForCommit = ( 1 == nResult );
+ m_bServerWaitingForCommit = ( 0 == nResult );
+ }
+ return nResult;
+}
+
+// implementation for call from remote
+sal_Int32 SAL_CALL PropertyObject::implRequestChange( sal_Int32 nRandomNumber, uno_Any **ppException )
+{
+ sal_Int32 nResult = 0;
+ MutexGuard guard( m_mutex );
+ if( m_bRequestChangeHasBeenCalled )
+ {
+ // this side has also called requestChange, now negotiate, which side is allowed
+ // to commit the change !
+ if( m_nRandomNumberOfRequest > nRandomNumber )
+ {
+ // this side may commit !!!!
+ nResult = 0;
+ }
+ else if( m_nRandomNumberOfRequest == nRandomNumber )
+ {
+ // sorry, try again !
+ nResult = -1;
+ }
+ else if( m_nRandomNumberOfRequest < nRandomNumber )
+ {
+ // the other side may commit !
+ nResult = 1;
+ // m_bServerWaitingForCommit will be set by localRequestChange
+ }
+ }
+ else
+ {
+ // This side has NOT called requestChange, so the other side may commit
+ nResult = 1;
+ m_bServerWaitingForCommit = sal_True;
+ }
+
+ *ppException = 0;
+ return nResult;
+}
+
+static void extractTokens(
+ const ::rtl::OUString &sProps , ::std::list< OUString > &lst )
+{
+ sal_Int32 nNext = 0;
+ while ( sal_True )
+ {
+ sal_Int32 nStart = nNext;
+ nNext = sProps.indexOf( ',' , nNext );
+ if( -1 == nNext )
+ {
+ lst.push_back( sProps.copy( nStart, sProps.getLength() - nStart ) );
+ break;
+ }
+ lst.push_back( sProps.copy( nStart , nNext - nStart ) );
+ nNext ++;
+ }
+}
+
+
+void SAL_CALL PropertyObject::localCommitChange( const ::rtl::OUString &sProps , sal_Bool *pbExceptionThrown )
+{
+ // lock the bridge NOW !
+ // NOTE: it is not allowed for other threads to call, when a commit change is underway.
+ // The remote counterpart cannot if the call following the commit already uses
+ // the new properties or not.
+ MutexGuard guard( m_pBridgeImpl->m_marshalingMutex );
+
+ OUString oid = OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject );
+
+ osl_resetCondition( m_commitChangeCondition );
+ m_bClientWaitingForCommit = sal_True;
+
+ Properties props = *m_pLocalSetting;
+
+ typelib_TypeDescription *pInterfaceType = 0;
+ getCppuType( (Reference< XProtocolProperties > *) 0 ).getDescription( &pInterfaceType );
+
+ if( !pInterfaceType->bComplete )
+ {
+ typelib_typedescription_complete( &pInterfaceType );
+ }
+
+ typelib_TypeDescription *pMethodType = 0;
+ typelib_typedescriptionreference_getDescription(
+ &pMethodType,
+ ((typelib_InterfaceTypeDescription*) pInterfaceType)->ppAllMembers[METHOD_COMMIT_CHANGE] );
+
+ typelib_TypeDescription *pSequenceType= 0;
+
+ // extract name/value pairs
+ ::std::list< OUString > lst;
+ extractTokens( sProps , lst );
+
+ getCppuType( (Sequence< ProtocolProperty > *)0).getDescription( &pSequenceType );
+ uno_Sequence *pSeq = 0;
+ uno_sequence_construct( &pSeq , pSequenceType , 0, lst.size() , 0 );
+ ProtocolProperty *pElements = (ProtocolProperty * ) pSeq->elements;
+
+ sal_Int32 i = 0;
+ for( ::std::list< OUString >::iterator ii = lst.begin() ; ii != lst.end() ; ++ ii, i++ )
+ {
+ sal_Int32 nAssign = (*ii).indexOf( '=' );
+ if( -1 == nAssign )
+ {
+ OString o = OUStringToOString( *ii, RTL_TEXTENCODING_ASCII_US );
+ OSL_ENSURE( !"wrong protocol propertyt format, ignored", o.getStr() );
+ }
+ OUString sPropName = (*ii).copy( 0, nAssign );
+ OUString sValue = (*ii).copy( nAssign +1, (*ii).getLength() - nAssign -1 );
+
+ sal_Int32 nIndex = getIndexFromString( sPropName );
+ if( -1 == nIndex )
+ {
+ OString o = OUStringToOString( sPropName , RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSURE( !"unknown protocol property, ignored", o.getStr() );
+ }
+ switch( nIndex )
+ {
+ // bools
+ case PROPERTY_CLEARCACHE:
+ {
+ sal_Bool bClearCache = (sal_Bool ) sValue.toInt32();
+ assignToIdl( &(pElements[i]) , nIndex , bClearCache );
+ break;
+ }
+ // ints
+ case PROPERTY_TYPECACHESIZE:
+ case PROPERTY_OIDCACHESIZE:
+ case PROPERTY_TIDCACHESIZE:
+ case PROPERTY_FLUSHBLOCKSIZE:
+ case PROPERTY_ONEWAYTIMEOUT_MUSEC:
+ {
+ sal_Int32 nValue = sValue.toInt32();
+ assignToIdl( &(pElements[i]) , nIndex , nValue );
+ break;
+ }
+
+ // strings
+ case PROPERTY_VERSION:
+ assignToIdl( &(pElements[i]) , nIndex , sValue );
+ break;
+ default:
+ OString o = OUStringToOString( sPropName, RTL_TEXTENCODING_ASCII_US );
+ OSL_ENSURE( !"readonly protocol property, ignored" , o.getStr() );
+ }
+ assignFromIdlToStruct( &props, pElements[i] );
+ }
+
+ void *pArg1 = &pSeq;
+ uno_Sequence *pResult = 0;
+ uno_Any exception;
+ uno_Any *pException = &exception;
+
+ ClientJob job( m_pEnvRemote,
+ m_pBridgeImpl,
+ oid.pData,
+ pMethodType,
+ (typelib_InterfaceTypeDescription*) pInterfaceType,
+ 0,
+ &pArg1,
+ &pException );
+ job.setBridgePropertyCall();
+ job.pack();
+ job.wait();
+
+ ::uno_destructData( &pSeq, pSequenceType, 0 );
+
+ *pbExceptionThrown = pException ? sal_True : sal_False;
+
+ if( pException )
+ {
+ OString o = OUStringToOString( ((com::sun::star::uno::Exception*)pException->pData)->Message,
+ RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSURE( !"exception thrown during calling on PropertyObject",o.getStr() );
+ uno_any_destruct( pException , 0 );
+ }
+ else
+ {
+ m_pBridgeImpl->applyProtocolChanges( props );
+ m_bClientWaitingForCommit = sal_False;
+ m_bServerWaitingForCommit = sal_False;
+ m_bApplyProperties = sal_False;
+ }
+
+ // let the reader thread go ...
+ m_bClientWaitingForCommit = sal_False;
+ osl_setCondition( m_commitChangeCondition );
+
+ typelib_typedescription_release( pSequenceType );
+ typelib_typedescription_release( pMethodType );
+ typelib_typedescription_release( pInterfaceType );
+}
+
+void SAL_CALL PropertyObject::implCommitChange( uno_Sequence *pSequence, uno_Any **ppException )
+{
+ MutexGuard guard( m_mutex );
+ m_propsToBeApplied = *m_pLocalSetting;
+
+ ProtocolProperty *pP = (ProtocolProperty * ) pSequence->elements;
+ for( sal_Int32 i = 0; i < pSequence->nElements ; i ++ )
+ {
+ if( ! assignFromIdlToStruct( &m_propsToBeApplied , pP[i] ) )
+ {
+ InvalidProtocolChangeException exception;
+ Type type = getCppuType( &exception );
+ exception.Message = OUString::createFromAscii( "urp: unknown Property " );
+ exception.Message += pP[i].Name;
+ exception.invalidProperty = pP[i];
+ exception.reason = 1;
+
+ uno_type_any_construct( *ppException, &exception, type.getTypeLibType() , 0 );
+
+ m_bApplyProperties = sal_False;
+ m_bClientWaitingForCommit = sal_False;
+ m_bServerWaitingForCommit = sal_False;
+ return;
+ }
+ }
+
+ m_bApplyProperties = sal_True;
+ *ppException = 0;
+}
+
+Properties SAL_CALL PropertyObject::getCommitedChanges()
+{
+ MutexGuard guard( m_mutex );
+ OSL_ASSERT( m_bApplyProperties );
+ m_bApplyProperties = sal_False;
+ m_bClientWaitingForCommit = sal_False;
+ m_bServerWaitingForCommit = sal_False;
+ return m_propsToBeApplied;
+}
+
+void SAL_CALL PropertyObject::waitUntilChangesAreCommitted()
+{
+ osl_waitCondition( m_commitChangeCondition , 0 );
+}
+}
diff --git a/bridges/source/remote/urp/urp_propertyobject.hxx b/bridges/source/remote/urp/urp_propertyobject.hxx
new file mode 100644
index 000000000..8e1ec2db5
--- /dev/null
+++ b/bridges/source/remote/urp/urp_propertyobject.hxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_propertyobject.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+
+#include <osl/interlck.h>
+#include <osl/mutex.hxx>
+#include <osl/conditn.h>
+
+#include <rtl/string.hxx>
+#include <uno/sequence2.h>
+
+#include <bridges/remote/remote.h>
+
+#include "urp_property.hxx"
+
+namespace bridges_urp {
+
+struct urp_BridgeImpl;
+const sal_Char g_NameOfUrpProtocolPropertiesObject[] = "UrpProtocolProperties";
+
+class PropertyObject : public remote_Interface
+{
+private:
+ ::osl::Mutex m_mutex;
+ oslCondition m_commitChangeCondition;
+ oslInterlockedCount m_nRefCount;
+ urp_BridgeImpl *m_pBridgeImpl;
+ struct Properties *m_pLocalSetting;
+ struct Properties m_propsToBeApplied;
+
+ uno_Environment *m_pEnvRemote;
+ sal_Int32 m_nRandomNumberOfRequest;
+ sal_Bool m_bRequestChangeHasBeenCalled;
+ sal_Bool m_bClientWaitingForCommit;
+ sal_Bool m_bServerWaitingForCommit;
+ sal_Bool m_bApplyProperties;
+
+public:
+ PropertyObject(
+ struct Properties *pLocalSetting , uno_Environment *pEnvRemote, urp_BridgeImpl *pImpl );
+ ~PropertyObject();
+
+ void SAL_CALL thisAcquire( )
+ {
+ osl_incrementInterlockedCount( &m_nRefCount );
+ }
+
+ void SAL_CALL thisRelease()
+ {
+ if( ! osl_decrementInterlockedCount( &m_nRefCount ) )
+ {
+ delete this;
+ }
+ }
+
+ void SAL_CALL thisDispatch( typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+
+public: // local
+ sal_Int32 SAL_CALL localRequestChange( );
+ void SAL_CALL localCommitChange( const ::rtl::OUString &properties, sal_Bool *pbExceptionThrown );
+ void SAL_CALL localGetPropertiesFromRemote( struct Properties * );
+
+ // returns 0, if nothing was commited.
+ inline sal_Bool SAL_CALL changesHaveBeenCommited()
+ { return m_bApplyProperties; }
+ Properties SAL_CALL getCommitedChanges();
+
+ inline sal_Bool SAL_CALL waitingForCommitChangeReply()
+ { return m_bClientWaitingForCommit; }
+ void SAL_CALL waitUntilChangesAreCommitted();
+
+protected:
+ // these methods are called by thisDispatch
+ void SAL_CALL implGetProperties( uno_Sequence **ppReturnValue );
+ sal_Int32 SAL_CALL implRequestChange( sal_Int32 nRandomNumber, uno_Any **ppException );
+ void SAL_CALL implCommitChange( uno_Sequence *seqOfProperties, uno_Any **ppException );
+
+
+ // static helper methods
+public:
+ static void SAL_CALL staticAcquire( remote_Interface *pRemoteI )
+ {
+ PropertyObject *pProperties = (PropertyObject *) pRemoteI;
+ pProperties->thisAcquire();
+ }
+
+ static void SAL_CALL staticRelease( remote_Interface *pRemoteI )
+ {
+ PropertyObject *pProperties = (PropertyObject *) pRemoteI;
+ pProperties->thisRelease();
+ }
+
+ static void SAL_CALL staticDispatch( remote_Interface * pRemoteI,
+ typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException )
+ {
+ PropertyObject *pProperties = (PropertyObject *) pRemoteI;
+ pProperties->thisDispatch( pMemberType, pReturn, pArgs, ppException );
+ }
+};
+
+}
diff --git a/bridges/source/remote/urp/urp_reader.cxx b/bridges/source/remote/urp/urp_reader.cxx
index 5b87022c7..e602359ab 100644
--- a/bridges/source/remote/urp/urp_reader.cxx
+++ b/bridges/source/remote/urp/urp_reader.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_reader.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,6 +60,9 @@
************************************************************************/
/**************************************************************************
* $Log: not supported by cvs2svn $
+ * Revision 1.1.1.1 2000/09/18 15:28:50 hr
+ * initial import
+ *
* Revision 1.7 2000/09/15 13:05:58 jbu
* extensive performance optimizations
*
@@ -98,6 +101,7 @@
#include "urp_job.hxx"
#include "urp_bridgeimpl.hxx"
#include "urp_log.hxx"
+#include "urp_propertyobject.hxx"
using namespace ::rtl;
using namespace ::osl;
@@ -109,6 +113,33 @@ static MyCounter thisCounter( "DEBUG : ReaderThread" );
namespace bridges_urp
{
+ struct MessageFlags
+ {
+ sal_uInt16 nMethodId;
+ sal_Bool bRequest;
+ sal_Bool bType;
+ sal_Bool bOid;
+ sal_Bool bTid;
+ sal_Bool bException;
+ sal_Bool bMustReply;
+ sal_Bool bSynchronous;
+ sal_Bool bMoreFlags;
+ sal_Bool bIgnoreCache;
+ sal_Bool bBridgePropertyCall;
+ ///--------------------------
+ inline MessageFlags()
+ {
+ bTid = sal_False;
+ bOid = sal_False;
+ bType = sal_False;
+ bException = sal_False;
+ bMoreFlags = sal_False;
+ bIgnoreCache = sal_False;
+ bBridgePropertyCall = sal_False;
+ }
+ //---------------------------
+ }; // end struct MessageFlags
+
inline sal_Bool getMemberTypeDescription(
typelib_InterfaceAttributeTypeDescription **ppAttributeType,
@@ -239,62 +270,149 @@ void OReaderThread::disposeEnvironment()
}
}
-void OReaderThread::run()
+inline sal_Bool OReaderThread::readBlock( sal_Int32 *pnMessageCount )
{
- sal_Bool bContinue = sal_True;
- while( bContinue )
+ m_unmarshal.setSize( 8 );
+ if( 8 != m_pConnection->read( m_pConnection , m_unmarshal.getBuffer(), 8 ) )
{
- sal_Int32 nSize;
- sal_uInt8 n8Size;
- if( 1 != m_pConnection->read( m_pConnection , (sal_Int8*) &n8Size, 1) )
- {
- disposeEnvironment();
- break;
- }
- if( 255 == n8Size )
+ return sal_False;
+ }
+
+ sal_Int32 nSize;
+ m_unmarshal.unpackInt32( &nSize );
+ m_unmarshal.unpackInt32( pnMessageCount );
+
+ if( nSize < 0 )
+ {
+ // buffer too big
+ // no exception can be thrown, because there is no thread id, which could be
+ // used. -> terminate !
+ OSL_ENSURE( 0 , "urp bridge: invalid message size, terminating connection." );
+ disposeEnvironment();
+ return sal_False;
+ }
+
+ if( 0 == nSize )
+ {
+ return sal_False;
+ }
+
+ // allocate the necessary memory
+ if( ! m_unmarshal.setSize( nSize ) )
+ {
+ OSL_ENSURE( 0 , "urp bridge: messages size too large, terminating connection" );
+ return sal_False;
+ }
+
+ sal_Int32 nRead = m_pConnection->read( m_pConnection , m_unmarshal.getBuffer() , nSize );
+
+ if( nSize != nRead )
+ {
+ // couldn't get the asked amount of bytes, quit
+ // should only occur, when the environment has already been disposed
+ OSL_ENSURE( m_pBridgeImpl->m_bDisposed , "urp bridge: couldn't read complete message, terminating connection." );
+ return sal_False;
+ }
+ return sal_True;
+}
+
+inline sal_Bool OReaderThread::readFlags( struct MessageFlags *pFlags )
+{
+ sal_uInt8 nBitField;
+ if( ! m_unmarshal.unpackInt8( &nBitField ) )
+ {
+ return sal_False;
+ }
+
+ if( HDRFLAG_LONGHEADER & nBitField )
+ {
+ // this is a long header, interpret the byte as bitfield
+ pFlags->bTid = (HDRFLAG_NEWTID & nBitField );
+ pFlags->bRequest = (HDRFLAG_REQUEST & nBitField);
+
+ if( pFlags->bRequest )
{
- sal_uInt8 buf[4];
- m_pConnection->read( m_pConnection ,(sal_Int8*)buf, 4);
+ // request
+ pFlags->bType = ( HDRFLAG_NEWTYPE & nBitField );
+ pFlags->bOid = ( HDRFLAG_NEWOID & nBitField );
+ pFlags->bIgnoreCache = ( HDRFLAG_IGNORECACHE & nBitField );
+ pFlags->bMoreFlags = ( HDRFLAG_MOREFLAGS & nBitField );
+
+ if( pFlags->bMoreFlags )
+ {
+ // another byte with flags
+ sal_Int8 moreFlags;
+ if( ! m_unmarshal.unpackInt8( &moreFlags ) )
+ {
+ return sal_False;
+ }
+ pFlags->bSynchronous = ( HDRFLAG_SYNCHRONOUS & moreFlags );
+ pFlags->bMustReply = ( HDRFLAG_MUSTREPLY & moreFlags );
+ OSL_ENSURE( pFlags->bSynchronous && pFlags->bMustReply ||
+ ! pFlags->bSynchronous && !pFlags->bMustReply,
+ "urp-bridge : customized calls currently not supported !");
+ }
- nSize = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
+ if( HDRFLAG_LONGMETHODID & nBitField )
+ {
+ // methodid as unsigned short
+ if( ! m_unmarshal.unpackInt16( &(pFlags->nMethodId )) )
+ {
+ return sal_False;
+ }
+ }
+ else
+ {
+ sal_uInt8 id;
+ if( ! m_unmarshal.unpackInt8( &id ) )
+ {
+ return sal_False;
+ }
+ pFlags->nMethodId = (sal_uInt16) id;
+ }
}
else
{
- nSize = ( sal_Int32 ) n8Size;
- }
-
- if( nSize < 0 )
- {
- // buffer too big
- // no exception can be thrown, because there is no thread id, which could be
- // used. -> terminate !
- OSL_ENSURE( 0 , "urp bridge: invalid message size, terminating connection." );
- disposeEnvironment();
- break;
+ // reply
+ pFlags->bRequest = sal_False;
+ pFlags->bException = ( HDRFLAG_EXCEPTION & nBitField );
}
-
- if( 0 == nSize )
+ }
+ else
+ {
+ // short request
+ pFlags->bRequest = sal_True;
+ if( 0x40 & nBitField )
{
- disposeEnvironment();
- break;
+ sal_uInt8 lower;
+ if( ! m_unmarshal.unpackInt8( &lower ) )
+ {
+ return sal_False;
+ }
+ pFlags->nMethodId = ( nBitField & 0x3f ) << 8 | lower;
}
-
- // allocate the necessary memory
- if( ! m_unmarshal.setSize( nSize ) )
+ else
{
- OSL_ENSURE( 0 , "urp bridge: messages size too large, terminating connection" );
- disposeEnvironment();
- break;
+ pFlags->nMethodId = ( nBitField & 0x3f );
}
-
- sal_Int32 nRead = m_pConnection->read( m_pConnection , m_unmarshal.getBuffer() , nSize );
-
- if( nSize != nRead )
- {
- // couldn't get the asked amount of bytes, quit
- // should only occur, when the environment has already been disposed
- OSL_ENSURE( m_pBridgeImpl->m_bDisposed , "urp bridge: couldn't read complete message, terminating connection." );
+ }
+ return sal_True;
+}
+void OReaderThread::run()
+{
+ sal_Bool bContinue = sal_True;
+
+ // This vars are needed to hold oid,tid and type information, which should not be cached.
+ Type lastTypeNoCache;
+ OUString lastOidNoCache;
+ ByteSequence lastTidNoCache;
+
+ while( bContinue )
+ {
+ sal_Int32 nMessageCount;
+ if( ! readBlock( &nMessageCount ) )
+ {
disposeEnvironment();
break;
}
@@ -308,73 +426,43 @@ void OReaderThread::run()
sal_Bool bIsOneWay = sal_False;
OUString sMemberName;
#endif
- sal_uInt8 nBitField;
- sal_Bool bSuccess = m_unmarshal.unpackInt8( &nBitField );
+ MessageFlags flags;
- sal_Bool bRequest = sal_True;
- sal_uInt16 nMethodId = 0;
- sal_Bool bType = sal_False, bOid = sal_False, bTid = sal_False;
- sal_Bool bExceptionOccured = sal_False;
-
- if( HDRFLAG_LONG & nBitField )
- {
- // this is a long header, interpret the byte as bitfield
- // this is a bitfield
- bTid = ( HDRFLAG_NEWTID & nBitField );
-
- if( HDRFLAG_REQUEST & nBitField )
- {
- bType = ( HDRFLAG_NEWTYPE & nBitField );
- bOid = ( HDRFLAG_NEWOID & nBitField );
-
- // request
- if( HDRFLAG_LONGMETHODID & nBitField )
- {
- // methodid as unsigned short
- bSuccess = bSuccess && m_unmarshal.unpackInt16( &nMethodId );
- }
- else
- {
- sal_uInt8 id;
- bSuccess = bSuccess && m_unmarshal.unpackInt8( &id );
- nMethodId = (sal_uInt16) id;
- }
- }
- else
- {
- // reply
- bRequest = sal_False;
- bExceptionOccured = ( HDRFLAG_EXCEPTIONOCCURED & nBitField );
- }
- }
- else
- {
- // method request + synchronous-asynchronous default
- if( 0x40 & nBitField )
- {
- sal_uInt8 lower;
- bSuccess = bSuccess && m_unmarshal.unpackInt8( &lower );
- nMethodId = ( nBitField & 0x3f ) << 8 | lower;
- }
- else
- {
- nMethodId = ( nBitField & 0x3f );
- }
- }
-
- if( ! bSuccess )
+ if( ! readFlags( &flags ) )
{
OSL_ENSURE ( 0 , "urp-bridge : incomplete message, skipping block" );
break;
}
- // get new type,oid,tid
- if( bType )
+ // use these ** to access the ids fast ( avoid acquire/release calls )
+ sal_Sequence **ppLastTid = flags.bIgnoreCache ?
+ (sal_Sequence **) &lastTidNoCache :
+ (sal_Sequence **) &(m_pBridgeImpl->m_lastInTid);
+ rtl_uString **ppLastOid = flags.bIgnoreCache ?
+ (rtl_uString ** ) &lastOidNoCache :
+ (rtl_uString ** ) &(m_pBridgeImpl->m_lastInOid);
+ typelib_TypeDescriptionReference **ppLastType =
+ flags.bIgnoreCache ?
+ (typelib_TypeDescriptionReference ** ) &lastTidNoCache :
+ (typelib_TypeDescriptionReference ** ) &(m_pBridgeImpl->m_lastInType);
+
+ // get new type
+ if( flags.bType )
{
- if( ! m_unmarshal.unpackAndDestruct(
- &m_pBridgeImpl->m_lastInType , getCppuType( &m_pBridgeImpl->m_lastInType ) ) )
+ typelib_TypeDescriptionReference *pTypeRef = 0;
+ if( m_unmarshal.unpackType( &pTypeRef ) )
{
- OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" );
+ // release the old type
+ typelib_typedescriptionreference_release( *ppLastType );
+ // set the new type
+ *ppLastType = pTypeRef;
+
+ // no release on pTypeRef necessary (will be released by type dtor)
+ }
+ else
+ {
+ typelib_typedescriptionreference_release( pTypeRef );
+ OSL_ENSURE( 0 , "urp-bridge : error during unpacking interface type, terminating connection" );
disposeEnvironment();
return;
}
@@ -385,54 +473,67 @@ void OReaderThread::run()
return;
}
}
- if( bOid )
+ if( flags.bOid )
{
rtl_uString *pOid = 0;
if( m_unmarshal.unpackOid( &pOid ) )
{
- m_pBridgeImpl->m_lastInOid = pOid;
+ rtl_uString_release( *ppLastOid );
+ *ppLastOid = pOid;
}
else
{
+ rtl_uString_release( pOid );
OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" );
disposeEnvironment();
return;
}
}
- if( bTid )
+
+ if( flags.bTid )
{
- if( ! m_unmarshal.unpackTid( &(m_pBridgeImpl->m_lastInTid) ) )
+ sal_Sequence *pSeq = 0;
+ if( m_unmarshal.unpackTid( &pSeq ) )
+ {
+ rtl_byte_sequence_release( *ppLastTid );
+ *ppLastTid = pSeq;
+ }
+ else
{
+ rtl_byte_sequence_release( pSeq );
+
OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" );
disposeEnvironment();
return;
}
}
- Job *pJob;
// do the job
- if( bRequest )
+ if( flags.bRequest )
{
+ //--------------------------
+ // handle request
+ //--------------------------
// get the membertypedescription
-
typelib_InterfaceMethodTypeDescription *pMethodType = 0;
typelib_InterfaceAttributeTypeDescription *pAttributeType = 0;
sal_Bool bIsSetter = sal_False;
- if( getMemberTypeDescription( &pAttributeType, &pMethodType, &bIsSetter,
- nMethodId, m_pBridgeImpl->m_lastInType ) )
+ if( getMemberTypeDescription(
+ &pAttributeType, &pMethodType, &bIsSetter,
+ flags.nMethodId, *ppLastType ) )
{
- if( ! pLastRemoteI || bOid || bType )
+ if( ! pLastRemoteI || flags.bOid || flags.bType )
{
// a new interface must be retrieved
-
+
// retrieve the interface NOW from the environment
// (avoid race conditions : oneway followed by release )
typelib_InterfaceTypeDescription *pInterfaceType = 0;
TYPELIB_DANGER_GET(
(typelib_TypeDescription ** ) &pInterfaceType ,
- m_pBridgeImpl->m_lastInType.getTypeLibType() );
+ *ppLastType );
if( !pInterfaceType )
{
delete pMultiJob;
@@ -442,14 +543,24 @@ void OReaderThread::run()
}
m_pEnvRemote->pExtEnv->getRegisteredInterface(
m_pEnvRemote->pExtEnv, ( void ** ) &pLastRemoteI,
- m_pBridgeImpl->m_lastInOid.pData, pInterfaceType );
+ *ppLastOid, pInterfaceType );
TYPELIB_DANGER_RELEASE( (typelib_TypeDescription * )pInterfaceType );
+ if( !pLastRemoteI &&
+ REMOTE_RELEASE_METHOD_INDEX != flags.nMethodId &&
+ OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject ).equals( *ppLastOid ) )
+ {
+ // check for bridge internal propertyobject
+ pLastRemoteI = m_pBridgeImpl->m_pPropertyObject;
+ pLastRemoteI->acquire( pLastRemoteI );
+ flags.bBridgePropertyCall = sal_True;
+ }
+
// NOTE : Instance provider is called in the executing thread
// Otherwise, instance provider may block the bridge
}
- if( pMultiJob && ! bTid && pMethodType && pMethodType->bOneWay && ! pMultiJob->isFull())
+ if( pMultiJob && ! flags.bTid && pMethodType && pMethodType->bOneWay && ! pMultiJob->isFull())
{
// add to the existing multijob, nothing to do here
}
@@ -458,32 +569,26 @@ void OReaderThread::run()
// create a new multijob
if( pMultiJob )
{
- // start a previously existing multijob
+ // there exists an old one, start it first.
pMultiJob->initiate();
}
pMultiJob = new ServerMultiJob(
- m_pEnvRemote, m_pBridgeImpl->m_lastInTid.getHandle(),
- m_pBridgeImpl, &m_unmarshal );
+ m_pEnvRemote, *ppLastTid,
+ m_pBridgeImpl, &m_unmarshal , nMessageCount );
}
-
- pMultiJob->setType( m_pBridgeImpl->m_lastInType );
+
+ pMultiJob->setIgnoreCache( flags.bIgnoreCache );
+ pMultiJob->setType( *ppLastType );
if( pMethodType )
- pMultiJob->setMethodType( pMethodType , REMOTE_RELEASE_METHOD_INDEX == nMethodId);
+ pMultiJob->setMethodType( pMethodType , REMOTE_RELEASE_METHOD_INDEX == flags.nMethodId);
else if( pAttributeType )
pMultiJob->setAttributeType( pAttributeType, bIsSetter );
if( pLastRemoteI )
pMultiJob->setInterface( pLastRemoteI );
else
- pMultiJob->setOid( m_pBridgeImpl->m_lastInOid );
-
-#ifdef BRIDGES_URP_PROT
- bIsOneWay = pMethodType && pMethodType->bOneWay;
- sMemberName = pMethodType ?
- pMethodType->aBase.pMemberName :
- pAttributeType->aBase.pMemberName;
-#endif
+ pMultiJob->setOid( *ppLastOid );
}
else
{
@@ -492,10 +597,60 @@ void OReaderThread::run()
bContinue = sal_False;
break;
}
- pJob = pMultiJob;
+#ifdef BRIDGES_URP_PROT
+ bIsOneWay = pMethodType && pMethodType->bOneWay;
+ sMemberName = pMethodType ?
+ pMethodType->aBase.pMemberName :
+ pAttributeType->aBase.pMemberName;
+ sal_uInt32 nLogHeader = m_unmarshal.getPos();
+#endif
+ if( ! pMultiJob->extract( ) )
+ {
+ // severe error during extracting, dispose
+ delete pMultiJob;
+ disposeEnvironment();
+ bContinue = sal_False;
+ break;
+ }
+
+#ifdef BRIDGES_URP_PROT
+ urp_logServingRequest(
+ m_pBridgeImpl, m_unmarshal.getPos() - nLogStart,
+ m_unmarshal.getPos() - nLogHeader,
+ !bIsOneWay,
+ sMemberName );
+#endif
+ if ( flags.bBridgePropertyCall )
+ {
+ // call to the bridge internal object.
+ // these calls MUST be executed within the dispatcher thread in order
+ // to synchronize properly with protocol changes
+ // NOTE : Threadid is not preserved for this call.
+
+ // lock the marshaling NOW !
+ {
+ MutexGuard guard( m_pBridgeImpl->m_marshalingMutex );
+
+ pMultiJob->execute();
+
+ if( m_pBridgeImpl->m_pPropertyObject->changesHaveBeenCommited() )
+ {
+ Properties props;
+ props = m_pBridgeImpl->m_pPropertyObject->getCommitedChanges();
+
+ // This call modified the protocol, apply the changes NOW !
+ m_pBridgeImpl->applyProtocolChanges( props );
+ }
+ }
+ delete pMultiJob;
+ pMultiJob = 0;
+ }
}
else
{
+ //--------------------------
+ // handle reply
+ //--------------------------
if( pMultiJob )
{
pMultiJob->initiate();
@@ -507,54 +662,44 @@ void OReaderThread::run()
pLastRemoteI = 0;
}
ClientJob *pClientJob =
- m_pBridgeImpl->m_clientJobContainer.remove( m_pBridgeImpl->m_lastInTid );
+ m_pBridgeImpl->m_clientJobContainer.remove( *( ByteSequence * )ppLastTid );
OSL_ASSERT( pClientJob );
- pClientJob->m_bExceptionOccured = bExceptionOccured;
+ pClientJob->m_bExceptionOccured = flags.bException;
- pJob = pClientJob;
- pJob->setThreadId( m_pBridgeImpl->m_lastInTid.getHandle() );
- pJob->setUnmarshal( &m_unmarshal );
+ pClientJob->setUnmarshal( &m_unmarshal );
#ifdef BRIDGES_URP_PROT
sMemberName = pClientJob->m_pMethodType ?
pClientJob->m_pMethodType->aBase.pMemberName :
pClientJob->m_pAttributeType->aBase.pMemberName;
+ sal_uInt32 nLogHeader = m_unmarshal.getPos();
#endif
- }
-
-#ifdef BRIDGES_URP_PROT
- sal_uInt32 nLogHeader = m_unmarshal.getPos();
-#endif
-
- if( ! pJob->extract( ) )
- {
- // severe error during extracting, dispose
- delete pJob;
- disposeEnvironment();
- bContinue = sal_False;
- break;
- }
-
+ if( ! pClientJob->extract( ) )
+ {
+ // severe error during extracting, dispose
+ disposeEnvironment();
+ bContinue = sal_False;
+ break;
+ }
#ifdef BRIDGES_URP_PROT
- {
- if( bRequest )
- {
- urp_logServingRequest(
- m_pBridgeImpl, m_unmarshal.getPos() - nLogStart,
- m_unmarshal.getPos() - nLogHeader,
- !bIsOneWay,
- sMemberName );
- }
- else
- {
- urp_logGettingReply(
- m_pBridgeImpl, m_unmarshal.getPos() - nLogStart,
- m_unmarshal.getPos() - nLogHeader, sMemberName );
- }
- }
+ urp_logGettingReply(
+ m_pBridgeImpl, m_unmarshal.getPos() - nLogStart,
+ m_unmarshal.getPos() - nLogHeader, sMemberName );
#endif
- if( ! pMultiJob )
- {
- pJob->initiate();
+ sal_Bool bBridgePropertyCallAndWaitingForReply =
+ m_pBridgeImpl->m_pPropertyObject->waitingForCommitChangeReply() &&
+ pClientJob->isBridgePropertyCall();
+
+ pClientJob->initiate();
+
+ if( bBridgePropertyCallAndWaitingForReply )
+ {
+ // NOTE : This must be the reply for commit change. The new properties
+ // are now applied by the clientJob thread, but the reader thread
+ // must wait for it, because the next message on the wire already
+ // uses the new protocol settings.
+ // waiting for the commit change reply
+ m_pBridgeImpl->m_pPropertyObject->waitUntilChangesAreCommitted();
+ }
}
} // end while( !m_unmarshal.finished() )
@@ -565,8 +710,6 @@ void OReaderThread::run()
{
pMultiJob->initiate();
}
-
- m_unmarshal.restart();
}
if( m_pConnection )
@@ -575,4 +718,7 @@ void OReaderThread::run()
m_pConnection = 0;
}
}
+
+
+
}
diff --git a/bridges/source/remote/urp/urp_reader.hxx b/bridges/source/remote/urp/urp_reader.hxx
index 61cf9531a..328e74ce7 100644
--- a/bridges/source/remote/urp/urp_reader.hxx
+++ b/bridges/source/remote/urp/urp_reader.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_reader.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,6 +69,7 @@ namespace bridges_urp
{
class OWriterThread;
+struct MessageFlags;
class OReaderThread :
public ::vos::OThread
@@ -85,11 +86,11 @@ public:
// may only be called in the callstack of this thread !!!!!
// run() -> disposeEnvironment() -> dispose() -> destroyYourself()
void destroyYourself();
-
-private:
+ inline sal_Bool readBlock( sal_Int32 *pnMessageCount );
+ inline sal_Bool readFlags( struct MessageFlags *pFlags );
+private:
void disposeEnvironment();
- void throwUnmarshalException( const ::rtl::OUString &sMessage );
remote_Connection *m_pConnection;
uno_Environment *m_pEnvRemote;
diff --git a/bridges/source/remote/urp/urp_replycontainer.hxx b/bridges/source/remote/urp/urp_replycontainer.hxx
index e73c0ee9c..fadbe3b3c 100644
--- a/bridges/source/remote/urp/urp_replycontainer.hxx
+++ b/bridges/source/remote/urp/urp_replycontainer.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_replycontainer.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,7 +68,6 @@
namespace bridges_urp
{
-
class ClientJob;
typedef ::std::hash_map< ::rtl::ByteSequence ,
::std::list < ClientJob * > ,
@@ -83,12 +82,12 @@ namespace bridges_urp
::osl::MutexGuard guard( m_mutex );
m_map[id].push_back( p );
}
-
+
ClientJob *remove( const ::rtl::ByteSequence & id )
{
::osl::MutexGuard guard( m_mutex );
Id2ClientJobStackMap::iterator ii = m_map.find( id );
-
+
OSL_ASSERT( ii != m_map.end() );
ClientJob *p = (*ii).second.back();
@@ -104,7 +103,4 @@ namespace bridges_urp
::osl::Mutex m_mutex;
Id2ClientJobStackMap m_map;
};
-
-
-
}
diff --git a/bridges/source/remote/urp/urp_unmarshal.cxx b/bridges/source/remote/urp/urp_unmarshal.cxx
index 4aa1861fc..407ee2461 100644
--- a/bridges/source/remote/urp/urp_unmarshal.cxx
+++ b/bridges/source/remote/urp/urp_unmarshal.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_unmarshal.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -101,48 +101,8 @@ Unmarshal::~Unmarshal()
rtl_freeMemory( m_base );
}
-sal_Bool Unmarshal::setSize( sal_Int32 nSize )
-{
- if( nSize > m_nBufferSize )
- {
- m_nBufferSize = nSize;
- m_base = (sal_Int8 * ) rtl_reallocateMemory( (sal_uInt8*) m_base , m_nBufferSize );
- m_pos = m_base;
- }
- m_nLength = nSize;
- return ( 0 != m_base );
-}
-
-
-// sal_Bool Unmarshal::unpack( void *pDest, const ::com::sun::star::uno::Type &rType)
-// {
-// typelib_TypeDescription * pDataTD = 0;
-// TYPELIB_DANGER_GET( &pDataTD, rType.getTypeLibType() );
-// sal_Bool b = unpack( pDest, pDataTD );
-// TYPELIB_DANGER_RELEASE( pDataTD );
-// return b;
-// }
-
-sal_Bool Unmarshal::unpackAndDestruct( void *pDest, const ::com::sun::star::uno::Type &rType)
-{
- typelib_TypeDescription * pDataTD = 0;
- TYPELIB_DANGER_GET( &pDataTD, rType.getTypeLibType() );
- uno_destructData( pDest , pDataTD , 0 );
- sal_Bool b = unpack( pDest, pDataTD );
- TYPELIB_DANGER_RELEASE( pDataTD );
- return b;
-}
-
-sal_Bool Unmarshal::unpackAndDestruct( void *pDest, typelib_TypeDescription *pType)
-{
- uno_destructData( pDest , pType , 0 );
- return unpack( pDest, pType );
-}
-
-
-
// special unpacks
-sal_Bool Unmarshal::unpackTid( ::rtl::ByteSequence *pId )
+sal_Bool Unmarshal::unpackTid( sal_Sequence **ppThreadId )
{
sal_Int32 nSize;
sal_Bool bReturn = unpackCompressedSize( &nSize );
@@ -150,18 +110,18 @@ sal_Bool Unmarshal::unpackTid( ::rtl::ByteSequence *pId )
{
if( nSize )
{
- *pId = ByteSequence( m_pos , nSize );
+ rtl_byte_sequence_constructFromArray( ppThreadId , m_pos , nSize );
m_pos += nSize;
sal_uInt16 nIndex;
bReturn = unpackInt16( &nIndex );
- if( nIndex < m_pBridgeImpl->m_nCacheSize )
+ if( nIndex < m_pBridgeImpl->m_properties.nTidCacheSize )
{
- m_pBridgeImpl->m_pTidIn[nIndex] = *pId;
+ m_pBridgeImpl->m_pTidIn[nIndex] = *(ByteSequence * )ppThreadId;
}
else if( 0xffff != nIndex )
{
bReturn = sal_False;
- *pId = ByteSequence();
+ rtl_byte_sequence_construct( ppThreadId , 0 );
OSL_ENSURE( 0 , "unknown thread id" );
}
}
@@ -169,14 +129,15 @@ sal_Bool Unmarshal::unpackTid( ::rtl::ByteSequence *pId )
{
sal_uInt16 nIndex;
bReturn = unpackInt16( &nIndex );
- if( nIndex < m_pBridgeImpl->m_nCacheSize )
+ if( nIndex < m_pBridgeImpl->m_properties.nTidCacheSize )
{
- *pId = m_pBridgeImpl->m_pTidIn[nIndex];
+ *ppThreadId = m_pBridgeImpl->m_pTidIn[nIndex].getHandle();
+ rtl_byte_sequence_acquire( *ppThreadId );
}
else
{
bReturn = sal_False;
- *pId = ByteSequence();
+ rtl_byte_sequence_construct( ppThreadId , 0 );
OSL_ENSURE( 0 , "unknown thread id" );
}
}
@@ -201,7 +162,7 @@ sal_Bool Unmarshal::unpackOid( rtl_uString **ppOid )
if( 0xffff != nCacheIndex )
{
// oid should be cached ?
- if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ if( nCacheIndex < m_pBridgeImpl->m_properties.nOidCacheSize )
{
m_pBridgeImpl->m_pOidIn[nCacheIndex] = *ppOid;
}
@@ -214,7 +175,7 @@ sal_Bool Unmarshal::unpackOid( rtl_uString **ppOid )
else
{
// reference in cache !
- if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ if( nCacheIndex < m_pBridgeImpl->m_properties.nOidCacheSize )
{
rtl_uString_assign( ppOid , m_pBridgeImpl->m_pOidIn[nCacheIndex].pData );
}
@@ -228,111 +189,20 @@ sal_Bool Unmarshal::unpackOid( rtl_uString **ppOid )
return bReturn;
}
-template < class t >
-inline sal_Int32 convertFromPackedInt( t* pTarget , const sal_uInt8 *pSource , sal_Int32 nMaxToGo )
-{
- *pTarget = 0;
- sal_Int32 i = 0;
- do
- {
- *pTarget |= ( ( sal_Int64) (pSource[i] & 0x7f) ) << ( i * 7 );
- i ++;
- } while ( i < nMaxToGo && (pSource[i-1] & 0x80) );
-
- return i;
-}
-
-
sal_Bool Unmarshal::unpackType( void *pDest )
{
*(typelib_TypeDescriptionReference **) pDest = 0;
sal_uInt8 nTypeClass;
sal_Bool bReturn = unpackInt8( &nTypeClass );
-
- Type type;
+
+ typelib_TypeDescriptionReference *pTypeRef = 0;
if( bReturn )
{
if( nTypeClass <= 14 /* any */ )
{
- switch( nTypeClass )
- {
- case typelib_TypeClass_VOID:
- {
- type = getVoidCppuType( );
- break;
- }
- case typelib_TypeClass_CHAR:
- {
- type = getCharCppuType( );
- break;
- }
- case typelib_TypeClass_BOOLEAN:
- {
- type = getBooleanCppuType();
- break;
- }
- case typelib_TypeClass_BYTE:
- {
- type = getCppuType( (sal_Int8 *) 0);
- break;
- }
- case typelib_TypeClass_SHORT:
- {
- type = getCppuType( ( sal_Int16 *)0 );
- break;
- }
- case typelib_TypeClass_UNSIGNED_SHORT:
- {
- type = getCppuType( (sal_uInt16 *)0 );
- break;
- }
- case typelib_TypeClass_LONG:
- {
- type = getCppuType( ( sal_Int32 *) 0 );
- break;
- }
- case typelib_TypeClass_UNSIGNED_LONG:
- {
- type = getCppuType( ( sal_uInt32 *) 0 );
- break;
- }
- case typelib_TypeClass_HYPER:
- {
- type = getCppuType( ( sal_Int64 *) 0 );
- break;
- }
- case typelib_TypeClass_UNSIGNED_HYPER:
- {
- type = getCppuType( ( sal_uInt64 *) 0 );
- break;
- }
- case typelib_TypeClass_FLOAT:
- {
- type = getCppuType( ( float *) 0 );
- break;
- }
- case typelib_TypeClass_DOUBLE:
- {
- type = getCppuType( (double*) 0 );
- break;
- }
- case typelib_TypeClass_STRING:
- {
- type = getCppuType( (OUString *) 0 );
- break;
- }
- case typelib_TypeClass_TYPE:
- {
- type = getCppuType( (Type *) 0 );
- break;
- }
- case typelib_TypeClass_ANY:
- {
- type = getCppuType( (Any *) 0 );
- break;
- }
- }
+ pTypeRef = * typelib_static_type_getByTypeClass((enum typelib_TypeClass )nTypeClass);
+ typelib_typedescriptionreference_acquire( pTypeRef );
}
else
{
@@ -345,15 +215,16 @@ sal_Bool Unmarshal::unpackType( void *pDest )
{
// new type
rtl_uString *pString = 0;
- bReturn = bReturn && unpackString( &pString );
+ bReturn = bReturn && unpackString( &pString );
if( bReturn )
{
- type = Type( (enum TypeClass )(nTypeClass & 0x7f) , pString );
+ ::typelib_typedescriptionreference_new(
+ &pTypeRef, (enum typelib_TypeClass )(nTypeClass & 0x7f), pString );
if( nCacheIndex != 0xffff )
{
- if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ if( nCacheIndex < m_pBridgeImpl->m_properties.nTypeCacheSize )
{
- m_pBridgeImpl->m_pTypeIn[nCacheIndex] = type;
+ m_pBridgeImpl->m_pTypeIn[nCacheIndex] = *( Type * )&pTypeRef;
}
else
{
@@ -368,20 +239,26 @@ sal_Bool Unmarshal::unpackType( void *pDest )
}
else
{
- if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ if( nCacheIndex < m_pBridgeImpl->m_properties.nTypeCacheSize )
{
- type = m_pBridgeImpl->m_pTypeIn[nCacheIndex];
+ pTypeRef = m_pBridgeImpl->m_pTypeIn[nCacheIndex].getTypeLibType();
+ typelib_typedescriptionreference_acquire( pTypeRef );
}
else
{
bReturn = sal_False;
}
- }
+ }
}
}
- }
- *(typelib_TypeDescriptionReference**)pDest = type.getTypeLibType();
- typelib_typedescriptionreference_acquire( *(typelib_TypeDescriptionReference**)pDest );
+ }
+ if( ! pTypeRef )
+ {
+ pTypeRef = * typelib_static_type_getByTypeClass(typelib_TypeClass_VOID);
+ typelib_typedescriptionreference_acquire( pTypeRef );
+ }
+ // pTypeRef is already acquired
+ *(typelib_TypeDescriptionReference**)pDest = pTypeRef;
return bReturn;
}
diff --git a/bridges/source/remote/urp/urp_unmarshal.hxx b/bridges/source/remote/urp/urp_unmarshal.hxx
index a3fe865d5..f3354cd03 100644
--- a/bridges/source/remote/urp/urp_unmarshal.hxx
+++ b/bridges/source/remote/urp/urp_unmarshal.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_unmarshal.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,9 +73,10 @@ struct remote_Interface;
namespace bridges_urp
{
- extern char g_bSystemIsLittleEndian;
+extern char g_bSystemIsLittleEndian;
class ThreadId;
struct urp_BridgeImpl;
+
class Unmarshal
{
public:
@@ -85,15 +86,13 @@ public:
remote_createStubFunc callback );
~Unmarshal();
- sal_Bool unpackAndDestruct( void *pDest , const ::com::sun::star::uno::Type &rType );
- sal_Bool unpackAndDestruct( void *pDest , typelib_TypeDescription *pType );
sal_Bool unpackRecursive( void *pDest , typelib_TypeDescription *pType );
- sal_Bool finished()
+ inline sal_Bool finished()
{ return m_base + m_nLength == m_pos; }
- sal_uInt32 getPos()
+ inline sal_uInt32 getPos()
{ return (sal_uInt32 ) (m_pos - m_base); }
- sal_Bool setSize( sal_Int32 nSize );
+ inline sal_Bool setSize( sal_Int32 nSize );
inline sal_Bool unpackCompressedSize( sal_Int32 *pData );
inline sal_Bool unpack( void *pDest, typelib_TypeDescription *pType );
@@ -105,10 +104,7 @@ public:
sal_Bool unpackAny( void *pDest );
sal_Bool unpackOid( rtl_uString **ppOid );
- sal_Bool unpackTid( ::rtl::ByteSequence *pId );
-
- void restart()
- { m_pos = m_base; }
+ sal_Bool unpackTid( sal_Sequence **ppThreadId );
sal_Int8 *getBuffer()
{ return m_base; }
@@ -121,7 +117,6 @@ private:
sal_Int32 m_nBufferSize;
sal_Int8 *m_base;
sal_Int8 *m_pos;
-
sal_Int32 m_nLength;
remote_createStubFunc m_callback;
@@ -129,6 +124,18 @@ private:
urp_BridgeImpl *m_pBridgeImpl;
};
+inline sal_Bool Unmarshal::setSize( sal_Int32 nSize )
+{
+ if( nSize > m_nBufferSize )
+ {
+ m_nBufferSize = nSize;
+ m_base = (sal_Int8 * ) rtl_reallocateMemory( (sal_uInt8*) m_base , m_nBufferSize );
+ }
+ m_pos = m_base;
+ m_nLength = nSize;
+ return ( 0 != m_base );
+}
+
inline sal_Bool Unmarshal::checkOverflow( sal_Int32 nNextMem )
{
return nNextMem < 0 ||
@@ -229,7 +236,7 @@ inline sal_Bool Unmarshal::unpackString( void *pDest )
}
-sal_Bool Unmarshal::unpackCompressedSize( sal_Int32 *pData )
+inline sal_Bool Unmarshal::unpackCompressedSize( sal_Int32 *pData )
{
sal_uInt8 n8Size;
sal_Bool bReturn = unpackInt8( &n8Size );
@@ -282,6 +289,7 @@ inline sal_Bool Unmarshal::unpack( void *pDest , typelib_TypeDescription *pType
unpackInt16( pDest );
break;
}
+ case typelib_TypeClass_ENUM:
case typelib_TypeClass_FLOAT:
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
@@ -334,11 +342,6 @@ inline sal_Bool Unmarshal::unpack( void *pDest , typelib_TypeDescription *pType
bReturn = unpackAny( pDest );
break;
}
- case typelib_TypeClass_ENUM:
- {
- bReturn = unpackCompressedSize( (sal_Int32 *) pDest );
- break;
- }
case typelib_TypeClass_INTERFACE:
{
*(remote_Interface**)pDest = 0;
@@ -383,10 +386,8 @@ inline sal_Bool Unmarshal::unpack( void *pDest , typelib_TypeDescription *pType
OSL_ASSERT( 0 );
}
-
return bReturn;
}
}
-
#endif
diff --git a/bridges/source/remote/urp/urp_writer.cxx b/bridges/source/remote/urp/urp_writer.cxx
index f5dff3992..17ad83753 100644
--- a/bridges/source/remote/urp/urp_writer.cxx
+++ b/bridges/source/remote/urp/urp_writer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_writer.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -112,7 +112,7 @@ OWriterThread::~OWriterThread()
// touch is called with locked m_marshalingMutex
void OWriterThread::touch( sal_Bool bImmediately )
{
- if( bImmediately || m_pBridgeImpl->m_blockMarshaler.getPos() > m_pBridgeImpl->m_nFlushBlockSize )
+ if( bImmediately || m_pBridgeImpl->m_blockMarshaler.getPos() > m_pBridgeImpl->m_properties.nFlushBlockSize )
{
write();
}
@@ -132,7 +132,8 @@ void OWriterThread::write()
{
if( ! m_pBridgeImpl->m_blockMarshaler.empty() )
{
- m_pBridgeImpl->m_blockMarshaler.finish();
+ m_pBridgeImpl->m_blockMarshaler.finish( m_pBridgeImpl->m_nMarshaledMessages);
+ m_pBridgeImpl->m_nMarshaledMessages = 0;
sal_Int32 nLength = m_pBridgeImpl->m_blockMarshaler.getSize();
sal_Int8 *pBuf = m_pBridgeImpl->m_blockMarshaler.getBuffer();
@@ -150,10 +151,10 @@ void OWriterThread::write()
void OWriterThread::sendEmptyMessage()
{
// must be called with locked marshaling mutex
- sal_Int8 n = 0;
+ sal_Int32 a[2] = {0,0};
if( m_pConnection )
{
- m_pConnection->write( m_pConnection , &n , 1 );
+ m_pConnection->write( m_pConnection , (sal_Int8*) a , sizeof( sal_Int32) *2 );
}
}
@@ -162,20 +163,9 @@ void OWriterThread::run()
while( sal_True )
{
// Wait for some work to do
-// osl_waitCondition( m_oslCondition , 0 );
-// if( m_bAbort )
-// {
-// break;
-// }
-
-// if( m_bWaitForTimeout )
-// {
- // wait for timeout
-// printf( "Waiting for timeout ....\n" );
- TimeValue value = { 0 , 1000 * m_pBridgeImpl->m_nTimeoutMUSEC };
- osl_resetCondition( m_oslCondition );
- osl_waitCondition( m_oslCondition , &value );
-// }
+ TimeValue value = { 0 , 1000 * m_pBridgeImpl->m_properties.nOnewayTimeoutMUSEC };
+ osl_resetCondition( m_oslCondition );
+ osl_waitCondition( m_oslCondition , &value );
{
// write to the socket
@@ -183,7 +173,6 @@ void OWriterThread::run()
m_bWaitForTimeout = sal_False;
if( ! m_pBridgeImpl->m_blockMarshaler.empty() )
{
-// printf( "Sending with timeout\n" );
write();
}
osl_resetCondition( m_oslCondition );
diff --git a/bridges/source/remote/urp/urp_writer.hxx b/bridges/source/remote/urp/urp_writer.hxx
index f77d6b1ac..a6195ff2b 100644
--- a/bridges/source/remote/urp/urp_writer.hxx
+++ b/bridges/source/remote/urp/urp_writer.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: urp_writer.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ * last change: $Author: jbu $ $Date: 2000-09-29 08:42:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,13 +85,10 @@ namespace bridges_urp
private:
void write();
oslCondition m_oslCondition;
-
sal_Bool m_bAbort;
sal_Bool m_bWaitForTimeout;
remote_Connection *m_pConnection;
urp_BridgeImpl *m_pBridgeImpl;
};
-
-
}