From 1db66c2a1a8ad5a60c68b09ddacc1bb6e021299f Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Wed, 22 Aug 2012 12:44:42 +0200 Subject: Bluetooth connection working (Linux). Change-Id: Iac77c3ce0ab0ea7bda3105c58859888e55e64d2d --- sd/source/ui/remotecontrol/Communicator.cxx | 31 ++++++++++------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'sd/source/ui/remotecontrol/Communicator.cxx') diff --git a/sd/source/ui/remotecontrol/Communicator.cxx b/sd/source/ui/remotecontrol/Communicator.cxx index 303f85a123a8..58f213071e5a 100644 --- a/sd/source/ui/remotecontrol/Communicator.cxx +++ b/sd/source/ui/remotecontrol/Communicator.cxx @@ -37,7 +37,7 @@ Communicator::~Communicator() // Run as a thread void Communicator::execute() { - pTransmitter = new Transmitter( *mpSocket ); + pTransmitter = new Transmitter( mpSocket ); pTransmitter->launch(); pTransmitter->addMessage( "LO_SERVER_SERVER_PAIRED\n\n", @@ -61,33 +61,24 @@ void Communicator::execute() { } - sal_uInt64 aRet, aRead; - vector aBuffer; + sal_uInt64 aRet; vector aCommand; - aRead = 0; while ( true ) { - aBuffer.resize( aRead + 100 ); - aRet = mpSocket->recv( &aBuffer[aRead], 100 ); + OString aLine; + aRet = mpSocket->readLine( aLine ); if ( aRet == 0 ) { break; // I.e. transmission finished. } - aRead += aRet; - vector::iterator aIt; - while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' )) - != aBuffer.end() ) + if ( aLine.getLength() ) { - sal_uInt64 aLocation = aIt - aBuffer.begin(); - - aCommand.push_back( OString( &(*aBuffer.begin()), aLocation ) ); - if ( aIt == aBuffer.begin() ) - { - aReceiver.parseCommand( aCommand ); - aCommand.clear(); - } - aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line - aRead -= (aLocation + 1); + aCommand.push_back( aLine ); + } + else + { + aReceiver.parseCommand( aCommand ); + aCommand.clear(); } } // TODO: deal with transmision errors gracefully. -- cgit v1.2.3