Bug 805724 - patch 4: fire dom request events after calling OPP related functions, r=qdot

This commit is contained in:
Eric Chou 2012-11-03 09:36:43 +08:00
parent 92f04e9b2b
commit 17cd9f8f35
8 changed files with 54 additions and 35 deletions

View File

@ -253,8 +253,7 @@ BluetoothOppManager::Listen()
}
bool
BluetoothOppManager::SendFile(BlobParent* aActor,
BluetoothReplyRunnable* aRunnable)
BluetoothOppManager::SendFile(BlobParent* aActor)
{
if (mBlob) {
// Means there's a sending process. Reply error.
@ -275,20 +274,19 @@ BluetoothOppManager::SendFile(BlobParent* aActor,
}
bool
BluetoothOppManager::StopSendingFile(BluetoothReplyRunnable* aRunnable)
BluetoothOppManager::StopSendingFile()
{
mAbortFlag = true;
return true;
}
void
BluetoothOppManager::ConfirmReceivingFile(bool aConfirm,
BluetoothReplyRunnable* aRunnable)
bool
BluetoothOppManager::ConfirmReceivingFile(bool aConfirm)
{
if (!mWaitingForConfirmationFlag) {
NS_WARNING("We are not waiting for a confirmation now.");
return;
return false;
}
NS_ASSERTION(mPacketLeftLength == 0,
@ -307,6 +305,8 @@ BluetoothOppManager::ConfirmReceivingFile(bool aConfirm,
FileTransferComplete(mConnectedDeviceAddress, aConfirm, true, sFileName,
sSentFileLength, sContentType);
}
return true;
}
void

View File

@ -50,10 +50,9 @@ public:
void Disconnect();
bool Listen();
bool SendFile(BlobParent* aBlob,
BluetoothReplyRunnable* aRunnable);
bool StopSendingFile(BluetoothReplyRunnable* aRunnable);
void ConfirmReceivingFile(bool aConfirm, BluetoothReplyRunnable* aRunnable);
bool SendFile(BlobParent* aBlob);
bool StopSendingFile();
bool ConfirmReceivingFile(bool aConfirm);
void SendConnectRequest();
void SendPutHeaderRequest(const nsAString& aFileName, int aFileSize);

View File

@ -273,13 +273,13 @@ public:
virtual void
Disconnect(uint16_t aProfileId, BluetoothReplyRunnable* aRunnable) = 0;
virtual bool
virtual void
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) = 0;
virtual bool
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) = 0;

View File

@ -529,10 +529,12 @@ BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
return mService->SendFile(aRequest.devicePath(),
(BlobParent*)aRequest.blobParent(),
(BlobChild*)aRequest.blobChild(),
mReplyRunnable.get());
mService->SendFile(aRequest.devicePath(),
(BlobParent*)aRequest.blobParent(),
(BlobChild*)aRequest.blobChild(),
mReplyRunnable.get());
return true;
}
bool
@ -541,8 +543,10 @@ BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest)
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest);
return mService->StopSendingFile(aRequest.devicePath(),
mReplyRunnable.get());
mService->StopSendingFile(aRequest.devicePath(),
mReplyRunnable.get());
return true;
}
bool

View File

@ -323,7 +323,7 @@ BluetoothServiceChildProcess::Disconnect(
SendRequest(aRunnable, DisconnectRequest(aProfileId));
}
bool
void
BluetoothServiceChildProcess::SendFile(
const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
@ -332,17 +332,15 @@ BluetoothServiceChildProcess::SendFile(
{
SendRequest(aRunnable,
SendFileRequest(nsString(aDeviceAddress), nullptr, aBlobChild));
return true;
}
bool
void
BluetoothServiceChildProcess::StopSendingFile(
const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
StopSendingFileRequest(nsString(aDeviceAddress)));
return true;
}
void

View File

@ -139,13 +139,13 @@ public:
Disconnect(const uint16_t aProfileId,
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
virtual bool
virtual void
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
virtual bool
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;

View File

@ -2368,7 +2368,8 @@ void
BluetoothDBusService::Disconnect(const uint16_t aProfileId,
BluetoothReplyRunnable* aRunnable)
{
if (aProfileId == (uint16_t)(BluetoothServiceUuid::Handsfree >> 32)) {
if (aProfileId == (uint16_t)(BluetoothServiceUuid::Handsfree >> 32) ||
aProfileId == (uint16_t)(BluetoothServiceUuid::Headset >> 32)) {
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
hfp->Disconnect();
} else if (aProfileId == (uint16_t)(BluetoothServiceUuid::ObjectPush >> 32)) {
@ -2557,7 +2558,7 @@ BluetoothDBusService::GetScoSocket(const nsAString& aAddress,
return NS_OK;
}
bool
void
BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
@ -2570,12 +2571,17 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
opp->SendFile(aBlobParent, aRunnable);
BluetoothValue v = true;
nsString errorStr;
return true;
if (!opp->SendFile(aBlobParent)) {
errorStr.AssignLiteral("Calling SendFile() failed");
}
DispatchBluetoothReply(aRunnable, v, errorStr);
}
bool
void
BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable)
{
@ -2586,9 +2592,14 @@ BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress,
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
opp->StopSendingFile(aRunnable);
BluetoothValue v = true;
nsString errorStr;
return true;
if (!opp->StopSendingFile()) {
errorStr.AssignLiteral("Calling StopSendingFile() failed");
}
DispatchBluetoothReply(aRunnable, v, errorStr);
}
void
@ -2603,7 +2614,14 @@ BluetoothDBusService::ConfirmReceivingFile(const nsAString& aDeviceAddress,
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
opp->ConfirmReceivingFile(aConfirm, aRunnable);
BluetoothValue v = true;
nsString errorStr;
if (!opp->ConfirmReceivingFile(aConfirm)) {
errorStr.AssignLiteral("Calling ConfirmReceivingFile() failed");
}
DispatchBluetoothReply(aRunnable, v, errorStr);
}
nsresult

View File

@ -142,13 +142,13 @@ public:
virtual void
Disconnect(const uint16_t aProfileId, BluetoothReplyRunnable* aRunnable);
virtual bool
virtual void
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable);
virtual bool
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable);