Bug 830551 - Send file-transfer-complete message after receiving unexpected response code from remote, r=echou

This commit is contained in:
Gina Yeh 2013-02-25 12:40:31 +08:00
Родитель c43fe3d9b7
Коммит ee53812c34
1 изменённых файлов: 20 добавлений и 18 удалений

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

@ -361,6 +361,7 @@ BluetoothOppManager::SendFile(BlobParent* aActor)
SendConnectRequest(); SendConnectRequest();
mTransferMode = false; mTransferMode = false;
StartFileTransfer();
return true; return true;
} }
@ -797,24 +798,26 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage)
packetLength = (((int)aMessage->mData[1]) << 8) | aMessage->mData[2]; packetLength = (((int)aMessage->mData[1]) << 8) | aMessage->mData[2];
} }
// Check response code // Check response code and send out system message as finished if the reponse
if (mLastCommand == ObexRequestCode::Put && // code is somehow incorrect.
opCode != ObexResponseCode::Continue) { uint8_t expectedOpCode = ObexResponseCode::Success;
NS_WARNING("[OPP] Put(0x02) failed"); if (mLastCommand == ObexRequestCode::Put) {
SendDisconnectRequest(); expectedOpCode = ObexResponseCode::Continue;
return; }
} else if (mLastCommand == ObexRequestCode::Abort ||
mLastCommand == ObexRequestCode::Connect || if (opCode != expectedOpCode) {
mLastCommand == ObexRequestCode::Disconnect || if (mLastCommand == ObexRequestCode::Put ||
mLastCommand == ObexRequestCode::PutFinal){ mLastCommand == ObexRequestCode::Abort ||
if (opCode != ObexResponseCode::Success) { mLastCommand == ObexRequestCode::PutFinal) {
nsAutoCString str; SendDisconnectRequest();
str += "[OPP] 0x";
str += mLastCommand;
str += " failed";
NS_WARNING(str.get());
return;
} }
nsAutoCString str;
str += "[OPP] 0x";
str.AppendInt(mLastCommand, 16);
str += " failed";
NS_WARNING(str.get());
FileTransferComplete();
return;
} }
if (mLastCommand == ObexRequestCode::PutFinal) { if (mLastCommand == ObexRequestCode::PutFinal) {
@ -849,7 +852,6 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage)
*/ */
if (ExtractBlobHeaders()) { if (ExtractBlobHeaders()) {
sInstance->SendPutHeaderRequest(sFileName, sFileLength); sInstance->SendPutHeaderRequest(sFileName, sFileLength);
StartFileTransfer();
} }
} else if (mLastCommand == ObexRequestCode::Put) { } else if (mLastCommand == ObexRequestCode::Put) {