mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 11:28:38 +00:00
Bug 802590 - Patch 3: Implemented the logic, r=qdot
This commit is contained in:
parent
9e7732996a
commit
38f083e7e5
@ -100,6 +100,7 @@ BluetoothOppManager::BluetoothOppManager() : mConnected(false)
|
||||
, mPacketLeftLength(0)
|
||||
, mReceiving(false)
|
||||
, mPutFinal(false)
|
||||
, mWaitingForConfirmationFlag(false)
|
||||
{
|
||||
// FIXME / Bug 800249:
|
||||
// mConnectedDeviceAddress is Bluetooth address of connected device,
|
||||
@ -219,7 +220,22 @@ void
|
||||
BluetoothOppManager::ConfirmReceivingFile(bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// FIXME(Eric): Will implement in the third patch
|
||||
if (!mWaitingForConfirmationFlag) {
|
||||
NS_WARNING("We are not waiting for a confirmation now.");
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mPacketLeftLength == 0,
|
||||
"Should not be in the middle of receiving a PUT packet.");
|
||||
|
||||
mWaitingForConfirmationFlag = false;
|
||||
ReplyToPut(mPutFinal, aConfirm);
|
||||
|
||||
if (mPutFinal || !aConfirm) {
|
||||
mReceiving = false;
|
||||
FileTransferComplete(mConnectedDeviceAddress, aConfirm, true, sFileName,
|
||||
sSentFileLength, sContentType);
|
||||
}
|
||||
}
|
||||
|
||||
// Virtual function of class SocketConsumer
|
||||
@ -372,8 +388,8 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
pktHeaders.GetContentType(sContentType);
|
||||
pktHeaders.GetLength(&sFileLength);
|
||||
|
||||
ReceivingFileConfirmation(mConnectedDeviceAddress, sFileName, sFileLength, sContentType);
|
||||
mReceiving = true;
|
||||
mWaitingForConfirmationFlag = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -395,7 +411,11 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
}
|
||||
|
||||
if (mPacketLeftLength == 0) {
|
||||
ReplyToPut(mPutFinal);
|
||||
if (mWaitingForConfirmationFlag) {
|
||||
ReceivingFileConfirmation(mConnectedDeviceAddress, sFileName,
|
||||
sFileLength, sContentType);
|
||||
} else {
|
||||
ReplyToPut(mPutFinal, true);
|
||||
|
||||
if (mPutFinal) {
|
||||
mReceiving = false;
|
||||
@ -406,6 +426,7 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::SendConnectRequest()
|
||||
@ -576,7 +597,7 @@ BluetoothOppManager::ReplyToDisconnect()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::ReplyToPut(bool aFinal)
|
||||
BluetoothOppManager::ReplyToPut(bool aFinal, bool aContinue)
|
||||
{
|
||||
if (!mConnected) return;
|
||||
|
||||
@ -585,11 +606,19 @@ BluetoothOppManager::ReplyToPut(bool aFinal)
|
||||
uint8_t req[255];
|
||||
int index = 3;
|
||||
|
||||
if (aContinue) {
|
||||
if (aFinal) {
|
||||
SetObexPacketInfo(req, ObexResponseCode::Success, index);
|
||||
} else {
|
||||
SetObexPacketInfo(req, ObexResponseCode::Continue, index);
|
||||
}
|
||||
} else {
|
||||
if (aFinal) {
|
||||
SetObexPacketInfo(req, ObexResponseCode::Unauthorized, index);
|
||||
} else {
|
||||
SetObexPacketInfo(req, ObexResponseCode::Unauthorized & (~FINAL_BIT), index);
|
||||
}
|
||||
}
|
||||
|
||||
UnixSocketRawData* s = new UnixSocketRawData(index);
|
||||
memcpy(s->mData, req, s->mSize);
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
const nsString& aContentType);
|
||||
void ReplyToConnect();
|
||||
void ReplyToDisconnect();
|
||||
void ReplyToPut(bool aFinal);
|
||||
void ReplyToPut(bool aFinal, bool aContinue);
|
||||
virtual void OnConnectSuccess() MOZ_OVERRIDE;
|
||||
virtual void OnConnectError() MOZ_OVERRIDE;
|
||||
virtual void OnDisconnect() MOZ_OVERRIDE;
|
||||
@ -99,6 +99,7 @@ private:
|
||||
nsString mConnectedDeviceAddress;
|
||||
bool mReceiving;
|
||||
bool mPutFinal;
|
||||
bool mWaitingForConfirmationFlag;
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> mBlob;
|
||||
nsCOMPtr<nsIThread> mReadFileThread;
|
||||
|
Loading…
Reference in New Issue
Block a user