[Libreoffice-commits] core.git: sd/source

Tor Lillqvist tml at iki.fi
Mon Feb 18 12:14:45 PST 2013


 sd/source/ui/remotecontrol/BluetoothServer.cxx     |   11 +++++++++++
 sd/source/ui/remotecontrol/OSXBluetooth.mm         |    7 ++++++-
 sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx |    1 +
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 6ce04df28c8b5d6043340efe6fdc229b51dd8c36
Author: Tor Lillqvist <tml at iki.fi>
Date:   Mon Feb 18 22:13:03 2013 +0200

    Handle gracefully the remote end closing the RFCOMM channel
    
    Avoids a crash if one presses the "back" key on the Android remote
    control.
    
    Change-Id: Icc7562676a79910b77c7f95d76ce07c348ec2b22

diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx
index b9736a2..ad6dadf 100644
--- a/sd/source/ui/remotecontrol/BluetoothServer.cxx
+++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx
@@ -189,6 +189,10 @@ sal_Int32 OSXBluetoothWrapper::write( const void* pBuffer, sal_uInt32 n )
 
     char* ptr = (char*)pBuffer;
     sal_uInt32 nBytesWritten = 0;
+
+    if (mpChannel == nil)
+        return 0;
+
     while( nBytesWritten < n )
     {
         int toWrite = n - nBytesWritten;
@@ -222,6 +226,13 @@ void OSXBluetoothWrapper::appendData(void* pBuffer, size_t len)
     }
 }
 
+void OSXBluetoothWrapper::channelClosed()
+{
+    SAL_INFO( "sdremote.bluetooth", "OSXBluetoothWrapper::channelClosed()" );
+
+    mpChannel = nil;
+}
+
 void incomingCallback( void *userRefCon,
                        IOBluetoothUserNotificationRef inRef,
                        IOBluetoothObjectRef objectRef )
diff --git a/sd/source/ui/remotecontrol/OSXBluetooth.mm b/sd/source/ui/remotecontrol/OSXBluetooth.mm
index ef1b700..f364389 100644
--- a/sd/source/ui/remotecontrol/OSXBluetooth.mm
+++ b/sd/source/ui/remotecontrol/OSXBluetooth.mm
@@ -37,7 +37,12 @@
 {
     (void) rfcommChannel;
 
-    // TODO: broadcast premature closing of data channel
+    SAL_INFO( "sdremote.bluetooth", "ChannelDelegate::rfcommChannelClosed()\n");
+
+    if ( pSocket )
+    {
+        pSocket->channelClosed();
+    }
     pCommunicator = NULL;
     pSocket = NULL;
 }
diff --git a/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx b/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx
index 6a61a24..cecaa7a 100644
--- a/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx
+++ b/sd/source/ui/remotecontrol/OSXBluetoothWrapper.hxx
@@ -32,6 +32,7 @@ namespace sd
         virtual sal_Int32 readLine( rtl::OString& aLine );
         virtual sal_Int32 write( const void* pBuffer, sal_uInt32 len );
         void appendData(void* pBuffer, size_t len );
+        void channelClosed();
     };
 }
 


More information about the Libreoffice-commits mailing list