diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2010-10-11 00:10:31 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2010-10-11 00:10:31 -0500 |
commit | 0c5893833bb680123b3a241618028c14f8793ff7 (patch) | |
tree | 6deb30f01f538460c5ff83a457b87174e2195842 /automation/source | |
parent | f81e36d56ed79d1d4d06d928dbf095966261dbca (diff) |
merge vosremoval-socket patch
Diffstat (limited to 'automation/source')
-rw-r--r-- | automation/source/communi/communi.cxx | 33 | ||||
-rw-r--r-- | automation/source/server/server.cxx | 3 | ||||
-rw-r--r-- | automation/source/simplecm/simplecm.cxx | 67 | ||||
-rw-r--r-- | automation/source/simplecm/tcpio.cxx | 2 | ||||
-rw-r--r-- | automation/source/simplecm/tcpio.hxx | 8 | ||||
-rw-r--r-- | automation/source/testtool/httprequest.cxx | 16 | ||||
-rw-r--r-- | automation/source/testtool/httprequest.hxx | 10 |
7 files changed, 66 insertions, 73 deletions
diff --git a/automation/source/communi/communi.cxx b/automation/source/communi/communi.cxx index dd2340bcaaa0..015bcd371ffc 100644 --- a/automation/source/communi/communi.cxx +++ b/automation/source/communi/communi.cxx @@ -35,7 +35,7 @@ #endif #include <tools/debug.hxx> #include <vcl/svapp.hxx> -#include <vos/socket.hxx> +#include <osl/socket.hxx> #include <tools/stream.hxx> #include <vcl/timer.hxx> #include <tools/fsys.hxx> @@ -68,7 +68,7 @@ SV_IMPL_PTRARR_SORT( CommunicationLinkList, CommunicationLink* ); NAMESPACE_VOS(OMutex) *pMPostUserEvent=NULL; // Notwendig, da nicht threadfest -CommunicationLinkViaSocket::CommunicationLinkViaSocket( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ) +CommunicationLinkViaSocket::CommunicationLinkViaSocket( CommunicationManager *pMan, osl::StreamSocket* pSocket ) : SimpleCommunicationLinkViaSocket( pMan, pSocket ) , nConnectionClosedEventId( 0 ) , nDataReceivedEventId( 0 ) @@ -132,7 +132,7 @@ BOOL CommunicationLinkViaSocket::ShutdownCommunication() join(); - NAMESPACE_VOS(OStreamSocket) *pTempSocket = GetStreamSocket(); + osl::StreamSocket* pTempSocket = GetStreamSocket(); SetStreamSocket( NULL ); delete pTempSocket; @@ -500,11 +500,11 @@ void CommunicationManagerServerAcceptThread::run() if ( !nPortToListen ) return; - pAcceptorSocket = new NAMESPACE_VOS(OAcceptorSocket)(); - NAMESPACE_VOS(OInetSocketAddr) Addr; + pAcceptorSocket = new osl::AcceptorSocket(); + osl::SocketAddr Addr; Addr.setPort( nPortToListen ); - pAcceptorSocket->setReuseAddr( 1 ); - if ( !pAcceptorSocket->bind( Addr ) ) + pAcceptorSocket->setOption( osl_Socket_OptionReuseAddr, 1 ); + if ( !pAcceptorSocket->bind( Addr ) ) { return; } @@ -514,16 +514,16 @@ void CommunicationManagerServerAcceptThread::run() } - NAMESPACE_VOS(OStreamSocket) *pStreamSocket = NULL; + osl::StreamSocket* pStreamSocket = NULL; while ( schedule() ) { - pStreamSocket = new NAMESPACE_VOS(OStreamSocket); + pStreamSocket = new osl::StreamSocket; switch ( pAcceptorSocket->acceptConnection( *pStreamSocket ) ) { - case NAMESPACE_VOS(ISocketTypes::TResult_Ok): + case osl_Socket_Ok: { - pStreamSocket->setTcpNoDelay( 1 ); + pStreamSocket->setOption( osl_Socket_OptionTcpNoDelay, 1 ); TimeValue sNochEins = {0, 100}; while ( schedule() && xmNewConnection.Is() ) // Solange die letzte Connection nicht abgeholt wurde warten wir @@ -537,18 +537,19 @@ void CommunicationManagerServerAcceptThread::run() } } break; - case NAMESPACE_VOS(ISocketTypes::TResult_TimedOut): + case osl_Socket_TimedOut: delete pStreamSocket; pStreamSocket = NULL; break; - case NAMESPACE_VOS(ISocketTypes::TResult_Error): + case osl_Socket_Error: delete pStreamSocket; pStreamSocket = NULL; break; - case NAMESPACE_VOS(ISocketTypes::TResult_Interrupted): - case NAMESPACE_VOS(ISocketTypes::TResult_InProgress): - break; // -Wall not handled... + case osl_Socket_Interrupted: + case osl_Socket_InProgress: + default: + break; } } } diff --git a/automation/source/server/server.cxx b/automation/source/server/server.cxx index 762df69a554f..660242539723 100644 --- a/automation/source/server/server.cxx +++ b/automation/source/server/server.cxx @@ -40,13 +40,12 @@ #include <vcl/wrkwin.hxx> #include <osl/diagnose.h> #include <osl/mutex.hxx> +#include <osl/socket.hxx> #include <vcl/dialog.hxx> #include <tools/stream.hxx> #include <tools/config.hxx> -#include <vos/socket.hxx> - #if 1 #include <svtools/ttprops.hxx> #include <basic/ttstrhlp.hxx> diff --git a/automation/source/simplecm/simplecm.cxx b/automation/source/simplecm/simplecm.cxx index 92642e8cd7c5..48a3c9fa64f4 100644 --- a/automation/source/simplecm/simplecm.cxx +++ b/automation/source/simplecm/simplecm.cxx @@ -136,7 +136,7 @@ void CommunicationLink::SetApplication( const ByteString& aApp ) } -SimpleCommunicationLinkViaSocket::SimpleCommunicationLinkViaSocket( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ) +SimpleCommunicationLinkViaSocket::SimpleCommunicationLinkViaSocket( CommunicationManager *pMan, osl::StreamSocket* pSocket ) : CommunicationLink( pMan ) , aCommunicationPartner() , aMyName() @@ -158,7 +158,7 @@ SimpleCommunicationLinkViaSocket::~SimpleCommunicationLinkViaSocket() pStreamSocket = NULL; } -void SimpleCommunicationLinkViaSocket::SetStreamSocket( NAMESPACE_VOS(OStreamSocket)* pSocket ) +void SimpleCommunicationLinkViaSocket::SetStreamSocket( osl::StreamSocket* pSocket ) { if ( pTCPIO ) pTCPIO->SetStreamSocket( pSocket ); @@ -179,15 +179,6 @@ BOOL SimpleCommunicationLinkViaSocket::StopCommunication() return TRUE; } -void SimpleCommunicationLinkViaSocket::SetFinalRecieveTimeout() -{ - if ( !IsCommunicationError() ) - { - TimeValue aTime = {30, 0}; // 30 seconds - pStreamSocket->setRecvTimeout( &aTime ); - } -} - BOOL SimpleCommunicationLinkViaSocket::IsCommunicationError() { return !pStreamSocket; @@ -202,9 +193,9 @@ ByteString SimpleCommunicationLinkViaSocket::GetCommunicationPartner( CM_NameTyp case CM_DOTTED: { rtl::OUString aDotted; - NAMESPACE_VOS(OSocketAddr) *pPeerAdr = new NAMESPACE_VOS(OSocketAddr); + osl::SocketAddr* pPeerAdr = new osl::SocketAddr; pStreamSocket->getPeerAddr( *pPeerAdr ); - ((NAMESPACE_VOS(OInetSocketAddr*))pPeerAdr)->getDottedAddr( aDotted ); + osl_getDottedInetAddrOfSocketAddr( pPeerAdr->getHandle(), &aDotted.pData); delete pPeerAdr; return ByteString( UniString(aDotted), RTL_TEXTENCODING_UTF8 ); } @@ -213,8 +204,7 @@ ByteString SimpleCommunicationLinkViaSocket::GetCommunicationPartner( CM_NameTyp { if ( !aCommunicationPartner.Len() ) { - rtl::OUString aFQDN; - pStreamSocket->getPeerHost( aFQDN ); + rtl::OUString aFQDN( pStreamSocket->getPeerHost()); aCommunicationPartner = ByteString( UniString(aFQDN), RTL_TEXTENCODING_UTF8 ); } return aCommunicationPartner; @@ -234,9 +224,9 @@ ByteString SimpleCommunicationLinkViaSocket::GetMyName( CM_NameType eType ) case CM_DOTTED: { rtl::OUString aDotted; - NAMESPACE_VOS(OSocketAddr) *pPeerAdr = new NAMESPACE_VOS(OSocketAddr); - pStreamSocket->getLocalAddr( *pPeerAdr ); - ((NAMESPACE_VOS(OInetSocketAddr*))pPeerAdr)->getDottedAddr( aDotted ); + osl::SocketAddr* pPeerAdr = new osl::SocketAddr; + pStreamSocket->getPeerAddr( *pPeerAdr ); + osl_getDottedInetAddrOfSocketAddr( pPeerAdr->getHandle(), &aDotted.pData); delete pPeerAdr; return ByteString( UniString(aDotted), RTL_TEXTENCODING_UTF8 ); } @@ -245,8 +235,7 @@ ByteString SimpleCommunicationLinkViaSocket::GetMyName( CM_NameType eType ) { if ( !aMyName.Len() ) { - rtl::OUString aFQDN; - pStreamSocket->getLocalHost( aFQDN ); + rtl::OUString aFQDN(pStreamSocket->getLocalHost()); aMyName = ByteString( UniString(aFQDN), RTL_TEXTENCODING_UTF8 ); } return aMyName; @@ -352,7 +341,7 @@ BOOL SimpleCommunicationLinkViaSocket::SendHandshake( HandshakeType aHandshakeTy return !bWasError; } -SimpleCommunicationLinkViaSocketWithReceiveCallbacks::SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ) +SimpleCommunicationLinkViaSocketWithReceiveCallbacks::SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, osl::StreamSocket* pSocket ) : SimpleCommunicationLinkViaSocket( pMan, pSocket ) { } @@ -363,11 +352,22 @@ SimpleCommunicationLinkViaSocketWithReceiveCallbacks::~SimpleCommunicationLinkVi StopCommunication(); } +bool SimpleCommunicationLinkViaSocket::IsReceiveReady() +{ + if ( !IsCommunicationError() ) + { + TimeValue aTime = {30, 0}; // 30 seconds + return pStreamSocket->isRecvReady( &aTime ); + } + + return false; +} + void SimpleCommunicationLinkViaSocketWithReceiveCallbacks::WaitForShutdown() { CommunicationLinkRef rHold(this); // avoid deleting this link before the end of the method - SetFinalRecieveTimeout(); - while ( pMyManager && !IsCommunicationError() ) + + while( pMyManager && !IsCommunicationError() && IsReceiveReady()) ReceiveDataStream(); } @@ -396,7 +396,7 @@ BOOL SimpleCommunicationLinkViaSocketWithReceiveCallbacks::ShutdownCommunication if ( GetStreamSocket() ) GetStreamSocket()->close(); - NAMESPACE_VOS(OStreamSocket) *pTempSocket = GetStreamSocket(); + osl::StreamSocket* pTempSocket = GetStreamSocket(); SetStreamSocket( NULL ); delete pTempSocket; @@ -436,8 +436,7 @@ BOOL CommunicationManager::StartCommunication( ByteString aHost, ULONG nPort ) ByteString CommunicationManager::GetMyName( CM_NameType ) { - rtl::OUString aHostname; - NAMESPACE_VOS(OSocketAddr)::getLocalHostname( aHostname ); + rtl::OUString aHostname( osl::SocketAddr::getLocalHostname()); return ByteString( UniString(aHostname), RTL_TEXTENCODING_UTF8 ); } @@ -672,23 +671,20 @@ SingleCommunicationManagerClientViaSocket::SingleCommunicationManagerClientViaSo BOOL CommonSocketFunctions::DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, ULONG nPort ) { - NAMESPACE_VOS(OInetSocketAddr) Addr; - NAMESPACE_VOS(OConnectorSocket) *pConnSocket; + osl::SocketAddr Addr( rtl::OUString( UniString( aHost, RTL_TEXTENCODING_UTF8 ) ), nPort ); + osl::ConnectorSocket *pConnSocket; - Addr.setAddr( rtl::OUString( UniString( aHost, RTL_TEXTENCODING_UTF8 ) ) ); - Addr.setPort( nPort ); TimeValue aTV; aTV.Seconds = 10; // Warte 10 Sekunden aTV.Nanosec = 0; do { - pConnSocket = new NAMESPACE_VOS(OConnectorSocket)(); - pConnSocket->setTcpNoDelay( 1 ); - if ( pConnSocket->connect( Addr, &aTV ) == NAMESPACE_VOS(ISocketTypes::TResult_Ok) ) + pConnSocket = new osl::ConnectorSocket(); + pConnSocket->setOption( osl_Socket_OptionTcpNoDelay, 1 ); + if ( pConnSocket->connect( Addr, &aTV ) == osl_Socket_Ok ) { - pConnSocket->setTcpNoDelay( 1 ); - + pConnSocket->setOption( osl_Socket_OptionTcpNoDelay, 1 ); pCM->CallConnectionOpened( CreateCommunicationLink( pCM, pConnSocket ) ); return TRUE; } @@ -699,4 +695,3 @@ BOOL CommonSocketFunctions::DoStartCommunication( CommunicationManager *pCM, ICo return FALSE; } - diff --git a/automation/source/simplecm/tcpio.cxx b/automation/source/simplecm/tcpio.cxx index 5498e3a69774..7cf5088f1c96 100644 --- a/automation/source/simplecm/tcpio.cxx +++ b/automation/source/simplecm/tcpio.cxx @@ -63,7 +63,7 @@ comm_USHORT TCPIO::ReceiveBytes( void* pBuffer, comm_UINT32 nLen ) // helper -void TCPIO::SetStreamSocket( NAMESPACE_VOS(OStreamSocket) *pSocket ) +void TCPIO::SetStreamSocket( osl::StreamSocket* pSocket ) { vos::OGuard aRGuard( aMSocketReadAccess ); vos::OGuard aWGuard( aMSocketWriteAccess ); diff --git a/automation/source/simplecm/tcpio.hxx b/automation/source/simplecm/tcpio.hxx index 626f164ba0f5..c5a3e5cd77d6 100644 --- a/automation/source/simplecm/tcpio.hxx +++ b/automation/source/simplecm/tcpio.hxx @@ -28,7 +28,7 @@ #ifndef TCPIO_HXX #define TCPIO_HXX -#include <vos/socket.hxx> +#include <osl/socket.hxx> #include <vos/mutex.hxx> #include "communiio.hxx" @@ -36,14 +36,14 @@ class TCPIO : public ITransmiter, public IReceiver { private: - NAMESPACE_VOS(OStreamSocket) *pStreamSocket; + osl::StreamSocket* pStreamSocket; vos::OMutex aMSocketReadAccess; vos::OMutex aMSocketWriteAccess; public: /// - TCPIO( NAMESPACE_VOS(OStreamSocket) *pSocket ):pStreamSocket( pSocket ){} + TCPIO( osl::StreamSocket* pSocket ):pStreamSocket( pSocket ){} virtual ~TCPIO(){} @@ -54,7 +54,7 @@ public: virtual comm_USHORT ReceiveBytes( void* pBuffer, comm_UINT32 nLen ); // helper - void SetStreamSocket( NAMESPACE_VOS(OStreamSocket) *pSocket ); + void SetStreamSocket( osl::StreamSocket* pSocket ); }; diff --git a/automation/source/testtool/httprequest.cxx b/automation/source/testtool/httprequest.cxx index 1e45fd1fc976..a0d0cdab6ac1 100644 --- a/automation/source/testtool/httprequest.cxx +++ b/automation/source/testtool/httprequest.cxx @@ -30,7 +30,7 @@ #include <stdio.h> #include "httprequest.hxx" -#include <vos/socket.hxx> +#include <osl/socket.hxx> #include <tools/debug.hxx> @@ -78,25 +78,23 @@ BOOL HttpRequest::Execute() Init(); // Open channel to standard redir host - NAMESPACE_VOS(OInetSocketAddr) aConnectAddr; + osl::SocketAddr aConnectAddr; if ( aProxyHost.Len() ) { - aConnectAddr.setAddr( rtl::OUString( UniString( aProxyHost, RTL_TEXTENCODING_UTF8 ) ) ); - aConnectAddr.setPort( nProxyPort ); + aConnectAddr = osl::SocketAddr( rtl::OUString( UniString( aProxyHost, RTL_TEXTENCODING_UTF8 ) ), nProxyPort ); } else { - aConnectAddr.setAddr( rtl::OUString( UniString( aRequestHost, RTL_TEXTENCODING_UTF8 ) ) ); - aConnectAddr.setPort( nRequestPort ); + aConnectAddr = osl::SocketAddr( rtl::OUString( UniString( aRequestHost, RTL_TEXTENCODING_UTF8 ) ), nRequestPort ); } TimeValue aTV; aTV.Seconds = 10; // Warte 10 Sekunden aTV.Nanosec = 0; - pOutSocket = new NAMESPACE_VOS(OConnectorSocket)(); - if ( pOutSocket->connect( aConnectAddr, &aTV ) == NAMESPACE_VOS(ISocketTypes::TResult_Ok) ) + pOutSocket = new osl::ConnectorSocket(); + if ( pOutSocket->connect( aConnectAddr, &aTV ) == osl_Socket_Ok ) { // pOutSocket->setTcpNoDelay( 1 ); } @@ -202,7 +200,7 @@ Servlet-Engine: Tomcat Web Server/3.2.1 (JSP 1.1; Servlet 2.2; Java 1.3.0; Linux Connection: close Content-Type: text/xml; charset=ISO-8859-1 */ -void HttpRequest::SendString( vos::OStreamSocket* pSocket , ByteString aText ) +void HttpRequest::SendString( osl::StreamSocket* pSocket , ByteString aText ) { if ( nStatus == HTTP_REQUEST_PENDING ) pSocket->write( aText.GetBuffer(), aText.Len() ); diff --git a/automation/source/testtool/httprequest.hxx b/automation/source/testtool/httprequest.hxx index 44234239b81f..7864414cfa4c 100644 --- a/automation/source/testtool/httprequest.hxx +++ b/automation/source/testtool/httprequest.hxx @@ -37,10 +37,10 @@ #include <tools/string.hxx> #include <tools/stream.hxx> -namespace vos +namespace osl { - class OStreamSocket; - class OConnectorSocket; + class StreamSocket; + class ConnectorSocket; } class HttpRequest @@ -52,14 +52,14 @@ class HttpRequest USHORT nProxyPort; USHORT nStatus; - vos::OConnectorSocket *pOutSocket; + osl::ConnectorSocket *pOutSocket; ByteString aHeader; USHORT nResultId; ByteString aContentType; SvMemoryStream* pStream; - void SendString( vos::OStreamSocket* pSocket, ByteString aText ); + void SendString( osl::StreamSocket* pSocket, ByteString aText ); BOOL IsItem( ByteString aItem, ByteString aLine ); void Init(); public: |