Bluetooth Pref: Updating view of incomming connection when Paring
This is not my code but from ticket #9265 * Made a picture of how it looks, old left andnew right. https://imagebin.ca/v/5wIe6TIMzw4C * Think we have a bug somewhere and don't store the name of the Bluetooth device (shown i the image). * I have made som small changes but other than that it's the same code as in the ticket * Ran the src/tools/checkstyle/checkstyle.py to get som style stuff, probably missed some anyway. Change-Id: Ifeb75c8ad890f541e100cdcf78b394675a48ada9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3825 Reviewed-by: Fredrik Modéen <fredrik@modeen.se>
This commit is contained in:
parent
560961ee2a
commit
16196fd3b7
33
headers/private/bluetooth/BluetoothIconView.h
Normal file
33
headers/private/bluetooth/BluetoothIconView.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _BLUETOOTH_ICON_VIEW_H_
|
||||
#define _BLUETOOTH_ICON_VIEW_H_
|
||||
|
||||
#include <View.h>
|
||||
#include <Bitmap.h>
|
||||
#include <MimeType.h>
|
||||
#include <IconUtils.h>
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
class BluetoothIconView : public BView {
|
||||
public:
|
||||
BluetoothIconView();
|
||||
~BluetoothIconView();
|
||||
|
||||
void Draw(BRect rect);
|
||||
|
||||
private:
|
||||
static BBitmap* fBitmap;
|
||||
static int32 fRefCount;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* _BLUETOOTH_ICON_VIEW_H_ */
|
@ -1,52 +1,44 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||
*
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*
|
||||
*/
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _CONNECTION_INCOMING_H_
|
||||
#define _CONNECTION_INCOMING_H_
|
||||
|
||||
|
||||
//----------------------- Global includes ----------------------
|
||||
#include <AppKit.h>
|
||||
#include <SupportKit.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <SupportKit.h>
|
||||
#include <InterfaceKit.h>
|
||||
|
||||
#include <ConnectionView.h>
|
||||
#include <bluetooth/RemoteDevice.h>
|
||||
#include <bluetooth/bdaddrUtils.h>
|
||||
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
class RemoteDevice;
|
||||
class ConnectionView;
|
||||
|
||||
class ConnectionView
|
||||
: public BView
|
||||
{
|
||||
class ConnectionIncoming : public BWindow {
|
||||
public:
|
||||
ConnectionView(BRect frame, const char *name);
|
||||
~ConnectionView();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
void Draw(BRect update);
|
||||
void Pulse();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ConnectionIncoming : public BWindow
|
||||
{
|
||||
public:
|
||||
ConnectionIncoming(RemoteDevice* rDevice);
|
||||
ConnectionIncoming(bdaddr_t address);
|
||||
ConnectionIncoming(RemoteDevice* rDevice = NULL);
|
||||
~ConnectionIncoming();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
private:
|
||||
ConnectionView* _ConnectionView;
|
||||
ConnectionView* fView;
|
||||
};
|
||||
|
||||
}
|
||||
@ -55,5 +47,4 @@ private:
|
||||
using Bluetooth::ConnectionIncoming;
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif /* _CONNECTION_INCOMING_H_ */
|
||||
|
44
headers/private/bluetooth/ConnectionView.h
Normal file
44
headers/private/bluetooth/ConnectionView.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _CONNECTION_VIEW_H_
|
||||
#define _CONNECTION_VIEW_H_
|
||||
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include <StringView.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Font.h>
|
||||
#include <String.h>
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
class BluetoothIconView;
|
||||
|
||||
class ConnectionView : public BView {
|
||||
public:
|
||||
ConnectionView(BRect frame,
|
||||
BString device, BString address);
|
||||
|
||||
void Pulse();
|
||||
|
||||
private:
|
||||
BString strMessage;
|
||||
BluetoothIconView* fIcon;
|
||||
BStringView* fMessage;
|
||||
BStringView* fDeviceLabel;
|
||||
BStringView* fDeviceText;
|
||||
BStringView* fAddressLabel;
|
||||
BStringView* fAddressText;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* _CONNECTION_VIEW_H_ */
|
@ -1,9 +1,14 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PINCODE_REQUEST_WINDOW_H
|
||||
#define _PINCODE_REQUEST_WINDOW_H
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _PINCODE_REQUEST_WINDOW_H_
|
||||
#define _PINCODE_REQUEST_WINDOW_H_
|
||||
|
||||
|
||||
#include <View.h>
|
||||
@ -12,20 +17,21 @@
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/HCI/btHCI.h>
|
||||
|
||||
#include <BluetoothIconView.h>
|
||||
|
||||
class BStringView;
|
||||
class BButton;
|
||||
class BTextControl;
|
||||
|
||||
namespace Bluetooth {
|
||||
namespace Bluetooth {
|
||||
|
||||
class RemoteDevice;
|
||||
|
||||
class PincodeWindow : public BWindow
|
||||
{
|
||||
class PincodeWindow : public BWindow {
|
||||
public:
|
||||
PincodeWindow(bdaddr_t address, hci_id hid);
|
||||
PincodeWindow(RemoteDevice* rDevice);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
virtual bool QuitRequested();
|
||||
void SetBDaddr(BString address);
|
||||
|
||||
@ -39,6 +45,13 @@ private:
|
||||
BButton* fAcceptButton;
|
||||
BButton* fCancelButton;
|
||||
BTextControl* fPincodeText;
|
||||
|
||||
BluetoothIconView* fIcon;
|
||||
BStringView* fMessage2;
|
||||
BStringView* fDeviceLabel;
|
||||
BStringView* fDeviceText;
|
||||
BStringView* fAddressLabel;
|
||||
BStringView* fAddressText;
|
||||
};
|
||||
|
||||
}
|
||||
@ -47,4 +60,4 @@ private:
|
||||
using Bluetooth::PincodeWindow;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* _PINCODE_REQUEST_WINDOW_H_ */
|
||||
|
@ -25,6 +25,8 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
#UI
|
||||
PincodeWindow.cpp
|
||||
ConnectionIncoming.cpp
|
||||
ConnectionView.cpp
|
||||
BluetoothIconView.cpp
|
||||
:
|
||||
be localestub [ TargetLibstdc++ ]
|
||||
;
|
||||
|
59
src/kits/bluetooth/UI/BluetoothIconView.cpp
Normal file
59
src/kits/bluetooth/UI/BluetoothIconView.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
#include <BluetoothIconView.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
BBitmap* BluetoothIconView::fBitmap = NULL;
|
||||
int32 BluetoothIconView::fRefCount = 0;
|
||||
|
||||
BluetoothIconView::BluetoothIconView()
|
||||
:
|
||||
BView(BRect(0, 0, 80, 80), "", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
if (fRefCount == 0) {
|
||||
fBitmap = new BBitmap(BRect(0, 0, 64, 64), 0, B_RGBA32);
|
||||
|
||||
uint8* tempIcon;
|
||||
size_t tempSize;
|
||||
|
||||
BMimeType mime("application/x-vnd.Haiku-bluetooth_server");
|
||||
mime.GetIcon(&tempIcon, &tempSize);
|
||||
|
||||
BIconUtils::GetVectorIcon(tempIcon, tempSize, fBitmap);
|
||||
|
||||
fRefCount++;
|
||||
} else {
|
||||
fRefCount++;
|
||||
}
|
||||
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
|
||||
}
|
||||
|
||||
|
||||
BluetoothIconView::~BluetoothIconView()
|
||||
{
|
||||
fRefCount--;
|
||||
|
||||
if (fRefCount <= 0)
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BluetoothIconView::Draw(BRect rect)
|
||||
{
|
||||
this->DrawBitmap(fBitmap);
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +1,51 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <ConnectionIncoming.h>
|
||||
#include <ConnectionView.h>
|
||||
|
||||
namespace Bluetooth
|
||||
{
|
||||
|
||||
#define B_PULSES_BY_SECOND(x) (2*x)
|
||||
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
|
||||
ConnectionView::ConnectionView(BRect frame, const char *name)
|
||||
ConnectionIncoming::ConnectionIncoming(bdaddr_t address)
|
||||
:
|
||||
BView(BRect(0, 0, 400, 400), "MyViewName", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_PULSE_NEEDED)
|
||||
BWindow(BRect(600, 100, 1000, 180), "Incoming Connection..",
|
||||
B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
||||
// 400x80
|
||||
{
|
||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
SetPulseRate(1 * 1000 * 1000);
|
||||
// 1 second
|
||||
fView = new ConnectionView(BRect(0, 0, 400, 80), "<unknown_device>",
|
||||
bdaddrUtils::ToString(address));
|
||||
AddChild(fView);
|
||||
}
|
||||
|
||||
|
||||
ConnectionView::~ConnectionView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ConnectionView::MessageReceived(BMessage *message)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ConnectionView::Draw(BRect update)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ConnectionView::Pulse()
|
||||
{
|
||||
static int a = 0;
|
||||
|
||||
if (a++ == B_PULSES_BY_SECOND(5)) {
|
||||
// BUG: for some reason the window is not being removed...
|
||||
Window()->PostMessage(B_QUIT_REQUESTED);
|
||||
Window()->Quit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//#pragma mark -
|
||||
|
||||
|
||||
ConnectionIncoming::ConnectionIncoming(RemoteDevice* rDevice)
|
||||
:
|
||||
BWindow(BRect(700, 100, 900, 150), "Connection completed",
|
||||
BWindow(BRect(600, 100, 1000, 180), "Incoming Connection",
|
||||
B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
||||
{
|
||||
_ConnectionView = new ConnectionView(BRect(0, 0, 400, 400),"mViewName");
|
||||
SetPulseRate(1 * 1000 * 1000);
|
||||
// 1 second
|
||||
|
||||
AddChild(_ConnectionView);
|
||||
if (rDevice != NULL)
|
||||
fView = new ConnectionView(BRect(0, 0, 400, 80), rDevice->GetFriendlyName(),
|
||||
bdaddrUtils::ToString(rDevice->GetBluetoothAddress()));
|
||||
else
|
||||
fView = new ConnectionView(BRect(0, 0, 400, 80), "<unknown_device>",
|
||||
bdaddrUtils::ToString(bdaddrUtils::NullAddress()));
|
||||
|
||||
AddChild(fView);
|
||||
}
|
||||
|
||||
|
||||
@ -69,12 +54,14 @@ ConnectionIncoming::~ConnectionIncoming()
|
||||
}
|
||||
|
||||
|
||||
void ConnectionIncoming::MessageReceived(BMessage *message)
|
||||
void
|
||||
ConnectionIncoming::MessageReceived(BMessage* message)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool ConnectionIncoming::QuitRequested()
|
||||
bool
|
||||
ConnectionIncoming::QuitRequested()
|
||||
{
|
||||
return BWindow::QuitRequested();
|
||||
}
|
||||
|
81
src/kits/bluetooth/UI/ConnectionView.cpp
Normal file
81
src/kits/bluetooth/UI/ConnectionView.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
#include <ConnectionView.h>
|
||||
#include <BluetoothIconView.h>
|
||||
|
||||
namespace Bluetooth
|
||||
{
|
||||
|
||||
ConnectionView::ConnectionView(BRect frame, BString device, BString address)
|
||||
:
|
||||
BView(frame, "ConnectionView", 0, B_PULSE_NEEDED)
|
||||
{
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
fIcon = new BluetoothIconView();
|
||||
|
||||
strMessage = "A new connection is incoming..";
|
||||
|
||||
fMessage = new BStringView(frame, "", strMessage, B_FOLLOW_LEFT);
|
||||
fMessage->SetAlignment(B_ALIGN_LEFT);
|
||||
|
||||
fDeviceLabel = new BStringView(frame, "", "Device Name:", B_FOLLOW_LEFT);
|
||||
fDeviceLabel->SetFont(be_bold_font);
|
||||
|
||||
fDeviceText = new BStringView(frame, "", device, B_FOLLOW_RIGHT);
|
||||
fDeviceText->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
fAddressLabel = new BStringView(frame, "", "MAC Address:", B_FOLLOW_LEFT);
|
||||
fAddressLabel->SetFont(be_bold_font);
|
||||
|
||||
fAddressText = new BStringView(frame, "", address, B_FOLLOW_RIGHT);
|
||||
fAddressText->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||
.Add(BGroupLayoutBuilder(B_VERTICAL, 8)
|
||||
.Add(fIcon)
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||
.Add(fMessage)
|
||||
.AddGlue()
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
|
||||
.Add(fDeviceLabel)
|
||||
.AddGlue()
|
||||
.Add(fDeviceText)
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
|
||||
.Add(fAddressLabel)
|
||||
.AddGlue()
|
||||
.Add(fAddressText)
|
||||
)
|
||||
.AddGlue()
|
||||
)
|
||||
.AddGlue()
|
||||
.SetInsets(8, 8, 8, 8)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConnectionView::Pulse()
|
||||
{
|
||||
static int pulses = 0;
|
||||
|
||||
pulses++;
|
||||
|
||||
if (pulses >= 5) {
|
||||
Window()->PostMessage(B_QUIT_REQUESTED);
|
||||
} else {
|
||||
strMessage += ".";
|
||||
fMessage->SetText(strMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
* Copyright 2021, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
||||
* Tri-Edge AI <triedgeai@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
@ -41,20 +45,15 @@ static const uint32 skMessageAcceptButton = 'acCp';
|
||||
static const uint32 skMessageCancelButton = 'mVch';
|
||||
|
||||
|
||||
namespace Bluetooth {
|
||||
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
namespace Bluetooth
|
||||
{
|
||||
|
||||
PincodeWindow::PincodeWindow(bdaddr_t address, hci_id hid)
|
||||
: BWindow(BRect(800, 200, 900, 300), "Pincode request",
|
||||
B_FLOATING_WINDOW,
|
||||
B_WILL_ACCEPT_FIRST_CLICK | B_NOT_RESIZABLE| B_NOT_ZOOMABLE
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS,
|
||||
B_ALL_WORKSPACES), fBdaddr(address), fHid(hid)
|
||||
: BWindow(BRect(700, 200, 1000, 400), "PIN Code Request",
|
||||
B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fBdaddr(address),
|
||||
fHid(hid)
|
||||
{
|
||||
InitUI();
|
||||
|
||||
@ -65,12 +64,12 @@ PincodeWindow::PincodeWindow(bdaddr_t address, hci_id hid)
|
||||
|
||||
|
||||
PincodeWindow::PincodeWindow(RemoteDevice* rDevice)
|
||||
: BWindow(BRect(800, 200, 900, 300), "Pincode request",
|
||||
B_FLOATING_WINDOW,
|
||||
B_WILL_ACCEPT_FIRST_CLICK | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS,
|
||||
B_ALL_WORKSPACES)
|
||||
: BWindow(BRect(700, 200, 1000, 400), "PIN Code Request",
|
||||
B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
||||
{
|
||||
InitUI();
|
||||
|
||||
// TODO: Get more info about device" ote name/features/encry/auth... etc
|
||||
SetBDaddr(bdaddrUtils::ToString(rDevice->GetBluetoothAddress()));
|
||||
fHid = (rDevice->GetLocalDeviceOwner())->ID();
|
||||
@ -82,14 +81,24 @@ PincodeWindow::InitUI()
|
||||
{
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
|
||||
fMessage = new BStringView("Pincode", "Please enter the pincode ...");
|
||||
fMessage->SetFont(be_bold_font);
|
||||
fIcon = new BluetoothIconView();
|
||||
|
||||
fRemoteInfo = new BStringView("bdaddr","BD_ADDR: ");
|
||||
fMessage = new BStringView("fMessage", "Input the PIN code to pair with");
|
||||
fMessage2 = new BStringView("fMessage2", "the following Bluetooth device.");
|
||||
|
||||
// TODO: Pincode cannot be more than 16 bytes
|
||||
fPincodeText = new BTextControl("pincode TextControl", "PIN code:",
|
||||
"5555", NULL);
|
||||
fDeviceLabel = new BStringView("fDeviceLabel","Device Name: ");
|
||||
fDeviceLabel->SetFont(be_bold_font);
|
||||
|
||||
fDeviceText = new BStringView("fDeviceText", "<unknown_device>");
|
||||
|
||||
fAddressLabel = new BStringView("fAddressLabel", "MAC Address: ");
|
||||
fAddressLabel->SetFont(be_bold_font);
|
||||
|
||||
fAddressText = new BStringView("fAddressText", "<mac_address>");
|
||||
|
||||
fPincodeText = new BTextControl("fPINCode", "PIN Code:", "0000", NULL);
|
||||
fPincodeText->TextView()->SetMaxBytes(16 * sizeof(fPincodeText->Text()[0]));
|
||||
fPincodeText->MakeFocus();
|
||||
|
||||
fAcceptButton = new BButton("fAcceptButton", "Pair",
|
||||
new BMessage(skMessageAcceptButton));
|
||||
@ -97,27 +106,44 @@ PincodeWindow::InitUI()
|
||||
fCancelButton = new BButton("fCancelButton", "Cancel",
|
||||
new BMessage(skMessageCancelButton));
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 8)
|
||||
.Add(fIcon)
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||
.Add(fMessage)
|
||||
.Add(fRemoteInfo)
|
||||
.Add(fPincodeText)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
|
||||
.AddGlue()
|
||||
.Add(fCancelButton)
|
||||
.Add(fAcceptButton)
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
)
|
||||
.SetInsets(15, 15, 15, 15)
|
||||
.Add(fMessage2)
|
||||
.AddGlue()
|
||||
)
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||
.Add(fDeviceLabel)
|
||||
.AddGlue()
|
||||
.Add(fDeviceText)
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||
.Add(fAddressLabel)
|
||||
.AddGlue()
|
||||
.Add(fAddressText)
|
||||
)
|
||||
.AddGlue()
|
||||
.Add(fPincodeText)
|
||||
.AddGlue()
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
|
||||
.AddGlue()
|
||||
.Add(fCancelButton)
|
||||
.Add(fAcceptButton)
|
||||
)
|
||||
.SetInsets(8, 8, 8, 8)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PincodeWindow::MessageReceived(BMessage *msg)
|
||||
PincodeWindow::MessageReceived(BMessage* msg)
|
||||
{
|
||||
// status_t err = B_OK;
|
||||
|
||||
switch(msg->what)
|
||||
switch (msg->what)
|
||||
{
|
||||
case skMessageAcceptButton:
|
||||
{
|
||||
@ -142,7 +168,7 @@ PincodeWindow::MessageReceived(BMessage *msg)
|
||||
|
||||
// we reside in the server
|
||||
if (be_app_messenger.SendMessage(&request, &reply) == B_OK) {
|
||||
if (reply.FindInt8("status", &bt_status ) == B_OK ) {
|
||||
if (reply.FindInt8("status", &bt_status ) == B_OK) {
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
// TODO: something failed here
|
||||
@ -185,23 +211,17 @@ PincodeWindow::MessageReceived(BMessage *msg)
|
||||
}
|
||||
|
||||
|
||||
bool PincodeWindow::QuitRequested()
|
||||
bool
|
||||
PincodeWindow::QuitRequested()
|
||||
{
|
||||
return BWindow::QuitRequested();
|
||||
}
|
||||
|
||||
|
||||
void PincodeWindow::SetBDaddr(BString address)
|
||||
void
|
||||
PincodeWindow::SetBDaddr(BString address)
|
||||
{
|
||||
BString label;
|
||||
|
||||
label << BD_ADDR_LABEL << address;
|
||||
printf("++ %s\n",label.String());
|
||||
fRemoteInfo->SetText(label.String());
|
||||
fRemoteInfo->ResizeToPreferred();
|
||||
//Invalidate();
|
||||
|
||||
fAddressText->SetText(address);
|
||||
}
|
||||
|
||||
|
||||
} /* end namespace Bluetooth */
|
||||
|
Loading…
Reference in New Issue
Block a user