summaryrefslogtreecommitdiff
path: root/sd/source/ui/remotecontrol
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2012-08-13 21:39:12 +0200
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2012-08-13 21:41:52 +0200
commit837a125ba6d31fb4cbc654e982884430464e8bba (patch)
tree2a7894d176dc79fee064460128316da4d28ba93a /sd/source/ui/remotecontrol
parent4533d34d9acdd3779333334d1d560bf707267e04 (diff)
Final fixes for pairing.
Change-Id: Ib66f227062f9c263dbc3dfefaf70525c73bdedc9
Diffstat (limited to 'sd/source/ui/remotecontrol')
-rw-r--r--sd/source/ui/remotecontrol/BufferedStreamSocket.cxx30
-rw-r--r--sd/source/ui/remotecontrol/Server.cxx2
2 files changed, 19 insertions, 13 deletions
diff --git a/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx b/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
index 8232bd085a06..0e274c30295a 100644
--- a/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
+++ b/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
@@ -27,8 +27,25 @@ sal_Int32 BufferedStreamSocket::readLine( OString& aLine )
{
while ( true )
{
+ // Process buffer first incase data already present.
+ vector<char>::iterator aIt;
+ if ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' ))
+ != aBuffer.end() )
+ {
+ sal_uInt64 aLocation = aIt - aBuffer.begin();
+
+ aLine = OString( &(*aBuffer.begin()), aLocation );
+
+ aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line
+ aRead -= (aLocation + 1);
+
+ return aLine.getLength();
+ }
+
+ // Then try and receive if nothing present
aBuffer.resize( aRead + 100 );
aRet = recv( &aBuffer[aRead], 100 );
+
if ( aRet == 0 )
{
return aRet;
@@ -40,19 +57,6 @@ sal_Int32 BufferedStreamSocket::readLine( OString& aLine )
return 0;
}
aRead += aRet;
- vector<char>::iterator aIt;
- while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' ))
- != aBuffer.end() )
- {
- sal_uInt64 aLocation = aIt - aBuffer.begin();
-
- aLine = OString( &(*aBuffer.begin()), aLocation );
-
- aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line
- aRead -= (aLocation + 1);
-
- return aLine.getLength();
- }
}
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index af4170aed6dd..e7a361e59e51 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -82,6 +82,7 @@ void RemoteServer::execute()
if ( ! pSocket->readLine( aLine ) ) delete pSocket;
OString aPin( aLine );
+ fprintf( stderr, "Pin:%s\n", aPin.getStr() );
SocketAddr aClientAddr;
pSocket->getPeerAddr( aClientAddr );
@@ -191,6 +192,7 @@ sal_Bool RemoteServer::connectClient( ClientInfo* pClient, rtl::OUString aPin )
break;
}
}
+ pCommunicator->launch();
return true;
}
else