Bug 802080 - Update connected device address. r=qdot, a=blocking-basecamp
authorEric Chou <echou@mozilla.com>
Wed, 31 Oct 2012 14:07:06 +0800
changeset 113842 db7a309969a716f4c6c820d41af7a5f7b70a189a
parent 113841 451b59edba14d0dbfac8056686147c7eda5a1e10
child 113843 e39dec4b812b97e9333212144a4ec4e74d4bbe66
push id2528
push userryanvm@gmail.com
push dateThu, 01 Nov 2012 02:25:20 +0000
treeherdermozilla-aurora@d2f9b781aea0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot, blocking-basecamp
bugs802080
milestone18.0a2
Bug 802080 - Update connected device address. r=qdot, a=blocking-basecamp
dom/bluetooth/BluetoothOppManager.cpp
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -95,21 +95,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*
@@ -271,16 +267,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;
@@ -883,19 +881,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();
 }