Add Pair button to show the pincode screen(class testing purposes)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34331 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes 2009-11-28 19:31:56 +00:00
parent e97e2846af
commit b973d02fde
2 changed files with 41 additions and 23 deletions

View File

@ -6,15 +6,18 @@
#include <Alert.h>
#include <Catalog.h>
#include <Locale.h>
#include <Messenger.h>
#include <Directory.h>
#include <Entry.h>
#include <File.h>
#include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <Messenger.h>
#include <Path.h>
#include <GroupLayoutBuilder.h>
#include <SpaceLayoutItem.h>
#include <PincodeWindow.h>
#include "defs.h"
#include "InquiryPanel.h"
@ -26,7 +29,7 @@
static const uint32 kMsgAddDevices = 'ddDv';
static const uint32 kMsgRemoveDevice = 'rmDv';
static const uint32 kMsgTrustDevice = 'trDv';
static const uint32 kMsgPairDevice = 'trDv';
static const uint32 kMsgBlockDevice = 'blDv';
static const uint32 kMsgRefreshDevices = 'rfDv';
@ -34,29 +37,27 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
: BView(name, flags)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
addButton = new BButton("add", TR("Add" B_UTF8_ELLIPSIS),
new BMessage(kMsgAddDevices));
removeButton = new BButton("remove", TR("Remove"),
new BMessage(kMsgRemoveDevice));
trustButton = new BButton("trust", TR("As Trusted"),
new BMessage(kMsgTrustDevice));
pairButton = new BButton("pair", TR("Pair" B_UTF8_ELLIPSIS),
new BMessage(kMsgPairDevice));
blockButton = new BButton("trust", TR("As Blocked"),
blockButton = new BButton("block", TR("As Blocked"),
new BMessage(kMsgBlockDevice));
availButton = new BButton("check", TR("Refresh" B_UTF8_ELLIPSIS),
new BMessage(kMsgRefreshDevices));
// Set up device list
fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST);
fScrollView = new BScrollView("ScrollView", fDeviceList, 0, false, true);
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@ -66,13 +67,13 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fScrollView)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
.Add(BGroupLayoutBuilder(B_VERTICAL)
.Add(BGroupLayoutBuilder(B_VERTICAL)
.Add(addButton)
.Add(removeButton)
.Add(removeButton)
.AddGlue()
.Add(availButton)
.AddGlue()
.Add(trustButton)
.Add(pairButton)
.Add(blockButton)
.AddGlue()
.SetInsets(0, 15, 0, 15)
@ -94,7 +95,7 @@ RemoteDevicesView::AttachedToWindow(void)
fDeviceList->SetTarget(this);
addButton->SetTarget(this);
removeButton->SetTarget(this);
trustButton->SetTarget(this);
pairButton->SetTarget(this);
blockButton->SetTarget(this);
availButton->SetTarget(this);
@ -111,20 +112,37 @@ RemoteDevicesView::MessageReceived(BMessage *msg)
{
InquiryPanel* iPanel = new InquiryPanel(BRect(100,100,450,450), ActiveLocalDevice);
iPanel->Show();
break;
}
break;
case kMsgRemoveDevice:
printf("kMsgRemoveDevice: %ld\n", fDeviceList->CurrentSelection(0));
fDeviceList->RemoveItem(fDeviceList->CurrentSelection(0));
break;
break;
case kMsgAddToRemoteList:
{
BListItem* device;
msg->FindPointer("device", (void**)&device);
fDeviceList->AddItem(device);
fDeviceList->Invalidate();
break;
}
break;
case kMsgPairDevice:
{
bdaddr_t address;
address.b[5] = 0x55;
address.b[4] = 0x44;
address.b[3] = 0x33;
address.b[2] = 0x22;
address.b[1] = 0x11;
address.b[0] = 0x00;
PincodeWindow* iPincode = new PincodeWindow(address, 0);
iPincode->Show();
break;
}
default:
BView::MessageReceived(msg);
break;

View File

@ -29,7 +29,7 @@ public:
~RemoteDevicesView(void);
void AttachedToWindow(void);
void MessageReceived(BMessage *msg);
void LoadSettings(void);
bool IsDefaultable(void);
@ -41,12 +41,12 @@ protected:
BButton* addButton;
BButton* removeButton;
BButton* trustButton;
BButton* pairButton;
BButton* blockButton;
BButton* availButton;
BListView* fDeviceList;
BListView* fDeviceList;
BScrollView* fScrollView;
};