Bug 1220121: Convert IPDL of Bluetooth OPP API to |BluetoothAddress|, r=btian

This commit is contained in:
Thomas Zimmermann 2015-11-12 11:23:35 +01:00
parent f914c37e2c
commit 339b98b18d
10 changed files with 73 additions and 82 deletions

View File

@ -1526,27 +1526,20 @@ BluetoothServiceBluedroid::Disconnect(
}
void
BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothAddress deviceAddress;
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
if (NS_FAILED(rv)) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
// Currently we only support one device sending one file at a time,
// so we don't need aDeviceAddress here because the target device
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) {
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
return;
}
@ -1555,26 +1548,19 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
}
void
BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress,
Blob* aBlob,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothAddress deviceAddress;
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
if (NS_FAILED(rv)) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
// Currently we only support one device sending one file at a time,
// so we don't need aDeviceAddress here because the target device
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (!opp || !opp->SendFile(deviceAddress, aBlob)) {
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
return;
}
@ -1583,8 +1569,8 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
}
void
BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable)
BluetoothServiceBluedroid::StopSendingFile(
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1605,7 +1591,7 @@ BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
void
BluetoothServiceBluedroid::ConfirmReceivingFile(
const nsAString& aDeviceAddress, bool aConfirm,
const BluetoothAddress& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());

View File

@ -121,22 +121,22 @@ public:
BluetoothReplyRunnable* aRunnable);
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable);
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
Blob* aBlob,
BluetoothReplyRunnable* aRunnable);
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
StopSendingFile(const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable);
virtual void
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable);
virtual void

View File

@ -3778,26 +3778,20 @@ BluetoothDBusService::UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
}
void
BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothAddress deviceAddress;
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
// Currently we only support one device sending one file at a time,
// so we don't need aDeviceAddress here because the target device
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
nsAutoString errorStr;
if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) {
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
errorStr.AssignLiteral("Calling SendFile() failed");
}
@ -3805,25 +3799,19 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
}
void
BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress,
Blob* aBlob,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothAddress deviceAddress;
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
// Currently we only support one device sending one file at a time,
// so we don't need aDeviceAddress here because the target device
// has been determined when calling 'Connect()'. Nevertheless, keep
// it for future use.
BluetoothOppManager* opp = BluetoothOppManager::Get();
nsAutoString errorStr;
if (!opp || !opp->SendFile(deviceAddress, aBlob)) {
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
errorStr.AssignLiteral("Calling SendFile() failed");
}
@ -3831,7 +3819,7 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
}
void
BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress,
BluetoothDBusService::StopSendingFile(const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
@ -3850,9 +3838,10 @@ BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress,
}
void
BluetoothDBusService::ConfirmReceivingFile(const nsAString& aDeviceAddress,
bool aConfirm,
BluetoothReplyRunnable* aRunnable)
BluetoothDBusService::ConfirmReceivingFile(
const BluetoothAddress& aDeviceAddress,
bool aConfirm,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread(), "Must be called from main thread!");

View File

@ -133,22 +133,22 @@ public:
BluetoothReplyRunnable* aRunnable) override;
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) override;
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
Blob* aBlob,
BluetoothReplyRunnable* aRunnable) override;
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
StopSendingFile(const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override;
virtual void
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable) override;
virtual void

View File

@ -286,22 +286,22 @@ public:
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
Blob* aBlob,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
StopSendingFile(const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void

View File

@ -1748,6 +1748,13 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
RefPtr<BluetoothVoidReplyRunnable> results =
new BluetoothVoidReplyRunnable(request);
BluetoothAddress deviceAddress;
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
@ -1756,7 +1763,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
if (XRE_IsParentProcess()) {
// In-process transfer
bs->SendFile(aDeviceAddress, &aBlob, results);
bs->SendFile(deviceAddress, &aBlob, results);
} else {
ContentChild *cc = ContentChild::GetSingleton();
if (!cc) {
@ -1770,7 +1777,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
return nullptr;
}
bs->SendFile(aDeviceAddress, nullptr, actor, results);
bs->SendFile(deviceAddress, nullptr, actor, results);
}
return request.forget();
@ -1790,12 +1797,19 @@ BluetoothAdapter::StopSendingFile(
RefPtr<BluetoothVoidReplyRunnable> results =
new BluetoothVoidReplyRunnable(request);
BluetoothAddress deviceAddress;
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
bs->StopSendingFile(aDeviceAddress, results);
bs->StopSendingFile(deviceAddress, results);
return request.forget();
}
@ -1814,12 +1828,19 @@ BluetoothAdapter::ConfirmReceivingFile(const nsAString& aDeviceAddress,
RefPtr<BluetoothVoidReplyRunnable> results =
new BluetoothVoidReplyRunnable(request);
BluetoothAddress deviceAddress;
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
bs->ConfirmReceivingFile(aDeviceAddress, aConfirmation, results);
bs->ConfirmReceivingFile(deviceAddress, aConfirmation, results);
return request.forget();
}

View File

@ -680,7 +680,7 @@ BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
mService->SendFile(aRequest.devicePath(),
mService->SendFile(aRequest.address(),
(BlobParent*)aRequest.blobParent(),
(BlobChild*)aRequest.blobChild(),
mReplyRunnable.get());
@ -694,7 +694,7 @@ BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest)
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest);
mService->StopSendingFile(aRequest.devicePath(),
mService->StopSendingFile(aRequest.address(),
mReplyRunnable.get());
return true;
@ -706,7 +706,7 @@ BluetoothRequestParent::DoRequest(const ConfirmReceivingFileRequest& aRequest)
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TConfirmReceivingFileRequest);
mService->ConfirmReceivingFile(aRequest.devicePath(),
mService->ConfirmReceivingFile(aRequest.address(),
true,
mReplyRunnable.get());
return true;
@ -718,7 +718,7 @@ BluetoothRequestParent::DoRequest(const DenyReceivingFileRequest& aRequest)
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TDenyReceivingFileRequest);
mService->ConfirmReceivingFile(aRequest.devicePath(),
mService->ConfirmReceivingFile(aRequest.address(),
false,
mReplyRunnable.get());
return true;

View File

@ -286,18 +286,17 @@ BluetoothServiceChildProcess::Disconnect(
void
BluetoothServiceChildProcess::SendFile(
const nsAString& aDeviceAddress,
const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
SendFileRequest(nsString(aDeviceAddress), nullptr, aBlobChild));
SendRequest(aRunnable, SendFileRequest(aDeviceAddress, nullptr, aBlobChild));
}
void
BluetoothServiceChildProcess::SendFile(
const nsAString& aDeviceAddress,
const BluetoothAddress& aDeviceAddress,
Blob* aBlobChild,
BluetoothReplyRunnable* aRunnable)
{
@ -307,27 +306,23 @@ BluetoothServiceChildProcess::SendFile(
void
BluetoothServiceChildProcess::StopSendingFile(
const nsAString& aDeviceAddress,
const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
StopSendingFileRequest(nsString(aDeviceAddress)));
SendRequest(aRunnable, StopSendingFileRequest(aDeviceAddress));
}
void
BluetoothServiceChildProcess::ConfirmReceivingFile(
const nsAString& aDeviceAddress,
bool aConfirm,
const BluetoothAddress& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable)
{
if(aConfirm) {
SendRequest(aRunnable,
ConfirmReceivingFileRequest(nsString(aDeviceAddress)));
SendRequest(aRunnable, ConfirmReceivingFileRequest(aDeviceAddress));
return;
}
SendRequest(aRunnable,
DenyReceivingFileRequest(nsString(aDeviceAddress)));
SendRequest(aRunnable, DenyReceivingFileRequest(aDeviceAddress));
}
void

View File

@ -130,22 +130,22 @@ public:
BluetoothReplyRunnable* aRunnable) override;
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) override;
virtual void
SendFile(const nsAString& aDeviceAddress,
SendFile(const BluetoothAddress& aDeviceAddress,
Blob* aBlob,
BluetoothReplyRunnable* aRunnable) override;
virtual void
StopSendingFile(const nsAString& aDeviceAddress,
StopSendingFile(const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override;
virtual void
ConfirmReceivingFile(const nsAString& aDeviceAddress,
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress,
bool aConfirm,
BluetoothReplyRunnable* aRunnable) override;

View File

@ -145,23 +145,23 @@ struct DisconnectRequest
struct SendFileRequest
{
nsString devicePath;
BluetoothAddress address;
PBlob blob;
};
struct StopSendingFileRequest
{
nsString devicePath;
BluetoothAddress address;
};
struct ConfirmReceivingFileRequest
{
nsString devicePath;
BluetoothAddress address;
};
struct DenyReceivingFileRequest
{
nsString devicePath;
BluetoothAddress address;
};
struct ConnectScoRequest