Bug 816859 - Patch 1: Failed to receive a file, r=echou

This commit is contained in:
Gina Yeh 2012-11-30 17:49:08 +08:00
Родитель eb58c9b017
Коммит 8241611b48
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -333,6 +333,7 @@ BluetoothOppManager::SendFile(BlobParent* aActor)
} }
SendConnectRequest(); SendConnectRequest();
mTransferMode = false;
return true; return true;
} }
@ -379,6 +380,7 @@ BluetoothOppManager::AfterOppConnected()
sSentFileLength = 0; sSentFileLength = 0;
mReceivedDataBufferOffset = 0; mReceivedDataBufferOffset = 0;
mAbortFlag = false; mAbortFlag = false;
mSuccessFlag = false;
mWaitingForConfirmationFlag = true; mWaitingForConfirmationFlag = true;
} }
@ -391,6 +393,10 @@ BluetoothOppManager::AfterOppDisconnected()
mLastCommand = 0; mLastCommand = 0;
mBlob = nullptr; mBlob = nullptr;
// We can't reset mSuccessFlag here since this function may be called
// before we send system message of transfer complete
// mSuccessFlag = false;
if (mInputStream) { if (mInputStream) {
mInputStream->Close(); mInputStream->Close();
mInputStream = nullptr; mInputStream = nullptr;
@ -608,8 +614,6 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
SendDisconnectRequest(); SendDisconnectRequest();
} else { } else {
// Remote request or unknown mLastCommand // Remote request or unknown mLastCommand
mTransferMode = true;
mSuccessFlag = false;
ObexHeaderSet pktHeaders(opCode); ObexHeaderSet pktHeaders(opCode);
if (opCode == ObexRequestCode::Connect) { if (opCode == ObexRequestCode::Connect) {
@ -621,6 +625,7 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
&pktHeaders); &pktHeaders);
ReplyToConnect(); ReplyToConnect();
AfterOppConnected(); AfterOppConnected();
mTransferMode = true;
} else if (opCode == ObexRequestCode::Disconnect) { } else if (opCode == ObexRequestCode::Disconnect) {
// Section 3.3.2 "Disconnect", IrOBEX 1.2 // Section 3.3.2 "Disconnect", IrOBEX 1.2
// [opcode:1][length:2][Headers:var] // [opcode:1][length:2][Headers:var]
@ -739,8 +744,6 @@ BluetoothOppManager::SendConnectRequest()
index += AppendHeaderConnectionId(&req[index], mConnectionId); index += AppendHeaderConnectionId(&req[index], mConnectionId);
SetObexPacketInfo(req, ObexRequestCode::Connect, index); SetObexPacketInfo(req, ObexRequestCode::Connect, index);
mLastCommand = ObexRequestCode::Connect; mLastCommand = ObexRequestCode::Connect;
mTransferMode = false;
mSuccessFlag = false;
UnixSocketRawData* s = new UnixSocketRawData(index); UnixSocketRawData* s = new UnixSocketRawData(index);
memcpy(s->mData, req, s->mSize); memcpy(s->mData, req, s->mSize);
@ -1109,4 +1112,5 @@ BluetoothOppManager::OnDisconnect()
// call AfterOppDisconnected here to ensure all variables will be cleaned. // call AfterOppDisconnected here to ensure all variables will be cleaned.
AfterOppDisconnected(); AfterOppDisconnected();
mConnectedDeviceAddress.AssignLiteral("00:00:00:00:00:00"); mConnectedDeviceAddress.AssignLiteral("00:00:00:00:00:00");
mSuccessFlag = false;
} }