diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-08-22 12:44:42 +0200 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-08-22 20:23:07 +0200 |
commit | 1db66c2a1a8ad5a60c68b09ddacc1bb6e021299f (patch) | |
tree | f4693b0a0c1a689783c9dbf956a56d8d350afb3a /sd/source/ui/remotecontrol/Communicator.cxx | |
parent | 9d73597289be9049e8300ff92980fdffbe4d7040 (diff) |
Bluetooth connection working (Linux).
Change-Id: Iac77c3ce0ab0ea7bda3105c58859888e55e64d2d
Diffstat (limited to 'sd/source/ui/remotecontrol/Communicator.cxx')
-rw-r--r-- | sd/source/ui/remotecontrol/Communicator.cxx | 31 |
1 files changed, 11 insertions, 20 deletions
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<char> aBuffer; + sal_uInt64 aRet; vector<OString> 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<char>::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. |