- Add authentication checkbox to force authenticate connections

- Implement Pair button for allowing Haiku initiate the connection



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36448 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2010-04-24 13:14:52 +00:00
parent 040fb3eaac
commit c2ee80e5da
7 changed files with 218 additions and 189 deletions
+45 -42
View File
@@ -10,7 +10,6 @@
#include <bluetooth/BluetoothDevice.h> #include <bluetooth/BluetoothDevice.h>
/*#include "../media/iconfile.h"*/ /*#include "../media/iconfile.h"*/
#include "DeviceListItem.h" #include "DeviceListItem.h"
#define INSETS 5 #define INSETS 5
@@ -19,22 +18,13 @@
namespace Bluetooth { namespace Bluetooth {
DeviceListItem::DeviceListItem(BluetoothDevice* bDevice) DeviceListItem::DeviceListItem(BluetoothDevice* bDevice)
: BListItem(), :
fDevice(bDevice) BListItem(),
fDevice(bDevice),
fName("unknown")
{ {
SetDevice(fDevice); fAddress = bDevice->GetBluetoothAddress();
} fClass = bDevice->GetDeviceClass();
DeviceListItem::DeviceListItem(bdaddr_t bdaddr, DeviceClass dClass, int32 rssi)
: BListItem(),
fDevice(NULL),
fAddress(bdaddr),
fClass(dClass),
fName("unknown"),
fRSSI(rssi)
{
} }
@@ -44,7 +34,7 @@ DeviceListItem::SetDevice(BluetoothDevice* bDevice)
fAddress = bDevice->GetBluetoothAddress(); fAddress = bDevice->GetBluetoothAddress();
fClass = bDevice->GetDeviceClass(); fClass = bDevice->GetDeviceClass();
fName = bDevice->GetFriendlyName(); fName = bDevice->GetFriendlyName();
// AKAIR rssi can only be got at inquiry time... // AKAIR rssi we can just have it @ inquiry time...
} }
@@ -57,8 +47,8 @@ DeviceListItem::~DeviceListItem()
void void
DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete) DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
{ {
rgb_color kBlack = { 0,0,0,0 }; rgb_color kBlack = { 0, 0, 0, 0 };
rgb_color kHighlight = { 156,154,156,0 }; rgb_color kHighlight = { 156, 154, 156, 0 };
if (IsSelected() || complete) { if (IsSelected() || complete) {
rgb_color color; rgb_color color;
@@ -79,7 +69,8 @@ DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
font_height finfo; font_height finfo;
be_plain_font->GetHeight(&finfo); be_plain_font->GetHeight(&finfo);
BPoint point = BPoint(itemRect.left + DeviceClass::PixelsForIcon + 2*INSETS, itemRect.bottom - finfo.descent + 1); BPoint point = BPoint(itemRect.left + DeviceClass::PixelsForIcon
+ 2 * INSETS, itemRect.bottom - finfo.descent + 1);
owner->SetFont(be_fixed_font); owner->SetFont(be_fixed_font);
owner->SetHighColor(kBlack); owner->SetHighColor(kBlack);
owner->MovePenTo(point); owner->MovePenTo(point);
@@ -105,24 +96,24 @@ DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
switch (fClass.GetMajorDeviceClass()) { switch (fClass.GetMajorDeviceClass()) {
case 1: case 1:
{ {
BRect iconRect(0,0,15,15); BRect iconRect(0, 0, 15, 15);
BBitmap *icon=new BBitmap(iconRect, B_CMAP8); BBitmap* icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kTVBits, kTVWidth*kTVHeight, 0, kTVColorSpace); icon->SetBits(kTVBits, kTVWidth * kTVHeight, 0, kTVColorSpace);
owner->DrawBitmap(icon, iconRect,BRect(itemRect.left + INSETS, itemRect.top + INSETS, owner->DrawBitmap(icon, iconRect, BRect(itemRect.left + INSETS,
itemRect.left + INSETS + PIXELS_FOR_ICON, itemRect.top + INSETS + PIXELS_FOR_ICON)); itemRect.top + INSETS, itemRect.left + INSETS + PIXELS_FOR_ICON,
itemRect.top + INSETS + PIXELS_FOR_ICON));
break;
} }
break;
case 4: case 4:
{ {
BRect iconRect(0,0,15,15); BRect iconRect(0, 0, 15, 15);
BBitmap *icon=new BBitmap(iconRect, B_CMAP8); BBitmap* icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kMixerBits, kMixerWidth*kMixerHeight, 0, kMixerColorSpace); icon->SetBits(kMixerBits, kMixerWidth * kMixerHeight, 0, kMixerColorSpace);
owner->DrawBitmap(icon, iconRect,BRect(itemRect.left + INSETS, itemRect.top + INSETS, owner->DrawBitmap(icon, iconRect, BRect(itemRect.left + INSETS,
itemRect.left + INSETS + PIXELS_FOR_ICON, itemRect.top + INSETS + PIXELS_FOR_ICON)); itemRect.top + INSETS, itemRect.left + INSETS + PIXELS_FOR_ICON,
itemRect.top + INSETS + PIXELS_FOR_ICON));
break;
} }
break;
} }
#endif #endif
@@ -132,24 +123,36 @@ DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
void void
DeviceListItem::Update(BView *owner, const BFont *font) DeviceListItem::Update(BView* owner, const BFont* font)
{ {
BListItem::Update(owner,font); BListItem::Update(owner, font);
font_height height; font_height height;
font->GetHeight(&height); font->GetHeight(&height);
SetHeight(MAX((height.ascent + height.descent + height.leading) * TEXT_ROWS + SetHeight(MAX((height.ascent + height.descent + height.leading) * TEXT_ROWS
(TEXT_ROWS+1)*INSETS, DeviceClass::PixelsForIcon + 2 * INSETS)); + (TEXT_ROWS + 1)*INSETS, DeviceClass::PixelsForIcon + 2 * INSETS));
} }
int int
DeviceListItem::Compare(const void *firstArg, const void *secondArg) DeviceListItem::Compare(const void *firstArg, const void *secondArg)
{ {
const DeviceListItem *item1 = *static_cast<const DeviceListItem * const *>(firstArg); const DeviceListItem* item1 = *static_cast<const DeviceListItem* const *>
const DeviceListItem *item2 = *static_cast<const DeviceListItem * const *>(secondArg); (firstArg);
const DeviceListItem* item2 = *static_cast<const DeviceListItem* const *>
(secondArg);
return (int)bdaddrUtils::Compare((bdaddr_t*)&item1->fAddress, (bdaddr_t*)&item2->fAddress); return (int)bdaddrUtils::Compare((bdaddr_t*)&item1->fAddress,
(bdaddr_t*)&item2->fAddress);
} }
BluetoothDevice*
DeviceListItem::Device() const
{
return fDevice;
}
} }
+4 -4
View File
@@ -19,15 +19,15 @@ class DeviceListItem : public BListItem
{ {
public: public:
DeviceListItem(BluetoothDevice* bDevice); DeviceListItem(BluetoothDevice* bDevice);
DeviceListItem(bdaddr_t bdaddr, DeviceClass dClass, int32 rssi = 0);
~DeviceListItem(); ~DeviceListItem();
void DrawItem(BView *, BRect, bool = false); void DrawItem(BView*, BRect, bool = false);
void Update(BView *owner, const BFont *font); void Update(BView* owner, const BFont* font);
static int Compare(const void *firstArg, const void *secondArg); static int Compare(const void* firstArg, const void* secondArg);
void SetDevice(BluetoothDevice* bDevice); void SetDevice(BluetoothDevice* bDevice);
BluetoothDevice* Device() const;
private: private:
BluetoothDevice* fDevice; BluetoothDevice* fDevice;
@@ -18,22 +18,27 @@
#define TR_CONTEXT "Extended local device view" #define TR_CONTEXT "Extended local device view"
ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame, LocalDevice* bDevice, uint32 resizingMode, uint32 flags) ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame,
: BView(frame,"ExtendedLocalDeviceView", resizingMode, flags | B_WILL_DRAW), LocalDevice* bDevice, uint32 resizingMode, uint32 flags)
:
BView(frame,"ExtendedLocalDeviceView", resizingMode, flags | B_WILL_DRAW),
fDevice(bDevice), fDevice(bDevice),
fScanMode(0) fScanMode(0)
{ {
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0,0,0); SetLowColor(0, 0, 0);
BRect iDontCare(0,0,0,0); BRect iDontCare(0, 0, 0, 0);
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
fDeviceView = new BluetoothDeviceView(BRect(0,0,5,5), bDevice); fDeviceView = new BluetoothDeviceView(BRect(0, 0, 5, 5), bDevice);
fDiscoverable = new BCheckBox(iDontCare, "Discoverable", TR("Discoverable"), fDiscoverable = new BCheckBox(iDontCare, "Discoverable", TR("Discoverable"),
new BMessage(SET_DISCOVERABLE)); new BMessage(SET_DISCOVERABLE));
fVisible = new BCheckBox(iDontCare, "Visible", TR("Show name"), new BMessage(SET_VISIBLE)); fVisible = new BCheckBox(iDontCare, "Visible", TR("Show name"),
new BMessage(SET_VISIBLE));
fAuthentication = new BCheckBox(iDontCare, "Authenticate", TR("Authenticate"),
new BMessage(SET_AUTHENTICATION));
fDiscoverable->SetEnabled(false); fDiscoverable->SetEnabled(false);
fVisible->SetEnabled(false); fVisible->SetEnabled(false);
@@ -46,6 +51,7 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame, LocalDevice* bDevi
.Add(fVisible) .Add(fVisible)
.SetInsets(5, 5, 5, 5) .SetInsets(5, 5, 5, 5)
) )
.Add(fAuthentication)
.Add(BSpaceLayoutItem::CreateVerticalStrut(0)) .Add(BSpaceLayoutItem::CreateVerticalStrut(0))
.SetInsets(5, 5, 5, 5) .SetInsets(5, 5, 5, 5)
); );
@@ -75,24 +81,25 @@ ExtendedLocalDeviceView::AttachedToWindow()
{ {
fDiscoverable->SetTarget(this); fDiscoverable->SetTarget(this);
fVisible->SetTarget(this); fVisible->SetTarget(this);
fAuthentication->SetTarget(this);
} }
void void
ExtendedLocalDeviceView::SetTarget(BHandler *tgt) ExtendedLocalDeviceView::SetTarget(BHandler* target)
{ {
} }
void void
ExtendedLocalDeviceView::MessageReceived(BMessage *msg) ExtendedLocalDeviceView::MessageReceived(BMessage* message)
{ {
if(msg->WasDropped()) { if (message->WasDropped()) {
} }
switch(msg->what) switch (message->what)
{ {
case SET_DISCOVERABLE: case SET_DISCOVERABLE:
case SET_VISIBLE: case SET_VISIBLE:
@@ -111,10 +118,13 @@ ExtendedLocalDeviceView::MessageReceived(BMessage *msg)
if (fDevice != NULL) if (fDevice != NULL)
fDevice->SetDiscoverable(fScanMode); fDevice->SetDiscoverable(fScanMode);
break; break;
case SET_AUTHENTICATION:
fDevice->SetAuthentication(fAuthentication->Value());
break;
default: default:
BView::MessageReceived(msg); BView::MessageReceived(message);
break; break;
} }
} }
@@ -30,13 +30,14 @@ public:
void SetLocalDevice(LocalDevice* lDevice); void SetLocalDevice(LocalDevice* lDevice);
virtual void MessageReceived(BMessage *msg); virtual void MessageReceived(BMessage* message);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void SetTarget(BHandler *tgt); virtual void SetTarget(BHandler* target);
virtual void SetEnabled(bool value); virtual void SetEnabled(bool value);
protected: protected:
LocalDevice* fDevice; LocalDevice* fDevice;
BCheckBox* fAuthentication;
BCheckBox* fDiscoverable; BCheckBox* fDiscoverable;
BCheckBox* fVisible; BCheckBox* fVisible;
BluetoothDeviceView* fDeviceView; BluetoothDeviceView* fDeviceView;
+33 -24
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com> * Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
*/ */
@@ -17,14 +17,14 @@
#include <TextView.h> #include <TextView.h>
#include <TabView.h> #include <TabView.h>
#include <bluetooth/bdaddrUtils.h>
#include <bluetooth/DiscoveryAgent.h> #include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/DiscoveryListener.h> #include <bluetooth/DiscoveryListener.h>
#include <bluetooth/LocalDevice.h> #include <bluetooth/LocalDevice.h>
#include <bluetooth/bdaddrUtils.h>
#include "InquiryPanel.h"
#include "DeviceListItem.h"
#include "defs.h" #include "defs.h"
#include "DeviceListItem.h"
#include "InquiryPanel.h"
#define TR_CONTEXT "Inquiry panel" #define TR_CONTEXT "Inquiry panel"
@@ -49,7 +49,10 @@ class PanelDiscoveryListener : public DiscoveryListener {
public: public:
PanelDiscoveryListener(InquiryPanel* iPanel) : DiscoveryListener() , fInquiryPanel(iPanel) PanelDiscoveryListener(InquiryPanel* iPanel)
:
DiscoveryListener(),
fInquiryPanel(iPanel)
{ {
} }
@@ -60,7 +63,7 @@ public:
{ {
BMessage* message = new BMessage(kMsgAddListDevice); BMessage* message = new BMessage(kMsgAddListDevice);
message->AddPointer("remoteItem", new DeviceListItem(btDevice->GetBluetoothAddress(), cod)); message->AddPointer("remoteItem", new DeviceListItem(btDevice));
fInquiryPanel->PostMessage(message); fInquiryPanel->PostMessage(message);
} }
@@ -88,12 +91,13 @@ private:
InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
: BWindow(frame, "Bluetooth", B_FLOATING_WINDOW, :
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, BWindow(frame, "Bluetooth", B_FLOATING_WINDOW,
B_ALL_WORKSPACES ), fMessenger(this) B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES ),
, fScanning(false) fMessenger(this),
, fRetrieving(false) fScanning(false),
, fLocalDevice(lDevice) fRetrieving(false),
fLocalDevice(lDevice)
{ {
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
@@ -124,11 +128,12 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
if (fLocalDevice != NULL) { if (fLocalDevice != NULL) {
fMessage->SetText(TR("Check that the Bluetooth capabilities of your remote device" fMessage->SetText(TR("Check that the Bluetooth capabilities of your"
" are activated. Press 'Inquiry' to start scanning. The needed time" " remote device are activated. Press 'Inquiry' to start scanning."
" for the retrieval of the names is unknown, although should not" " The needed time for the retrieval of the names is unknown, "
" take more than 3 seconds per device. Afterwards you will be able" "although should not take more than 3 seconds per device. "
" to add them to your main list, where you will be able to pair with them.")); "Afterwards you will be able to add them to your main list,"
" where you will be able to pair with them."));
fInquiryButton->SetEnabled(true); fInquiryButton->SetEnabled(true);
fDiscoveryAgent = fLocalDevice->GetDiscoveryAgent(); fDiscoveryAgent = fLocalDevice->GetDiscoveryAgent();
fDiscoveryListener = new PanelDiscoveryListener(this); fDiscoveryListener = new PanelDiscoveryListener(this);
@@ -165,7 +170,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
void void
InquiryPanel::MessageReceived(BMessage *message) InquiryPanel::MessageReceived(BMessage* message)
{ {
static float timer = 0; // expected time of the inquiry process static float timer = 0; // expected time of the inquiry process
static float scanningTime = 0; static float scanningTime = 0;
@@ -178,7 +183,8 @@ InquiryPanel::MessageReceived(BMessage *message)
fDiscoveryAgent->StartInquiry(BT_GIAC, fDiscoveryListener, GetInquiryTime()); fDiscoveryAgent->StartInquiry(BT_GIAC, fDiscoveryListener, GetInquiryTime());
timer = BT_BASE_INQUIRY_TIME * GetInquiryTime() + 1; timer = BT_BASE_INQUIRY_TIME * GetInquiryTime() + 1;
fScanProgress->SetMaxValue(timer); // does it works as expected? // does it works as expected?
fScanProgress->SetMaxValue(timer);
break; break;
@@ -244,7 +250,8 @@ InquiryPanel::MessageReceived(BMessage *message)
// TODO time formatting could use Locale Kit // TODO time formatting could use Locale Kit
BString elapsedTime = TR("Remaining "); BString elapsedTime = TR("Remaining ");
fScanProgress->SetTo(scanningTime*100/timer); // TODO should not be needed if SetMaxValue works... // TODO should not be needed if SetMaxValue works...
fScanProgress->SetTo(scanningTime * 100 / timer);
elapsedTime << (int)(timer - scanningTime) << TR(" seconds"); elapsedTime << (int)(timer - scanningTime) << TR(" seconds");
fScanProgress->SetTrailingText(elapsedTime.String()); fScanProgress->SetTrailingText(elapsedTime.String());
@@ -263,15 +270,17 @@ InquiryPanel::MessageReceived(BMessage *message)
labelPlaced = true; labelPlaced = true;
BString progressText = TR("Retrieving name of "); BString progressText = TR("Retrieving name of ");
progressText << bdaddrUtils::ToString(fDiscoveryAgent->RetrieveDevices(0).ItemAt( progressText << bdaddrUtils::ToString(fDiscoveryAgent
retrievalIndex)->GetBluetoothAddress()); ->RetrieveDevices(0).ItemAt(retrievalIndex)
->GetBluetoothAddress());
fScanProgress->SetTrailingText(progressText.String()); fScanProgress->SetTrailingText(progressText.String());
} else { } else {
// Really erally expensive operation should be done in a separate thread // Really erally expensive operation should be done in a separate thread
// once Haiku gets a BarberPole in API replacing the progress bar // once Haiku gets a BarberPole in API replacing the progress bar
((DeviceListItem*)fRemoteList->ItemAt(retrievalIndex))->SetDevice((BluetoothDevice*) ((DeviceListItem*)fRemoteList->ItemAt(retrievalIndex))
fDiscoveryAgent->RetrieveDevices(0).ItemAt(retrievalIndex)); ->SetDevice((BluetoothDevice*) fDiscoveryAgent
->RetrieveDevices(0).ItemAt(retrievalIndex));
fRemoteList->InvalidateItem(retrievalIndex); fRemoteList->InvalidateItem(retrievalIndex);
retrievalIndex++; retrievalIndex++;
+40 -35
View File
@@ -18,11 +18,12 @@
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
#include <PincodeWindow.h> #include <PincodeWindow.h>
#include <bluetooth/RemoteDevice.h>
#include "defs.h"
#include "InquiryPanel.h"
#include "BluetoothWindow.h" #include "BluetoothWindow.h"
#include "defs.h"
#include "DeviceListItem.h"
#include "InquiryPanel.h"
#include "RemoteDevicesView.h" #include "RemoteDevicesView.h"
#define TR_CONTEXT "Remote devices" #define TR_CONTEXT "Remote devices"
@@ -33,27 +34,29 @@ static const uint32 kMsgPairDevice = 'trDv';
static const uint32 kMsgBlockDevice = 'blDv'; static const uint32 kMsgBlockDevice = 'blDv';
static const uint32 kMsgRefreshDevices = 'rfDv'; static const uint32 kMsgRefreshDevices = 'rfDv';
RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags) using namespace Bluetooth;
RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
: BView(name, flags) : BView(name, flags)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
addButton = new BButton("add", TR("Add" B_UTF8_ELLIPSIS), addButton = new BButton("add", TR("Add" B_UTF8_ELLIPSIS),
new BMessage(kMsgAddDevices)); new BMessage(kMsgAddDevices));
removeButton = new BButton("remove", TR("Remove"), removeButton = new BButton("remove", TR("Remove"),
new BMessage(kMsgRemoveDevice)); new BMessage(kMsgRemoveDevice));
pairButton = new BButton("pair", TR("Pair" B_UTF8_ELLIPSIS), pairButton = new BButton("pair", TR("Pair" B_UTF8_ELLIPSIS),
new BMessage(kMsgPairDevice)); new BMessage(kMsgPairDevice));
blockButton = new BButton("block", TR("As blocked"), blockButton = new BButton("block", TR("As blocked"),
new BMessage(kMsgBlockDevice)); new BMessage(kMsgBlockDevice));
availButton = new BButton("check", TR("Refresh" B_UTF8_ELLIPSIS), availButton = new BButton("check", TR("Refresh" B_UTF8_ELLIPSIS),
new BMessage(kMsgRefreshDevices)); new BMessage(kMsgRefreshDevices));
// Set up device list // Set up device list
fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST); fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST);
@@ -68,27 +71,29 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
.Add(fScrollView) .Add(fScrollView)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) //.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
.Add(BGroupLayoutBuilder(B_VERTICAL) .Add(BGroupLayoutBuilder(B_VERTICAL)
.Add(addButton) .Add(addButton)
.Add(removeButton) .Add(removeButton)
.AddGlue() .AddGlue()
.Add(availButton) .Add(availButton)
.AddGlue() .AddGlue()
.Add(pairButton) .Add(pairButton)
.Add(blockButton) .Add(blockButton)
.AddGlue() .AddGlue()
.SetInsets(0, 15, 0, 15) .SetInsets(0, 15, 0, 15)
) )
.SetInsets(5, 5, 5, 100) .SetInsets(5, 5, 5, 100)
); );
fDeviceList->SetSelectionMessage(NULL); fDeviceList->SetSelectionMessage(NULL);
} }
RemoteDevicesView::~RemoteDevicesView(void) RemoteDevicesView::~RemoteDevicesView(void)
{ {
} }
void void
RemoteDevicesView::AttachedToWindow(void) RemoteDevicesView::AttachedToWindow(void)
{ {
@@ -103,15 +108,16 @@ RemoteDevicesView::AttachedToWindow(void)
fDeviceList->Select(0); fDeviceList->Select(0);
} }
void void
RemoteDevicesView::MessageReceived(BMessage *msg) RemoteDevicesView::MessageReceived(BMessage* message)
{ {
printf("what = %ld\n", msg->what); switch (message->what) {
switch(msg->what) {
case kMsgAddDevices: case kMsgAddDevices:
{ {
InquiryPanel* iPanel = new InquiryPanel(BRect(100,100,450,450), ActiveLocalDevice); InquiryPanel* inquiryPanel = new InquiryPanel(BRect(100, 100, 450, 450),
iPanel->Show(); ActiveLocalDevice);
inquiryPanel->Show();
break; break;
} }
@@ -122,7 +128,7 @@ RemoteDevicesView::MessageReceived(BMessage *msg)
case kMsgAddToRemoteList: case kMsgAddToRemoteList:
{ {
BListItem* device; BListItem* device;
msg->FindPointer("device", (void**)&device); message->FindPointer("device", (void**)&device);
fDeviceList->AddItem(device); fDeviceList->AddItem(device);
fDeviceList->Invalidate(); fDeviceList->Invalidate();
break; break;
@@ -130,30 +136,29 @@ RemoteDevicesView::MessageReceived(BMessage *msg)
case kMsgPairDevice: case kMsgPairDevice:
{ {
bdaddr_t address; DeviceListItem* device = static_cast<DeviceListItem*>(fDeviceList
address.b[5] = 0x55; ->ItemAt(fDeviceList->CurrentSelection(0)));
address.b[4] = 0x44; RemoteDevice* remote = dynamic_cast<RemoteDevice*>(device->Device());
address.b[3] = 0x33;
address.b[2] = 0x22; if (remote != NULL)
address.b[1] = 0x11; remote->Authenticate();
address.b[0] = 0x00;
PincodeWindow* iPincode = new PincodeWindow(address, 0);
iPincode->Show();
break; break;
} }
default: default:
BView::MessageReceived(msg); BView::MessageReceived(message);
break; break;
} }
} }
void RemoteDevicesView::LoadSettings(void) void RemoteDevicesView::LoadSettings(void)
{ {
} }
bool RemoteDevicesView::IsDefaultable(void) bool RemoteDevicesView::IsDefaultable(void)
{ {
return true; return true;
+1
View File
@@ -19,6 +19,7 @@
#define SET_VISIBLE 'sVis' #define SET_VISIBLE 'sVis'
#define SET_DISCOVERABLE 'sDis' #define SET_DISCOVERABLE 'sDis'
#define SET_AUTHENTICATION 'sAth'
#define SET_UI_COLORS 'suic' #define SET_UI_COLORS 'suic'
#define PREFS_CHOSEN 'prch' #define PREFS_CHOSEN 'prch'