- 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:
@@ -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...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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);
|
||||||
@@ -108,21 +99,21 @@ DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
|
|||||||
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
|
||||||
|
|
||||||
@@ -138,18 +129,30 @@ DeviceListItem::Update(BView *owner, const BFont *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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class DeviceListItem : public BListItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeviceListItem(BluetoothDevice* bDevice);
|
DeviceListItem(BluetoothDevice* bDevice);
|
||||||
DeviceListItem(bdaddr_t bdaddr, DeviceClass dClass, int32 rssi = 0);
|
|
||||||
|
|
||||||
~DeviceListItem();
|
~DeviceListItem();
|
||||||
|
|
||||||
@@ -28,6 +27,7 @@ class DeviceListItem : public BListItem
|
|||||||
|
|
||||||
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,8 +18,10 @@
|
|||||||
|
|
||||||
#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)
|
||||||
{
|
{
|
||||||
@@ -33,7 +35,10 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame, LocalDevice* bDevi
|
|||||||
|
|
||||||
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:
|
||||||
@@ -112,9 +119,12 @@ ExtendedLocalDeviceView::MessageReceived(BMessage *msg)
|
|||||||
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;
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -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++;
|
||||||
|
|||||||
@@ -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,6 +34,8 @@ 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';
|
||||||
|
|
||||||
|
using namespace Bluetooth;
|
||||||
|
|
||||||
RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
|
RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
|
||||||
: BView(name, flags)
|
: BView(name, flags)
|
||||||
{
|
{
|
||||||
@@ -84,11 +87,13 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
|
|||||||
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;
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
Reference in New Issue
Block a user