Bug 801507 - Listen to ObjectPush service socket, r=qdot

This commit is contained in:
Eric Chou 2012-10-15 14:16:41 +08:00
Родитель 2798f40d68
Коммит 0f311715a5
3 изменённых файлов: 35 добавлений и 0 удалений

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

@ -158,6 +158,27 @@ BluetoothOppManager::Disconnect()
CloseSocket();
}
bool
BluetoothOppManager::Listen()
{
MOZ_ASSERT(NS_IsMainThread());
CloseSocket();
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
NS_WARNING("BluetoothService not available!");
return false;
}
nsresult rv = bs->ListenSocketViaService(BluetoothReservedChannels::OPUSH,
BluetoothSocketType::RFCOMM,
true,
false,
this);
return NS_FAILED(rv) ? false : true;
}
bool
BluetoothOppManager::SendFile(BlobParent* aActor,
BluetoothReplyRunnable* aRunnable)

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

@ -46,6 +46,7 @@ public:
bool Connect(const nsAString& aDeviceObjectPath,
BluetoothReplyRunnable* aRunnable);
void Disconnect();
bool Listen();
bool SendFile(BlobParent* aBlob,
BluetoothReplyRunnable* aRunnable);

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

@ -757,6 +757,12 @@ public:
if (h) {
h->Listen();
}
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (opp) {
opp->Listen();
}
return NS_OK;
}
};
@ -771,6 +777,12 @@ public:
if (h) {
h->CloseSocket();
}
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (opp) {
opp->CloseSocket();
}
return NS_OK;
}
};
@ -793,6 +805,7 @@ public:
uuids.AppendElement((uint32_t)(BluetoothServiceUuid::HandsfreeAG >> 32));
uuids.AppendElement((uint32_t)(BluetoothServiceUuid::HeadsetAG >> 32));
uuids.AppendElement((uint32_t)(BluetoothServiceUuid::ObjectPush >> 32));
// TODO/qdot: This needs to be held for the life of the bluetooth connection
// so we could clean it up. For right now though, we can throw it away.