summaryrefslogtreecommitdiff
path: root/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2012-08-22 12:44:42 +0200
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2012-08-22 20:23:07 +0200
commit1db66c2a1a8ad5a60c68b09ddacc1bb6e021299f (patch)
treef4693b0a0c1a689783c9dbf956a56d8d350afb3a /sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
parent9d73597289be9049e8300ff92980fdffbe4d7040 (diff)
Bluetooth connection working (Linux).
Change-Id: Iac77c3ce0ab0ea7bda3105c58859888e55e64d2d
Diffstat (limited to 'sd/source/ui/remotecontrol/BufferedStreamSocket.cxx')
-rw-r--r--sd/source/ui/remotecontrol/BufferedStreamSocket.cxx41
1 files changed, 38 insertions, 3 deletions
diff --git a/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx b/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
index 0e274c30295a..2b659705a6e4 100644
--- a/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
+++ b/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
@@ -11,6 +11,12 @@
#include <algorithm>
+#ifdef WIN32
+ #include <winsock2.h>
+#else
+ #include <sys/socket.h>
+ #include <unistd.h>
+#endif
using namespace sd;
using namespace std;
using namespace osl;
@@ -19,10 +25,36 @@ BufferedStreamSocket::BufferedStreamSocket( const osl::StreamSocket &aSocket ):
StreamSocket( aSocket ),
aRet( 0 ),
aRead( 0 ),
- aBuffer()
+ aBuffer(),
+ mSocket( 0 ),
+ usingCSocket( false)
{
}
+BufferedStreamSocket::BufferedStreamSocket( int aSocket ):
+ StreamSocket(),
+ aRet( 0 ),
+ aRead( 0 ),
+ aBuffer(),
+ mSocket( aSocket ),
+ usingCSocket( true )
+{
+}
+
+void BufferedStreamSocket::getPeerAddr(osl::SocketAddr& rAddr)
+{
+ assert ( !usingCSocket );
+ StreamSocket::getPeerAddr( rAddr );
+}
+
+sal_Int32 BufferedStreamSocket::write( const void* pBuffer, sal_uInt32 n )
+{
+ if ( !usingCSocket )
+ return StreamSocket::write( pBuffer, n );
+ else
+ return ::write( mSocket, pBuffer, (size_t) n );
+}
+
sal_Int32 BufferedStreamSocket::readLine( OString& aLine )
{
while ( true )
@@ -39,12 +71,15 @@ sal_Int32 BufferedStreamSocket::readLine( OString& aLine )
aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line
aRead -= (aLocation + 1);
- return aLine.getLength();
+ return aLine.getLength() + 1;
}
// Then try and receive if nothing present
aBuffer.resize( aRead + 100 );
- aRet = recv( &aBuffer[aRead], 100 );
+ if ( !usingCSocket)
+ aRet = StreamSocket::recv( &aBuffer[aRead], 100 );
+ else
+ aRet = ::read( mSocket, &aBuffer[aRead], 100 );
if ( aRet == 0 )
{