From 0963754edfc87f8f7d7fc15cda5a0b8356d55528 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Wed, 21 May 2008 21:56:55 +0000 Subject: [PATCH] Create a parent class for the 2 devices class (RemoteDevice LocalDevice) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25596 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/BluetoothDevice.h | 46 ++++++++++++++++++++++++++ headers/os/bluetooth/DeviceClass.h | 5 +++ headers/os/bluetooth/LocalDevice.h | 3 +- headers/os/bluetooth/RemoteDevice.h | 12 +++++-- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 headers/os/bluetooth/BluetoothDevice.h diff --git a/headers/os/bluetooth/BluetoothDevice.h b/headers/os/bluetooth/BluetoothDevice.h new file mode 100644 index 0000000000..4da041348b --- /dev/null +++ b/headers/os/bluetooth/BluetoothDevice.h @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BLUETOOTH_DEVICE_H +#define _BLUETOOTH_DEVICE_H + +#include +#include + + +#include +#include + +#include + + +namespace Bluetooth { + +class BluetoothDevice { + + public: + + virtual BString GetFriendlyName()=0; + virtual DeviceClass GetDeviceClass()=0; + + virtual BString GetProperty(const char* property)=0; + virtual void GetProperty(const char* property, uint32* value)=0; + + virtual bdaddr_t GetBluetoothAddress()=0; + + protected: + bdaddr_t fBdaddr; + DeviceClass fDeviceClass; +}; + +} + +#ifndef _BT_USE_EXPLICIT_NAMESPACE +using Bluetooth::BluetoothDevice; +#endif + +#endif diff --git a/headers/os/bluetooth/DeviceClass.h b/headers/os/bluetooth/DeviceClass.h index 89c3dfb5d3..e4efc88b0d 100644 --- a/headers/os/bluetooth/DeviceClass.h +++ b/headers/os/bluetooth/DeviceClass.h @@ -21,6 +21,11 @@ class DeviceClass { this->record = record; } + DeviceClass() + { + this->record = 0; + } + int GetServiceClasses() { diff --git a/headers/os/bluetooth/LocalDevice.h b/headers/os/bluetooth/LocalDevice.h index 92cb3528e6..1bff94ad52 100644 --- a/headers/os/bluetooth/LocalDevice.h +++ b/headers/os/bluetooth/LocalDevice.h @@ -10,6 +10,7 @@ #include #include +#include #include @@ -23,7 +24,7 @@ namespace Bluetooth { class DiscoveryAgent; -class LocalDevice { +class LocalDevice : public BluetoothDevice { public: /* Possible throwing */ diff --git a/headers/os/bluetooth/RemoteDevice.h b/headers/os/bluetooth/RemoteDevice.h index 2d7ad5c4db..0678e58681 100644 --- a/headers/os/bluetooth/RemoteDevice.h +++ b/headers/os/bluetooth/RemoteDevice.h @@ -9,6 +9,7 @@ #define _REMOTE_DEVICE_H #include +#include #include @@ -21,7 +22,7 @@ namespace Bluetooth { class Connection; class LocalDevice; -class RemoteDevice { +class RemoteDevice : public BluetoothDevice { public: @@ -30,7 +31,10 @@ class RemoteDevice { bool IsTrustedDevice(); BString GetFriendlyName(bool alwaysAsk); /* Throwing */ + BString GetFriendlyName(void); /* Throwing */ bdaddr_t GetBluetoothAddress(); + DeviceClass GetDeviceClass(); + bool Equals(RemoteDevice* obj); /*static RemoteDevice* GetRemoteDevice(Connection conn); Throwing */ @@ -40,6 +44,10 @@ class RemoteDevice { bool IsAuthenticated(); /* Throwing */ /*bool IsAuthorized(Connection conn); Throwing */ bool IsEncrypted(); /* Throwing */ + + BString GetProperty(const char* property); /* Throwing */ + void GetProperty(const char* property, uint32* value); /* Throwing */ + protected: RemoteDevice(BString address); @@ -51,7 +59,7 @@ class RemoteDevice { private: void SetLocalDeviceOwner(LocalDevice* ld); - bdaddr_t fBdaddr; + LocalDevice* fDiscovererLocalDevice; uint8 fPageRepetitionMode;