diff --git a/headers/private/bluetooth/ConnectionIncoming.h b/headers/private/bluetooth/ConnectionIncoming.h index 5924fed21c..2d03713262 100644 --- a/headers/private/bluetooth/ConnectionIncoming.h +++ b/headers/private/bluetooth/ConnectionIncoming.h @@ -1,9 +1,9 @@ /* +* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2021, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: -* Oliver Ruiz Dorantes * Tri-Edge AI */ diff --git a/headers/private/bluetooth/ConnectionView.h b/headers/private/bluetooth/ConnectionView.h index 38e2b04cc1..7d9d7f83c8 100644 --- a/headers/private/bluetooth/ConnectionView.h +++ b/headers/private/bluetooth/ConnectionView.h @@ -1,10 +1,10 @@ /* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2021, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: * Tri-Edge AI - * Oliver Ruiz Dorantes */ #ifndef _CONNECTION_VIEW_H_ diff --git a/headers/private/bluetooth/PincodeWindow.h b/headers/private/bluetooth/PincodeWindow.h index 169ab79124..7963ee2ec1 100644 --- a/headers/private/bluetooth/PincodeWindow.h +++ b/headers/private/bluetooth/PincodeWindow.h @@ -1,4 +1,5 @@ /* +* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2021, Haiku, Inc. * Distributed under the terms of the MIT License. * diff --git a/src/kits/bluetooth/UI/ConnectionIncoming.cpp b/src/kits/bluetooth/UI/ConnectionIncoming.cpp index c76fc38818..0f5ccb2dd1 100644 --- a/src/kits/bluetooth/UI/ConnectionIncoming.cpp +++ b/src/kits/bluetooth/UI/ConnectionIncoming.cpp @@ -1,9 +1,9 @@ /* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2021, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: - * Oliver Ruiz Dorantes * Tri-Edge AI */ diff --git a/src/kits/bluetooth/UI/PincodeWindow.cpp b/src/kits/bluetooth/UI/PincodeWindow.cpp index e911b20457..f1f2612641 100644 --- a/src/kits/bluetooth/UI/PincodeWindow.cpp +++ b/src/kits/bluetooth/UI/PincodeWindow.cpp @@ -1,9 +1,9 @@ /* + * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2021, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: - * Oliver Ruiz Dorantes * Tri-Edge AI */ diff --git a/src/preferences/bluetooth/BluetoothSettings.cpp b/src/preferences/bluetooth/BluetoothSettings.cpp index 8e398061f4..d31d6da4b3 100644 --- a/src/preferences/bluetooth/BluetoothSettings.cpp +++ b/src/preferences/bluetooth/BluetoothSettings.cpp @@ -1,10 +1,12 @@ /* * Copyright 2008-2009, Oliver Ruiz Dorantes, * Copyright 2012-2013, Tri-Edge AI + * 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 */ - #include "BluetoothSettings.h" BluetoothSettings::BluetoothSettings() @@ -24,6 +26,8 @@ BluetoothSettings::Defaults() { Data.PickedDevice = bdaddrUtils::NullAddress(); Data.LocalDeviceClass = DeviceClass(); + Data.Policy = 0; + Data.InquiryTime = 15; } @@ -34,7 +38,6 @@ BluetoothSettings::Load() if (fFile->InitCheck() == B_OK) { fFile->Read(&Data, sizeof(Data)); - // TODO: Add more settings here. } else Defaults(); @@ -49,7 +52,6 @@ BluetoothSettings::Save() if (fFile->InitCheck() == B_OK) { fFile->Write(&Data, sizeof(Data)); - // TODO: Add more settings here. } delete fFile; diff --git a/src/preferences/bluetooth/BluetoothSettings.h b/src/preferences/bluetooth/BluetoothSettings.h index 0ba558b150..e13d489baa 100644 --- a/src/preferences/bluetooth/BluetoothSettings.h +++ b/src/preferences/bluetooth/BluetoothSettings.h @@ -1,8 +1,11 @@ /* * Copyright 2008-2009, Oliver Ruiz Dorantes, * Copyright 2012-2013, Tri-Edge AI + * 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 */ #ifndef BLUETOOTH_SETTINGS_H @@ -21,6 +24,8 @@ public: struct { bdaddr_t PickedDevice; DeviceClass LocalDeviceClass; + int32 Policy; + int32 InquiryTime; } Data; BluetoothSettings(); diff --git a/src/preferences/bluetooth/BluetoothSettingsView.cpp b/src/preferences/bluetooth/BluetoothSettingsView.cpp index 1302b9cf99..13e9afdb98 100644 --- a/src/preferences/bluetooth/BluetoothSettingsView.cpp +++ b/src/preferences/bluetooth/BluetoothSettingsView.cpp @@ -1,8 +1,11 @@ /* * Copyright 2008-2009, Oliver Ruiz Dorantes * Copyright 2012-2013, Tri-Edge AI, + * 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 */ #include "BluetoothSettingsView.h" @@ -20,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -31,11 +35,6 @@ #undef B_TRANSLATION_CONTEXT #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* kTrustedLabel = B_TRANSLATE_MARK("Only from trusted devices"); @@ -56,18 +55,25 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name) { fSettings.Load(); - _BuildConnectionPolicy(); - fPolicyMenuField = new BMenuField("policy", - B_TRANSLATE("Incoming connections policy:"), fPolicyMenu); + fPolicyMenu = new BOptionPopUp("policy", + B_TRANSLATE("Incoming connections policy:"), + 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", - B_TRANSLATE("Default inquiry time:"), new BMessage(kMsgSetInquiryTime), - 0, 255, B_HORIZONTAL); + fPolicyMenu->SetValue(fSettings.Data.Policy); + + 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"), B_TRANSLATE("61 secs")); fInquiryTimeControl->SetHashMarks(B_HASH_MARKS_BOTTOM); - fInquiryTimeControl->SetHashMarkCount(255 / 15); + fInquiryTimeControl->SetHashMarkCount(20); fInquiryTimeControl->SetEnabled(true); + fInquiryTimeControl->SetValue(fSettings.Data.InquiryTime); fExtDeviceView = new ExtendedLocalDeviceView(NULL); @@ -87,18 +93,20 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name) fSettings.Data.LocalDeviceClass = rememberedClass; } - // hinting menu - _BuildClassMenu(); - fClassMenuField = new BMenuField("class", B_TRANSLATE("Identify host as:"), - fClassMenu); + fClassMenu = new BOptionPopUp("DeviceClass", B_TRANSLATE("Identify host as:"), + new BMessage(kMsgSetDeviceClass)); + fClassMenu->AddOption(B_TRANSLATE_NOCOLLECT(kDesktopLabel), 1); + 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) .SetInsets(10) - .Add(fClassMenuField->CreateLabelLayoutItem(), 0, 0) - .Add(fClassMenuField->CreateMenuBarLayoutItem(), 1, 0) - - .Add(fPolicyMenuField->CreateLabelLayoutItem(), 0, 1) - .Add(fPolicyMenuField->CreateMenuBarLayoutItem(), 1, 1) + .Add(fClassMenu, 0, 0) + .Add(fPolicyMenu, 0, 1) .Add(fInquiryTimeControl, 0, 2, 2) @@ -124,8 +132,6 @@ BluetoothSettingsView::AttachedToWindow() else SetViewUIColor(B_PANEL_BACKGROUND_COLOR); - fPolicyMenu->SetTargetForItems(this); - fClassMenu->SetTargetForItems(this); fLocalDevicesMenu->SetTargetForItems(this); fInquiryTimeControl->SetTarget(this); } @@ -134,7 +140,9 @@ BluetoothSettingsView::AttachedToWindow() void BluetoothSettingsView::MessageReceived(BMessage* message) { + //message->PrintToStream(); switch (message->what) { + case kMsgLocalSwitched: { LocalDevice* lDevice; @@ -147,27 +155,33 @@ BluetoothSettingsView::MessageReceived(BMessage* message) break; } - // TODO: To be fixed. :) - /* case kMsgSetConnectionPolicy: { - //uint8 Policy; - //if (message->FindInt8("Policy", (int8*)&Policy) == B_OK) + int32 policy; + if (message->FindInt32("be:value", (int32*)&policy) == B_OK) { + fSettings.Data.Policy = policy; + printf("Policy = %d\n", fSettings.Data.Policy); + } break; } case kMsgSetInquiryTime: { + fSettings.Data.InquiryTime = fInquiryTimeControl->Value(); + BString label(B_TRANSLATE("Default inquiry time:")); + label << " " << fInquiryTimeControl->Value(); + fInquiryTimeControl->SetLabel(label.String()); break; } - */ + case kMsgSetDeviceClass: { - uint8 deviceClass; + int32 deviceClass; + if (message->FindInt32("be:value", + (int32*)&deviceClass) == B_OK) { - if (message->FindInt8("DeviceClass", - (int8*)&deviceClass) == B_OK) { + printf("deviceClass = %d\n", deviceClass); if (deviceClass == 5) _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 BluetoothSettingsView::_BuildLocalDevicesMenu() { @@ -338,3 +273,22 @@ BluetoothSettingsView::_MarkLocalDevice(LocalDevice* lDevice) ActiveLocalDevice = lDevice; 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; +} diff --git a/src/preferences/bluetooth/BluetoothSettingsView.h b/src/preferences/bluetooth/BluetoothSettingsView.h index a083c0e083..2c6f02eb7f 100644 --- a/src/preferences/bluetooth/BluetoothSettingsView.h +++ b/src/preferences/bluetooth/BluetoothSettingsView.h @@ -19,6 +19,7 @@ class BBox; class BMenuField; class BPopUpMenu; class BSlider; +class BOptionPopUp; class BluetoothSettingsView : public BView { public: @@ -30,22 +31,19 @@ public: private: - void _BuildConnectionPolicy(); - void _BuildClassMenu(); void _BuildLocalDevicesMenu(); bool _SetDeviceClass(uint8 major, uint8 minor, uint16 service); void _MarkLocalDevice(LocalDevice* lDevice); + int _GetClassForMenu(); protected: BluetoothSettings fSettings; float fDivider; - BMenuField* fPolicyMenuField; - BPopUpMenu* fPolicyMenu; - BMenuField* fClassMenuField; - BPopUpMenu* fClassMenu; + BOptionPopUp* fPolicyMenu; + BOptionPopUp* fClassMenu; BMenuField* fLocalDevicesMenuField; BPopUpMenu* fLocalDevicesMenu; diff --git a/src/preferences/bluetooth/BluetoothWindow.cpp b/src/preferences/bluetooth/BluetoothWindow.cpp index c39cb157c8..a119f78ee5 100644 --- a/src/preferences/bluetooth/BluetoothWindow.cpp +++ b/src/preferences/bluetooth/BluetoothWindow.cpp @@ -41,9 +41,11 @@ BluetoothWindow::BluetoothWindow(BRect frame) { fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"), new BMessage(kMsgSetDefaults), B_WILL_DRAW); + fDefaultsButton->SetEnabled(false); fRevertButton = new BButton("revert", B_TRANSLATE("Revert"), new BMessage(kMsgRevert), B_WILL_DRAW); + fRevertButton->SetEnabled(false); // Add the menu bar fMenubar = new BMenuBar(Bounds(), "menu_bar"); @@ -71,16 +73,12 @@ BluetoothWindow::BluetoothWindow(BRect frame) tabView->SetBorder(B_NO_BORDER); fSettingsView = new BluetoothSettingsView(B_TRANSLATE("Settings")); -// fConnChan = new ConnChanView("Connections & Channels", B_WILL_DRAW); fRemoteDevices = new RemoteDevicesView( B_TRANSLATE("Remote devices"), B_WILL_DRAW); tabView->AddTab(fRemoteDevices); -// tabView->AddTab(fConnChan); tabView->AddTab(fSettingsView); - fRevertButton->SetEnabled(false); - BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(0) .Add(fMenubar) @@ -102,7 +100,13 @@ BluetoothWindow::BluetoothWindow(BRect frame) void BluetoothWindow::MessageReceived(BMessage* message) { + //message->PrintToStream(); switch (message->what) { + case kMsgSetConnectionPolicy: + case kMsgSetDeviceClass: + fSettingsView->MessageReceived(message); + break; + case kMsgSetDefaults: /* fColorsView -> MessageReceived(new BMessage(DEFAULT_SETTINGS)); fAntialiasingSettings->SetDefaults(); diff --git a/src/preferences/bluetooth/BluetoothWindow.h b/src/preferences/bluetooth/BluetoothWindow.h index 71e8fc5854..c2dc653d0d 100644 --- a/src/preferences/bluetooth/BluetoothWindow.h +++ b/src/preferences/bluetooth/BluetoothWindow.h @@ -16,7 +16,6 @@ class BluetoothSettingsView; class RemoteDevicesView; -class ConnChanView; class BluetoothWindow : public BWindow { public: @@ -26,7 +25,6 @@ public: private: RemoteDevicesView* fRemoteDevices; - ConnChanView* fConnChan; BButton* fDefaultsButton; BButton* fRevertButton; BMenuBar* fMenubar; diff --git a/src/preferences/bluetooth/DeviceListItem.cpp b/src/preferences/bluetooth/DeviceListItem.cpp index 0b64d0abd5..1835ca5c22 100644 --- a/src/preferences/bluetooth/DeviceListItem.cpp +++ b/src/preferences/bluetooth/DeviceListItem.cpp @@ -8,7 +8,6 @@ #include #include -/*#include "../media/iconfile.h"*/ #include "DeviceListItem.h" diff --git a/src/preferences/bluetooth/ExtendedLocalDeviceView.cpp b/src/preferences/bluetooth/ExtendedLocalDeviceView.cpp index 9cfad3c7ef..d8b9cd4d03 100644 --- a/src/preferences/bluetooth/ExtendedLocalDeviceView.cpp +++ b/src/preferences/bluetooth/ExtendedLocalDeviceView.cpp @@ -1,7 +1,12 @@ /* - * Copyright 2008-09, Oliver Ruiz Dorantes, - * All rights reserved. Distributed under the terms of the MIT License. + * Copyright 2008-2009, Oliver Ruiz Dorantes, + * Copyright 2021, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fredrik Modéen */ + #include "ExtendedLocalDeviceView.h" #include @@ -34,6 +39,7 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(LocalDevice* bDevice, B_TRANSLATE("Show name"), new BMessage(SET_VISIBLE)); fAuthentication = new BCheckBox("Authenticate", B_TRANSLATE("Authenticate"), new BMessage(SET_AUTHENTICATION)); + fAuthentication->SetEnabled(false); SetEnabled(false); @@ -42,11 +48,10 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(LocalDevice* bDevice, .Add(fDeviceView) .AddGroup(B_HORIZONTAL, 0) .SetInsets(5) - .AddGlue() .Add(fDiscoverable) .Add(fVisible) + .Add(fAuthentication) .End() - .Add(fAuthentication) .End(); } @@ -67,7 +72,6 @@ ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice) ClearDevice(); int value = fDevice->GetDiscoverable(); - printf("ExtendedLocalDeviceView::SetLocalDevice value = %d\n", value); if (value == 1) fDiscoverable->SetValue(true); else if (value == 2) @@ -76,6 +80,11 @@ ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice) fDiscoverable->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: fScanMode = 0; - if (fDiscoverable->Value()) { + if (fDiscoverable->Value()) fScanMode = 1; - fVisible->SetEnabled(true); - } else { - fVisible->SetValue(false); - fVisible->SetEnabled(false); - } if (fVisible->Value()) - fScanMode |= 2; + fScanMode = 2; + + if (fVisible->Value() && fDiscoverable->Value()) + fScanMode = 3; if (fDevice != NULL) fDevice->SetDiscoverable(fScanMode); diff --git a/src/preferences/bluetooth/InquiryPanel.cpp b/src/preferences/bluetooth/InquiryPanel.cpp index 02778522b0..1cd5f2794d 100644 --- a/src/preferences/bluetooth/InquiryPanel.cpp +++ b/src/preferences/bluetooth/InquiryPanel.cpp @@ -1,6 +1,10 @@ /* - * Copyright 2008-09, Oliver Ruiz Dorantes, - * All rights reserved. Distributed under the terms of the MIT License. + * Copyright 2008-2009, Oliver Ruiz Dorantes, + * Copyright 2021, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fredrik Modéen */ #include @@ -63,9 +67,7 @@ public: DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod) { BMessage* message = new BMessage(kMsgAddListDevice); - message->AddPointer("remoteItem", new DeviceListItem(btDevice)); - fInquiryPanel->PostMessage(message); } @@ -149,11 +151,11 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) fRetrieveMessage = new BMessage(kMsgRetrieve); fSecondsMessage = new BMessage(kMsgSecond); - BLayoutBuilder::Group<>(this, B_VERTICAL, 10) - .SetInsets(15) - .Add(fMessage) + BLayoutBuilder::Group<>(this, B_VERTICAL, 0) + .SetInsets(B_USE_SMALL_SPACING) + .Add(fMessage, 0) .Add(fScanProgress, 10) - .Add(fScrollView) + .Add(fScrollView, 20) .AddGroup(B_HORIZONTAL, 10) .Add(fAddButton) .AddGlue() diff --git a/src/preferences/bluetooth/RemoteDevicesView.cpp b/src/preferences/bluetooth/RemoteDevicesView.cpp index 15545a9ccc..a534399b89 100644 --- a/src/preferences/bluetooth/RemoteDevicesView.cpp +++ b/src/preferences/bluetooth/RemoteDevicesView.cpp @@ -1,7 +1,12 @@ /* - * Copyright 2008-09, Oliver Ruiz Dorantes, - * All rights reserved. Distributed under the terms of the MIT License. + * Copyright 2008-2009, Oliver Ruiz Dorantes, + * Copyright 2021, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fredrik Modéen */ + #include #include @@ -33,8 +38,8 @@ static const uint32 kMsgAddDevices = 'ddDv'; static const uint32 kMsgRemoveDevice = 'rmDv'; static const uint32 kMsgPairDevice = 'trDv'; static const uint32 kMsgDisconnectDevice = 'dsDv'; -static const uint32 kMsgBlockDevice = 'blDv'; -static const uint32 kMsgRefreshDevices = 'rfDv'; +//static const uint32 kMsgBlockDevice = 'blDv'; +//static const uint32 kMsgRefreshDevices = 'rfDv'; using namespace Bluetooth; @@ -52,14 +57,13 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags) disconnectButton = new BButton("disconnect", B_TRANSLATE("Disconnect"), new BMessage(kMsgDisconnectDevice)); - +/* blockButton = new BButton("block", B_TRANSLATE("As blocked"), new BMessage(kMsgBlockDevice)); - availButton = new BButton("check", B_TRANSLATE("Refresh" B_UTF8_ELLIPSIS), new BMessage(kMsgRefreshDevices)); - +*/ // Set up device list fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST); @@ -74,11 +78,11 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags) .Add(addButton) .Add(removeButton) .AddGlue() - .Add(availButton) - .AddGlue() +// .Add(availButton) + // .AddGlue() .Add(pairButton) .Add(disconnectButton) - .Add(blockButton) +// .Add(blockButton) .AddGlue() .End() .End(); @@ -101,8 +105,8 @@ RemoteDevicesView::AttachedToWindow(void) removeButton->SetTarget(this); pairButton->SetTarget(this); disconnectButton->SetTarget(this); - blockButton->SetTarget(this); - availButton->SetTarget(this); +// blockButton->SetTarget(this); +// availButton->SetTarget(this); LoadSettings(); fDeviceList->Select(0); @@ -122,8 +126,6 @@ RemoteDevicesView::MessageReceived(BMessage* message) } case kMsgRemoveDevice: - printf("kMsgRemoveDevice: %" B_PRId32 "\n", - fDeviceList->CurrentSelection(0)); fDeviceList->RemoveItem(fDeviceList->CurrentSelection(0)); break; case kMsgAddToRemoteList: diff --git a/src/preferences/bluetooth/RemoteDevicesView.h b/src/preferences/bluetooth/RemoteDevicesView.h index b13ae3c160..2ebaf9e365 100644 --- a/src/preferences/bluetooth/RemoteDevicesView.h +++ b/src/preferences/bluetooth/RemoteDevicesView.h @@ -43,8 +43,8 @@ protected: BButton* removeButton; BButton* pairButton; BButton* disconnectButton; - BButton* blockButton; - BButton* availButton; +// BButton* blockButton; +// BButton* availButton; BListView* fDeviceList; BScrollView* fScrollView; diff --git a/src/preferences/bluetooth/defs.h b/src/preferences/bluetooth/defs.h index 5a5d1528cc..0a369dac0c 100644 --- a/src/preferences/bluetooth/defs.h +++ b/src/preferences/bluetooth/defs.h @@ -31,6 +31,11 @@ const uint32 kItemSpace = 7; static const uint32 kMsgAddToRemoteList = 'aDdL'; 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; #endif