Code for current bluetooth preferences, non ready/standard/polished code (meant to be backup)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29192 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2009-02-14 00:07:45 +00:00
parent 3f31053904
commit 96455f01e8
15 changed files with 1334 additions and 0 deletions
@@ -0,0 +1,119 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "BluetoothDeviceView.h"
#include <bluetooth/bdaddrUtils.h>
#include <Bitmap.h>
#include <GroupLayoutBuilder.h>
#include <SpaceLayoutItem.h>
#include <StringView.h>
#include <TextView.h>
BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, uint32 resizingMode, uint32 flags)
: BView(frame,"BluetoothDeviceView", resizingMode, flags | B_WILL_DRAW),
fDevice(bDevice)
{
SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0,0,0);
BRect iDontCare(0,0,0,0);
SetLayout(new BGroupLayout(B_VERTICAL));
fName = new BStringView(iDontCare, "name", "");
fName->SetFont(be_bold_font);
fBdaddr = new BStringView(iDontCare, "bdaddr", bdaddrUtils::ToString(bdaddrUtils::NullAddress()));
fClassService = new BStringView(iDontCare, "ServiceClass", "Service Classes: ");
fClass = new BStringView(iDontCare, "class", "- / -");
fIcon = new BitmapView(new BBitmap(BRect(0, 0, 64 - 1, 64 - 1), B_RGBA32));
fIcon->SetViewColor(0,0,0);
SetBluetoothDevice(bDevice);
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fIcon)
.Add(BGroupLayoutBuilder(B_VERTICAL)
.Add(fName)
.AddGlue()
.Add(fBdaddr)
.AddGlue()
.AddGlue()
.Add(fClass)
.AddGlue()
.Add(fClassService)
.SetInsets(5, 25, 25, 25)
)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10)
).SetInsets(20, 20, 20, 20)
);
}
BluetoothDeviceView::~BluetoothDeviceView(void)
{
}
void
BluetoothDeviceView::SetBluetoothDevice(BluetoothDevice* bDevice)
{
if (bDevice != NULL) {
SetName(bDevice->GetFriendlyName().String());
fName->SetText(bDevice->GetFriendlyName().String());
fBdaddr->SetText(bdaddrUtils::ToString(bDevice->GetBluetoothAddress()));
BString str("Service Classes: ");
bDevice->GetDeviceClass().GetServiceClass(str);
fClassService->SetText(str.String());
str = "";
bDevice->GetDeviceClass().GetMajorDeviceClass(str);
str << " / ";
bDevice->GetDeviceClass().GetMinorDeviceClass(str);
fClass->SetText(str.String());
}
}
void
BluetoothDeviceView::SetTarget(BHandler *tgt)
{
}
void
BluetoothDeviceView::MessageReceived(BMessage *msg)
{
// If we received a dropped message, try to see if it has color data
// in it
if(msg->WasDropped()) {
}
// The default
BView::MessageReceived(msg);
}
void
BluetoothDeviceView::SetEnabled(bool value)
{
}
@@ -0,0 +1,83 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef BLUETOOTHDEVICEVIEW_H_
#define BLUETOOTHDEVICEVIEW_H_
#include <View.h>
#include <Message.h>
#include <Invoker.h>
#include <Box.h>
#include <Bitmap.h>
#include <bluetooth/BluetoothDevice.h>
class BStringView;
class BitmapView;
class BluetoothDeviceView : public BView
{
public:
BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
~BluetoothDeviceView(void);
void SetBluetoothDevice(BluetoothDevice* bdev);
virtual void MessageReceived(BMessage *msg);
virtual void SetTarget(BHandler *tgt);
virtual void SetEnabled(bool value);
protected:
BluetoothDevice* fDevice;
BStringView* fName;
BStringView* fBdaddr;
BStringView* fClassService;
BStringView* fClass;
BitmapView* fIcon;
};
class BitmapView : public BView
{
public:
BitmapView(BBitmap *bitmap) : BView(bitmap->Bounds(), NULL,
B_FOLLOW_NONE, B_WILL_DRAW)
{
fBitmap = bitmap;
SetDrawingMode(B_OP_ALPHA);
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
}
~BitmapView()
{
delete fBitmap;
}
virtual void AttachedToWindow()
{
//SetViewColor(Parent()->ViewColor());
//MoveTo((Parent()->Bounds().Width() - Bounds().Width()) / 2, Frame().top);
}
virtual void Draw(BRect updateRect)
{
DrawBitmap(fBitmap, updateRect, updateRect);
}
private:
BBitmap *fBitmap;
};
#endif
@@ -0,0 +1,72 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <Alert.h>
#include "BluetoothMain.h"
#include "BluetoothWindow.h"
#include "defs.h"
BluetoothApplication::BluetoothApplication(void)
: BApplication(BLUETOOTH_APP_SIGNATURE)
{
fWindow = new BluetoothWindow(BRect(100, 100, 550, 420));
fWindow->Show();
}
void
BluetoothApplication::AboutRequested()
{
(new BAlert("about", "Haiku Bluetooth System, (ARCE)
Created by Oliver Ruiz Dorantes
With support of:
- Mika Lindqvist
- Maksym Yevmenkin
Thanks to the individuals who helped...
Shipping/donating hardware:
- Henry Jair Abril Florez(el Colombian)
& Stefanie Bartolich
- Dennis d'Entremont
- Luroh
- Pieter Panman
Economically:
- Karl von Dorf, Andrea Bernardi (OSDrawer),
- Matt M, Doug F, Hubert H,
- Sebastian B, Andrew M, Jared E,
- Frederik H, Tom S, Ferry B,
- Greg G, David F, Richard S, Martin W:
With patches:
- Fredrik Ekdahl
- Andreas Färber
Testing:
- Petter H. Juliussen
- Raynald Lesieur
- Adrien Destugues
- Jörg Meyer
Who gave me all the knowledge:
- the yellowTAB team", "OK"))->Go();
}
int
main(int, char**)
{
BluetoothApplication myApplication;
myApplication.Run();
return 0;
}
+24
View File
@@ -0,0 +1,24 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef BLUETOOTH_MAIN_H
#define BLUETOOTH_MAIN_H
#include <Application.h>
class BluetoothWindow;
class BluetoothApplication : public BApplication
{
public:
BluetoothApplication(void);
virtual void AboutRequested();
private:
BluetoothWindow *fWindow;
};
#endif
@@ -0,0 +1,232 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "BluetoothSettingsView.h"
#include <stdio.h>
#include <stdlib.h>
#include <Box.h>
#include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <Slider.h>
#include <SpaceLayoutItem.h>
#include <String.h>
#include <TextView.h>
#include <bluetooth/LocalDevice.h>
#include "ExtendedLocalDeviceView.h"
#include "BluetoothWindow.h"
static const int32 kMsgSetAntialiasing = 'anti';
static const int32 kMsgSetHinting = 'hint';
static const int32 kMsgSetAverageWeight = 'afEa';
static const int32 kMsgLocalSwitched = 'lDsW';
static const char* kAllLabel = "From all devices";
static const char* kTrustedLabel = "Only from Trusted devices";
static const char* kAlwaysLabel = "Always ask";
static const char* kDesktopLabel = "Desktop";
static const char* kLaptopLabel = "Laptop";
static const char* kPhoneLabel = "Haiku Phone";
// #pragma mark -
BluetoothSettingsView::BluetoothSettingsView(const char* name)
: BView(name, 0)
{
// antialiasing menu
_BuildConnectionPolicy();
fAntialiasingMenuField = new BMenuField("antialiasing",
"Incoming connections policy:", fAntialiasingMenu, NULL);
fAverageWeightControl = new BSlider("averageWeightControl",
"Default Inquiry time:", new BMessage(kMsgSetAverageWeight), 0, 255, B_HORIZONTAL);
fAverageWeightControl->SetLimitLabels("15 secs", "61 secs");
fAverageWeightControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAverageWeightControl->SetHashMarkCount(255 / 15);
fAverageWeightControl->SetEnabled(true);
// hinting menu
_BuildHintingMenu();
fHintingMenuField = new BMenuField("hinting", "Identify host as:",
fHintingMenu, NULL);
// localdevices menu
_BuildLocalDevicesMenu();
fLocalDevicesMenuField = new BMenuField("devices", "Local Devices found on system:",
fLocalDevicesMenu, NULL);
fExtDeviceView = new ExtendedLocalDeviceView(BRect(0,0,5,5), NULL);
SetLayout(new BGroupLayout(B_VERTICAL));
// controls pane
AddChild(BGridLayoutBuilder(10, 10)
.Add(fHintingMenuField->CreateLabelLayoutItem(), 0, 0)
.Add(fHintingMenuField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fAntialiasingMenuField->CreateLabelLayoutItem(), 0, 1)
.Add(fAntialiasingMenuField->CreateMenuBarLayoutItem(), 1, 1)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 2, 2)
.Add(fAverageWeightControl, 0, 3, 2)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 4, 2)
.Add(fLocalDevicesMenuField->CreateLabelLayoutItem(), 0, 5)
.Add(fLocalDevicesMenuField->CreateMenuBarLayoutItem(), 1, 5)
.Add(fExtDeviceView, 0, 6, 2)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 7, 2)
.SetInsets(10, 10, 10, 10)
);
}
BluetoothSettingsView::~BluetoothSettingsView()
{
}
void
BluetoothSettingsView::AttachedToWindow()
{
if (Parent() != NULL)
SetViewColor(Parent()->ViewColor());
else
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fAntialiasingMenu->SetTargetForItems(this);
fHintingMenu->SetTargetForItems(this);
fLocalDevicesMenu->SetTargetForItems(this);
fAverageWeightControl->SetTarget(this);
}
void
BluetoothSettingsView::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kMsgSetAntialiasing:
{
/* bool subpixelAntialiasing;
if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK
|| subpixelAntialiasing == fCurrentSubpixelAntialiasing)
break;
fCurrentSubpixelAntialiasing = subpixelAntialiasing;
fAverageWeightControl->SetEnabled(fCurrentSubpixelAntialiasing);
Window()->PostMessage(kMsgUpdate);
*/ break;
}
case kMsgSetHinting:
{
/* bool hinting;
if (msg->FindBool("hinting", &hinting) != B_OK
|| hinting == fCurrentHinting)
break;
fCurrentHinting = hinting;
Window()->PostMessage(kMsgUpdate);
*/ break;
}
case kMsgLocalSwitched:
{
LocalDevice* lDevice;
if (msg->FindPointer("LocalDevice", (void**) &lDevice) == B_OK) {
// Device integrity should be rechecked
fExtDeviceView->SetLocalDevice(lDevice);
}
break;
}
default:
BView::MessageReceived(msg);
}
}
void
BluetoothSettingsView::_BuildConnectionPolicy()
{
fAntialiasingMenu = new BPopUpMenu("Policy...");
BMessage* message = new BMessage(kMsgSetAntialiasing);
message->AddBool("antialiasing", false);
BMenuItem* item = new BMenuItem(kAllLabel, message);
fAntialiasingMenu->AddItem(item);
message = new BMessage(kMsgSetAntialiasing);
message->AddBool("antialiasing", true);
item = new BMenuItem(kTrustedLabel, message);
fAntialiasingMenu->AddItem(item);
BMenuItem* item2 = new BMenuItem(kAlwaysLabel, NULL);
fAntialiasingMenu->AddItem(item2);
}
void
BluetoothSettingsView::_BuildHintingMenu()
{
fHintingMenu = new BPopUpMenu("Identify us as...");
BMessage* message = new BMessage(kMsgSetHinting);
message->AddBool("hinting", false);
BMenuItem* item = new BMenuItem(kDesktopLabel, message);
fHintingMenu->AddItem(item);
message = new BMessage(kMsgSetAverageWeight);
message->AddBool("hinting", true);
item = new BMenuItem(kLaptopLabel, message);
fHintingMenu->AddItem(item);
BMenuItem* item2 = new BMenuItem(kPhoneLabel, NULL);
fHintingMenu->AddItem(item2);
}
void
BluetoothSettingsView::_BuildLocalDevicesMenu()
{
LocalDevice* lDevice;
fLocalDevicesMenu = new BPopUpMenu("Pick LocalDevice...");
for (uint32 index = 0 ; index < LocalDevice::GetLocalDeviceCount() ; index++) {
lDevice = LocalDevice::GetLocalDevice();
if (lDevice != NULL) {
BMessage* message = new BMessage(kMsgLocalSwitched);
message->AddPointer("LocalDevice", lDevice);
BMenuItem* item = new BMenuItem((lDevice->GetFriendlyName().String()), message);
fLocalDevicesMenu->AddItem(item);
}
}
}
@@ -0,0 +1,57 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef ANTIALIASING_SETTINGS_VIEW_H
#define ANTIALIASING_SETTINGS_VIEW_H
#include <View.h>
class BBox;
class BMenuField;
class BPopUpMenu;
class BSlider;
class ExtendedLocalDeviceView;
class BluetoothSettingsView : public BView {
public:
BluetoothSettingsView(const char* name);
virtual ~BluetoothSettingsView();
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* message);
private:
void _BuildConnectionPolicy();
void _SetCurrentAntialiasing();
void _BuildHintingMenu();
void _SetCurrentHinting();
void _SetCurrentAverageWeight();
void _BuildLocalDevicesMenu();
protected:
float fDivider;
BMenuField* fAntialiasingMenuField;
BPopUpMenu* fAntialiasingMenu;
BMenuField* fHintingMenuField;
BPopUpMenu* fHintingMenu;
BMenuField* fLocalDevicesMenuField;
BPopUpMenu* fLocalDevicesMenu;
ExtendedLocalDeviceView* fExtDeviceView;
BSlider* fAverageWeightControl;
bool fSavedSubpixelAntialiasing;
bool fCurrentSubpixelAntialiasing;
bool fSavedHinting;
bool fCurrentHinting;
unsigned char fSavedAverageWeight;
unsigned char fCurrentAverageWeight;
};
#endif // ANTIALIASING_SETTINGS_VIEW_H
@@ -0,0 +1,123 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "BluetoothWindow.h"
#include <Button.h>
#include <GroupLayoutBuilder.h>
#include <Messenger.h>
#include <SpaceLayoutItem.h>
#include <TabView.h>
#include "RemoteDevicesView.h"
//#include "ConnChanView.h"
#include "defs.h"
static const uint32 kMsgSetDefaults = 'dflt';
static const uint32 kMsgRevert = 'rvrt';
static const uint32 kMsgStartServices = 'SrSR';
static const uint32 kMsgStopServices = 'StST';
static const uint32 kMsgShowDebug = 'ShDG';
BluetoothWindow::BluetoothWindow(BRect frame)
: BWindow(frame, "Bluetooth", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
B_ALL_WORKSPACES)
{
SetLayout(new BGroupLayout(B_HORIZONTAL));
fDefaultsButton = new BButton("defaults", "Defaults",
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
fRevertButton = new BButton("revert", "Revert",
new BMessage(kMsgRevert), B_WILL_DRAW);
// Add the menu bar
fMenubar = new BMenuBar(Bounds(), "menu_bar");
// Add File menu to menu bar
BMenu *menu = new BMenu("Server");
menu->AddItem(new BMenuItem("Start Bluetooth Services" B_UTF8_ELLIPSIS, new BMessage(kMsgStartServices), 0));
menu->AddItem(new BMenuItem("Stop Bluetooth Services" B_UTF8_ELLIPSIS, new BMessage(kMsgStopServices), 0));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Show Bluetooth console" B_UTF8_ELLIPSIS, new BMessage(kMsgStartServices), 0));
fMenubar->AddItem(menu);
menu = new BMenu("View");
menu->AddItem(new BMenuItem("Connections & Channels list" B_UTF8_ELLIPSIS, NULL, 0));
menu->AddItem(new BMenuItem("Remote Devices List" B_UTF8_ELLIPSIS, NULL, 0));
fMenubar->AddItem(menu);
menu = new BMenu("Help");
menu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED), 0));
fMenubar->AddItem(menu);
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
fSettingsView = new BluetoothSettingsView("Settings");
// fConnChan = new ConnChanView("Connections & Channels", B_WILL_DRAW);
fRemoteDevices = new RemoteDevicesView("Remote Devices", B_WILL_DRAW);
tabView->AddTab(fRemoteDevices);
// tabView->AddTab(fConnChan);
tabView->AddTab(fSettingsView);
fRevertButton->SetEnabled(false);
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fMenubar)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(tabView)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fRevertButton)
.AddGlue()
.Add(fDefaultsButton)
)
.SetInsets(5, 5, 5, 5)
);
}
void
BluetoothWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
case kMsgSetDefaults:
/* fColorsView -> MessageReceived(new BMessage(DEFAULT_SETTINGS));
fAntialiasingSettings->SetDefaults();
fDefaultsButton->SetEnabled(false);
fRevertButton->SetEnabled(true);
*/ break;
case kMsgRevert:
/* fColorsView -> MessageReceived(new BMessage(REVERT_SETTINGS));
fAntialiasingSettings->Revert();
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|| fAntialiasingSettings->IsDefaultable());
fRevertButton->SetEnabled(false);
*/ break;
case B_ABOUT_REQUESTED:
be_app->PostMessage(message);
break;
default:
BWindow::MessageReceived(message);
break;
}
}
bool
BluetoothWindow::QuitRequested(void)
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
@@ -0,0 +1,38 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef BLUETOOTH_WINDOW_H
#define BLUETOOTH_WINDOW_H
#include <Application.h>
#include <Button.h>
#include <Window.h>
#include <Message.h>
#include <TabView.h>
#include "BluetoothSettingsView.h"
class RemoteDevicesView;
class ConnChanView;
class BluetoothWindow : public BWindow
{
public:
BluetoothWindow(BRect frame);
bool QuitRequested(void);
void MessageReceived(BMessage *message);
private:
RemoteDevicesView* fRemoteDevices;
ConnChanView* fConnChan;
BButton* fDefaultsButton;
BButton* fRevertButton;
BMenuBar* fMenubar;
BluetoothSettingsView* fSettingsView;
};
#endif
@@ -0,0 +1,122 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "ExtendedLocalDeviceView.h"
#include <bluetooth/bdaddrUtils.h>
#include "defs.h"
#include <Bitmap.h>
#include <CheckBox.h>
#include <GroupLayoutBuilder.h>
#include <SpaceLayoutItem.h>
#include <StringView.h>
ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame, LocalDevice* bDevice, uint32 resizingMode, uint32 flags)
: BView(frame,"ExtendedLocalDeviceView", resizingMode, flags | B_WILL_DRAW),
fDevice(bDevice),
fScanMode(0)
{
SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0,0,0);
BRect iDontCare(0,0,0,0);
SetLayout(new BGroupLayout(B_HORIZONTAL));
fDeviceView = new BluetoothDeviceView(BRect(0,0,5,5), bDevice);
fDiscoverable = new BCheckBox(iDontCare, "Discoverable","Discoverable", new BMessage(SET_DISCOVERABLE));
fVisible = new BCheckBox(iDontCare, "Visible", "Show Name", new BMessage(SET_VISIBLE));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fDeviceView)
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
.AddGlue()
.Add(fDiscoverable)
.Add(fVisible)
.SetInsets(5, 5, 5, 5)
)
.Add(BSpaceLayoutItem::CreateVerticalStrut(0))
.SetInsets(5, 5, 5, 5)
);
}
ExtendedLocalDeviceView::~ExtendedLocalDeviceView(void)
{
}
void
ExtendedLocalDeviceView::SetLocalDevice(LocalDevice* lDevice)
{
if (lDevice != NULL) {
fDevice = lDevice;
SetName(lDevice->GetFriendlyName().String());
fDeviceView->SetBluetoothDevice(lDevice);
}
}
void
ExtendedLocalDeviceView::AttachedToWindow()
{
fDiscoverable->SetTarget(this);
fVisible->SetTarget(this);
}
void
ExtendedLocalDeviceView::SetTarget(BHandler *tgt)
{
}
void
ExtendedLocalDeviceView::MessageReceived(BMessage *msg)
{
if(msg->WasDropped()) {
}
switch(msg->what)
{
case SET_DISCOVERABLE:
case SET_VISIBLE:
fScanMode = 0;
if (fDiscoverable->Value()) {
fScanMode = 1;
fVisible->SetEnabled(true);
} else {
fVisible->SetValue(false);
fVisible->SetEnabled(false);
}
if (fVisible->Value())
fScanMode |= 2;
fDevice->SetDiscoverable(fScanMode);
break;
default:
BView::MessageReceived(msg);
break;
}
}
void
ExtendedLocalDeviceView::SetEnabled(bool value)
{
}
@@ -0,0 +1,48 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef EXTENDEDLOCALDEVICEVIEW_H_
#define EXTENDEDLOCALDEVICEVIEW_H_
#include <View.h>
#include <Message.h>
#include <Invoker.h>
#include <Box.h>
#include <Bitmap.h>
#include <bluetooth/LocalDevice.h>
#include "BluetoothDeviceView.h"
class BStringView;
class BitmapView;
class BCheckBox;
class ExtendedLocalDeviceView : public BView
{
public:
ExtendedLocalDeviceView(BRect frame, LocalDevice* bDevice,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
~ExtendedLocalDeviceView(void);
void SetLocalDevice(LocalDevice* lDevice);
virtual void MessageReceived(BMessage *msg);
virtual void AttachedToWindow();
virtual void SetTarget(BHandler *tgt);
virtual void SetEnabled(bool value);
protected:
LocalDevice* fDevice;
BCheckBox* fDiscoverable;
BCheckBox* fVisible;
BluetoothDeviceView* fDeviceView;
uint8 fScanMode;
};
#endif
+171
View File
@@ -0,0 +1,171 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "BluetoothWindow.h"
#include <Alert.h>
#include <Button.h>
#include <GroupLayoutBuilder.h>
#include <Messenger.h>
#include <SpaceLayoutItem.h>
#include <TabView.h>
#include "RemoteDevicesView.h"
//#include "ConnChanView.h"
#include "defs.h"
static const uint32 kMsgSetDefaults = 'dflt';
static const uint32 kMsgRevert = 'rvrt';
static const uint32 kMsgStartServices = 'SrSR';
static const uint32 kMsgStopServices = 'StST';
static const uint32 kMsgShowDebug = 'ShDG';
BluetoothWindow::BluetoothWindow(BRect frame)
: BWindow(frame, "Bluetooth", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
B_ALL_WORKSPACES)
{
SetLayout(new BGroupLayout(B_HORIZONTAL));
fDefaultsButton = new BButton("defaults", "Defaults",
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
fRevertButton = new BButton("revert", "Revert",
new BMessage(kMsgRevert), B_WILL_DRAW);
// Add the menu bar
fMenubar = new BMenuBar(Bounds(), "menu_bar");
// Add File menu to menu bar
BMenu *menu = new BMenu("Server");
menu->AddItem(new BMenuItem("Start Bluetooth Services" B_UTF8_ELLIPSIS, new BMessage(kMsgStartServices), 0));
menu->AddItem(new BMenuItem("Stop Bluetooth Services" B_UTF8_ELLIPSIS, new BMessage(kMsgStopServices), 0));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Show Bluetooth console" B_UTF8_ELLIPSIS, new BMessage(kMsgStartServices), 0));
fMenubar->AddItem(menu);
menu = new BMenu("View");
menu->AddItem(new BMenuItem("Connections & Channels list" B_UTF8_ELLIPSIS, NULL, 0));
menu->AddItem(new BMenuItem("Remote Devices List" B_UTF8_ELLIPSIS, NULL, 0));
fMenubar->AddItem(menu);
menu = new BMenu("Help");
menu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED), 0));
fMenubar->AddItem(menu);
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
fSettingsView = new BluetoothSettingsView("Settings");
// fConnChan = new ConnChanView("Connections & Channels", B_WILL_DRAW);
fRemoteDevices = new RemoteDevicesView("Remote Devices", B_WILL_DRAW);
tabView->AddTab(fRemoteDevices);
// tabView->AddTab(fConnChan);
tabView->AddTab(fSettingsView);
fRevertButton->SetEnabled(false);
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fMenubar)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(tabView)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fRevertButton)
.AddGlue()
.Add(fDefaultsButton)
)
.SetInsets(5, 5, 5, 5)
);
}
void
BluetoothWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
case kMsgUpdate:
/* fDefaultsButton->SetEnabled(fRemoteDevices->IsDefaultable()
|| fAntialiasingSettings->IsDefaultable());
fRevertButton->SetEnabled(true);*/
break;
case kMsgSetDefaults:
/* fColorsView -> MessageReceived(new BMessage(DEFAULT_SETTINGS));
fAntialiasingSettings->SetDefaults();
fDefaultsButton->SetEnabled(false);
fRevertButton->SetEnabled(true);
*/ break;
case kMsgRevert:
/* fColorsView -> MessageReceived(new BMessage(REVERT_SETTINGS));
fAntialiasingSettings->Revert();
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|| fAntialiasingSettings->IsDefaultable());
fRevertButton->SetEnabled(false);
*/ break;
case B_ABOUT_REQUESTED:
AboutRequested();
break;
default:
BWindow::MessageReceived(message);
break;
}
}
void
BluetoothWindow::AboutRequested()
{
(new BAlert("about", "Haiku Bluetooth System, (ARCE)
Created by Oliver Ruiz Dorantes
With support of:
- Mika Lindqvist
- Maksym Yevmenkin
Thanks to the individuals who helped...
Shipping/donating hardware:
- Henry Jair Abril Florez(el Colombian)
& Stefanie Bartolich
- Dennis d'Entremont
- Luroh
- Pieter Panman
Economically:
- Karl von Dorf, Andrea Bernardi (OSDrawer),
- Matt M, Doug F, Hubert H,
- Sebastian B, Andrew M, Jared E,
- Frederik H, Tom S, Ferry B,
- Greg G, David F, Richard S, Martin W:
With patches:
- Fredrik Ekdahl
- Andreas Färber
Testing:
- Petter H. Juliussen
- Raynald Lesieur
- Adrien Destugues
- Jörg Meyer
Who gave me all the knowledge:
- the yellowTAB team", "OK"))->Go();
}
bool
BluetoothWindow::QuitRequested(void)
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
+38
View File
@@ -0,0 +1,38 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef INQUIRY_WINDOW_H
#define INQUIRY_WINDOW_H
#include <Application.h>
#include <Button.h>
#include <Window.h>
#include <Message.h>
#include <TabView.h>
#include "InquirySettingsView.h"
class RemoteDevicesView;
class ConnChanView;
class InquiryWindow : public BWindow
{
public:
InquiryWindow(BRect frame);
bool QuitRequested(void);
void MessageReceived(BMessage *message);
private:
RemoteDevicesView* fRemoteDevices;
ConnChanView* fConnChan;
BButton* fDefaultsButton;
BButton* fRevertButton;
BMenuBar* fMenubar;
};
#endif
@@ -0,0 +1,123 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "RemoteDevicesView.h"
#include <Alert.h>
#include <Directory.h>
#include <Entry.h>
#include <File.h>
#include <GroupLayoutBuilder.h>
#include <Messenger.h>
#include <Path.h>
#include <SpaceLayoutItem.h>
#include <stdio.h>
#include "BluetoothWindow.h"
#include "defs.h"
static const uint32 kMsgAddDevices = 'ddDv';
RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
: BView(name, flags)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BButton* addButton = new BButton(BRect(5,5,5,5), "add", "Add" B_UTF8_ELLIPSIS,
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
BButton* removeButton = new BButton(BRect(5,5,5,5), "remove", "Remove",
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
BButton* trustButton = new BButton(BRect(5,5,5,5), "trust", "As Trusted",
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
BButton* blockButton = new BButton(BRect(5,5,5,5), "trust", "As Blocked",
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
BButton* availButton = new BButton(BRect(5,5,5,5), "check", "Refresh" B_UTF8_ELLIPSIS,
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
// Set up list of color attributes
fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
fScrollView = new BScrollView("ScrollView", fAttrList, 0, false, true);
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLayout(new BGroupLayout(B_VERTICAL));
// TODO: Make list view and scroller use all the additional height
// available!
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fScrollView)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
.Add(BGroupLayoutBuilder(B_VERTICAL)
.Add(addButton)
.Add(removeButton)
.AddGlue()
.Add(availButton)
.AddGlue()
.Add(trustButton)
.Add(blockButton)
.AddGlue()
.SetInsets(0, 15, 0, 15)
)
.SetInsets(5, 5, 5, 100)
);
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
}
RemoteDevicesView::~RemoteDevicesView(void)
{
}
void
RemoteDevicesView::AttachedToWindow(void)
{
fAttrList->SetTarget(this);
LoadSettings();
fAttrList->Select(0);
}
void
RemoteDevicesView::MessageReceived(BMessage *msg)
{
if (msg->WasDropped()) {
rgb_color *color;
ssize_t size;
if (msg->FindData("RGBColor", (type_code)'RGBC', (const void**)&color, &size) == B_OK) {
}
}
switch(msg->what) {
default:
BView::MessageReceived(msg);
break;
}
}
void RemoteDevicesView::LoadSettings(void)
{
}
bool RemoteDevicesView::IsDefaultable(void)
{
return true;
}
@@ -0,0 +1,48 @@
/*
* Copyright 2008-09, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef REMOTE_DEVICES_VIEW_H_
#define REMOTE_DEVICES_VIEW_H_
#include <View.h>
#include <ColorControl.h>
#include <Message.h>
#include <ListItem.h>
#include <ListView.h>
#include <Button.h>
#include <ScrollView.h>
#include <ScrollBar.h>
#include <String.h>
#include <Menu.h>
#include <MenuField.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <StringView.h>
#include <Invoker.h>
class RemoteDevicesView : public BView
{
public:
RemoteDevicesView(const char *name, uint32 flags);
~RemoteDevicesView(void);
void AttachedToWindow(void);
void MessageReceived(BMessage *msg);
void LoadSettings(void);
bool IsDefaultable(void);
protected:
void SetCurrentColor(rgb_color color);
void UpdateControls();
void UpdateAllColors();
BListView *fAttrList;
BScrollView *fScrollView;
};
#endif
+36
View File
@@ -0,0 +1,36 @@
#ifndef DEFS_H_
#define DEFS_H_
// If these paths are changed, ensure that they all end in a '/' character
/*
#define SETTINGS_DIR "/boot/home/config/settings/app_server/"
#define COLOR_SET_DIR "/boot/home/config/settings/color_sets/"
#define CURSOR_SET_DIR "/boot/home/config/settings/cursor_sets/"
#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/"
#define COLOR_SETTINGS_NAME "system_colors"
*/
#define BLUETOOTH_APP_SIGNATURE "application/x-vnd.haiku-BluetoothPrefs"
#define APPLY_SETTINGS 'aply'
#define REVERT_SETTINGS 'rvrt'
#define DEFAULT_SETTINGS 'dflt'
#define TRY_SETTINGS 'trys'
#define ATTRIBUTE_CHOSEN 'atch'
#define UPDATE_COLOR 'upcl'
#define DECORATOR_CHOSEN 'dcch'
#define UPDATE_DECORATOR 'updc'
#define UPDATE_COLOR_SET 'upcs'
#define SET_VISIBLE 'sVis'
#define SET_DISCOVERABLE 'sDis'
#define SET_UI_COLORS 'suic'
#define PREFS_CHOSEN 'prch'
// user interface
const uint32 kBorderSpace = 10;
const uint32 kItemSpace = 7;
#endif