Bug 1205577: Use enum constants for Bluetooth Socket module, r=btian

This commit is contained in:
Thomas Zimmermann 2015-09-17 14:46:18 +02:00
parent 5befe35395
commit 4afaf44ef6
3 changed files with 21 additions and 6 deletions

View File

@ -256,7 +256,8 @@ BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU)
&BluetoothDaemonProtocol::HandleSetupSvc,
[BluetoothDaemonCoreModule::SERVICE_ID] =
&BluetoothDaemonProtocol::HandleCoreSvc,
[0x02] = &BluetoothDaemonProtocol::HandleSocketSvc,
[BluetoothDaemonSocketModule::SERVICE_ID] =
&BluetoothDaemonProtocol::HandleSocketSvc,
[0x03] = nullptr, // HID host
[0x04] = nullptr, // PAN
[BluetoothDaemonHandsfreeModule::SERVICE_ID] =

View File

@ -32,7 +32,9 @@ BluetoothDaemonSocketModule::ListenCmd(BluetoothSocketType aType,
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<DaemonSocketPDU> pdu(new DaemonSocketPDU(0x02, 0x01, 0));
nsAutoPtr<DaemonSocketPDU> pdu(
new DaemonSocketPDU(SERVICE_ID, OPCODE_LISTEN,
0));
nsresult rv = PackPDU(
aType,
@ -61,7 +63,9 @@ BluetoothDaemonSocketModule::ConnectCmd(const nsAString& aBdAddr,
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<DaemonSocketPDU> pdu(new DaemonSocketPDU(0x02, 0x02, 0));
nsAutoPtr<DaemonSocketPDU> pdu(
new DaemonSocketPDU(SERVICE_ID, OPCODE_CONNECT,
0));
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr),
@ -166,9 +170,9 @@ BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
const DaemonSocketPDUHeader&,
DaemonSocketPDU&,
BluetoothSocketResultHandler*) = {
[0x00] = &BluetoothDaemonSocketModule::ErrorRsp,
[0x01] = &BluetoothDaemonSocketModule::ListenRsp,
[0x02] = &BluetoothDaemonSocketModule::ConnectRsp
[OPCODE_ERROR] = &BluetoothDaemonSocketModule::ErrorRsp,
[OPCODE_LISTEN] = &BluetoothDaemonSocketModule::ListenRsp,
[OPCODE_CONNECT] = &BluetoothDaemonSocketModule::ConnectRsp
};
if (NS_WARN_IF(MOZ_ARRAY_LENGTH(HandleRsp) <= aHeader.mOpcode) ||

View File

@ -20,6 +20,16 @@ using mozilla::ipc::DaemonSocketResultHandler;
class BluetoothDaemonSocketModule
{
public:
enum {
SERVICE_ID = 0x02
};
enum {
OPCODE_ERROR = 0x00,
OPCODE_LISTEN = 0x01,
OPCODE_CONNECT = 0x02
};
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(DaemonSocketPDU* aPDU,