Bluetooth Pref: Inactiveate button and things that don't do anything.
* Inactiveate button and things that don't do anything. * Those button and controlles that hade any actions in the Bluetooth Pref now saves in settings. * Fix some windows/views. * Fix Copyright in last Bluetooth commit. * Last commit before we move saving settings with BMessage. * Changed PoupMenu to BOptionPopUp Change-Id: I32b85f1985b558d24b294a184665e08e6ce18a7d Reviewed-on: https://review.haiku-os.org/c/haiku/+/3829 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
6d93dff127
commit
91cbfa855e
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
* Copyright 2021, Haiku, Inc.
|
* Copyright 2021, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
|
||||||
* Tri-Edge AI <triedgeai@gmail.com>
|
* Tri-Edge AI <triedgeai@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
* Copyright 2021, Haiku, Inc.
|
* Copyright 2021, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Tri-Edge AI <triedgeai@gmail.com>
|
* Tri-Edge AI <triedgeai@gmail.com>
|
||||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CONNECTION_VIEW_H_
|
#ifndef _CONNECTION_VIEW_H_
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
* Copyright 2021, Haiku, Inc.
|
* Copyright 2021, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
* Copyright 2021, Haiku, Inc.
|
* Copyright 2021, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
|
||||||
* Tri-Edge AI <triedgeai@gmail.com>
|
* Tri-Edge AI <triedgeai@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
* Copyright 2021, Haiku, Inc.
|
* Copyright 2021, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
|
||||||
* Tri-Edge AI <triedgeai@gmail.com>
|
* Tri-Edge AI <triedgeai@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@gmail.com>
|
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@gmail.com>
|
||||||
* Copyright 2012-2013, Tri-Edge AI <triedgeai@gmail.com>
|
* Copyright 2012-2013, Tri-Edge AI <triedgeai@gmail.com>
|
||||||
|
* Copyright 2021, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* Authors:
|
||||||
|
* Fredrik Modéen <fredrik_at_modeen.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BluetoothSettings.h"
|
#include "BluetoothSettings.h"
|
||||||
|
|
||||||
BluetoothSettings::BluetoothSettings()
|
BluetoothSettings::BluetoothSettings()
|
||||||
@ -24,6 +26,8 @@ BluetoothSettings::Defaults()
|
|||||||
{
|
{
|
||||||
Data.PickedDevice = bdaddrUtils::NullAddress();
|
Data.PickedDevice = bdaddrUtils::NullAddress();
|
||||||
Data.LocalDeviceClass = DeviceClass();
|
Data.LocalDeviceClass = DeviceClass();
|
||||||
|
Data.Policy = 0;
|
||||||
|
Data.InquiryTime = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -34,7 +38,6 @@ BluetoothSettings::Load()
|
|||||||
|
|
||||||
if (fFile->InitCheck() == B_OK) {
|
if (fFile->InitCheck() == B_OK) {
|
||||||
fFile->Read(&Data, sizeof(Data));
|
fFile->Read(&Data, sizeof(Data));
|
||||||
// TODO: Add more settings here.
|
|
||||||
} else
|
} else
|
||||||
Defaults();
|
Defaults();
|
||||||
|
|
||||||
@ -49,7 +52,6 @@ BluetoothSettings::Save()
|
|||||||
|
|
||||||
if (fFile->InitCheck() == B_OK) {
|
if (fFile->InitCheck() == B_OK) {
|
||||||
fFile->Write(&Data, sizeof(Data));
|
fFile->Write(&Data, sizeof(Data));
|
||||||
// TODO: Add more settings here.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fFile;
|
delete fFile;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@gmail.com>
|
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@gmail.com>
|
||||||
* Copyright 2012-2013, Tri-Edge AI <triedgeai@gmail.com>
|
* Copyright 2012-2013, Tri-Edge AI <triedgeai@gmail.com>
|
||||||
|
* Copyright 2021, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* Authors:
|
||||||
|
* Fredrik Modéen <fredrik_at_modeen.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BLUETOOTH_SETTINGS_H
|
#ifndef BLUETOOTH_SETTINGS_H
|
||||||
@ -21,6 +24,8 @@ public:
|
|||||||
struct {
|
struct {
|
||||||
bdaddr_t PickedDevice;
|
bdaddr_t PickedDevice;
|
||||||
DeviceClass LocalDeviceClass;
|
DeviceClass LocalDeviceClass;
|
||||||
|
int32 Policy;
|
||||||
|
int32 InquiryTime;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
||||||
BluetoothSettings();
|
BluetoothSettings();
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2009, Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
* Copyright 2008-2009, Oliver Ruiz Dorantes <oliver.ruiz.dorantes@gmail.com>
|
||||||
* Copyright 2012-2013, Tri-Edge AI, <triedgeai@gmail.com>
|
* Copyright 2012-2013, Tri-Edge AI, <triedgeai@gmail.com>
|
||||||
|
* Copyright 2021, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* Authors:
|
||||||
|
* Fredrik Modéen <fredrik_at_modeen.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BluetoothSettingsView.h"
|
#include "BluetoothSettingsView.h"
|
||||||
@ -20,6 +23,7 @@
|
|||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
#include <OptionPopUp.h>
|
||||||
#include <Slider.h>
|
#include <Slider.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@ -31,11 +35,6 @@
|
|||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "Settings view"
|
#define B_TRANSLATION_CONTEXT "Settings view"
|
||||||
|
|
||||||
static const int32 kMsgSetConnectionPolicy = 'sCpo';
|
|
||||||
static const int32 kMsgSetDeviceClass = 'sDC0';
|
|
||||||
static const int32 kMsgSetInquiryTime = 'afEa';
|
|
||||||
static const int32 kMsgLocalSwitched = 'lDsW';
|
|
||||||
|
|
||||||
static const char* kAllLabel = B_TRANSLATE_MARK("From all devices");
|
static const char* kAllLabel = B_TRANSLATE_MARK("From all devices");
|
||||||
static const char* kTrustedLabel =
|
static const char* kTrustedLabel =
|
||||||
B_TRANSLATE_MARK("Only from trusted devices");
|
B_TRANSLATE_MARK("Only from trusted devices");
|
||||||
@ -56,18 +55,25 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name)
|
|||||||
{
|
{
|
||||||
fSettings.Load();
|
fSettings.Load();
|
||||||
|
|
||||||
_BuildConnectionPolicy();
|
fPolicyMenu = new BOptionPopUp("policy",
|
||||||
fPolicyMenuField = new BMenuField("policy",
|
B_TRANSLATE("Incoming connections policy:"),
|
||||||
B_TRANSLATE("Incoming connections policy:"), fPolicyMenu);
|
new BMessage(kMsgSetConnectionPolicy));
|
||||||
|
fPolicyMenu->AddOption(B_TRANSLATE_NOCOLLECT(kAllLabel), 1);
|
||||||
|
fPolicyMenu->AddOption(B_TRANSLATE_NOCOLLECT(kTrustedLabel), 2);
|
||||||
|
fPolicyMenu->AddOption(B_TRANSLATE_NOCOLLECT(kAlwaysLabel), 3);
|
||||||
|
|
||||||
fInquiryTimeControl = new BSlider("time",
|
fPolicyMenu->SetValue(fSettings.Data.Policy);
|
||||||
B_TRANSLATE("Default inquiry time:"), new BMessage(kMsgSetInquiryTime),
|
|
||||||
0, 255, B_HORIZONTAL);
|
BString label(B_TRANSLATE("Default inquiry time:"));
|
||||||
|
label << " " << fSettings.Data.InquiryTime;
|
||||||
|
fInquiryTimeControl = new BSlider("time", label.String()
|
||||||
|
, new BMessage(kMsgSetInquiryTime), 15, 61, B_HORIZONTAL);
|
||||||
fInquiryTimeControl->SetLimitLabels(B_TRANSLATE("15 secs"),
|
fInquiryTimeControl->SetLimitLabels(B_TRANSLATE("15 secs"),
|
||||||
B_TRANSLATE("61 secs"));
|
B_TRANSLATE("61 secs"));
|
||||||
fInquiryTimeControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
fInquiryTimeControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||||
fInquiryTimeControl->SetHashMarkCount(255 / 15);
|
fInquiryTimeControl->SetHashMarkCount(20);
|
||||||
fInquiryTimeControl->SetEnabled(true);
|
fInquiryTimeControl->SetEnabled(true);
|
||||||
|
fInquiryTimeControl->SetValue(fSettings.Data.InquiryTime);
|
||||||
|
|
||||||
fExtDeviceView = new ExtendedLocalDeviceView(NULL);
|
fExtDeviceView = new ExtendedLocalDeviceView(NULL);
|
||||||
|
|
||||||
@ -87,18 +93,20 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name)
|
|||||||
fSettings.Data.LocalDeviceClass = rememberedClass;
|
fSettings.Data.LocalDeviceClass = rememberedClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hinting menu
|
fClassMenu = new BOptionPopUp("DeviceClass", B_TRANSLATE("Identify host as:"),
|
||||||
_BuildClassMenu();
|
new BMessage(kMsgSetDeviceClass));
|
||||||
fClassMenuField = new BMenuField("class", B_TRANSLATE("Identify host as:"),
|
fClassMenu->AddOption(B_TRANSLATE_NOCOLLECT(kDesktopLabel), 1);
|
||||||
fClassMenu);
|
fClassMenu->AddOption(B_TRANSLATE_NOCOLLECT(kServerLabel), 2);
|
||||||
|
fClassMenu->AddOption(B_TRANSLATE_NOCOLLECT(kLaptopLabel), 3);
|
||||||
|
fClassMenu->AddOption(B_TRANSLATE_NOCOLLECT(kHandheldLabel), 4);
|
||||||
|
fClassMenu->AddOption(B_TRANSLATE_NOCOLLECT(kPhoneLabel), 5);
|
||||||
|
|
||||||
|
fClassMenu->SetValue(_GetClassForMenu());
|
||||||
|
|
||||||
BLayoutBuilder::Grid<>(this, 0)
|
BLayoutBuilder::Grid<>(this, 0)
|
||||||
.SetInsets(10)
|
.SetInsets(10)
|
||||||
.Add(fClassMenuField->CreateLabelLayoutItem(), 0, 0)
|
.Add(fClassMenu, 0, 0)
|
||||||
.Add(fClassMenuField->CreateMenuBarLayoutItem(), 1, 0)
|
.Add(fPolicyMenu, 0, 1)
|
||||||
|
|
||||||
.Add(fPolicyMenuField->CreateLabelLayoutItem(), 0, 1)
|
|
||||||
.Add(fPolicyMenuField->CreateMenuBarLayoutItem(), 1, 1)
|
|
||||||
|
|
||||||
.Add(fInquiryTimeControl, 0, 2, 2)
|
.Add(fInquiryTimeControl, 0, 2, 2)
|
||||||
|
|
||||||
@ -124,8 +132,6 @@ BluetoothSettingsView::AttachedToWindow()
|
|||||||
else
|
else
|
||||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
fPolicyMenu->SetTargetForItems(this);
|
|
||||||
fClassMenu->SetTargetForItems(this);
|
|
||||||
fLocalDevicesMenu->SetTargetForItems(this);
|
fLocalDevicesMenu->SetTargetForItems(this);
|
||||||
fInquiryTimeControl->SetTarget(this);
|
fInquiryTimeControl->SetTarget(this);
|
||||||
}
|
}
|
||||||
@ -134,7 +140,9 @@ BluetoothSettingsView::AttachedToWindow()
|
|||||||
void
|
void
|
||||||
BluetoothSettingsView::MessageReceived(BMessage* message)
|
BluetoothSettingsView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
//message->PrintToStream();
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
|
|
||||||
case kMsgLocalSwitched:
|
case kMsgLocalSwitched:
|
||||||
{
|
{
|
||||||
LocalDevice* lDevice;
|
LocalDevice* lDevice;
|
||||||
@ -147,27 +155,33 @@ BluetoothSettingsView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// TODO: To be fixed. :)
|
|
||||||
|
|
||||||
/*
|
|
||||||
case kMsgSetConnectionPolicy:
|
case kMsgSetConnectionPolicy:
|
||||||
{
|
{
|
||||||
//uint8 Policy;
|
int32 policy;
|
||||||
//if (message->FindInt8("Policy", (int8*)&Policy) == B_OK)
|
if (message->FindInt32("be:value", (int32*)&policy) == B_OK) {
|
||||||
|
fSettings.Data.Policy = policy;
|
||||||
|
printf("Policy = %d\n", fSettings.Data.Policy);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMsgSetInquiryTime:
|
case kMsgSetInquiryTime:
|
||||||
{
|
{
|
||||||
|
fSettings.Data.InquiryTime = fInquiryTimeControl->Value();
|
||||||
|
BString label(B_TRANSLATE("Default inquiry time:"));
|
||||||
|
label << " " << fInquiryTimeControl->Value();
|
||||||
|
fInquiryTimeControl->SetLabel(label.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
case kMsgSetDeviceClass:
|
case kMsgSetDeviceClass:
|
||||||
{
|
{
|
||||||
uint8 deviceClass;
|
int32 deviceClass;
|
||||||
|
if (message->FindInt32("be:value",
|
||||||
|
(int32*)&deviceClass) == B_OK) {
|
||||||
|
|
||||||
if (message->FindInt8("DeviceClass",
|
printf("deviceClass = %d\n", deviceClass);
|
||||||
(int8*)&deviceClass) == B_OK) {
|
|
||||||
|
|
||||||
if (deviceClass == 5)
|
if (deviceClass == 5)
|
||||||
_SetDeviceClass(2, 3, 0x72);
|
_SetDeviceClass(2, 3, 0x72);
|
||||||
@ -208,85 +222,6 @@ BluetoothSettingsView::_SetDeviceClass(uint8 major, uint8 minor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BluetoothSettingsView::_BuildConnectionPolicy()
|
|
||||||
{
|
|
||||||
BMessage* message = NULL;
|
|
||||||
BMenuItem* item = NULL;
|
|
||||||
|
|
||||||
fPolicyMenu = new BPopUpMenu(B_TRANSLATE("Policy" B_UTF8_ELLIPSIS));
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetConnectionPolicy);
|
|
||||||
message->AddInt8("Policy", 1);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kAllLabel), message);
|
|
||||||
fPolicyMenu->AddItem(item);
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetConnectionPolicy);
|
|
||||||
message->AddInt8("Policy", 2);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kTrustedLabel), message);
|
|
||||||
fPolicyMenu->AddItem(item);
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetConnectionPolicy);
|
|
||||||
message->AddInt8("Policy", 3);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kAlwaysLabel), NULL);
|
|
||||||
fPolicyMenu->AddItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BluetoothSettingsView::_BuildClassMenu()
|
|
||||||
{
|
|
||||||
BMessage* message = NULL;
|
|
||||||
BMenuItem* item = NULL;
|
|
||||||
|
|
||||||
fClassMenu = new BPopUpMenu(B_TRANSLATE("Identify us as" B_UTF8_ELLIPSIS));
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetDeviceClass);
|
|
||||||
message->AddInt8("DeviceClass", 1);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kDesktopLabel), message);
|
|
||||||
fClassMenu->AddItem(item);
|
|
||||||
|
|
||||||
if (fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 1 &&
|
|
||||||
fSettings.Data.LocalDeviceClass.MinorDeviceClass() == 1)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetDeviceClass);
|
|
||||||
message->AddInt8("DeviceClass", 2);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kServerLabel), message);
|
|
||||||
fClassMenu->AddItem(item);
|
|
||||||
|
|
||||||
if (fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 1 &&
|
|
||||||
fSettings.Data.LocalDeviceClass.MinorDeviceClass() == 2)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetDeviceClass);
|
|
||||||
message->AddInt8("DeviceClass", 3);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kLaptopLabel), message);
|
|
||||||
fClassMenu->AddItem(item);
|
|
||||||
|
|
||||||
if (fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 1 &&
|
|
||||||
fSettings.Data.LocalDeviceClass.MinorDeviceClass() == 3)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetDeviceClass);
|
|
||||||
message->AddInt8("DeviceClass", 4);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kHandheldLabel), message);
|
|
||||||
fClassMenu->AddItem(item);
|
|
||||||
|
|
||||||
if (fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 1 &&
|
|
||||||
fSettings.Data.LocalDeviceClass.MinorDeviceClass() == 4)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
message = new BMessage(kMsgSetDeviceClass);
|
|
||||||
message->AddInt8("DeviceClass", 5);
|
|
||||||
item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kPhoneLabel), message);
|
|
||||||
fClassMenu->AddItem(item);
|
|
||||||
|
|
||||||
if (fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 2 &&
|
|
||||||
fSettings.Data.LocalDeviceClass.MinorDeviceClass() == 3)
|
|
||||||
item->SetMarked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BluetoothSettingsView::_BuildLocalDevicesMenu()
|
BluetoothSettingsView::_BuildLocalDevicesMenu()
|
||||||
{
|
{
|
||||||
@ -338,3 +273,22 @@ BluetoothSettingsView::_MarkLocalDevice(LocalDevice* lDevice)
|
|||||||
ActiveLocalDevice = lDevice;
|
ActiveLocalDevice = lDevice;
|
||||||
fSettings.Data.PickedDevice = lDevice->GetBluetoothAddress();
|
fSettings.Data.PickedDevice = lDevice->GetBluetoothAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
BluetoothSettingsView::_GetClassForMenu()
|
||||||
|
{
|
||||||
|
int deviceClass = fSettings.Data.LocalDeviceClass.MajorDeviceClass() +
|
||||||
|
fSettings.Data.LocalDeviceClass.MinorDeviceClass()-1;
|
||||||
|
|
||||||
|
// As of now we only support MajorDeviceClass = 1 and MinorDeviceClass 1-4
|
||||||
|
// and MajorDeviceClass = 2 and MinorDeviceClass 3.
|
||||||
|
if ((fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 1
|
||||||
|
&& (fSettings.Data.LocalDeviceClass.MinorDeviceClass() > 0
|
||||||
|
&& fSettings.Data.LocalDeviceClass.MinorDeviceClass() < 5))
|
||||||
|
|| (fSettings.Data.LocalDeviceClass.MajorDeviceClass() == 2 &&
|
||||||
|
fSettings.Data.LocalDeviceClass.MinorDeviceClass() == 3))
|
||||||
|
return deviceClass; //No other wil have the same number.
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@ class BBox;
|
|||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BSlider;
|
class BSlider;
|
||||||
|
class BOptionPopUp;
|
||||||
|
|
||||||
class BluetoothSettingsView : public BView {
|
class BluetoothSettingsView : public BView {
|
||||||
public:
|
public:
|
||||||
@ -30,22 +31,19 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _BuildConnectionPolicy();
|
|
||||||
void _BuildClassMenu();
|
|
||||||
void _BuildLocalDevicesMenu();
|
void _BuildLocalDevicesMenu();
|
||||||
bool _SetDeviceClass(uint8 major, uint8 minor,
|
bool _SetDeviceClass(uint8 major, uint8 minor,
|
||||||
uint16 service);
|
uint16 service);
|
||||||
void _MarkLocalDevice(LocalDevice* lDevice);
|
void _MarkLocalDevice(LocalDevice* lDevice);
|
||||||
|
int _GetClassForMenu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BluetoothSettings fSettings;
|
BluetoothSettings fSettings;
|
||||||
|
|
||||||
float fDivider;
|
float fDivider;
|
||||||
|
|
||||||
BMenuField* fPolicyMenuField;
|
BOptionPopUp* fPolicyMenu;
|
||||||
BPopUpMenu* fPolicyMenu;
|
BOptionPopUp* fClassMenu;
|
||||||
BMenuField* fClassMenuField;
|
|
||||||
BPopUpMenu* fClassMenu;
|
|
||||||
BMenuField* fLocalDevicesMenuField;
|
BMenuField* fLocalDevicesMenuField;
|
||||||
BPopUpMenu* fLocalDevicesMenu;
|
BPopUpMenu* fLocalDevicesMenu;
|
||||||
|
|
||||||
|
@ -41,9 +41,11 @@ BluetoothWindow::BluetoothWindow(BRect frame)
|
|||||||
{
|
{
|
||||||
fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
|
fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
|
||||||
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
|
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
|
||||||
|
fDefaultsButton->SetEnabled(false);
|
||||||
|
|
||||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||||
new BMessage(kMsgRevert), B_WILL_DRAW);
|
new BMessage(kMsgRevert), B_WILL_DRAW);
|
||||||
|
fRevertButton->SetEnabled(false);
|
||||||
|
|
||||||
// Add the menu bar
|
// Add the menu bar
|
||||||
fMenubar = new BMenuBar(Bounds(), "menu_bar");
|
fMenubar = new BMenuBar(Bounds(), "menu_bar");
|
||||||
@ -71,16 +73,12 @@ BluetoothWindow::BluetoothWindow(BRect frame)
|
|||||||
tabView->SetBorder(B_NO_BORDER);
|
tabView->SetBorder(B_NO_BORDER);
|
||||||
|
|
||||||
fSettingsView = new BluetoothSettingsView(B_TRANSLATE("Settings"));
|
fSettingsView = new BluetoothSettingsView(B_TRANSLATE("Settings"));
|
||||||
// fConnChan = new ConnChanView("Connections & Channels", B_WILL_DRAW);
|
|
||||||
fRemoteDevices = new RemoteDevicesView(
|
fRemoteDevices = new RemoteDevicesView(
|
||||||
B_TRANSLATE("Remote devices"), B_WILL_DRAW);
|
B_TRANSLATE("Remote devices"), B_WILL_DRAW);
|
||||||
|
|
||||||
tabView->AddTab(fRemoteDevices);
|
tabView->AddTab(fRemoteDevices);
|
||||||
// tabView->AddTab(fConnChan);
|
|
||||||
tabView->AddTab(fSettingsView);
|
tabView->AddTab(fSettingsView);
|
||||||
|
|
||||||
fRevertButton->SetEnabled(false);
|
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||||
.SetInsets(0)
|
.SetInsets(0)
|
||||||
.Add(fMenubar)
|
.Add(fMenubar)
|
||||||
@ -102,7 +100,13 @@ BluetoothWindow::BluetoothWindow(BRect frame)
|
|||||||
void
|
void
|
||||||
BluetoothWindow::MessageReceived(BMessage* message)
|
BluetoothWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
//message->PrintToStream();
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
|
case kMsgSetConnectionPolicy:
|
||||||
|
case kMsgSetDeviceClass:
|
||||||
|
fSettingsView->MessageReceived(message);
|
||||||
|
break;
|
||||||
|
|
||||||
case kMsgSetDefaults:
|
case kMsgSetDefaults:
|
||||||
/* fColorsView -> MessageReceived(new BMessage(DEFAULT_SETTINGS));
|
/* fColorsView -> MessageReceived(new BMessage(DEFAULT_SETTINGS));
|
||||||
fAntialiasingSettings->SetDefaults();
|
fAntialiasingSettings->SetDefaults();
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
class BluetoothSettingsView;
|
class BluetoothSettingsView;
|
||||||
class RemoteDevicesView;
|
class RemoteDevicesView;
|
||||||
class ConnChanView;
|
|
||||||
|
|
||||||
class BluetoothWindow : public BWindow {
|
class BluetoothWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
@ -26,7 +25,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RemoteDevicesView* fRemoteDevices;
|
RemoteDevicesView* fRemoteDevices;
|
||||||
ConnChanView* fConnChan;
|
|
||||||
BButton* fDefaultsButton;
|
BButton* fDefaultsButton;
|
||||||
BButton* fRevertButton;
|
BButton* fRevertButton;
|
||||||
BMenuBar* fMenubar;
|
BMenuBar* fMenubar;
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <bluetooth/bdaddrUtils.h>
|
#include <bluetooth/bdaddrUtils.h>
|
||||||
#include <bluetooth/BluetoothDevice.h>
|
#include <bluetooth/BluetoothDevice.h>
|
||||||
/*#include "../media/iconfile.h"*/
|
|
||||||
|
|
||||||
#include "DeviceListItem.h"
|
#include "DeviceListItem.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
|
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@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:
|
||||||
|
* Fredrik Modéen <fredrik_at_modeen.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ExtendedLocalDeviceView.h"
|
#include "ExtendedLocalDeviceView.h"
|
||||||
|
|
||||||
#include <bluetooth/bdaddrUtils.h>
|
#include <bluetooth/bdaddrUtils.h>
|
||||||
@ -34,6 +39,7 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(LocalDevice* bDevice,
|
|||||||
B_TRANSLATE("Show name"), new BMessage(SET_VISIBLE));
|
B_TRANSLATE("Show name"), new BMessage(SET_VISIBLE));
|
||||||
fAuthentication = new BCheckBox("Authenticate",
|
fAuthentication = new BCheckBox("Authenticate",
|
||||||
B_TRANSLATE("Authenticate"), new BMessage(SET_AUTHENTICATION));
|
B_TRANSLATE("Authenticate"), new BMessage(SET_AUTHENTICATION));
|
||||||
|
fAuthentication->SetEnabled(false);
|
||||||
|
|
||||||
SetEnabled(false);
|
SetEnabled(false);
|
||||||
|
|
||||||
@ -42,11 +48,10 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(LocalDevice* bDevice,
|
|||||||
.Add(fDeviceView)
|
.Add(fDeviceView)
|
||||||
.AddGroup(B_HORIZONTAL, 0)
|
.AddGroup(B_HORIZONTAL, 0)
|
||||||
.SetInsets(5)
|
.SetInsets(5)
|
||||||
.AddGlue()
|
|
||||||
.Add(fDiscoverable)
|
.Add(fDiscoverable)
|
||||||
.Add(fVisible)
|
.Add(fVisible)
|
||||||
.End()
|
|
||||||
.Add(fAuthentication)
|
.Add(fAuthentication)
|
||||||
|
.End()
|
||||||
.End();
|
.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +72,6 @@ ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice)
|
|||||||
ClearDevice();
|
ClearDevice();
|
||||||
|
|
||||||
int value = fDevice->GetDiscoverable();
|
int value = fDevice->GetDiscoverable();
|
||||||
printf("ExtendedLocalDeviceView::SetLocalDevice value = %d\n", value);
|
|
||||||
if (value == 1)
|
if (value == 1)
|
||||||
fDiscoverable->SetValue(true);
|
fDiscoverable->SetValue(true);
|
||||||
else if (value == 2)
|
else if (value == 2)
|
||||||
@ -76,6 +80,11 @@ ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice)
|
|||||||
fDiscoverable->SetValue(true);
|
fDiscoverable->SetValue(true);
|
||||||
fVisible->SetValue(true);
|
fVisible->SetValue(true);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
// TODO implement GetAuthentication in LocalDevice
|
||||||
|
if (fDevice->GetAuthentication())
|
||||||
|
fAuthentication->SetValue(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,16 +124,14 @@ ExtendedLocalDeviceView::MessageReceived(BMessage* message)
|
|||||||
case SET_VISIBLE:
|
case SET_VISIBLE:
|
||||||
fScanMode = 0;
|
fScanMode = 0;
|
||||||
|
|
||||||
if (fDiscoverable->Value()) {
|
if (fDiscoverable->Value())
|
||||||
fScanMode = 1;
|
fScanMode = 1;
|
||||||
fVisible->SetEnabled(true);
|
|
||||||
} else {
|
|
||||||
fVisible->SetValue(false);
|
|
||||||
fVisible->SetEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fVisible->Value())
|
if (fVisible->Value())
|
||||||
fScanMode |= 2;
|
fScanMode = 2;
|
||||||
|
|
||||||
|
if (fVisible->Value() && fDiscoverable->Value())
|
||||||
|
fScanMode = 3;
|
||||||
|
|
||||||
if (fDevice != NULL)
|
if (fDevice != NULL)
|
||||||
fDevice->SetDiscoverable(fScanMode);
|
fDevice->SetDiscoverable(fScanMode);
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
|
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@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:
|
||||||
|
* Fredrik Modéen <fredrik_at_modeen.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@ -63,9 +67,7 @@ public:
|
|||||||
DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod)
|
DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod)
|
||||||
{
|
{
|
||||||
BMessage* message = new BMessage(kMsgAddListDevice);
|
BMessage* message = new BMessage(kMsgAddListDevice);
|
||||||
|
|
||||||
message->AddPointer("remoteItem", new DeviceListItem(btDevice));
|
message->AddPointer("remoteItem", new DeviceListItem(btDevice));
|
||||||
|
|
||||||
fInquiryPanel->PostMessage(message);
|
fInquiryPanel->PostMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,11 +151,11 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
|
|||||||
fRetrieveMessage = new BMessage(kMsgRetrieve);
|
fRetrieveMessage = new BMessage(kMsgRetrieve);
|
||||||
fSecondsMessage = new BMessage(kMsgSecond);
|
fSecondsMessage = new BMessage(kMsgSecond);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 10)
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||||
.SetInsets(15)
|
.SetInsets(B_USE_SMALL_SPACING)
|
||||||
.Add(fMessage)
|
.Add(fMessage, 0)
|
||||||
.Add(fScanProgress, 10)
|
.Add(fScanProgress, 10)
|
||||||
.Add(fScrollView)
|
.Add(fScrollView, 20)
|
||||||
.AddGroup(B_HORIZONTAL, 10)
|
.AddGroup(B_HORIZONTAL, 10)
|
||||||
.Add(fAddButton)
|
.Add(fAddButton)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
|
* Copyright 2008-2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes@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:
|
||||||
|
* Fredrik Modéen <fredrik_at_modeen.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@ -33,8 +38,8 @@ static const uint32 kMsgAddDevices = 'ddDv';
|
|||||||
static const uint32 kMsgRemoveDevice = 'rmDv';
|
static const uint32 kMsgRemoveDevice = 'rmDv';
|
||||||
static const uint32 kMsgPairDevice = 'trDv';
|
static const uint32 kMsgPairDevice = 'trDv';
|
||||||
static const uint32 kMsgDisconnectDevice = 'dsDv';
|
static const uint32 kMsgDisconnectDevice = 'dsDv';
|
||||||
static const uint32 kMsgBlockDevice = 'blDv';
|
//static const uint32 kMsgBlockDevice = 'blDv';
|
||||||
static const uint32 kMsgRefreshDevices = 'rfDv';
|
//static const uint32 kMsgRefreshDevices = 'rfDv';
|
||||||
|
|
||||||
using namespace Bluetooth;
|
using namespace Bluetooth;
|
||||||
|
|
||||||
@ -52,14 +57,13 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
|
|||||||
|
|
||||||
disconnectButton = new BButton("disconnect", B_TRANSLATE("Disconnect"),
|
disconnectButton = new BButton("disconnect", B_TRANSLATE("Disconnect"),
|
||||||
new BMessage(kMsgDisconnectDevice));
|
new BMessage(kMsgDisconnectDevice));
|
||||||
|
/*
|
||||||
blockButton = new BButton("block", B_TRANSLATE("As blocked"),
|
blockButton = new BButton("block", B_TRANSLATE("As blocked"),
|
||||||
new BMessage(kMsgBlockDevice));
|
new BMessage(kMsgBlockDevice));
|
||||||
|
|
||||||
|
|
||||||
availButton = new BButton("check", B_TRANSLATE("Refresh" B_UTF8_ELLIPSIS),
|
availButton = new BButton("check", B_TRANSLATE("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);
|
||||||
|
|
||||||
@ -74,11 +78,11 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
|
|||||||
.Add(addButton)
|
.Add(addButton)
|
||||||
.Add(removeButton)
|
.Add(removeButton)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(availButton)
|
// .Add(availButton)
|
||||||
.AddGlue()
|
// .AddGlue()
|
||||||
.Add(pairButton)
|
.Add(pairButton)
|
||||||
.Add(disconnectButton)
|
.Add(disconnectButton)
|
||||||
.Add(blockButton)
|
// .Add(blockButton)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.End()
|
.End()
|
||||||
.End();
|
.End();
|
||||||
@ -101,8 +105,8 @@ RemoteDevicesView::AttachedToWindow(void)
|
|||||||
removeButton->SetTarget(this);
|
removeButton->SetTarget(this);
|
||||||
pairButton->SetTarget(this);
|
pairButton->SetTarget(this);
|
||||||
disconnectButton->SetTarget(this);
|
disconnectButton->SetTarget(this);
|
||||||
blockButton->SetTarget(this);
|
// blockButton->SetTarget(this);
|
||||||
availButton->SetTarget(this);
|
// availButton->SetTarget(this);
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
fDeviceList->Select(0);
|
fDeviceList->Select(0);
|
||||||
@ -122,8 +126,6 @@ RemoteDevicesView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case kMsgRemoveDevice:
|
case kMsgRemoveDevice:
|
||||||
printf("kMsgRemoveDevice: %" B_PRId32 "\n",
|
|
||||||
fDeviceList->CurrentSelection(0));
|
|
||||||
fDeviceList->RemoveItem(fDeviceList->CurrentSelection(0));
|
fDeviceList->RemoveItem(fDeviceList->CurrentSelection(0));
|
||||||
break;
|
break;
|
||||||
case kMsgAddToRemoteList:
|
case kMsgAddToRemoteList:
|
||||||
|
@ -43,8 +43,8 @@ protected:
|
|||||||
BButton* removeButton;
|
BButton* removeButton;
|
||||||
BButton* pairButton;
|
BButton* pairButton;
|
||||||
BButton* disconnectButton;
|
BButton* disconnectButton;
|
||||||
BButton* blockButton;
|
// BButton* blockButton;
|
||||||
BButton* availButton;
|
// BButton* availButton;
|
||||||
BListView* fDeviceList;
|
BListView* fDeviceList;
|
||||||
BScrollView* fScrollView;
|
BScrollView* fScrollView;
|
||||||
|
|
||||||
|
@ -31,6 +31,11 @@ const uint32 kItemSpace = 7;
|
|||||||
static const uint32 kMsgAddToRemoteList = 'aDdL';
|
static const uint32 kMsgAddToRemoteList = 'aDdL';
|
||||||
static const uint32 kMsgRefresh = 'rFLd';
|
static const uint32 kMsgRefresh = 'rFLd';
|
||||||
|
|
||||||
|
static const int32 kMsgSetConnectionPolicy = 'sCpo';
|
||||||
|
static const int32 kMsgSetDeviceClass = 'sDC0';
|
||||||
|
static const int32 kMsgSetInquiryTime = 'afEa';
|
||||||
|
static const int32 kMsgLocalSwitched = 'lDsW';
|
||||||
|
|
||||||
extern LocalDevice* ActiveLocalDevice;
|
extern LocalDevice* ActiveLocalDevice;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user