Bug 791197 - [b2g-bluetooth] BluetoothHfpManager prototype, r=qdot

This commit is contained in:
Eric Chou 2012-09-26 21:34:55 +08:00
Родитель 438b02bc04
Коммит 1bcb230275
3 изменённых файлов: 116 добавлений и 0 удалений

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

@ -0,0 +1,80 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BluetoothHfpManager.h"
#include "BluetoothReplyRunnable.h"
#include "BluetoothService.h"
#include "BluetoothServiceUuid.h"
USING_BLUETOOTH_NAMESPACE
using namespace mozilla::ipc;
static nsRefPtr<BluetoothHfpManager> sInstance = nullptr;
BluetoothHfpManager::BluetoothHfpManager()
{
}
BluetoothHfpManager::~BluetoothHfpManager()
{
}
//static
BluetoothHfpManager*
BluetoothHfpManager::Get()
{
MOZ_ASSERT(NS_IsMainThread());
if (sInstance == nullptr) {
sInstance = new BluetoothHfpManager();
}
return sInstance;
}
// Virtual function of class SocketConsumer
void
BluetoothHfpManager::ReceiveSocketData(UnixSocketRawData* aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
}
bool
BluetoothHfpManager::Connect(const nsAString& aDeviceObjectPath,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
NS_WARNING("BluetoothService not available!");
return false;
}
nsString serviceUuidStr =
NS_ConvertUTF8toUTF16(mozilla::dom::bluetooth::BluetoothServiceUuidStr::Handsfree);
nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
nsresult rv = bs->GetSocketViaService(aDeviceObjectPath,
serviceUuidStr,
BluetoothSocketType::RFCOMM,
true,
false,
this,
runnable);
runnable.forget();
return NS_FAILED(rv) ? false : true;
}
void
BluetoothHfpManager::Disconnect()
{
CloseSocket();
}

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

@ -0,0 +1,35 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
#define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
#include "BluetoothCommon.h"
#include "mozilla/ipc/UnixSocket.h"
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothReplyRunnable;
class BluetoothHfpManager : public mozilla::ipc::UnixSocketConsumer
{
public:
~BluetoothHfpManager();
static BluetoothHfpManager* Get();
void ReceiveSocketData(mozilla::ipc::UnixSocketRawData* aMessage);
bool Connect(const nsAString& aDeviceObjectPath,
BluetoothReplyRunnable* aRunnable);
void Disconnect();
private:
BluetoothHfpManager();
};
END_BLUETOOTH_NAMESPACE
#endif

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

@ -52,6 +52,7 @@ CPPSRCS += \
BluetoothParent.cpp \ BluetoothParent.cpp \
BluetoothServiceChildProcess.cpp \ BluetoothServiceChildProcess.cpp \
BluetoothUnixSocketConnector.cpp \ BluetoothUnixSocketConnector.cpp \
BluetoothHfpManager.cpp \
$(NULL) $(NULL)
XPIDLSRCS = \ XPIDLSRCS = \