From af9ccaf25479a4d3ebcbe01c6a2d8a715d6c1b79 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Mon, 4 Aug 2008 17:58:09 +0000 Subject: [PATCH] Use const reference as input parameter as suggested by julun git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26801 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/RemoteDevice.h | 2 +- src/kits/bluetooth/RemoteDevice.cpp | 109 ++++++++++++++-------------- 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/headers/os/bluetooth/RemoteDevice.h b/headers/os/bluetooth/RemoteDevice.h index a75a59861c..50d08ae514 100644 --- a/headers/os/bluetooth/RemoteDevice.h +++ b/headers/os/bluetooth/RemoteDevice.h @@ -48,7 +48,7 @@ public: LocalDevice* GetLocalDeviceOwner(); - RemoteDevice(BString address); + RemoteDevice(const BString& address); RemoteDevice(bdaddr_t address); protected: diff --git a/src/kits/bluetooth/RemoteDevice.cpp b/src/kits/bluetooth/RemoteDevice.cpp index 599acfc383..bbf9bf39ed 100644 --- a/src/kits/bluetooth/RemoteDevice.cpp +++ b/src/kits/bluetooth/RemoteDevice.cpp @@ -30,7 +30,7 @@ namespace Bluetooth { bool RemoteDevice::IsTrustedDevice(void) { - return true; + return true; } @@ -38,58 +38,58 @@ BString RemoteDevice::GetFriendlyName(bool alwaysAsk) { - if (!alwaysAsk) { - // Check if the name is already retrieved - // TODO: Check if It is known from a KnownDevicesList - return BString("Not implemented"); - } - - if (fDiscovererLocalDevice == NULL) - return BString("#NoOwnerError#Not Valid name"); - - if (fMessenger == NULL) - return BString("#ServerNotReady#Not Valid name"); - - void* remoteNameCommand = NULL; + if (!alwaysAsk) { + // Check if the name is already retrieved + // TODO: Check if It is known from a KnownDevicesList + return BString("Not implemented"); + } + + if (fDiscovererLocalDevice == NULL) + return BString("#NoOwnerError#Not Valid name"); + + if (fMessenger == NULL) + return BString("#ServerNotReady#Not Valid name"); + + void* remoteNameCommand = NULL; size_t size; - - /* Issue inquiry command */ - BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); - BMessage reply; - - request.AddInt32("hci_id", fDiscovererLocalDevice->GetID()); - - // Fill the request + + // Issue inquiry command + BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); + BMessage reply; + + request.AddInt32("hci_id", fDiscovererLocalDevice->GetID()); + + // Fill the request remoteNameCommand = buildRemoteNameRequest(fBdaddr, fPageRepetitionMode, fClockOffset, &size); // Fill correctily - + request.AddData("raw command", B_ANY_TYPE, remoteNameCommand, size); request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS); - request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); - + request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); + request.AddInt16("eventExpected", HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE); - - - if (fMessenger->SendMessage(&request, &reply) == B_OK) - { - BString name; - int8 status; - - if ((reply.FindInt8("status", &status) == B_OK) && (status == BT_OK)) { - - if ((reply.FindString("friendlyname", &name) == B_OK ) ) { - return name; - } else { - return BString("");// should not happen - } - - } else { - // seems we got a netative event - return BString("#CommandFailed#Not Valid name"); - } - } - - return BString("#NotCompletedRequest#Not Valid name"); + + + if (fMessenger->SendMessage(&request, &reply) == B_OK) + { + BString name; + int8 status; + + if ((reply.FindInt8("status", &status) == B_OK) && (status == BT_OK)) { + + if ((reply.FindString("friendlyname", &name) == B_OK ) ) { + return name; + } else { + return BString(""); // should not happen + } + + } else { + // seems we got a negative event + return BString("#CommandFailed#Not Valid name"); + } + } + + return BString("#NotCompletedRequest#Not Valid name"); } @@ -103,16 +103,16 @@ RemoteDevice::GetFriendlyName() bdaddr_t RemoteDevice::GetBluetoothAddress() { - return fBdaddr; + return fBdaddr; } bool RemoteDevice::Equals(RemoteDevice* obj) { - bdaddr_t ba = obj->GetBluetoothAddress(); + bdaddr_t ba = obj->GetBluetoothAddress(); - return bdaddrUtils::Compare(&fBdaddr, &ba); + return bdaddrUtils::Compare(&fBdaddr, &ba); } // static RemoteDevice* GetRemoteDevice(Connection conn); @@ -120,7 +120,7 @@ RemoteDevice::Equals(RemoteDevice* obj) bool RemoteDevice::Authenticate() { - return true; + return true; } @@ -131,7 +131,7 @@ RemoteDevice::Authenticate() bool RemoteDevice::IsAuthenticated() { - return true; + return true; } @@ -141,7 +141,7 @@ RemoteDevice::IsAuthenticated() bool RemoteDevice::IsEncrypted() { - return true; + return true; } LocalDevice* @@ -166,7 +166,7 @@ RemoteDevice::RemoteDevice(bdaddr_t address) } -RemoteDevice::RemoteDevice(BString address) +RemoteDevice::RemoteDevice(const BString& address) { fBdaddr = bdaddrUtils::FromString((const char *)address.String()); fMessenger = _RetrieveBluetoothMessenger(); @@ -183,7 +183,6 @@ RemoteDevice::~RemoteDevice() BString RemoteDevice::GetProperty(const char* property) /* Throwing */ { - return NULL; }