зеркало из https://github.com/mozilla/gecko-dev.git
Bug 802590 - Patch 3: Implemented the logic, r=qdot
This commit is contained in:
Родитель
9e7732996a
Коммит
38f083e7e5
|
@ -100,6 +100,7 @@ BluetoothOppManager::BluetoothOppManager() : mConnected(false)
|
||||||
, mPacketLeftLength(0)
|
, mPacketLeftLength(0)
|
||||||
, mReceiving(false)
|
, mReceiving(false)
|
||||||
, mPutFinal(false)
|
, mPutFinal(false)
|
||||||
|
, mWaitingForConfirmationFlag(false)
|
||||||
{
|
{
|
||||||
// FIXME / Bug 800249:
|
// FIXME / Bug 800249:
|
||||||
// mConnectedDeviceAddress is Bluetooth address of connected device,
|
// mConnectedDeviceAddress is Bluetooth address of connected device,
|
||||||
|
@ -219,7 +220,22 @@ void
|
||||||
BluetoothOppManager::ConfirmReceivingFile(bool aConfirm,
|
BluetoothOppManager::ConfirmReceivingFile(bool aConfirm,
|
||||||
BluetoothReplyRunnable* aRunnable)
|
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
|
// Virtual function of class SocketConsumer
|
||||||
|
@ -372,8 +388,8 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||||
pktHeaders.GetContentType(sContentType);
|
pktHeaders.GetContentType(sContentType);
|
||||||
pktHeaders.GetLength(&sFileLength);
|
pktHeaders.GetLength(&sFileLength);
|
||||||
|
|
||||||
ReceivingFileConfirmation(mConnectedDeviceAddress, sFileName, sFileLength, sContentType);
|
|
||||||
mReceiving = true;
|
mReceiving = true;
|
||||||
|
mWaitingForConfirmationFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -395,12 +411,17 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPacketLeftLength == 0) {
|
if (mPacketLeftLength == 0) {
|
||||||
ReplyToPut(mPutFinal);
|
if (mWaitingForConfirmationFlag) {
|
||||||
|
ReceivingFileConfirmation(mConnectedDeviceAddress, sFileName,
|
||||||
|
sFileLength, sContentType);
|
||||||
|
} else {
|
||||||
|
ReplyToPut(mPutFinal, true);
|
||||||
|
|
||||||
if (mPutFinal) {
|
if (mPutFinal) {
|
||||||
mReceiving = false;
|
mReceiving = false;
|
||||||
FileTransferComplete(mConnectedDeviceAddress, true, true, sFileName,
|
FileTransferComplete(mConnectedDeviceAddress, true, true, sFileName,
|
||||||
sSentFileLength, sContentType);
|
sSentFileLength, sContentType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,7 +597,7 @@ BluetoothOppManager::ReplyToDisconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BluetoothOppManager::ReplyToPut(bool aFinal)
|
BluetoothOppManager::ReplyToPut(bool aFinal, bool aContinue)
|
||||||
{
|
{
|
||||||
if (!mConnected) return;
|
if (!mConnected) return;
|
||||||
|
|
||||||
|
@ -585,10 +606,18 @@ BluetoothOppManager::ReplyToPut(bool aFinal)
|
||||||
uint8_t req[255];
|
uint8_t req[255];
|
||||||
int index = 3;
|
int index = 3;
|
||||||
|
|
||||||
if (aFinal) {
|
if (aContinue) {
|
||||||
SetObexPacketInfo(req, ObexResponseCode::Success, index);
|
if (aFinal) {
|
||||||
|
SetObexPacketInfo(req, ObexResponseCode::Success, index);
|
||||||
|
} else {
|
||||||
|
SetObexPacketInfo(req, ObexResponseCode::Continue, index);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SetObexPacketInfo(req, ObexResponseCode::Continue, index);
|
if (aFinal) {
|
||||||
|
SetObexPacketInfo(req, ObexResponseCode::Unauthorized, index);
|
||||||
|
} else {
|
||||||
|
SetObexPacketInfo(req, ObexResponseCode::Unauthorized & (~FINAL_BIT), index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnixSocketRawData* s = new UnixSocketRawData(index);
|
UnixSocketRawData* s = new UnixSocketRawData(index);
|
||||||
|
|
|
@ -83,7 +83,7 @@ private:
|
||||||
const nsString& aContentType);
|
const nsString& aContentType);
|
||||||
void ReplyToConnect();
|
void ReplyToConnect();
|
||||||
void ReplyToDisconnect();
|
void ReplyToDisconnect();
|
||||||
void ReplyToPut(bool aFinal);
|
void ReplyToPut(bool aFinal, bool aContinue);
|
||||||
virtual void OnConnectSuccess() MOZ_OVERRIDE;
|
virtual void OnConnectSuccess() MOZ_OVERRIDE;
|
||||||
virtual void OnConnectError() MOZ_OVERRIDE;
|
virtual void OnConnectError() MOZ_OVERRIDE;
|
||||||
virtual void OnDisconnect() MOZ_OVERRIDE;
|
virtual void OnDisconnect() MOZ_OVERRIDE;
|
||||||
|
@ -99,6 +99,7 @@ private:
|
||||||
nsString mConnectedDeviceAddress;
|
nsString mConnectedDeviceAddress;
|
||||||
bool mReceiving;
|
bool mReceiving;
|
||||||
bool mPutFinal;
|
bool mPutFinal;
|
||||||
|
bool mWaitingForConfirmationFlag;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMBlob> mBlob;
|
nsCOMPtr<nsIDOMBlob> mBlob;
|
||||||
nsCOMPtr<nsIThread> mReadFileThread;
|
nsCOMPtr<nsIThread> mReadFileThread;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче