Bug 802080 - Update connected device address, r=qdot
authorEric Chou <echou@mozilla.com>
Wed, 31 Oct 2012 14:07:06 +0800
changeset 111869 b84d576e597ab0f7f7ebd20b4e07a0c0c2126af3
parent 111868 3781f04d144d29aba4a14813ea18ae2a82e96948
child 111870 7781dba5ed5e7f499e9c36505ae29af0f05d65a8
push id17301
push userechou@mozilla.com
push dateWed, 31 Oct 2012 06:07:57 +0000
treeherdermozilla-inbound@b84d576e597a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs802080
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 802080 - Update connected device address, r=qdot
dom/bluetooth/BluetoothOppManager.cpp
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -156,21 +156,17 @@ BluetoothOppManager::BluetoothOppManager
                                            , mRemoteConnectionFlags(0)
                                            , mRemoteMaxPacketLength(0)
                                            , mAbortFlag(false)
                                            , mPacketLeftLength(0)
                                            , mReceiving(false)
                                            , mPutFinal(false)
                                            , mWaitingForConfirmationFlag(false)
 {
-  // FIXME / Bug 800249:
-  //   mConnectedDeviceAddress is Bluetooth address of connected device,
-  //   we will be able to get this value after bug 800249 lands. For now,
-  //   just assign a fake value to it.
-  mConnectedDeviceAddress.AssignASCII("00:00:00:00:00:00");
+  mConnectedDeviceAddress.AssignLiteral("00:00:00:00:00:00");
 }
 
 BluetoothOppManager::~BluetoothOppManager()
 {
 }
 
 //static
 BluetoothOppManager*
@@ -342,16 +338,18 @@ BluetoothOppManager::AfterOppDisconnecte
     mOutputStream->Close();
     mOutputStream = nullptr;
   }
 
   if (mReadFileThread) {
     mReadFileThread->Shutdown();
     mReadFileThread = nullptr;
   }
+
+  mConnectedDeviceAddress.AssignLiteral("00:00:00:00:00:00");
 }
 
 // Virtual function of class SocketConsumer
 void
 BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
 {
   uint8_t opCode;
   int packetLength;
@@ -954,19 +952,26 @@ BluetoothOppManager::ReceivingFileConfir
     NS_WARNING("Failed to broadcast [bluetooth-opp-receiving-file-confirmation]");
     return;
   }
 }
 
 void
 BluetoothOppManager::OnConnectSuccess()
 {
+  // Cache device address since we can't get socket address when a remote
+  // device disconnect with us.
+  GetSocketAddr(mConnectedDeviceAddress);
 }
 
 void
 BluetoothOppManager::OnConnectError()
 {
 }
 
 void
 BluetoothOppManager::OnDisconnect()
 {
+  // It is valid for a bluetooth device which is transfering file via OPP
+  // closing socket without sending OBEX disconnect request first. So we
+  // call AfterOppDisconnected here to ensure all variables will be cleaned.
+  AfterOppDisconnected();
 }