From 24f4a20d25a51043faab4e1c69ca3ee5d8118625 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Wed, 18 Jun 2008 21:01:26 +0000 Subject: [PATCH] Add UI classes to the build. Adding some helper methods to the Local and remote devices git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26011 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/LocalDevice.h | 63 +++++++++++++++-------------- headers/os/bluetooth/RemoteDevice.h | 38 +++++++++-------- src/kits/bluetooth/Jamfile | 16 ++++++-- src/kits/bluetooth/LocalDevice.cpp | 12 +++--- src/kits/bluetooth/RemoteDevice.cpp | 5 +++ 5 files changed, 73 insertions(+), 61 deletions(-) diff --git a/headers/os/bluetooth/LocalDevice.h b/headers/os/bluetooth/LocalDevice.h index 1bff94ad52..b7c12bde69 100644 --- a/headers/os/bluetooth/LocalDevice.h +++ b/headers/os/bluetooth/LocalDevice.h @@ -28,42 +28,43 @@ class LocalDevice : public BluetoothDevice { public: /* Possible throwing */ - static LocalDevice* GetLocalDevice(); - static uint32 GetLocalDeviceCount(); - - static LocalDevice* GetLocalDevice(hci_id hid); - static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); - - DiscoveryAgent* GetDiscoveryAgent(); - BString GetFriendlyName(); - DeviceClass GetDeviceClass(); - /* Possible throwing */ - status_t SetDiscoverable(int mode); - - BString GetProperty(const char* property); - void GetProperty(const char* property, uint32* value); - - int GetDiscoverable(); - bdaddr_t GetBluetoothAddress(); - /* - ServiceRecord getRecord(Connection notifier); - void updateRecord(ServiceRecord srvRecord); - */ - private: - LocalDevice(hci_id hid); - - static LocalDevice* RequestLocalDeviceID(BMessage* request); - - static BMessenger* sfMessenger; - BMessenger* fMessenger; + static LocalDevice* GetLocalDevice(); + static uint32 GetLocalDeviceCount(); - hci_id hid; - hci_id GetID(void) {return hid;} + static LocalDevice* GetLocalDevice(hci_id hid); + static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); + + DiscoveryAgent* GetDiscoveryAgent(); + BString GetFriendlyName(); + DeviceClass GetDeviceClass(); + /* Possible throwing */ + status_t SetDiscoverable(int mode); + + BString GetProperty(const char* property); + void GetProperty(const char* property, uint32* value); + + int GetDiscoverable(); + bdaddr_t GetBluetoothAddress(); + /* + ServiceRecord getRecord(Connection notifier); + void updateRecord(ServiceRecord srvRecord); + */ + + private: + LocalDevice(hci_id hid); + hci_id GetID(void) {return hid;} + static LocalDevice* RequestLocalDeviceID(BMessage* request); + + static BMessenger* sfMessenger; + BMessenger* fMessenger; + + hci_id hid; friend class DiscoveryAgent; friend class RemoteDevice; + friend class PincodeWindow; }; - + } #ifndef _BT_USE_EXPLICIT_NAMESPACE diff --git a/headers/os/bluetooth/RemoteDevice.h b/headers/os/bluetooth/RemoteDevice.h index 0678e58681..3a0e167c10 100644 --- a/headers/os/bluetooth/RemoteDevice.h +++ b/headers/os/bluetooth/RemoteDevice.h @@ -25,18 +25,17 @@ class LocalDevice; class RemoteDevice : public BluetoothDevice { public: - static const int WAIT = B_BT_WAIT; static const int SUCCEEDED = B_BT_SUCCEEDED; - + 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 */ bool Authenticate(); /* Throwing */ /* bool Authorize(Connection conn); Throwing */ @@ -44,29 +43,28 @@ class RemoteDevice : public BluetoothDevice { 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 */ - + LocalDevice* GetLocalDeviceOwner(); protected: RemoteDevice(BString address); - RemoteDevice(bdaddr_t address); - - /* Instances of this class only will be done by Discovery[Listener|Agent] TODO */ - friend class DiscoveryListener; - + RemoteDevice(bdaddr_t address); + + /* Instances of this class only would be instantiated by Discovery[Listener|Agent] */ + friend class DiscoveryListener; + void SetLocalDeviceOwner(LocalDevice* ld); + private: - void SetLocalDeviceOwner(LocalDevice* ld); - - + LocalDevice* fDiscovererLocalDevice; - - uint8 fPageRepetitionMode; - uint8 fScanPeriodMode; - uint8 fScanMode; - uint16 fClockOffset; - + + uint8 fPageRepetitionMode; + uint8 fScanPeriodMode; + uint8 fScanMode; + uint16 fClockOffset; + }; } diff --git a/src/kits/bluetooth/Jamfile b/src/kits/bluetooth/Jamfile index 28013ea824..cea2169e3e 100644 --- a/src/kits/bluetooth/Jamfile +++ b/src/kits/bluetooth/Jamfile @@ -2,11 +2,16 @@ SubDir HAIKU_TOP src kits bluetooth ; SetSubDirSupportedPlatformsBeOSCompatible ; -if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { - UseHeaders [ FDirName $(HAIKU_TOP) headers os ] : true ; -} +#if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { +# UseHeaders [ FDirName $(HAIKU_TOP) headers os ] : true ; +#} + +UsePrivateHeaders shared bluetooth ; + +SubDirHdrs [ FDirName $(SUBDIR) UI ] ; + +SEARCH_SOURCE += [ FDirName $(SUBDIR) UI ] ; -UsePrivateHeaders bluetooth shared ; SharedLibrary libbluetooth.so : LocalDevice.cpp @@ -15,5 +20,8 @@ SharedLibrary libbluetooth.so : RemoteDevice.cpp CommandManager.cpp KitSupport.cpp + #UI + PincodeWindow.cpp + ConnectionIncoming.cpp : be ; diff --git a/src/kits/bluetooth/LocalDevice.cpp b/src/kits/bluetooth/LocalDevice.cpp index eb97ea1735..10e7bcb24f 100644 --- a/src/kits/bluetooth/LocalDevice.cpp +++ b/src/kits/bluetooth/LocalDevice.cpp @@ -152,10 +152,10 @@ LocalDevice::SetDiscoverable(int mode) BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; - size_t size; + size_t size; int8 bt_status = BT_ERROR; - - + + request.AddInt32("hci_id", hid); @@ -170,12 +170,12 @@ LocalDevice::SetDiscoverable(int mode) request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE)); if (fMessenger->SendMessage(&request, &reply) == B_OK) { - if (reply.FindInt8("status", &bt_status ) == B_OK ) { - return bt_status; + if (reply.FindInt8("status", &bt_status ) == B_OK ) { + return bt_status; } - } + } return B_ERROR; } diff --git a/src/kits/bluetooth/RemoteDevice.cpp b/src/kits/bluetooth/RemoteDevice.cpp index 99895cc6da..466a1c3f9b 100644 --- a/src/kits/bluetooth/RemoteDevice.cpp +++ b/src/kits/bluetooth/RemoteDevice.cpp @@ -134,6 +134,11 @@ RemoteDevice::IsEncrypted() return true; } +LocalDevice* +RemoteDevice::GetLocalDeviceOwner() +{ + return fDiscovererLocalDevice; +} /* Private */ void