Patch by Pieter Panman:
* Rewrote Devices application. -> Thanks a bunch!! Nice work! * Put Devices onto the image. Changes by myself: * Merge some code from the old "preflet" which the new app still relied on. * Fixed some coding style issues. I didn't review all of the code yet, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33640 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -62,9 +62,9 @@ SYSTEM_BIN = "[" addattr alert arp base64 basename bash bc beep bootman bzip2
|
||||
zdiff zforce zgrep zip zipcloak <bin>zipgrep zipnote zipsplit zmore znew
|
||||
;
|
||||
|
||||
SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc DiskProbe
|
||||
DiskUsage DriveSetup CDPlayer Expander Icon-O-Matic Installer LaunchBox
|
||||
Magnify Mail MediaConverter MediaPlayer MidiPlayer NetworkStatus
|
||||
SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc Devices
|
||||
DiskProbe DiskUsage DriveSetup CDPlayer Expander Icon-O-Matic Installer
|
||||
LaunchBox Magnify Mail MediaConverter MediaPlayer MidiPlayer NetworkStatus
|
||||
PackageInstaller People PoorMan PowerStatus ProcessController Screenshot
|
||||
ShowImage SoundRecorder StyledEdit Terminal TextSearch TV Workspaces
|
||||
;
|
||||
@@ -304,8 +304,8 @@ AddSymlinkToHaikuImage home config settings Mail : ../../../mail/in : mailbox ;
|
||||
# Deskbar Application links
|
||||
AddDirectoryToHaikuImage home config be Applications ;
|
||||
DESKBAR_APPLICATIONS = ActivityMonitor CharacterMap CodyCam CDPlayer DeskCalc
|
||||
DiskProbe DriveSetup DiskUsage Expander Icon-O-Matic Installer Magnify
|
||||
Mail MediaConverter MediaPlayer MidiPlayer People PoorMan Screenshot
|
||||
Devices DiskProbe DriveSetup DiskUsage Expander Icon-O-Matic Installer
|
||||
Magnify Mail MediaConverter MediaPlayer MidiPlayer People PoorMan Screenshot
|
||||
SoundRecorder StyledEdit Terminal TV
|
||||
;
|
||||
local linkTarget ;
|
||||
|
||||
@@ -1,633 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003-2004, Haiku
|
||||
//
|
||||
// This software is part of the Haiku distribution and is covered
|
||||
// by the Haiku license.
|
||||
//
|
||||
//
|
||||
// File: ConfigurationWindow.cpp
|
||||
// Author: Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : April 22, 2004
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
|
||||
// Includes ------------------------------------------------------------------------------------------ //
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <ByteOrder.h>
|
||||
#include <MenuItem.h>
|
||||
#include <MenuField.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Screen.h>
|
||||
#include <stdio.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
#include <TabView.h>
|
||||
#include <TextView.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "DevicesWindows.h"
|
||||
#include "pcihdr.h"
|
||||
|
||||
#define CONFIGURATION_CHANGED 'cfch'
|
||||
#define IRQ_CHANGED 'irch'
|
||||
#define DMA_CHANGED 'irch'
|
||||
|
||||
class RangeConfItem : public BListItem
|
||||
{
|
||||
public:
|
||||
RangeConfItem(uint32 lowAddress, uint32 highAddress);
|
||||
~RangeConfItem();
|
||||
virtual void DrawItem(BView *, BRect, bool = false);
|
||||
static int Compare(const void *firstArg, const void *secondArg);
|
||||
private:
|
||||
uint32 fLowAddress, fHighAddress;
|
||||
};
|
||||
|
||||
|
||||
RangeConfItem::RangeConfItem(uint32 lowAddress, uint32 highAddress)
|
||||
: BListItem(),
|
||||
fLowAddress(lowAddress),
|
||||
fHighAddress(highAddress)
|
||||
{
|
||||
}
|
||||
|
||||
RangeConfItem::~RangeConfItem()
|
||||
{
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DrawItem
|
||||
***********************************************************/
|
||||
void
|
||||
RangeConfItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
||||
{
|
||||
rgb_color kBlack = { 0,0,0,0 };
|
||||
rgb_color kHighlight = { 156,154,156,0 };
|
||||
|
||||
if (IsSelected() || complete) {
|
||||
rgb_color color;
|
||||
if (IsSelected())
|
||||
color = kHighlight;
|
||||
else
|
||||
color = owner->ViewColor();
|
||||
|
||||
owner->SetHighColor(color);
|
||||
owner->SetLowColor(color);
|
||||
owner->FillRect(itemRect);
|
||||
owner->SetHighColor(kBlack);
|
||||
} else {
|
||||
owner->SetLowColor(owner->ViewColor());
|
||||
}
|
||||
|
||||
BFont font = be_plain_font;
|
||||
font_height finfo;
|
||||
font.GetHeight(&finfo);
|
||||
|
||||
BPoint point = BPoint(itemRect.left + 4, itemRect.bottom - finfo.descent + 1);
|
||||
owner->SetFont(be_plain_font);
|
||||
owner->SetHighColor(kBlack);
|
||||
owner->MovePenTo(point);
|
||||
|
||||
char string[20];
|
||||
|
||||
if (fLowAddress >= 0) {
|
||||
sprintf(string, "0x%04lx", fLowAddress);
|
||||
owner->DrawString(string);
|
||||
}
|
||||
|
||||
point += BPoint(75, 0);
|
||||
owner->MovePenTo(point);
|
||||
owner->StrokeLine(point + BPoint(0,-3), point + BPoint(4,-3));
|
||||
|
||||
point += BPoint(15, 0);
|
||||
owner->MovePenTo(point);
|
||||
owner->SetFont(be_plain_font);
|
||||
|
||||
if (fHighAddress >= 0) {
|
||||
sprintf(string, "0x%04lx", fHighAddress);
|
||||
owner->DrawString(string);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
RangeConfItem::Compare(const void *firstArg, const void *secondArg)
|
||||
{
|
||||
const RangeConfItem *item1 = *static_cast<const RangeConfItem * const *>(firstArg);
|
||||
const RangeConfItem *item2 = *static_cast<const RangeConfItem * const *>(secondArg);
|
||||
|
||||
if (item1->fLowAddress < item2->fLowAddress) {
|
||||
return -1;
|
||||
} else if (item1->fLowAddress > item2->fLowAddress) {
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// ConfigurationWindow - Constructor
|
||||
ConfigurationWindow::ConfigurationWindow(BRect frame, DeviceItem *item)
|
||||
: BWindow (frame, item->GetInfo()->GetCardName(), B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL ,
|
||||
B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE|B_NOT_RESIZABLE),
|
||||
fItem(item)
|
||||
{
|
||||
CenterOnScreen();
|
||||
fItem->SetWindow(this);
|
||||
InitWindow();
|
||||
|
||||
Show();
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// ConfigurationWindow - Destructor
|
||||
ConfigurationWindow::~ConfigurationWindow()
|
||||
{
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
// ConfigurationWindow::InitWindow -- Initialization Commands here
|
||||
void
|
||||
ConfigurationWindow::InitWindow(void)
|
||||
{
|
||||
DevicesInfo *devicesInfo = fItem->GetInfo();
|
||||
|
||||
BRect bRect = Bounds();
|
||||
|
||||
BBox *background = new BBox(bRect, "background", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW, B_NO_BORDER);
|
||||
AddChild(background);
|
||||
|
||||
BRect rtab = Bounds();
|
||||
BRect rlist = Bounds();
|
||||
rtab.top += 10;
|
||||
rlist.top += 11;
|
||||
rlist.left += 13;
|
||||
rlist.right -= 13;
|
||||
rlist.bottom -= 44;
|
||||
|
||||
// Create the TabView and Tabs
|
||||
BTabView *tabView = new BTabView(rtab,"resource_usage_tabview");
|
||||
tabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
rtab = tabView->Bounds();
|
||||
rtab.InsetBy(5,5);
|
||||
|
||||
// Create the Views
|
||||
BBox *resources = new BBox(rlist, "resources",
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
|
||||
|
||||
BMenuItem *menuItem;
|
||||
fConfigurationMenu = new BPopUpMenu("<empty>");
|
||||
fConfigurationMenu->AddItem(menuItem = new BMenuItem("Current Configuration",
|
||||
new BMessage(CONFIGURATION_CHANGED)));
|
||||
menuItem->SetMarked(true);
|
||||
fConfigurationMenu->AddItem(menuItem = new BMenuItem("Default Configuration",
|
||||
new BMessage(CONFIGURATION_CHANGED)));
|
||||
menuItem->SetEnabled(false);
|
||||
fConfigurationMenu->AddItem(menuItem = new BMenuItem("Disable Device",
|
||||
new BMessage(CONFIGURATION_CHANGED)));
|
||||
menuItem->SetEnabled(false);
|
||||
fConfigurationMenu->AddSeparatorItem();
|
||||
fConfigurationMenu->AddItem(menuItem = new BMenuItem("Possible Configuration 0",
|
||||
new BMessage(CONFIGURATION_CHANGED)));
|
||||
|
||||
BMenuField *configurationMenuField = new BMenuField(BRect(0,0,174 + (be_plain_font->Size() - 12) * 10,18), "configurationMenuField",
|
||||
NULL, fConfigurationMenu, true);
|
||||
resources->SetLabel(configurationMenuField);
|
||||
|
||||
fIRQMenu[0] = new BPopUpMenu("<empty>");
|
||||
fIRQMenu[1] = new BPopUpMenu("<empty>");
|
||||
fIRQMenu[2] = new BPopUpMenu("<empty>");
|
||||
fDMAMenu[0] = new BPopUpMenu("<empty>");
|
||||
fDMAMenu[1] = new BPopUpMenu("<empty>");
|
||||
fDMAMenu[2] = new BPopUpMenu("<empty>");
|
||||
|
||||
BRect fieldRect;
|
||||
fieldRect.top = 25;
|
||||
fieldRect.left = 22;
|
||||
fieldRect.right = fieldRect.left + 72;
|
||||
fieldRect.bottom = fieldRect.top + 18;
|
||||
|
||||
BMenuField *field;
|
||||
fIRQField[0] = field = new BMenuField(fieldRect, "IRQ1Field", "IRQs", fIRQMenu[0], true);
|
||||
field->SetEnabled(false);
|
||||
field->SetDivider(33);
|
||||
resources->AddChild(field);
|
||||
fieldRect.left = 25;
|
||||
fieldRect.OffsetBy(71, 0);
|
||||
fIRQField[1] = field = new BMenuField(fieldRect, "IRQ2Field", " and", fIRQMenu[1], true);
|
||||
field->SetEnabled(false);
|
||||
field->SetDivider(30);
|
||||
resources->AddChild(field);
|
||||
fieldRect.OffsetBy(71, 0);
|
||||
fIRQField[2] = field = new BMenuField(fieldRect, "IRQ3Field", " and", fIRQMenu[2], true);
|
||||
field->SetEnabled(false);
|
||||
field->SetDivider(30);
|
||||
resources->AddChild(field);
|
||||
|
||||
fieldRect.OffsetBy(-142, 23);
|
||||
fieldRect.left = 14;
|
||||
fDMAField[0] = field = new BMenuField(fieldRect, "DMA1Field", "DMAs", fDMAMenu[0], true);
|
||||
field->SetEnabled(false);
|
||||
field->SetDivider(41);
|
||||
resources->AddChild(field);
|
||||
fieldRect.left = 25;
|
||||
fieldRect.OffsetBy(71, 0);
|
||||
fDMAField[1] = field = new BMenuField(fieldRect, "DMA2Field", " and", fDMAMenu[1], true);
|
||||
field->SetEnabled(false);
|
||||
field->SetDivider(30);
|
||||
resources->AddChild(field);
|
||||
fieldRect.OffsetBy(71, 0);
|
||||
fDMAField[2] = field = new BMenuField(fieldRect, "DMA3Field", " and", fDMAMenu[2], true);
|
||||
field->SetEnabled(false);
|
||||
field->SetDivider(30);
|
||||
resources->AddChild(field);
|
||||
|
||||
fIRQMenu[0]->Superitem()->SetLabel("");
|
||||
fIRQMenu[1]->Superitem()->SetLabel("");
|
||||
fIRQMenu[2]->Superitem()->SetLabel("");
|
||||
fDMAMenu[0]->Superitem()->SetLabel("");
|
||||
fDMAMenu[1]->Superitem()->SetLabel("");
|
||||
fDMAMenu[2]->Superitem()->SetLabel("");
|
||||
|
||||
BRect boxRect = resources->Bounds();
|
||||
boxRect.top = 74;
|
||||
boxRect.left += 13;
|
||||
boxRect.right -= 11;
|
||||
boxRect.bottom = boxRect.top + 141;
|
||||
BBox *ioPortBox = new BBox(boxRect, "ioPort",
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
ioPortBox->SetLabel(new BStringView(BRect(0,0,150,15), "ioPortLabel", " IO Port Ranges "));
|
||||
resources->AddChild(ioPortBox);
|
||||
boxRect.OffsetBy(0, 149);
|
||||
boxRect.bottom = boxRect.top + 140;
|
||||
BBox *memoryBox = new BBox(boxRect, "memory",
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
memoryBox->SetLabel(new BStringView(BRect(0,0,150,15), "memoryLabel", " Memory Ranges "));
|
||||
resources->AddChild(memoryBox);
|
||||
|
||||
ioListView = new BListView(BRect(14,22,164,127), "ioListView");
|
||||
memoryListView = new BListView(BRect(14,22,164,127), "memoryListView");
|
||||
|
||||
BScrollView *ioScrollView = new BScrollView("ioScrollView", ioListView, B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||
0, false, true, B_FANCY_BORDER);
|
||||
ioPortBox->AddChild(ioScrollView);
|
||||
BScrollView *memoryScrollView = new BScrollView("memoryScrollView", memoryListView, B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||
0, false, true, B_FANCY_BORDER);
|
||||
memoryBox->AddChild(memoryScrollView);
|
||||
|
||||
|
||||
struct device_configuration *current = devicesInfo->GetCurrent();
|
||||
resource_descriptor r;
|
||||
|
||||
{
|
||||
int32 k = 0;
|
||||
int32 num = count_resource_descriptors_of_type(current, B_IRQ_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_IRQ_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
uint32 mask = r.d.m.mask;
|
||||
int16 j = 0;
|
||||
if (!mask)
|
||||
continue;
|
||||
|
||||
for (;mask;mask>>=1,j++)
|
||||
if (mask & 1) {
|
||||
char value[50];
|
||||
sprintf(value, "%d", j);
|
||||
BMenuItem *item = new BMenuItem(value, new BMessage(IRQ_CHANGED));
|
||||
fIRQMenu[k]->AddItem(item);
|
||||
item->SetMarked(true);
|
||||
fIRQField[k]->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int32 k = 0;
|
||||
int32 num = count_resource_descriptors_of_type(current, B_DMA_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_DMA_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
uint32 mask = r.d.m.mask;
|
||||
int16 j = 0;
|
||||
if (!mask)
|
||||
continue;
|
||||
|
||||
for (;mask;mask>>=1,j++)
|
||||
if (mask & 1) {
|
||||
char value[50];
|
||||
sprintf(value, "%d", j);
|
||||
BMenuItem *item = new BMenuItem(value, new BMessage(DMA_CHANGED));
|
||||
fDMAMenu[k]->AddItem(item);
|
||||
item->SetMarked(true);
|
||||
fDMAField[k++]->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int32 num = count_resource_descriptors_of_type(current, B_IO_PORT_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_IO_PORT_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
|
||||
ioListView->AddItem(new RangeConfItem(r.d.r.minbase,
|
||||
r.d.r.minbase + r.d.r.len - 1));
|
||||
}
|
||||
|
||||
ioListView->SortItems(&RangeConfItem::Compare);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
int32 num = count_resource_descriptors_of_type(current, B_MEMORY_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_MEMORY_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
|
||||
memoryListView->AddItem(new RangeConfItem(r.d.r.minbase,
|
||||
r.d.r.minbase + r.d.r.len - 1));
|
||||
}
|
||||
|
||||
memoryListView->SortItems(&RangeConfItem::Compare);
|
||||
|
||||
}
|
||||
|
||||
BBox *info = new BBox(rlist, "info",
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW, B_NO_BORDER);
|
||||
|
||||
bool isISAPnP = false;
|
||||
BString compatibleIDString;
|
||||
|
||||
if (devicesInfo->GetInfo()->bus == B_ISA_BUS) {
|
||||
uint32 id = devicesInfo->GetInfo()->id[0];
|
||||
if ((id >> 24 == 'P')
|
||||
&& (((id >> 16) & 0xff) == 'n')
|
||||
&& (((id >> 8) & 0xff) == 'P')) {
|
||||
isISAPnP = true;
|
||||
|
||||
char string[255];
|
||||
sprintf(string, "Compatible ID #%ld:",
|
||||
devicesInfo->GetInfo()->id[3]);
|
||||
compatibleIDString = string;
|
||||
}
|
||||
}
|
||||
|
||||
BRect labelRect(1, 10, 132, 30);
|
||||
BStringView *label = new BStringView(labelRect, "Card Name", "Card Name:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Device Name", "Device Name:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Logical Device Name", "Logical Device Name:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Bus Type", "Bus Type:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Device Type", "Device Type:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 36);
|
||||
label = new BStringView(labelRect, "Vendor", "Vendor:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Card ID", "Card ID:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
if (isISAPnP) {
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Logical Device ID", "Logical Device ID:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Compatible ID#", compatibleIDString.String());
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
}
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Current State", "Current State:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Resource Conflicts", "Resource Conflicts:");
|
||||
label->SetAlignment(B_ALIGN_RIGHT);
|
||||
info->AddChild(label);
|
||||
|
||||
BString cardName = "<Unknown>";
|
||||
|
||||
BString logicalDeviceName = "<Unknown>";
|
||||
|
||||
BString bus;
|
||||
switch (devicesInfo->GetInfo()->bus) {
|
||||
case B_ISA_BUS: bus = "ISA device"; break;
|
||||
case B_PCI_BUS: bus = "PCI device"; break;
|
||||
case B_PCMCIA_BUS: bus = "PCMCIA device"; break;
|
||||
default: bus = "<Unknown>"; break;
|
||||
}
|
||||
|
||||
BString deviceType1, deviceType2;
|
||||
deviceType1 += devicesInfo->GetBaseString();
|
||||
deviceType1 += " (";
|
||||
deviceType1 += devicesInfo->GetSubTypeString();
|
||||
deviceType1 += ")";
|
||||
char typeString[255];
|
||||
sprintf(typeString, "Base: %x Subtype: %x Interface: %x",
|
||||
devicesInfo->GetInfo()->devtype.base,
|
||||
devicesInfo->GetInfo()->devtype.subtype,
|
||||
devicesInfo->GetInfo()->devtype.interface);
|
||||
deviceType2 = typeString;
|
||||
BString vendor;
|
||||
BString vendorString = "<Unknown>";
|
||||
BString cardID = "";
|
||||
BString resourceConflicts = "None";
|
||||
BString logicalString;
|
||||
|
||||
switch (devicesInfo->GetInfo()->bus) {
|
||||
case B_ISA_BUS:
|
||||
{
|
||||
char string[255];
|
||||
if (isISAPnP) {
|
||||
uint32 id = devicesInfo->GetInfo()->id[1];
|
||||
sprintf(string, "%c%c%c Product: %x%x%x Revision: %d",
|
||||
((uint8)(id >> 2) & 0x1f) + 'A' - 1,
|
||||
((uint8)(id & 0x3) << 3) + ((uint8)(id >> 13) & 0x7) + 'A' - 1,
|
||||
(uint8)(id >> 8) & 0x1f + 'A' - 1,
|
||||
(uint8)(id >> 20) & 0xf,
|
||||
(uint8)(id >> 16) & 0xf,
|
||||
(uint8)(id >> 28) & 0xf,
|
||||
(uint8)((id >> 24) & 0xf));
|
||||
vendor = string;
|
||||
|
||||
sprintf(string, "%08lx", devicesInfo->GetInfo()->id[2]);
|
||||
cardID = string;
|
||||
|
||||
id = devicesInfo->GetInfo()->id[3];
|
||||
sprintf(string, "%c%c%c Product: %x%x%x Revision: %d",
|
||||
((uint8)(id >> 2) & 0x1f) + 'A' - 1,
|
||||
((uint8)(id & 0x3) << 3) + ((uint8)(id >> 13) & 0x7) + 'A' - 1,
|
||||
(uint8)(id >> 8) & 0x1f + 'A' - 1,
|
||||
(uint8)(id >> 20) & 0xf,
|
||||
(uint8)(id >> 16) & 0xf,
|
||||
(uint8)(id >> 28) & 0xf,
|
||||
(uint8)((id >> 24) & 0xf));
|
||||
logicalString = string;
|
||||
|
||||
cardName = devicesInfo->GetCardName();
|
||||
|
||||
} else {
|
||||
uint32 id = devicesInfo->GetInfo()->id[2];
|
||||
sprintf(string, "%c%c%c Product: %x%x Revision: %d",
|
||||
((uint8)(id >> 2) & 0x1f) + 'A' - 1,
|
||||
((uint8)(id & 0x3) << 3) + ((uint8)(id >> 13) & 0x7) + 'A' - 1,
|
||||
(uint8)(id >> 8) & 0x1f + 'A' - 1,
|
||||
(uint8)(id >> 16) & 0xf,
|
||||
(uint8)(id >> 20) & 0xf,
|
||||
(uint8)((id >> 24) & 0xff));
|
||||
vendor = string;
|
||||
|
||||
cardID = "0";
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case B_PCI_BUS:
|
||||
{
|
||||
for (uint32 i=0; i<PCI_VENTABLE_LEN; i++)
|
||||
if (PciVenTable[i].VenId == devicesInfo->GetInfo()->id[0] & 0xffff) {
|
||||
vendorString = PciVenTable[i].VenFull;
|
||||
break;
|
||||
}
|
||||
|
||||
char string[255];
|
||||
sprintf(string, "%s (0x%04lx)", vendorString.String(), devicesInfo->GetInfo()->id[0] & 0xffff);
|
||||
vendor = string;
|
||||
sprintf(string, "%04lx", devicesInfo->GetInfo()->id[1] & 0xffff);
|
||||
cardID = string;
|
||||
|
||||
for (uint32 i = 0; i < PCI_DEVTABLE_LEN; i++) {
|
||||
if (PciDevTable[i].VenId == devicesInfo->GetInfo()->id[0] & 0xffff &&
|
||||
PciDevTable[i].DevId == devicesInfo->GetInfo()->id[1] & 0xffff) {
|
||||
cardName = PciDevTable[i].ChipDesc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case B_PCMCIA_BUS: vendor = "XX"; break;
|
||||
default: vendor = "<Unknown>"; break;
|
||||
}
|
||||
|
||||
BString state = "Enabled";
|
||||
if (!(devicesInfo->GetInfo()->flags & B_DEVICE_INFO_ENABLED))
|
||||
switch (devicesInfo->GetInfo()->config_status) {
|
||||
case B_DEV_RESOURCE_CONFLICT: state = "Disabled by System"; break;
|
||||
case B_DEV_DISABLED_BY_USER: state = "Disabled by User"; break;
|
||||
default: state = "Disabled for Unknown Reason"; break;
|
||||
}
|
||||
|
||||
labelRect = BRect(137, 10, 400, 30);
|
||||
label = new BStringView(labelRect, "Card Name", cardName.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Device Name", devicesInfo->GetDeviceName());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Logical Device Name", logicalDeviceName.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Bus Type", bus.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Device Type", deviceType1.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Device Type", deviceType2.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Vendor", vendor.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Card ID", cardID.String());
|
||||
info->AddChild(label);
|
||||
if (isISAPnP) {
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Logical Device ID", logicalString.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Compatible ID", logicalString.String());
|
||||
info->AddChild(label);
|
||||
}
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Current State", state.String());
|
||||
info->AddChild(label);
|
||||
labelRect.OffsetBy(0, 18);
|
||||
label = new BStringView(labelRect, "Resource Conflicts", resourceConflicts.String());
|
||||
info->AddChild(label);
|
||||
|
||||
|
||||
BTab *tab = new BTab();
|
||||
tabView->AddTab(resources, tab);
|
||||
tab->SetLabel("Resources");
|
||||
tab = new BTab();
|
||||
tabView->AddTab(info, tab);
|
||||
tab->SetLabel("Info");
|
||||
|
||||
background->AddChild(tabView);
|
||||
|
||||
ioListView->Select(0);
|
||||
memoryListView->Select(0);
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// ConfigurationWindow::MessageReceived -- receives messages
|
||||
void
|
||||
ConfigurationWindow::MessageReceived (BMessage *message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
// ConfigurationWindow::QuitRequested -- Post a message to the app to quit
|
||||
bool
|
||||
ConfigurationWindow::QuitRequested()
|
||||
{
|
||||
fItem->SetWindow(NULL);
|
||||
return true;
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
// This list comes from the pciid list, except for the last one
|
||||
const char* kCategoryString[] = {
|
||||
"Unclassified device", // 0x00
|
||||
"Mass storage controller", // 0x01
|
||||
"Network controller", // 0x02
|
||||
"Display controller", // 0x03
|
||||
"Multimedia controller", // 0x04
|
||||
"Memory controller", // 0x05
|
||||
"Bridge", // 0x06
|
||||
"Communication controller", // 0x07
|
||||
"Generic system peripheral", // 0x08
|
||||
"Input device controller", // 0x09
|
||||
"Docking station", // 0x0a
|
||||
"Processor", // 0x0b
|
||||
"Serial bus controller", // 0x0c
|
||||
"Wireless controller", // 0x0d
|
||||
"Intelligent controller", // 0x0e
|
||||
"Satellite communications controller", // 0x0f
|
||||
"Encryption controller", // 0x10
|
||||
"Signal processing controller", // 0x11
|
||||
"Computer" // 0x12 (added later)
|
||||
};
|
||||
|
||||
|
||||
Device::Device(Device* physicalParent, BusType busType, Category category,
|
||||
const BString& name, const BString& manufacturer,
|
||||
const BString& driverUsed, const BString& devPathsPublished)
|
||||
:
|
||||
BStringItem(name.String()),
|
||||
fBusType(busType),
|
||||
fCategory(category),
|
||||
fPhysicalParent(physicalParent)
|
||||
{
|
||||
SetAttribute("Device name", name);
|
||||
SetAttribute("Manufacturer", manufacturer);
|
||||
SetAttribute("Driver used", driverUsed);
|
||||
SetAttribute("Device paths", devPathsPublished);
|
||||
}
|
||||
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Device::SetAttribute(const BString& name, const BString& value)
|
||||
{
|
||||
if (name == "Device name") {
|
||||
SetText(value.String());
|
||||
}
|
||||
fAttributeMap[name] = value;
|
||||
}
|
||||
|
||||
|
||||
Attributes
|
||||
Device::GetBasicAttributes()
|
||||
{
|
||||
Attributes attributes;
|
||||
attributes.push_back(Attribute("Device name:", GetName()));
|
||||
attributes.push_back(Attribute("Manufacturer:", GetManufacturer()));
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
Attributes
|
||||
Device::GetBusAttributes()
|
||||
{
|
||||
Attributes attributes;
|
||||
attributes.push_back(Attribute("None", ""));
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
Attributes
|
||||
Device::GetAllAttributes()
|
||||
{
|
||||
Attributes attributes;
|
||||
AttributeMapIterator iter;
|
||||
for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) {
|
||||
attributes.push_back(Attribute(iter->first, iter->second));
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
Device::GetBasicStrings()
|
||||
{
|
||||
BString str;
|
||||
str << "Device Name\t\t\t\t: " << GetName() << "\n";
|
||||
str << "Manufacturer\t\t\t: " << GetManufacturer() << "\n";
|
||||
str << "Driver used\t\t\t\t: " << GetDriverUsed() << "\n";
|
||||
str << "Device paths\t: " << GetDevPathsPublished();
|
||||
return str;
|
||||
}
|
||||
|
||||
BString
|
||||
Device::GetBusStrings()
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
Device::GetAllStrings()
|
||||
{
|
||||
BString str;
|
||||
AttributeMapIterator iter;
|
||||
for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) {
|
||||
str << iter->first << " : " << iter->second << "\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
#ifndef DEVICE_H
|
||||
#define DEVICE_H
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <String.h>
|
||||
#include <StringItem.h>
|
||||
|
||||
extern "C" {
|
||||
#include "dm_wrapper.h"
|
||||
}
|
||||
|
||||
|
||||
typedef enum {
|
||||
BUS_ISA = 1,
|
||||
BUS_PCI,
|
||||
BUS_SCSI,
|
||||
BUS_NONE
|
||||
} BusType;
|
||||
|
||||
|
||||
struct Attribute {
|
||||
Attribute(BString name, BString value)
|
||||
{ fName = name; fValue = value; }
|
||||
BString fName;
|
||||
BString fValue;
|
||||
};
|
||||
|
||||
|
||||
typedef std::map<BString, BString>::const_iterator AttributeMapIterator;
|
||||
typedef std::map<BString, BString> AttributeMap;
|
||||
typedef std::pair<BString, BString> AttributePair;
|
||||
typedef std::vector<Attribute> Attributes;
|
||||
|
||||
|
||||
typedef enum {
|
||||
CAT_NONE = 0,
|
||||
CAT_BUS = 6,
|
||||
CAT_COMPUTER = 0x12
|
||||
} Category;
|
||||
|
||||
|
||||
extern const char* kCategoryString[];
|
||||
|
||||
|
||||
class Device : public BStringItem {
|
||||
public:
|
||||
Device(Device* physicalParent,
|
||||
BusType busType=BUS_NONE,
|
||||
Category category=CAT_NONE,
|
||||
const BString& name = "unknown",
|
||||
const BString& manufacturer = "unknown",
|
||||
const BString& driverUsed = "unknown",
|
||||
const BString& devPathsPublished = "unknown");
|
||||
virtual ~Device();
|
||||
|
||||
virtual BString GetName()
|
||||
{ return fAttributeMap["Device name"]; }
|
||||
virtual BString GetManufacturer()
|
||||
{ return fAttributeMap["Manufacturer"]; }
|
||||
virtual BString GetDriverUsed()
|
||||
{ return fAttributeMap["Driver used"]; }
|
||||
virtual BString GetDevPathsPublished()
|
||||
{ return fAttributeMap["Device paths"]; }
|
||||
virtual Category GetCategory() const
|
||||
{ return fCategory; }
|
||||
virtual Device* GetPhysicalParent() const
|
||||
{ return fPhysicalParent; }
|
||||
virtual BusType GetBusType() const
|
||||
{ return fBusType; }
|
||||
|
||||
virtual Attributes GetBasicAttributes();
|
||||
virtual Attributes GetBusAttributes();
|
||||
virtual Attributes GetAllAttributes();
|
||||
|
||||
virtual BString GetBasicStrings();
|
||||
virtual BString GetBusStrings();
|
||||
virtual BString GetAllStrings();
|
||||
|
||||
virtual BString GetBusTabName()
|
||||
{ return "Bus Information"; }
|
||||
|
||||
virtual Attribute GetAttribute(const BString& name)
|
||||
{ return Attribute(name.String(),
|
||||
fAttributeMap[name]); }
|
||||
|
||||
virtual void SetAttribute(const BString& name,
|
||||
const BString& value);
|
||||
|
||||
virtual void InitFromAttributes() { return; }
|
||||
|
||||
protected:
|
||||
AttributeMap fAttributeMap;
|
||||
BusType fBusType;
|
||||
Category fCategory;
|
||||
Device* fPhysicalParent;
|
||||
};
|
||||
|
||||
#endif /* DEVICE_H */
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "DevicePCI.h"
|
||||
|
||||
extern "C" {
|
||||
#include "dm_wrapper.h"
|
||||
#include "pcihdr.h"
|
||||
#include "pci-utils.h"
|
||||
}
|
||||
|
||||
|
||||
DevicePCI::DevicePCI(Device* parent)
|
||||
:
|
||||
Device(parent),
|
||||
fClassBaseId(0),
|
||||
fClassSubId(0),
|
||||
fClassApiId(0),
|
||||
fVendorId(0),
|
||||
fDeviceId(0),
|
||||
fSubsystemVendorId(0),
|
||||
fSubSystemId(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DevicePCI::~DevicePCI()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BString ToHex(uint16 num)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.flags(std::ios::hex | std::ios::showbase);
|
||||
ss << num;
|
||||
return BString(ss.str().c_str());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicePCI::InitFromAttributes()
|
||||
{
|
||||
// Process the attributes
|
||||
fClassBaseId = atoi(fAttributeMap[B_DEVICE_TYPE].String());
|
||||
fClassSubId = atoi(fAttributeMap[B_DEVICE_SUB_TYPE].String());
|
||||
fClassApiId = atoi(fAttributeMap[B_DEVICE_INTERFACE].String());
|
||||
fVendorId = atoi(fAttributeMap[B_DEVICE_VENDOR_ID].String());
|
||||
fDeviceId = atoi(fAttributeMap[B_DEVICE_ID].String());
|
||||
|
||||
// Looks better in Hex, so rewrite
|
||||
fAttributeMap[B_DEVICE_TYPE] = ToHex(fClassBaseId);
|
||||
fAttributeMap[B_DEVICE_SUB_TYPE] = ToHex(fClassSubId);
|
||||
fAttributeMap[B_DEVICE_INTERFACE] = ToHex(fClassApiId);
|
||||
fAttributeMap[B_DEVICE_VENDOR_ID] = ToHex(fVendorId);
|
||||
fAttributeMap[B_DEVICE_ID] = ToHex(fDeviceId);
|
||||
|
||||
// Fetch ClassInfo
|
||||
char classInfo[64];
|
||||
get_class_info(fClassBaseId, fClassSubId, fClassApiId, classInfo, sizeof(classInfo));
|
||||
|
||||
// Fetch ManufacturerName
|
||||
BString ManufacturerName;
|
||||
const char *venShort;
|
||||
const char *venFull;
|
||||
get_vendor_info(fVendorId, &venShort, &venFull);
|
||||
if (!venShort && !venFull) {
|
||||
ManufacturerName << "Unkown";
|
||||
} else if (venShort && venFull) {
|
||||
ManufacturerName << venFull << "(" << venShort << ")";
|
||||
} else {
|
||||
ManufacturerName << (venShort ? venShort : venFull);
|
||||
}
|
||||
|
||||
// Fetch DeviceName
|
||||
BString DeviceName;
|
||||
const char *devShort;
|
||||
const char *devFull;
|
||||
get_device_info(fVendorId, fDeviceId, fSubsystemVendorId, fSubSystemId, &devShort, &devFull);
|
||||
if (!devShort && !devFull) {
|
||||
DeviceName << "Unknown";
|
||||
} else if (devShort && devFull) {
|
||||
DeviceName << devFull << "(" << devShort << ")";
|
||||
} else {
|
||||
DeviceName << (devShort ? devShort : devFull);
|
||||
}
|
||||
|
||||
SetAttribute("Device name", DeviceName);
|
||||
SetAttribute("Manufacturer", ManufacturerName);
|
||||
SetAttribute("Driver used", "Not implemented");
|
||||
SetAttribute("Device paths", "Not implemented");
|
||||
SetAttribute("Class Info", classInfo);
|
||||
fCategory = (Category)fClassBaseId;
|
||||
BString outlineName;
|
||||
outlineName << ManufacturerName << " " << DeviceName;
|
||||
SetText(outlineName.String());
|
||||
}
|
||||
|
||||
|
||||
Attributes
|
||||
DevicePCI::GetBusAttributes()
|
||||
{
|
||||
Attributes attributes;
|
||||
attributes.push_back(GetAttribute(B_DEVICE_TYPE));
|
||||
attributes.push_back(GetAttribute(B_DEVICE_SUB_TYPE));
|
||||
attributes.push_back(GetAttribute(B_DEVICE_INTERFACE));
|
||||
attributes.push_back(GetAttribute(B_DEVICE_VENDOR_ID));
|
||||
attributes.push_back(GetAttribute(B_DEVICE_ID));
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
DevicePCI::GetBusStrings()
|
||||
{
|
||||
BString str;
|
||||
str << "Class Info:\t\t\t\t: " << fAttributeMap["Class Info"];
|
||||
return str;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
#ifndef DEVICEPCI_H
|
||||
#define DEVICEPCI_H
|
||||
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
|
||||
class DevicePCI : public Device {
|
||||
public:
|
||||
DevicePCI(Device* parent);
|
||||
virtual ~DevicePCI();
|
||||
virtual Attributes GetBusAttributes();
|
||||
virtual BString GetBusStrings();
|
||||
virtual void InitFromAttributes();
|
||||
|
||||
virtual BString GetBusTabName()
|
||||
{ return "PCI Information"; }
|
||||
|
||||
private:
|
||||
uint16 fClassBaseId;
|
||||
uint16 fClassSubId;
|
||||
uint16 fClassApiId;
|
||||
uint16 fVendorId;
|
||||
uint16 fDeviceId;
|
||||
uint16 fSubsystemVendorId;
|
||||
uint16 fSubSystemId;
|
||||
};
|
||||
|
||||
#endif /* DEVICEPCI_H */
|
||||
@@ -1,67 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003-2004, Haiku
|
||||
//
|
||||
// This software is part of the Haiku distribution and is covered
|
||||
// by the Haiku license.
|
||||
//
|
||||
//
|
||||
// File: Devices.cpp
|
||||
// Author: Sikosis, Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : March 04, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
|
||||
// Includes -------------------------------------------------------------------------------------------------- //
|
||||
#include <Application.h>
|
||||
|
||||
#include "DevicesWindows.h"
|
||||
|
||||
#define APP_SIGNATURE "application/x-vnd.Haiku.Devices" // Application Signature and Title
|
||||
|
||||
class Devices : public BApplication
|
||||
{
|
||||
public:
|
||||
Devices();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
// Devices -- constructor
|
||||
Devices::Devices() : BApplication (APP_SIGNATURE)
|
||||
{
|
||||
BRect DevicesWindowRect(0,0,396,400);
|
||||
new DevicesWindow(DevicesWindowRect);
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// Devices::MessageReceived -- handles incoming messages
|
||||
void Devices::MessageReceived (BMessage *message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
default:
|
||||
BApplication::MessageReceived(message); // pass it along ...
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// Devices Main
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
Devices theApp;
|
||||
theApp.Run();
|
||||
return 0;
|
||||
}
|
||||
// end ------------------------------------------------------------------------------------------------------ //
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
resource app_signature "application/x-vnd.Haiku.Devices";
|
||||
resource app_signature "application/x-vnd.Haiku-Devices";
|
||||
|
||||
resource app_version
|
||||
{
|
||||
@@ -9,12 +9,12 @@ resource app_version
|
||||
|
||||
/* 0 = development 1 = alpha 2 = beta
|
||||
3 = gamma 4 = golden master 5 = final */
|
||||
variety = 2,
|
||||
variety = 1,
|
||||
|
||||
internal = 0,
|
||||
|
||||
short_info = "Devices",
|
||||
long_info = "Devices ©2002-2009 Haiku"
|
||||
long_info = "Devices ©2009 Haiku"
|
||||
};
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include "DevicesView.h"
|
||||
|
||||
|
||||
class DevicesApplication : public BApplication {
|
||||
public:
|
||||
DevicesApplication();
|
||||
virtual void AboutRequested();
|
||||
static void ShowAbout();
|
||||
};
|
||||
|
||||
|
||||
class DevicesWindow : public BWindow {
|
||||
public:
|
||||
DevicesWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
private:
|
||||
DevicesView* fDevicesView;
|
||||
};
|
||||
|
||||
|
||||
DevicesApplication::DevicesApplication()
|
||||
:
|
||||
BApplication("application/x-vnd.Haiku-Devices")
|
||||
{
|
||||
DevicesWindow* window = new DevicesWindow();
|
||||
window->CenterOnScreen();
|
||||
window->Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesApplication::AboutRequested()
|
||||
{
|
||||
ShowAbout();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesApplication::ShowAbout()
|
||||
{
|
||||
BAlert* alert = new BAlert("about", "Devices\n"
|
||||
"\twritten by Pieter Panman\n"
|
||||
"\n"
|
||||
"\tBased on listdev by Jérôme Duval\n"
|
||||
"\tand the previous Devices preference\n"
|
||||
"\tby Jérôme Duval and Sikosis\n"
|
||||
"\tCopyright 2009, Haiku Inc.\n", "Ok");
|
||||
BTextView* view = alert->TextView();
|
||||
BFont font;
|
||||
|
||||
view->SetStylable(true);
|
||||
|
||||
view->GetFont(&font);
|
||||
font.SetSize(18);
|
||||
font.SetFace(B_BOLD_FACE);
|
||||
view->SetFontAndColor(0, 7, &font);
|
||||
|
||||
alert->Go();
|
||||
}
|
||||
|
||||
|
||||
DevicesWindow::DevicesWindow()
|
||||
:
|
||||
BWindow(BRect(50, 50, 750, 550), "Devices", B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
|
||||
| B_QUIT_ON_WINDOW_CLOSE)
|
||||
{
|
||||
float minWidth;
|
||||
float maxWidth;
|
||||
float minHeight;
|
||||
float maxHeight;
|
||||
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||
minWidth = 600;
|
||||
minHeight = 300;
|
||||
SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||
fDevicesView = new DevicesView(Bounds());
|
||||
AddChild(fDevicesView);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgRefresh:
|
||||
case kMsgReportCompatibility:
|
||||
case kMsgGenerateSysInfo:
|
||||
case kMsgSelectionChanged:
|
||||
case kMsgOrderCategory:
|
||||
case kMsgOrderConnection:
|
||||
fDevicesView->MessageReceived(message);
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
DevicesApplication app;
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2004, Haiku
|
||||
//
|
||||
// This software is part of the Haiku distribution and is covered
|
||||
// by the Haiku license.
|
||||
//
|
||||
//
|
||||
// File: DevicesInfo.cpp
|
||||
// Author: Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : April 15, 2004
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
#include <strings.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
#include "DevicesInfo.h"
|
||||
#include <stdio.h>
|
||||
#include "isapnpids.h"
|
||||
|
||||
const char *base_desc[] = {
|
||||
"Legacy",
|
||||
"Mass Storage Controller",
|
||||
"Network Controller", // "NIC"
|
||||
"Display Controller",
|
||||
"Multimedia Device",
|
||||
"Memory Controller",
|
||||
"Bridge Device",
|
||||
"Communication Device",
|
||||
"Motherboard Device", // "Generic System Peripheral"
|
||||
"Input Device",
|
||||
"Docking Station",
|
||||
"Processor", // "CPU"
|
||||
"Serial Bus Controller"
|
||||
};
|
||||
|
||||
struct subtype_descriptions {
|
||||
uchar base, subtype;
|
||||
char *name;
|
||||
} subtype_desc[] = {
|
||||
{ 0, 0, "non-VGA" },
|
||||
{ 0, 0, "VGA" },
|
||||
{ 1, 0, "SCSI Controller" },
|
||||
{ 1, 1, "IDE Controller" }, // "IDE"
|
||||
{ 1, 2, "Floppy Controller" }, // "Floppy"
|
||||
{ 1, 3, "IPI" },
|
||||
{ 1, 4, "RAID" },
|
||||
{ 2, 0, "Ethernet" },
|
||||
{ 2, 1, "Token Ring" },
|
||||
{ 2, 2, "FDDI" },
|
||||
{ 2, 3, "ATM" },
|
||||
{ 3, 0, "VGA" }, // "VGA/8514"
|
||||
{ 3, 1, "XGA" },
|
||||
{ 4, 0, "Video" },
|
||||
{ 4, 1, "Sound" }, // was "Audio"
|
||||
{ 5, 0, "RAM" },
|
||||
{ 5, 1, "Flash Memory" }, // "Flash"
|
||||
{ 6, 0, "Host bridge" }, // "Host"
|
||||
{ 6, 1, "ISA bridge" }, // "ISA"
|
||||
{ 6, 2, "EISA" },
|
||||
{ 6, 3, "MCA" },
|
||||
{ 6, 4, "PCI-PCI bridge"}, // "PCI-PCI"
|
||||
{ 6, 5, "PCMCIA" },
|
||||
{ 6, 6, "NuBus" },
|
||||
{ 6, 7, "CardBus bridge" }, // "CardBus"
|
||||
{ 7, 0, "Serial Port" }, // "Serial"
|
||||
{ 7, 1, "Parallel Port" }, // "Parallel"
|
||||
{ 8, 0, "PIC" },
|
||||
{ 8, 1, "DMA" },
|
||||
{ 8, 2, "Timer" },
|
||||
{ 8, 3, "RTC" },
|
||||
{ 9, 0, "Keyboard" },
|
||||
{ 9, 1, "Digitizer" },
|
||||
{ 9, 2, "Mouse" },
|
||||
{10, 0, "Generic" },
|
||||
{11, 0, "386" },
|
||||
{11, 1, "486" },
|
||||
{11, 2, "Pentium" },
|
||||
{11,16, "Alpha" },
|
||||
{11,32, "PowerPC" },
|
||||
{11,48, "Coprocessor" },
|
||||
{12, 0, "FireWire" }, // was "IEEE 1394"
|
||||
{12, 1, "ACCESS" },
|
||||
{12, 2, "SSA" },
|
||||
{12, 3, "USB" },
|
||||
{12, 4, "Fibre Channel" },
|
||||
{255,255, NULL }
|
||||
};
|
||||
|
||||
|
||||
DevicesInfo::DevicesInfo(struct device_info *info,
|
||||
struct device_configuration *current,
|
||||
struct possible_device_configurations *possible)
|
||||
: fInfo(info),
|
||||
fCurrent(current),
|
||||
fPossible(possible)
|
||||
{
|
||||
struct subtype_descriptions *s = NULL;
|
||||
|
||||
if (info->devtype.subtype != 0x80) {
|
||||
s = subtype_desc;
|
||||
|
||||
while (s->name) {
|
||||
if ((info->devtype.base == s->base) && (info->devtype.subtype == s->subtype))
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
fDeviceName = strdup((info->devtype.base < 13)
|
||||
? ( (s && s->name) ? s->name : base_desc[info->devtype.base])
|
||||
: "Unknown");
|
||||
|
||||
fCardName = fDeviceName;
|
||||
if (fInfo->bus == B_ISA_BUS) {
|
||||
uint32 id = fInfo->id[0];
|
||||
if ((id >> 24 == 'P')
|
||||
&& (((id >> 16) & 0xff) == 'n')
|
||||
&& (((id >> 8) & 0xff) == 'P')) {
|
||||
id = fInfo->id[3];
|
||||
char string[255];
|
||||
sprintf(string, "%c%c%c%x%x%x%x",
|
||||
((uint8)(id >> 2) & 0x1f) + 'A' - 1,
|
||||
((uint8)(id & 0x3) << 3) + ((uint8)(id >> 13) & 0x7) + 'A' - 1,
|
||||
(uint8)(id >> 8) & 0x1f + 'A' - 1,
|
||||
(uint8)(id >> 20) & 0xf,
|
||||
(uint8)(id >> 16) & 0xf,
|
||||
(uint8)(id >> 28) & 0xf,
|
||||
(uint8)((id >> 24) & 0xf));
|
||||
for (uint32 i=0; i<ISA_DEVTABLE_LEN; i++)
|
||||
if (strcasecmp(isapnp_devids[i].id, string)==0) {
|
||||
fCardName = isapnp_devids[i].devname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fBaseString = strdup((info->devtype.base < 13) ? base_desc[info->devtype.base] : "Unknown");
|
||||
fSubTypeString = strdup((s && s->name) ? s->name : "Unknown");
|
||||
}
|
||||
|
||||
|
||||
DevicesInfo::~DevicesInfo()
|
||||
{
|
||||
delete fInfo;
|
||||
delete fCurrent;
|
||||
delete fPossible;
|
||||
delete fDeviceName;
|
||||
delete fBaseString;
|
||||
delete fSubTypeString;
|
||||
}
|
||||
|
||||
|
||||
DeviceItem::DeviceItem(DevicesInfo *info, const char* name)
|
||||
: BListItem(),
|
||||
fInfo(info),
|
||||
fWindow(NULL)
|
||||
{
|
||||
fName = strdup(name);
|
||||
}
|
||||
|
||||
DeviceItem::~DeviceItem()
|
||||
{
|
||||
delete fName;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DrawItem
|
||||
***********************************************************/
|
||||
void
|
||||
DeviceItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
||||
{
|
||||
rgb_color kBlack = { 0,0,0,0 };
|
||||
rgb_color kHighlight = { 156,154,156,0 };
|
||||
|
||||
if (IsSelected() || complete) {
|
||||
rgb_color color;
|
||||
if (IsSelected())
|
||||
color = kHighlight;
|
||||
else
|
||||
color = owner->ViewColor();
|
||||
|
||||
owner->SetHighColor(color);
|
||||
owner->SetLowColor(color);
|
||||
owner->FillRect(itemRect);
|
||||
owner->SetHighColor(kBlack);
|
||||
|
||||
} else {
|
||||
owner->SetLowColor(owner->ViewColor());
|
||||
}
|
||||
|
||||
BFont font = be_plain_font;
|
||||
font_height finfo;
|
||||
font.GetHeight(&finfo);
|
||||
|
||||
BPoint point = BPoint(itemRect.left + 4, itemRect.bottom - finfo.descent + 1);
|
||||
|
||||
owner->SetHighColor(kBlack);
|
||||
owner->SetFont(&font);
|
||||
owner->MovePenTo(point);
|
||||
owner->DrawString(fName);
|
||||
|
||||
if (fInfo) {
|
||||
point += BPoint(222, 0);
|
||||
BString string = "enabled";
|
||||
if (!(fInfo->GetInfo()->flags & B_DEVICE_INFO_ENABLED))
|
||||
switch (fInfo->GetInfo()->config_status) {
|
||||
case B_DEV_RESOURCE_CONFLICT: string = "disabled by system"; break;
|
||||
case B_DEV_DISABLED_BY_USER: string = "disabled by user"; break;
|
||||
default: string = "disabled for unknown reason"; break;
|
||||
}
|
||||
|
||||
owner->MovePenTo(point);
|
||||
owner->DrawString(string.String());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2004, Haiku
|
||||
//
|
||||
// This software is part of the Haiku distribution and is covered
|
||||
// by the Haiku license.
|
||||
//
|
||||
//
|
||||
// File: DevicesInfo.h
|
||||
// Author: Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : April 15, 2004
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
#ifndef __DEVICESINFO_H__
|
||||
#define __DEVICESINFO_H__
|
||||
|
||||
#include <drivers/config_manager.h>
|
||||
#include <ListItem.h>
|
||||
#include <Window.h>
|
||||
|
||||
class DevicesInfo
|
||||
{
|
||||
public:
|
||||
DevicesInfo(struct device_info *info,
|
||||
struct device_configuration *current,
|
||||
struct possible_device_configurations *possible);
|
||||
~DevicesInfo();
|
||||
struct device_info * GetInfo() { return fInfo;}
|
||||
char * GetDeviceName() const { return fDeviceName; }
|
||||
char * GetCardName() const { return fCardName; }
|
||||
char * GetBaseString() const { return fBaseString; }
|
||||
char * GetSubTypeString() const { return fSubTypeString; }
|
||||
struct device_configuration * GetCurrent() { return fCurrent;}
|
||||
char * GetISAName() const;
|
||||
private:
|
||||
struct device_info *fInfo;
|
||||
struct device_configuration *fCurrent;
|
||||
struct possible_device_configurations *fPossible;
|
||||
char* fDeviceName, *fCardName, *fBaseString, *fSubTypeString;
|
||||
};
|
||||
|
||||
class DeviceItem : public BListItem
|
||||
{
|
||||
public:
|
||||
DeviceItem(DevicesInfo *info, const char* name);
|
||||
~DeviceItem();
|
||||
DevicesInfo *GetInfo() { return fInfo; }
|
||||
virtual void DrawItem(BView *, BRect, bool = false);
|
||||
BWindow *GetWindow() { return fWindow; };
|
||||
void SetWindow(BWindow *window) { fWindow = window; };
|
||||
private:
|
||||
DevicesInfo *fInfo;
|
||||
char* fName;
|
||||
BWindow *fWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <MenuBar.h>
|
||||
|
||||
#include "DevicesView.h"
|
||||
|
||||
|
||||
DevicesView::DevicesView(const BRect& rect)
|
||||
: BView(rect, "DevicesView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS)
|
||||
{
|
||||
CreateLayout();
|
||||
RescanDevices();
|
||||
RebuildDevicesOutline();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::CreateLayout()
|
||||
{
|
||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
|
||||
BMenuBar* menuBar = new BMenuBar("menu");
|
||||
BMenu* menu = new BMenu("Devices");
|
||||
BMenuItem* item;
|
||||
menu->AddItem(new BMenuItem("Refresh Devices", new BMessage(kMsgRefresh), 'R'));
|
||||
menu->AddItem(item = new BMenuItem("Report Compatibility",
|
||||
new BMessage(kMsgReportCompatibility)));
|
||||
item->SetEnabled(false);
|
||||
menu->AddItem(item = new BMenuItem("Generate System Information",
|
||||
new BMessage(kMsgGenerateSysInfo)));
|
||||
item->SetEnabled(false);
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(item = new BMenuItem("About Devices" B_UTF8_ELLIPSIS,
|
||||
new BMessage(B_ABOUT_REQUESTED)));
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
|
||||
menu->SetTargetForItems(this);
|
||||
item->SetTarget(be_app);
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
fDevicesOutline = new BOutlineListView("devices_list");
|
||||
fDevicesOutline->SetTarget(this);
|
||||
fDevicesOutline->SetSelectionMessage(new BMessage(kMsgSelectionChanged));
|
||||
|
||||
BScrollView *scrollView = new BScrollView("devicesScrollView",
|
||||
fDevicesOutline, B_WILL_DRAW | B_FRAME_EVENTS, true, true);
|
||||
// Horizontal scrollbar doesn't behave properly like the vertical
|
||||
// scrollbar... If you make the view bigger (exposing a larger percentage
|
||||
// of the view), it does not adjust the width of the scroll 'dragger'
|
||||
// why? Bug? In scrollview or in outlinelistview?
|
||||
|
||||
BPopUpMenu* orderByPopupMenu = new BPopUpMenu("orderByMenu");
|
||||
BMenuItem* byCategory = new BMenuItem("category",
|
||||
new BMessage(kMsgOrderCategory));
|
||||
BMenuItem* byConnection = new BMenuItem("connection",
|
||||
new BMessage(kMsgOrderConnection));
|
||||
byCategory->SetMarked(true);
|
||||
fOrderBy = byCategory->IsMarked() ? ORDER_BY_CATEGORY :
|
||||
ORDER_BY_CONNECTION;
|
||||
orderByPopupMenu->AddItem(byCategory);
|
||||
orderByPopupMenu->AddItem(byConnection);
|
||||
fOrderByMenu = new BMenuField("Order by:", orderByPopupMenu);
|
||||
|
||||
fTabView = new BTabView("fTabView", B_WIDTH_FROM_LABEL);
|
||||
|
||||
fBasicTab = new BTab();
|
||||
fBasicView = new PropertyListPlain("basicView");
|
||||
fTabView->AddTab(fBasicView, fBasicTab);
|
||||
fBasicTab->SetLabel("Basic Information");
|
||||
|
||||
fDeviceTypeTab = new BTab();
|
||||
fBusView = new PropertyListPlain("busView");
|
||||
fTabView->AddTab(fBusView, fDeviceTypeTab);
|
||||
fDeviceTypeTab->SetLabel("Bus");
|
||||
|
||||
fDetailedTab = new BTab();
|
||||
fAttributesView = new PropertyList("attributesView");
|
||||
fTabView->AddTab(fAttributesView, fDetailedTab);
|
||||
fDetailedTab->SetLabel("Detailed");
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL,0)
|
||||
.Add(menuBar)
|
||||
.Add(BSplitLayoutBuilder(B_HORIZONTAL, 5)
|
||||
.Add(BGroupLayoutBuilder(B_VERTICAL, 5)
|
||||
.Add(fOrderByMenu, 1)
|
||||
.Add(scrollView, 2)
|
||||
)
|
||||
.Add(fTabView, 2)
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::RescanDevices()
|
||||
{
|
||||
// Empty the outline and delete the devices in the list, incl. categories
|
||||
fDevicesOutline->MakeEmpty();
|
||||
DeleteDevices();
|
||||
DeleteCategoryMap();
|
||||
|
||||
// Fill the devices list
|
||||
status_t error;
|
||||
device_node_cookie rootCookie;
|
||||
if ((error = init_dm_wrapper()) < 0) {
|
||||
std::cerr << "Error initializing device manager: " << strerror(error)
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
get_root(&rootCookie);
|
||||
AddDeviceAndChildren(&rootCookie, NULL);
|
||||
|
||||
uninit_dm_wrapper();
|
||||
|
||||
CreateCategoryMap();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::DeleteDevices()
|
||||
{
|
||||
while(fDevices.size() > 0) {
|
||||
delete fDevices.back();
|
||||
fDevices.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::CreateCategoryMap()
|
||||
{
|
||||
CategoryMapIterator iter;
|
||||
for (unsigned int i = 0; i < fDevices.size(); i++) {
|
||||
Category category = fDevices[i]->GetCategory();
|
||||
const char* categoryName = kCategoryString[category];
|
||||
|
||||
iter = fCategoryMap.find(category);
|
||||
if( iter == fCategoryMap.end() ) {
|
||||
// This category has not yet been added, add it.
|
||||
fCategoryMap[category] = new Device(NULL, BUS_NONE, CAT_NONE,
|
||||
categoryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::DeleteCategoryMap()
|
||||
{
|
||||
CategoryMapIterator iter;
|
||||
for(iter = fCategoryMap.begin(); iter != fCategoryMap.end(); iter++) {
|
||||
delete iter->second;
|
||||
}
|
||||
fCategoryMap.clear();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DevicesView::SortItemsCompare(const BListItem *item1,
|
||||
const BListItem *item2)
|
||||
{
|
||||
const BStringItem* stringItem1 = dynamic_cast<const BStringItem*>(item1);
|
||||
const BStringItem* stringItem2 = dynamic_cast<const BStringItem*>(item2);
|
||||
if (!(stringItem1 && stringItem2)) {
|
||||
// is this check necessary?
|
||||
std::cerr << "Could not cast BListItem to BStringItem, file a bug\n";
|
||||
return 0;
|
||||
}
|
||||
return Compare(stringItem1->Text(),stringItem2->Text());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::RebuildDevicesOutline()
|
||||
{
|
||||
// Rearranges existing Devices into the proper hierarchy
|
||||
fDevicesOutline->MakeEmpty();
|
||||
|
||||
if (fOrderBy == ORDER_BY_CONNECTION) {
|
||||
for (unsigned int i = 0; i < fDevices.size(); i++) {
|
||||
if (fDevices[i]->GetPhysicalParent() == NULL) {
|
||||
// process each parent device and its children
|
||||
fDevicesOutline->AddItem(fDevices[i]);
|
||||
AddChildrenToOutlineByConnection(fDevices[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fOrderBy == ORDER_BY_CATEGORY) {
|
||||
// Add all categories to the outline
|
||||
CategoryMapIterator iter;
|
||||
for (iter = fCategoryMap.begin(); iter != fCategoryMap.end(); iter++) {
|
||||
fDevicesOutline->AddItem(iter->second);
|
||||
}
|
||||
|
||||
// Add all devices under the categories
|
||||
for (unsigned int i = 0; i < fDevices.size(); i++) {
|
||||
Category category = fDevices[i]->GetCategory();
|
||||
|
||||
iter = fCategoryMap.find(category);
|
||||
if(iter == fCategoryMap.end()) {
|
||||
std::cerr << "Tried to add device without category, file a bug\n";
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
fDevicesOutline->AddUnder(fDevices[i], iter->second);
|
||||
}
|
||||
}
|
||||
fDevicesOutline->SortItemsUnder(NULL, true, SortItemsCompare);
|
||||
}
|
||||
// TODO: Implement BY_BUS
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::AddChildrenToOutlineByConnection(Device* parent)
|
||||
{
|
||||
for (unsigned int i = 0; i < fDevices.size(); i++) {
|
||||
if (fDevices[i]->GetPhysicalParent() == parent) {
|
||||
fDevicesOutline->AddUnder(fDevices[i], parent);
|
||||
AddChildrenToOutlineByConnection(fDevices[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::AddDeviceAndChildren(device_node_cookie *node, Device* parent)
|
||||
{
|
||||
Attributes attributes;
|
||||
Device* newDevice = NULL;
|
||||
|
||||
// Copy all its attributes,
|
||||
// necessary because we can only request them once from the device manager
|
||||
char data[256];
|
||||
struct device_attr_info attr;
|
||||
attr.cookie = 0;
|
||||
attr.node_cookie = *node;
|
||||
attr.value.raw.data = data;
|
||||
attr.value.raw.length = sizeof(data);
|
||||
|
||||
while (dm_get_next_attr(&attr) == B_OK) {
|
||||
BString attrString;
|
||||
switch (attr.type) {
|
||||
case B_STRING_TYPE:
|
||||
attrString << attr.value.string;
|
||||
break;
|
||||
case B_UINT8_TYPE:
|
||||
attrString << attr.value.ui8;
|
||||
break;
|
||||
case B_UINT16_TYPE:
|
||||
attrString << attr.value.ui16;
|
||||
break;
|
||||
case B_UINT32_TYPE:
|
||||
attrString << attr.value.ui32;
|
||||
break;
|
||||
case B_UINT64_TYPE:
|
||||
attrString << attr.value.ui64;
|
||||
break;
|
||||
default:
|
||||
attrString << "Raw data";
|
||||
}
|
||||
attributes.push_back(Attribute(attr.name, attrString));
|
||||
}
|
||||
|
||||
// Determine what type of device it is and create it
|
||||
for (unsigned int i = 0; i < attributes.size(); i++) {
|
||||
// Devices Root
|
||||
if (attributes[i].fName == "device/pretty name"
|
||||
&& attributes[i].fValue == "Devices Root") {
|
||||
newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, "Computer");
|
||||
break;
|
||||
}
|
||||
|
||||
// PCI bus
|
||||
if (attributes[i].fName == "device/pretty name"
|
||||
&& attributes[i].fValue == "PCI") {
|
||||
newDevice = new Device(parent, BUS_PCI, CAT_BUS, "PCI Bus");
|
||||
break;
|
||||
}
|
||||
|
||||
// ISA bus
|
||||
if (attributes[i].fName == "device/bus"
|
||||
&& attributes[i].fValue == "isa") {
|
||||
newDevice = new Device(parent, BUS_ISA, CAT_BUS, "ISA Bus");
|
||||
break;
|
||||
}
|
||||
|
||||
// PCI device
|
||||
if (attributes[i].fName == B_DEVICE_BUS
|
||||
&& attributes[i].fValue == "pci") {
|
||||
newDevice = new DevicePCI(parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (newDevice == NULL) {
|
||||
newDevice = new Device(parent, BUS_NONE, CAT_NONE, "Unknown Device");
|
||||
}
|
||||
|
||||
// Add its attributes to the device, initialize it and add to the list.
|
||||
for (unsigned int i = 0; i < attributes.size(); i++) {
|
||||
newDevice->SetAttribute(attributes[i].fName, attributes[i].fValue);
|
||||
}
|
||||
newDevice->InitFromAttributes();
|
||||
fDevices.push_back(newDevice);
|
||||
|
||||
// Process children
|
||||
status_t err;
|
||||
device_node_cookie child = *node;
|
||||
|
||||
if (get_child(&child) != B_OK)
|
||||
return;
|
||||
|
||||
do {
|
||||
AddDeviceAndChildren(&child, newDevice);
|
||||
} while ((err = get_next_child(&child)) == B_OK);
|
||||
}
|
||||
|
||||
|
||||
DevicesView::~DevicesView()
|
||||
{
|
||||
DeleteDevices();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DevicesView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case kMsgSelectionChanged:
|
||||
{
|
||||
int32 selected = fDevicesOutline->CurrentSelection(0);
|
||||
if (selected >= 0) {
|
||||
Device* device = (Device*)fDevicesOutline->ItemAt(selected);
|
||||
fBasicView->AddAttributes(device->GetBasicAttributes());
|
||||
fBusView->AddAttributes(device->GetBusAttributes());
|
||||
fAttributesView->AddAttributes(device->GetAllAttributes());
|
||||
fDeviceTypeTab->SetLabel(device->GetBusTabName());
|
||||
// hmm the label doesn't automatically refresh
|
||||
fTabView->Invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgOrderCategory:
|
||||
{
|
||||
fOrderBy = ORDER_BY_CATEGORY;
|
||||
RescanDevices();
|
||||
RebuildDevicesOutline();
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgOrderConnection:
|
||||
{
|
||||
fOrderBy = ORDER_BY_CONNECTION;
|
||||
RescanDevices();
|
||||
RebuildDevicesOutline();
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgRefresh:
|
||||
{
|
||||
RescanDevices();
|
||||
RebuildDevicesOutline();
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgReportCompatibility:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgGenerateSysInfo:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
#ifndef DEVICESVIEW_H
|
||||
#define DEVICESVIEW_H
|
||||
|
||||
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <OutlineListView.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <SplitLayoutBuilder.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
#include <TabView.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "Device.h"
|
||||
#include "DevicePCI.h"
|
||||
#include "PropertyList.h"
|
||||
#include "PropertyListPlain.h"
|
||||
|
||||
static const uint32 kMsgRefresh = 'refr';
|
||||
static const uint32 kMsgReportCompatibility = 'repo';
|
||||
static const uint32 kMsgGenerateSysInfo = 'sysi';
|
||||
static const uint32 kMsgSelectionChanged = 'selc';
|
||||
static const uint32 kMsgOrderCategory = 'ocat';
|
||||
static const uint32 kMsgOrderConnection = 'ocon';
|
||||
|
||||
typedef enum {
|
||||
ORDER_BY_CONNECTION,
|
||||
ORDER_BY_CATEGORY
|
||||
} OrderByType;
|
||||
|
||||
typedef std::map<Category, Device*> CategoryMap;
|
||||
typedef std::map<Category, Device*>::const_iterator CategoryMapIterator;
|
||||
|
||||
typedef std::vector<Device*> Devices;
|
||||
|
||||
|
||||
class DevicesView : public BView {
|
||||
public:
|
||||
DevicesView(const BRect& r);
|
||||
~DevicesView();
|
||||
|
||||
virtual void CreateLayout();
|
||||
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
virtual void RescanDevices();
|
||||
virtual void CreateCategoryMap();
|
||||
virtual void DeleteCategoryMap();
|
||||
|
||||
virtual void DeleteDevices();
|
||||
virtual void RebuildDevicesOutline();
|
||||
virtual void AddChildrenToOutlineByConnection(Device* parent);
|
||||
virtual void AddDeviceAndChildren(device_node_cookie* node,
|
||||
Device* parent);
|
||||
static int SortItemsCompare(const BListItem*, const BListItem*);
|
||||
|
||||
private:
|
||||
BOutlineListView* fDevicesOutline;
|
||||
PropertyListPlain* fBasicView;
|
||||
PropertyListPlain* fBusView;
|
||||
PropertyList* fAttributesView;
|
||||
BMenuField* fOrderByMenu;
|
||||
BTabView* fTabView;
|
||||
Devices fDevices;
|
||||
OrderByType fOrderBy;
|
||||
CategoryMap fCategoryMap;
|
||||
BTab* fBasicTab;
|
||||
BTab* fDeviceTypeTab;
|
||||
BTab* fDetailedTab;
|
||||
|
||||
};
|
||||
|
||||
#endif /* DEVICESVIEW_H */
|
||||
@@ -1,507 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003-2004, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: DevicesWindow.cpp
|
||||
// Author: Sikosis, Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : March 04, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
// Includes -------------------------------------------------------------------------------------------------- //
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <ClassInfo.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <MenuBar.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <OutlineListView.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include "DevicesWindows.h"
|
||||
#include "DevicesInfo.h"
|
||||
|
||||
const uint32 MENU_FILE_ABOUT_DEVICES = 'mfad';
|
||||
const uint32 MENU_FILE_QUIT = 'mfqt';
|
||||
const uint32 MENU_DEVICES_REMOVE_JUMPERED_DEVICE = 'mdrj';
|
||||
const uint32 MENU_DEVICES_NEW_JUMPERED_DEVICE = 'mdnj';
|
||||
const uint32 MENU_DEVICES_NEW_JUMPERED_DEVICE_CUSTOM = 'mdcj';
|
||||
const uint32 MENU_DEVICES_NEW_JUMPERED_DEVICE_MODEM = 'mdcm';
|
||||
const uint32 MENU_DEVICES_RESOURCE_USAGE = 'mdru';
|
||||
const uint32 BTN_CONFIGURE = 'bcfg';
|
||||
const uint32 SELECTION_CHANGED = 'slch';
|
||||
|
||||
|
||||
// DevicesWindow - Constructor
|
||||
DevicesWindow::DevicesWindow(BRect frame) : BWindow (frame, "Devices", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0)
|
||||
{
|
||||
InitWindow();
|
||||
CenterOnScreen();
|
||||
|
||||
// Load User Settings
|
||||
BPath path;
|
||||
find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
||||
path.Append("Devices_Settings",true);
|
||||
BFile file(path.Path(),B_READ_ONLY);
|
||||
BMessage msg;
|
||||
msg.Unflatten(&file);
|
||||
LoadSettings (&msg);
|
||||
|
||||
status_t error;
|
||||
|
||||
if ((error = init_cm_wrapper()) < 0) {
|
||||
printf("Error initializing configuration manager (%s)\n", strerror(error));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
InitDevices(B_ISA_BUS);
|
||||
InitDevices(B_PCI_BUS);
|
||||
|
||||
for (int32 i=fList.CountItems()-1; i>=0; i--) {
|
||||
DevicesInfo *deviceInfo = (DevicesInfo *) fList.ItemAt(i);
|
||||
struct device_info *info = deviceInfo->GetInfo();
|
||||
BListItem *item = systemMenu;
|
||||
if (info->bus == B_ISA_BUS) {
|
||||
uint32 id = info->id[0];
|
||||
if ((id >> 24 == 'P')
|
||||
&& (((id >> 16) & 0xff) == 'n')
|
||||
&& (((id >> 8) & 0xff) == 'P')) {
|
||||
item = isaMenu;
|
||||
} else {
|
||||
item = systemMenu;
|
||||
}
|
||||
} else if (info->bus == B_PCI_BUS)
|
||||
item = pciMenu;
|
||||
|
||||
outline->AddUnder(new DeviceItem(deviceInfo, deviceInfo->GetCardName()), item);
|
||||
}
|
||||
|
||||
if (outline->CountItemsUnder(jumperedMenu, true)==0)
|
||||
outline->AddUnder(new BStringItem("<no devices>"), jumperedMenu);
|
||||
if (outline->CountItemsUnder(pciMenu, true)==0)
|
||||
outline->AddUnder(new BStringItem("<no devices>"), pciMenu);
|
||||
if (outline->CountItemsUnder(isaMenu, true)==0)
|
||||
outline->AddUnder(new BStringItem("<no devices>"), isaMenu);
|
||||
if (outline->CountItemsUnder(systemMenu, true)==0)
|
||||
outline->AddUnder(new BStringItem("<no devices>"), systemMenu);
|
||||
|
||||
Show();
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow - Destructor
|
||||
DevicesWindow::~DevicesWindow()
|
||||
{
|
||||
void *item;
|
||||
while ((item = fList.RemoveItem((int32)0)))
|
||||
delete (DevicesInfo*)item;
|
||||
uninit_cm_wrapper();
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::InitWindow -- Initialization Commands here
|
||||
void DevicesWindow::InitWindow(void)
|
||||
{
|
||||
BRect r;
|
||||
r = Bounds(); // the whole view
|
||||
|
||||
BMenuItem *mniRemoveJumperedDevice;
|
||||
|
||||
// Add the menu bar
|
||||
menubar = new BMenuBar(r, "menu_bar");
|
||||
|
||||
// Add File menu to menu bar
|
||||
BMenu *menu = new BMenu("File");
|
||||
menu->AddItem(new BMenuItem("About Devices" B_UTF8_ELLIPSIS, new BMessage(MENU_FILE_ABOUT_DEVICES), 0));
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem("Quit", new BMessage(MENU_FILE_QUIT), 'Q'));
|
||||
menubar->AddItem(menu);
|
||||
|
||||
menu = new BMenu("Devices");
|
||||
menubar->AddItem(menu);
|
||||
|
||||
BMenu *jumperedDevicesMenu = new BMenu("New Jumpered Device");
|
||||
jumperedDevicesMenu->AddItem(new BMenuItem("Custom" B_UTF8_ELLIPSIS, new BMessage(MENU_DEVICES_NEW_JUMPERED_DEVICE_CUSTOM), 0));
|
||||
jumperedDevicesMenu->AddItem(new BMenuItem("Modem" B_UTF8_ELLIPSIS, new BMessage(MENU_DEVICES_NEW_JUMPERED_DEVICE_MODEM), 0));
|
||||
|
||||
//DevicesMenu->AddItem(new BMenuItem("New Jumpered Device", new BMessage(MENU_DEVICES_NEW_JUMPERED_DEVICE), NULL));
|
||||
menu->AddItem(jumperedDevicesMenu);
|
||||
|
||||
menu->AddItem(mniRemoveJumperedDevice = new BMenuItem("Remove Jumpered Device", new BMessage(MENU_DEVICES_REMOVE_JUMPERED_DEVICE), 'R'));
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem("Resource Usage", new BMessage(MENU_DEVICES_RESOURCE_USAGE), 'U'));
|
||||
|
||||
mniRemoveJumperedDevice->SetEnabled(false);
|
||||
|
||||
// Create the StringViews
|
||||
stvDeviceName = new BStringView(BRect(16, 16, 150, 40), "DeviceName", "Device Name");
|
||||
stvCurrentState = new BStringView(BRect(248, 16, r.right-10, 40), "CurrentState", "Current State");
|
||||
|
||||
float fCurrentHeight = 279;
|
||||
float fCurrentGap = 15;
|
||||
stvIRQ = new BStringView(BRect(r.left+22,r.top+fCurrentHeight,r.right-13,r.top+fCurrentHeight+20),"IRQ","IRQs:", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fCurrentHeight = fCurrentHeight + fCurrentGap;
|
||||
stvDMA = new BStringView(BRect(r.left+22,r.top+fCurrentHeight,r.right-13,r.top+fCurrentHeight+20),"DMA","DMAs:", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fCurrentHeight = fCurrentHeight + fCurrentGap;
|
||||
stvIORanges = new BStringView(BRect(r.left+22,r.top+fCurrentHeight,r.right-13,r.top+fCurrentHeight+20),"IORanges","IO Ranges:", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fCurrentHeight = fCurrentHeight + fCurrentGap;
|
||||
stvMemoryRanges = new BStringView(BRect(r.left+22,r.top+fCurrentHeight,r.right-13,r.top+fCurrentHeight+20),"MemoryRanges","Memory Ranges:", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fCurrentHeight = fCurrentHeight + fCurrentGap;
|
||||
|
||||
// Create the OutlineView
|
||||
BRect outlinerect(r.left+14,r.top+45,r.right-28,r.top+262);
|
||||
BScrollView *outlinesv;
|
||||
|
||||
outline = new BOutlineListView(outlinerect,"devices_list", B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM);
|
||||
outline->AddItem(systemMenu = new DeviceItem(NULL, "System Devices"));
|
||||
outline->AddItem(isaMenu = new DeviceItem(NULL, "ISA/Plug and Play Devices"));
|
||||
outline->AddItem(pciMenu = new DeviceItem(NULL, "PCI Devices"));
|
||||
outline->AddItem(jumperedMenu = new DeviceItem(NULL, "Jumpered Devices"));
|
||||
|
||||
outline->SetSelectionMessage(new BMessage(SELECTION_CHANGED));
|
||||
outline->SetInvocationMessage(new BMessage(BTN_CONFIGURE));
|
||||
|
||||
// Add ScrollView to Devices Window
|
||||
outlinesv = new BScrollView("scroll_devices", outline, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, 0, false, true, B_FANCY_BORDER);
|
||||
|
||||
// Setup the OutlineView
|
||||
outline->AllAttached();
|
||||
outlinesv->SetBorderHighlighted(true);
|
||||
|
||||
// Back and Fore ground Colours
|
||||
outline->SetHighColor(0,0,0,0);
|
||||
outline->SetLowColor(255,255,255,0);
|
||||
|
||||
// Font Settings
|
||||
BFont OutlineFont;
|
||||
OutlineFont.SetSpacing(B_CHAR_SPACING);
|
||||
OutlineFont.SetSize(12);
|
||||
outline->SetFont(&OutlineFont,B_FONT_SHEAR | B_FONT_SPACING);
|
||||
|
||||
// Create BBox (or Frame)
|
||||
BBox *BottomFrame;
|
||||
BRect BottomFrameRect(r.left+11,r.bottom-124,r.right-12,r.bottom-12);
|
||||
BottomFrame = new BBox(BottomFrameRect, "BottomFrame", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);
|
||||
BRect bottomFrameBounds = BottomFrame->Bounds();
|
||||
|
||||
// Create BButton - Configure
|
||||
BRect ConfigureButtonRect(bottomFrameBounds.left+290, bottomFrameBounds.bottom-37,
|
||||
bottomFrameBounds.right-13, bottomFrameBounds.bottom-13);
|
||||
btnConfigure = new BButton(ConfigureButtonRect,"btnConfigure","Configure", new BMessage(BTN_CONFIGURE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
|
||||
btnConfigure->MakeDefault(true);
|
||||
btnConfigure->SetEnabled(false);
|
||||
|
||||
// Create a basic View
|
||||
BBox *background = new BBox(Bounds(), "background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW, B_PLAIN_BORDER);
|
||||
AddChild(background);
|
||||
|
||||
// Add Child(ren) - in reverse order to avoid one control overwriting another
|
||||
background->AddChild(BottomFrame);
|
||||
BottomFrame->AddChild(btnConfigure);
|
||||
background->AddChild(outlinesv);
|
||||
background->AddChild(stvMemoryRanges);
|
||||
background->AddChild(stvIORanges);
|
||||
background->AddChild(stvDMA);
|
||||
background->AddChild(stvIRQ);
|
||||
background->AddChild(stvDeviceName);
|
||||
background->AddChild(stvCurrentState);
|
||||
background->AddChild(menubar);
|
||||
|
||||
// Set Window Limits
|
||||
float xsize = 396 + (be_plain_font->Size()-10)*40;
|
||||
if (xsize > 443)
|
||||
xsize = 443;
|
||||
SetSizeLimits(xsize,xsize,400,BScreen().Frame().Height());
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::QuitRequested -- Post a message to the app to quit
|
||||
bool DevicesWindow::QuitRequested()
|
||||
{
|
||||
SaveSettings();
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::LoadSettings -- Loads your current settings
|
||||
void DevicesWindow::LoadSettings(BMessage *msg)
|
||||
{
|
||||
BRect frame;
|
||||
|
||||
if (B_OK == msg->FindRect("windowframe",&frame)) {
|
||||
MoveTo(frame.left,frame.top);
|
||||
ResizeTo(frame.right-frame.left,frame.bottom-frame.top);
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::SaveSettings -- Saves the Users settings
|
||||
void DevicesWindow::SaveSettings(void)
|
||||
{
|
||||
BMessage msg;
|
||||
msg.AddRect("windowframe",Frame());
|
||||
|
||||
BPath path;
|
||||
status_t result = find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
||||
if (result == B_OK)
|
||||
{
|
||||
path.Append("Devices_Settings",true);
|
||||
BFile file(path.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
msg.Flatten(&file);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// DevicesWindow::MessageReceived -- receives messages
|
||||
void
|
||||
DevicesWindow::MessageReceived (BMessage *message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
case MENU_FILE_ABOUT_DEVICES:
|
||||
{
|
||||
(new BAlert("", "Devices\n\n\t'Just write a simple app to add a jumpered\n\tdevice to the system', he said.\n\n\tAnd many years later another he said\n\t'recreate it' ;)", "OK"))->Go();
|
||||
}
|
||||
break;
|
||||
case MENU_FILE_QUIT:
|
||||
{
|
||||
QuitRequested();
|
||||
}
|
||||
break;
|
||||
case MENU_DEVICES_NEW_JUMPERED_DEVICE_MODEM:
|
||||
{
|
||||
ptrModemWindow = new ModemWindow(BRect(0,0,200,194), BMessenger(this));
|
||||
}
|
||||
break;
|
||||
case MENU_DEVICES_RESOURCE_USAGE:
|
||||
{
|
||||
ptrResourceUsageWindow = new ResourceUsageWindow(BRect(0,0,430,350), fList);
|
||||
}
|
||||
break;
|
||||
case SELECTION_CHANGED:
|
||||
{
|
||||
UpdateDeviceInfo();
|
||||
}
|
||||
break;
|
||||
case MODEM_ADDED:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case BTN_CONFIGURE:
|
||||
{
|
||||
DeviceItem *devItem = dynamic_cast<DeviceItem *>(outline->ItemAt(outline->CurrentSelection()));
|
||||
if (devItem && devItem->GetInfo()) {
|
||||
if (devItem->GetWindow()!=NULL)
|
||||
devItem->GetWindow()->Activate();
|
||||
else
|
||||
new ConfigurationWindow(BRect(150,150,562,602), devItem);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
UpdateIfNeeded();
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
void
|
||||
DevicesWindow::InitDevices(bus_type bus)
|
||||
{
|
||||
status_t size;
|
||||
uint64 cookie;
|
||||
struct device_info dummy, *info;
|
||||
struct device_configuration *current;
|
||||
struct possible_device_configurations *possible;
|
||||
|
||||
cookie = 0;
|
||||
while (get_next_device_info(bus, &cookie, &dummy, sizeof(dummy)) == B_OK) {
|
||||
info = (struct device_info *)malloc(dummy.size);
|
||||
if (!info) {
|
||||
printf("Out of core\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (get_device_info_for(cookie, info, dummy.size) != B_OK) {
|
||||
printf("Error getting device information\n");
|
||||
break;
|
||||
}
|
||||
|
||||
size = get_size_of_current_configuration_for(cookie);
|
||||
if (size < B_OK) {
|
||||
printf("Error getting the size of the current configuration\n");
|
||||
break;
|
||||
}
|
||||
current = (struct device_configuration *)malloc(size);
|
||||
if (!current) {
|
||||
printf("Out of core\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (get_current_configuration_for(cookie, current, size) != B_OK) {
|
||||
printf("Error getting the current configuration\n");
|
||||
break;
|
||||
}
|
||||
|
||||
size = get_size_of_possible_configurations_for(cookie);
|
||||
if (size < B_OK) {
|
||||
printf("Error getting the size of the possible configurations\n");
|
||||
break;
|
||||
}
|
||||
possible = (struct possible_device_configurations *)malloc(size);
|
||||
if (!possible) {
|
||||
printf("Out of core\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (get_possible_configurations_for(cookie, possible, size) != B_OK) {
|
||||
printf("Error getting the possible configurations\n");
|
||||
break;
|
||||
}
|
||||
|
||||
fList.AddItem(new DevicesInfo(info, current, possible));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DevicesWindow::UpdateDeviceInfo()
|
||||
{
|
||||
DeviceItem *item = dynamic_cast<DeviceItem *>(outline->ItemAt(outline->CurrentSelection()));
|
||||
if (item) {
|
||||
DevicesInfo *deviceInfo = item->GetInfo();
|
||||
if (deviceInfo) {
|
||||
struct device_configuration *current = deviceInfo->GetCurrent();
|
||||
resource_descriptor r;
|
||||
|
||||
{
|
||||
BString text = "IRQs: ";
|
||||
bool first = true;
|
||||
int32 num = count_resource_descriptors_of_type(current, B_IRQ_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_IRQ_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
uint32 mask = r.d.m.mask;
|
||||
int i = 0;
|
||||
if (!mask)
|
||||
continue;
|
||||
|
||||
for (;mask;mask>>=1,i++)
|
||||
if (mask & 1) {
|
||||
char value[50];
|
||||
sprintf(value, "%s%d", first ? "" : ", ", i);
|
||||
text += value;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
stvIRQ->SetText(text.String());
|
||||
}
|
||||
|
||||
{
|
||||
BString text = "DMAs: ";
|
||||
bool first = true;
|
||||
int32 num = count_resource_descriptors_of_type(current, B_DMA_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_DMA_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
uint32 mask = r.d.m.mask;
|
||||
int i = 0;
|
||||
if (!mask)
|
||||
continue;
|
||||
|
||||
for (;mask;mask>>=1,i++)
|
||||
if (mask & 1) {
|
||||
char value[50];
|
||||
sprintf(value, "%s%d", first ? "" : ", ", i);
|
||||
text += value;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
stvDMA->SetText(text.String());
|
||||
}
|
||||
|
||||
{
|
||||
BString text = "IO Ranges: ";
|
||||
bool first = true;
|
||||
int32 num = count_resource_descriptors_of_type(current, B_IO_PORT_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_IO_PORT_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
char value[50];
|
||||
sprintf(value, "%s0x%04lx - 0x%04lx", first ? "" : ", ", r.d.r.minbase, r.d.r.minbase + r.d.r.len - 1);
|
||||
text += value;
|
||||
first = false;
|
||||
}
|
||||
if (text.Length()>70) {
|
||||
text.Truncate(70);
|
||||
text += B_UTF8_ELLIPSIS;
|
||||
}
|
||||
stvIORanges->SetText(text.String());
|
||||
}
|
||||
|
||||
{
|
||||
BString text = "Memory Ranges: ";
|
||||
bool first = true;
|
||||
int32 num = count_resource_descriptors_of_type(current, B_MEMORY_RESOURCE);
|
||||
|
||||
for (int32 i=0;i<num;i++) {
|
||||
get_nth_resource_descriptor_of_type(current, i, B_MEMORY_RESOURCE,
|
||||
&r, sizeof(resource_descriptor));
|
||||
char value[50];
|
||||
sprintf(value, "%s0x%06lx - 0x%06lx", first ? "" : ", ", r.d.r.minbase, r.d.r.minbase + r.d.r.len - 1);
|
||||
text += value;
|
||||
first = false;
|
||||
}
|
||||
if (text.Length()>70) {
|
||||
text.Truncate(70);
|
||||
text += B_UTF8_ELLIPSIS;
|
||||
}
|
||||
stvMemoryRanges->SetText(text.String());
|
||||
}
|
||||
|
||||
btnConfigure->SetEnabled(true);
|
||||
} else {
|
||||
BlankDeviceInfoBox();
|
||||
}
|
||||
} else {
|
||||
BlankDeviceInfoBox();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DevicesWindow::BlankDeviceInfoBox()
|
||||
{
|
||||
stvIRQ->SetText("IRQs: ");
|
||||
stvDMA->SetText("DMAs: ");
|
||||
stvIORanges->SetText("IO Ranges: ");
|
||||
stvMemoryRanges->SetText("Memory Ranges: ");
|
||||
btnConfigure->SetEnabled(false);
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003-2004, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: DevicesWindows.h
|
||||
// Author: Sikosis, Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : March 04, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
|
||||
#ifndef __DEVICESWINDOWS_H__
|
||||
#define __DEVICESWINDOWS_H__
|
||||
|
||||
#include <ListView.h>
|
||||
#include <Menu.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "DevicesInfo.h"
|
||||
|
||||
#include "cm_wrapper.h"
|
||||
|
||||
class BMenuField;
|
||||
class BStringView;
|
||||
|
||||
#define MODEM_ADDED 'moad'
|
||||
|
||||
class ResourceUsageWindow : public BWindow {
|
||||
public:
|
||||
ResourceUsageWindow(BRect frame, BList &);
|
||||
~ResourceUsageWindow();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
void InitWindow(BList &);
|
||||
};
|
||||
|
||||
|
||||
class ModemWindow : public BWindow {
|
||||
public:
|
||||
ModemWindow(BRect frame, BMessenger);
|
||||
~ModemWindow();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
private:
|
||||
void InitWindow(void);
|
||||
BMessenger fMessenger;
|
||||
};
|
||||
|
||||
class ConfigurationWindow : public BWindow {
|
||||
public:
|
||||
ConfigurationWindow(BRect frame, DeviceItem *item);
|
||||
~ConfigurationWindow();
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
private:
|
||||
void InitWindow(void);
|
||||
DeviceItem *fItem;
|
||||
BMenu *fConfigurationMenu;
|
||||
BPopUpMenu *fIRQMenu[3];
|
||||
BMenuField *fIRQField[3];
|
||||
BPopUpMenu *fDMAMenu[3];
|
||||
BMenuField *fDMAField[3];
|
||||
BListView *ioListView, *memoryListView;
|
||||
};
|
||||
|
||||
|
||||
class DevicesWindow : public BWindow {
|
||||
public:
|
||||
DevicesWindow(BRect frame);
|
||||
~DevicesWindow();
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
private:
|
||||
void InitWindow(void);
|
||||
void InitDevices(bus_type bus);
|
||||
void LoadSettings(BMessage *msg);
|
||||
void SaveSettings(void);
|
||||
void UpdateDeviceInfo();
|
||||
void BlankDeviceInfoBox();
|
||||
|
||||
ResourceUsageWindow* ptrResourceUsageWindow;
|
||||
ModemWindow* ptrModemWindow;
|
||||
|
||||
BStringView *stvDeviceName;
|
||||
BStringView *stvCurrentState;
|
||||
BMenuBar *menubar;
|
||||
|
||||
BList fList;
|
||||
|
||||
BListItem *systemMenu, *isaMenu, *pciMenu, *jumperedMenu;
|
||||
BOutlineListView *outline;
|
||||
BStringView *stvIRQ;
|
||||
BStringView *stvDMA;
|
||||
BStringView *stvIORanges;
|
||||
BStringView *stvMemoryRanges;
|
||||
BButton *btnConfigure;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
DeviceManager Design
|
||||
====================
|
||||
|
||||
Requirements
|
||||
------------
|
||||
1) Graphically list each device in the system, with all the information available for that specific device type:
|
||||
- PCI
|
||||
- USB
|
||||
- SCSI
|
||||
- Bluetooth?
|
||||
- ISA?
|
||||
- ATAPI?
|
||||
- AHCI?
|
||||
- Firewire?
|
||||
|
||||
2) Generate a comprehensive text listing of the devices present to allow users to share detailed information with developers
|
||||
- Generate an email with this information attached
|
||||
|
||||
3) Let the user generate a report on how well Haiku supports the devices in the system.
|
||||
- Present a list of devices and per device a star rating on the support, and provide a space for comments on the device support.
|
||||
- For each device allow comments
|
||||
- Include all available information for the device (including loaded driver)
|
||||
- Perhaps this can go into the Haikuware compatibility database?
|
||||
|
||||
4) Arrange the devices in different orders (by category, by connection, by bus type, by resource assignment?)
|
||||
|
||||
Graphical Design
|
||||
----------------
|
||||
+=========+
|
||||
| Devices |
|
||||
+=========+======================================================+
|
||||
| Devices | Help | |
|
||||
+----------------------------------------------------------------+
|
||||
| +------------------------+-----------------------------------+ |
|
||||
| | Sort by: [Category v] | / Basic \/ <Bus> \/ Advanced \ | |
|
||||
| | ------------------- | + +--------+----------+--+ | |
|
||||
| | v Audio/Video Devices | | Device Name: Netlink 5787M | | |
|
||||
| | Hauppauge WinTV | | Manufacturer: Broadcom | | |
|
||||
| | Intel HDA Audio | | Category: Network Devices | | |
|
||||
| | v Human Interface Dev. | | Driver used: broadcom570x | | |
|
||||
| | USB Mouse | | | | |
|
||||
| | USB Keyboard | | | | |
|
||||
| | v Network Devices | | | | |
|
||||
| | -->Broadcom 5787M<-- | | | | |
|
||||
| | Intel 4965 WIFI | | | | |
|
||||
| | v Graphics Card | | | | |
|
||||
| | NVidia 8600M GT | | | | |
|
||||
| | .... | +-------------------------------+ | |
|
||||
| +------------------------+-----------------------------------+ |
|
||||
| +-------------------------+ +------------+ +-----------+ |
|
||||
| | Report hardware support | | Gen. email | | Gen. Text | |
|
||||
| +-------------------------+ +------------+ +-----------+ |
|
||||
+================================================================+
|
||||
|
||||
Menu:
|
||||
Devices
|
||||
- Refresh devices
|
||||
- Report compatibility
|
||||
- Generate system information
|
||||
- -----
|
||||
- About Devices
|
||||
- -----
|
||||
- Quit
|
||||
|
||||
Interface details:
|
||||
- The left list is an OutlineListView,
|
||||
- Is inside a scroll container
|
||||
- Will contain nice icons per type/device
|
||||
- Clicking on a device will show the details in the right view
|
||||
|
||||
- The right view contains 3 tabs:
|
||||
- Basic tab: Information available for every kind device
|
||||
- <Bus> tab: Information specific to the bus type of device. (PCI, USB, etc)
|
||||
- Advanced tab: Has a list of name-value pairs of all available information
|
||||
|
||||
- Sort by allows the user to arrange the treeview by:
|
||||
- Category:
|
||||
- Connection
|
||||
- Bus type
|
||||
|
||||
- Report Hardware Support
|
||||
- List all devices
|
||||
- For each device
|
||||
|
||||
When you click Report Hardware Support, this appears:
|
||||
|
||||
+=========================+
|
||||
| Report Hardware Support |
|
||||
+=========================+============================+
|
||||
| Report Device Supported Comment |
|
||||
| [x] Broadcom Netlink 5787M ***** _________ |
|
||||
| [x] Hauppauge WinTV ***** _________ |
|
||||
| [x] Intel 4965 WIFI ..... _________ |
|
||||
| [x] Intel HDA Audio ****. _________ |
|
||||
| [x] NVidia 8600M GT ***.. _________ |
|
||||
| [x] USB Keyboard ***** _________ |
|
||||
| [x] USB Mouse ***** _________ |
|
||||
| [ ] Intel 82801 PCI Bridge ..... _________ |
|
||||
| [ ] Intel 82801H PCI Express ..... _________ |
|
||||
| |
|
||||
| If you wish, you can leave your contact details so |
|
||||
| developers can get in touch with you for questions |
|
||||
| about your devices. These will be stored privately. |
|
||||
| |
|
||||
| Name: _______________ Email: __________________ |
|
||||
| |
|
||||
| Haiku-os.org account: __________________________ |
|
||||
| |
|
||||
| +--------------------+ +---------------+ |
|
||||
| | Preview submission | | Generate File | |
|
||||
| +--------------------+ +---------------+ |
|
||||
+======================================================+
|
||||
|
||||
Interface details:
|
||||
------------------
|
||||
- All devices are _not_ selected for report by default
|
||||
- As soon as a rating is given, it is selected to be reported
|
||||
- Preview submission will popup the generated list with a submit button
|
||||
- Generate file will generate a file that can be uploaded manually, or emailed to a specific address.
|
||||
- As you mouse over the rating, a popup will appear detailing what each star stands for:
|
||||
- ..... : No support
|
||||
- X.... : Crashes Haiku
|
||||
- **... : Detected but doesn't work with 3rd party driver
|
||||
- ***.. : Detected but doesn't work out of the box
|
||||
- ****. : Detected and works with 3rd party driver
|
||||
- ***** : Detected and works out of the box
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
Each device has:
|
||||
- Name (long/short)
|
||||
- Manufacturer (long/short)
|
||||
- Category (one master list, each bus type maps its device types onto the master list)
|
||||
- Driver used
|
||||
- Device paths
|
||||
- Its bus type
|
||||
- Its connection parent, if applicable
|
||||
|
||||
Each source has: (currently the RescanDevices method does this)
|
||||
- Init function
|
||||
- Scan method that returns the devices.
|
||||
- DevManSource, USBSource, FWSource, ...
|
||||
|
||||
DeviceManager Specification
|
||||
===========================
|
||||
|
||||
DeviceManager : BApplication
|
||||
-------------
|
||||
|
||||
DeviceManagerView : BView
|
||||
-----------------
|
||||
|
||||
|
||||
Device : public BStringItem
|
||||
------
|
||||
BString GetName() const;
|
||||
BString GetManufacturer() const;
|
||||
Category GetCategory() const;
|
||||
BString DriverUsed() const;
|
||||
BString DevPathsPublished() const;
|
||||
BView Get
|
||||
private:
|
||||
BString _name;
|
||||
BString _manufacturer;
|
||||
Category _category;
|
||||
BString _driverUsed;
|
||||
BString devPathsPublished;
|
||||
map<BString, BString> _attributes;
|
||||
|
||||
Bus : public BStringItem
|
||||
---
|
||||
virtual bool IsPresent() const = 0;
|
||||
virtual Scan() = 0;
|
||||
virtual vector<Device *> Devices() = 0;
|
||||
|
||||
PCIBus : public Bus
|
||||
------
|
||||
|
||||
PCIDevice: public Device
|
||||
---------
|
||||
|
||||
ISABus : public Bus
|
||||
-----
|
||||
|
||||
ISADevice : public Device
|
||||
---------
|
||||
|
||||
USBBus : public Bus
|
||||
------
|
||||
|
||||
USBDevice : public Device
|
||||
---------
|
||||
|
||||
SCSIBus : public Bus
|
||||
-------
|
||||
|
||||
SCSIDevice : public Device
|
||||
----------
|
||||
@@ -0,0 +1,13 @@
|
||||
TODO:
|
||||
* There still is a memory leak somewhere, hunt it down
|
||||
* Make Get methods of Device const
|
||||
* Fix view color?
|
||||
* Fix forwarding of messages to view
|
||||
* Bottom scrollbar strangeness
|
||||
* Reduce executable size?
|
||||
* Find a place for unknown devices (or decypher the names better)
|
||||
* Reselect currently selected on sort-by change - unique device id (device_node_cookie?)
|
||||
* Check for keyboard navigation
|
||||
* Loading and saving settings (sort by, position, size and sizes of views)
|
||||
* Icons per device type
|
||||
* Index attributes by enum, not string
|
||||
+16
-11
@@ -1,6 +1,10 @@
|
||||
SubDir HAIKU_TOP src apps devices ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders interface ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
|
||||
rule ISAPnPHeaderGen
|
||||
{
|
||||
@@ -56,17 +60,18 @@ actions PCIHeaderGen1
|
||||
|
||||
PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-header.awk ;
|
||||
|
||||
Preference Devices :
|
||||
Devices.cpp
|
||||
DevicesWindow.cpp
|
||||
ResourceUsageWindow.cpp
|
||||
ModemWindow.cpp
|
||||
cm_wrapper.c
|
||||
DevicesInfo.cpp
|
||||
ConfigurationWindow.cpp
|
||||
: be $(TARGET_LIBSUPC++)
|
||||
Application Devices :
|
||||
DevicesApplication.cpp
|
||||
DevicesView.cpp
|
||||
dm_wrapper.c
|
||||
DevicePCI.cpp
|
||||
Device.cpp
|
||||
PropertyList.cpp
|
||||
PropertyListPlain.cpp
|
||||
: be libcolumnlistview.a tracker $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++)
|
||||
: Devices.rdef
|
||||
;
|
||||
|
||||
Includes [ FGristFiles DevicesInfo.cpp ] : [ FGristFiles isapnpids.h usbdevs.h usbdevs_data.h ] ;
|
||||
Includes [ FGristFiles DevicesInfo.cpp ] : [ FGristFiles isapnpids.h usbdevs.h
|
||||
usbdevs_data.h ] ;
|
||||
Includes [ FGristFiles ConfigurationWindow.cpp ] : [ FGristFiles pcihdr.h ] ;
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003-2004, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: ModemWindow.cpp
|
||||
// Author: Sikosis, Jérôme Duval
|
||||
// Description: Devices Preferences
|
||||
// Created : August 23, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
|
||||
// Includes ------------------------------------------------------------------------------------------ //
|
||||
//#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <MenuItem.h>
|
||||
#include <MenuField.h>
|
||||
//#include <Path.h>
|
||||
//#include <PopUpMenu.h>
|
||||
#include <Screen.h>
|
||||
//#include <stdio.h>
|
||||
//#include <String.h>
|
||||
#include <TextView.h>
|
||||
//#include <Window.h>
|
||||
//#include <View.h>
|
||||
|
||||
#include "DevicesWindows.h"
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
const uint32 BTN_ADD = 'badd';
|
||||
const uint32 BTN_CANCEL = 'bcnl';
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// ModemWindow - Constructor
|
||||
ModemWindow::ModemWindow(BRect frame, BMessenger messenger)
|
||||
: BWindow (frame, "ModemWindow", B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE),
|
||||
fMessenger(messenger)
|
||||
{
|
||||
InitWindow();
|
||||
CenterOnScreen();
|
||||
Show();
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// ModemWindow - Destructor
|
||||
ModemWindow::~ModemWindow()
|
||||
{
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
// ModemWindow::InitWindow -- Initialization Commands here
|
||||
void
|
||||
ModemWindow::InitWindow(void)
|
||||
{
|
||||
BRect r;
|
||||
r = Bounds();
|
||||
|
||||
BBox *background = new BBox(r, "background", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW, B_PLAIN_BORDER);
|
||||
AddChild(background);
|
||||
|
||||
BBox *boxInternalModem = new BBox(BRect (r.left+9,r.top+9,r.right-11,r.bottom-44),
|
||||
"boxInternalModem", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW, B_FANCY_BORDER);
|
||||
boxInternalModem->SetLabel("Internal Modem");
|
||||
boxInternalModem->SetFont(be_plain_font);
|
||||
|
||||
rgb_color black = {0,0,0};
|
||||
BRect rect = boxInternalModem->Bounds();
|
||||
rect.left += 9;
|
||||
rect.top += 58;
|
||||
rect.right -= 11;
|
||||
rect.bottom -= 20;
|
||||
BRect textRect(rect);
|
||||
textRect.OffsetTo(B_ORIGIN);
|
||||
textRect.InsetBy(1,1);
|
||||
BTextView *textView = new BTextView(rect, "text", textRect, be_plain_font, &black, B_FOLLOW_TOP | B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||
textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
textView->SetText("This is intended for configuring\n"
|
||||
"jumpered modem only. Plug and\n"
|
||||
"Play modems are automatically\n"
|
||||
"detected by the system.");
|
||||
boxInternalModem->AddChild(textView);
|
||||
|
||||
BRect CancelButtonRect(29,r.bottom-34,104,r.bottom-13);
|
||||
BButton *btnCancel = new BButton(CancelButtonRect,"btnCancel","Cancel",
|
||||
new BMessage(BTN_CANCEL), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
BRect AddButtonRect(115,r.bottom-34,r.right - 10,r.bottom-13);
|
||||
BButton *btnAdd = new BButton(AddButtonRect,"btnAdd","Add",
|
||||
new BMessage(BTN_ADD), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_NAVIGABLE);
|
||||
btnAdd->MakeDefault(true);
|
||||
|
||||
rect = boxInternalModem->Bounds();
|
||||
rect.top += 28;
|
||||
rect.left += 38;
|
||||
rect.right = rect.left + 105;
|
||||
rect.bottom = rect.top + 5;
|
||||
BPopUpMenu *serialMenu = new BPopUpMenu("pick one");
|
||||
BMenuItem *item;
|
||||
serialMenu->AddItem(item = new BMenuItem("serial3 ", NULL));
|
||||
item->SetMarked(true);
|
||||
serialMenu->AddItem(item = new BMenuItem("serial4 ", NULL));
|
||||
|
||||
|
||||
BMenuField *serialMenuField = new BMenuField(rect, "serialMenuField",
|
||||
"Port:", serialMenu);
|
||||
serialMenuField->SetDivider(40.0);
|
||||
serialMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||
boxInternalModem->AddChild(serialMenuField);
|
||||
|
||||
// Create the Views
|
||||
background->AddChild(boxInternalModem);
|
||||
background->AddChild(btnCancel);
|
||||
background->AddChild(btnAdd);
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
// ModemWindow::MessageReceived -- receives messages
|
||||
void
|
||||
ModemWindow::MessageReceived (BMessage *message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
case BTN_CANCEL:
|
||||
{
|
||||
Quit();
|
||||
}
|
||||
break;
|
||||
case BTN_ADD:
|
||||
{
|
||||
fMessenger.SendMessage(MODEM_ADDED);
|
||||
Quit();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
|
||||
|
||||
#include "PropertyList.h"
|
||||
|
||||
#include <ColumnTypes.h>
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
|
||||
PropertyRow::PropertyRow(const char* name, const char* value)
|
||||
: BRow(),
|
||||
fName(name), fValue(value)
|
||||
{
|
||||
SetField(new BStringField(name), kNameColumn);
|
||||
SetField(new BStringField(value), kValueColumn);
|
||||
}
|
||||
|
||||
|
||||
PropertyRow::~PropertyRow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyRow::SetName(const char* name)
|
||||
{
|
||||
fName = name;
|
||||
SetField(new BStringField(name), kNameColumn);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyRow::SetValue(const char* value)
|
||||
{
|
||||
fValue = value;
|
||||
SetField(new BStringField(value), kValueColumn);
|
||||
}
|
||||
|
||||
|
||||
PropertyList::PropertyList(const char* name)
|
||||
: BColumnListView(BRect(0.0, 0.0, 1.0, 1.0), name, B_FOLLOW_ALL, 0,
|
||||
B_NO_BORDER, true)
|
||||
{
|
||||
BStringColumn* nameColumn;
|
||||
AddColumn(nameColumn = new BStringColumn("Name", 150, 50, 500,
|
||||
B_TRUNCATE_MIDDLE),
|
||||
kNameColumn);
|
||||
AddColumn(new BStringColumn("Value", 150, 50, 500, B_TRUNCATE_END),
|
||||
kValueColumn);
|
||||
SetSortColumn(nameColumn, false, true);
|
||||
}
|
||||
|
||||
|
||||
PropertyList::~PropertyList()
|
||||
{
|
||||
RemoveAll();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyList::AddAttributes(const Attributes& attributes)
|
||||
{
|
||||
RemoveAll();
|
||||
for (unsigned int i = 0; i < attributes.size(); i++) {
|
||||
AddRow(new PropertyRow(attributes[i].fName, attributes[i].fValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyList::RemoveAll()
|
||||
{
|
||||
BRow *row;
|
||||
while ((row = RowAt((int32)0, NULL))!=NULL) {
|
||||
RemoveRow(row);
|
||||
delete row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyList::SelectionChanged()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Pieter Panman
|
||||
*/
|
||||
#ifndef PROPERTYLIST_H
|
||||
#define PROPERTYLIST_H
|
||||
|
||||
|
||||
#include <ColumnListView.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
|
||||
struct Attribute;
|
||||
|
||||
enum {
|
||||
kNameColumn,
|
||||
kValueColumn
|
||||
};
|
||||
|
||||
|
||||
class PropertyRow : public BRow {
|
||||
public:
|
||||
PropertyRow(const char* name, const char* value);
|
||||
virtual ~PropertyRow();
|
||||
|
||||
const char* Name() const { return fName.String(); }
|
||||
const char* Value() const { return fValue.String(); }
|
||||
void SetName(const char* name);
|
||||
void SetValue(const char* value);
|
||||
private:
|
||||
BString fName;
|
||||
BString fValue;
|
||||
};
|
||||
|
||||
|
||||
class PropertyList : public BColumnListView {
|
||||
public:
|
||||
PropertyList(const char* name = "Properties");
|
||||
virtual ~PropertyList();
|
||||
void RemoveAll();
|
||||
void AddAttributes(const Attributes& attributes);
|
||||
protected:
|
||||
virtual void SelectionChanged();
|
||||
};
|
||||
|
||||
#endif /* PROPERTYLIST_H*/
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Author:
|
||||
* Artur Wyszynski <harakash@gmail.com>
|
||||
* Modified by Pieter Panman
|
||||
*/
|
||||
|
||||
#include "PropertyListPlain.h"
|
||||
|
||||
#include <GridLayout.h>
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Message.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
|
||||
PropertyListPlain::PropertyListPlain(const char* name)
|
||||
:
|
||||
BView(name, 0, NULL)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
}
|
||||
|
||||
|
||||
PropertyListPlain::~PropertyListPlain()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyListPlain::AddAttributes(const Attributes& attributes)
|
||||
{
|
||||
RemoveAll();
|
||||
BGridLayoutBuilder builder(5, 5);
|
||||
unsigned int i;
|
||||
for (i = 0; i < attributes.size(); i++) {
|
||||
const char* name = attributes[i].fName;
|
||||
const char* value = attributes[i].fValue;
|
||||
|
||||
BString tempViewName(name);
|
||||
BStringView *nameView = new BStringView(tempViewName.String(), name);
|
||||
tempViewName.Append("Value");
|
||||
BStringView *valueView = new BStringView(tempViewName.String(), value);
|
||||
|
||||
nameView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
||||
B_ALIGN_VERTICAL_UNSET));
|
||||
valueView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
||||
B_ALIGN_VERTICAL_UNSET));
|
||||
|
||||
builder
|
||||
.Add(nameView, 0, i)
|
||||
.Add(valueView, 1, i);
|
||||
}
|
||||
|
||||
// make sure that all content is left and top aligned
|
||||
builder.Add(BSpaceLayoutItem::CreateGlue(), 2, i);
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL,5)
|
||||
.Add(builder)
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyListPlain::RemoveAll()
|
||||
{
|
||||
BView *child;
|
||||
while((child = ChildAt(0))) {
|
||||
RemoveChild(child);
|
||||
delete child;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyListPlain::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyListPlain::AttachedToWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PropertyListPlain::DetachedFromWindow()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Author:
|
||||
* Artur Wyszynski <harakash@gmail.com>
|
||||
* Modified by Pieter Panman
|
||||
*/
|
||||
#ifndef PROPERTY_LIST_PLAIN_H
|
||||
#define PROPERTY_LIST_PLAIN_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
|
||||
class PropertyListPlain : public BView {
|
||||
public:
|
||||
PropertyListPlain(const char* name);
|
||||
virtual ~PropertyListPlain();
|
||||
|
||||
virtual void AddAttributes(const Attributes& attributes);
|
||||
virtual void RemoveAll();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
private:
|
||||
BView* rootView;
|
||||
};
|
||||
|
||||
#endif /* PROPERTY_LIST_PLAIN_H */
|
||||
@@ -1,141 +0,0 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cm_wrapper.h"
|
||||
#include "config_driver.h"
|
||||
|
||||
static int fd;
|
||||
|
||||
status_t init_cm_wrapper(void)
|
||||
{
|
||||
static const char device[] = "/dev/" CM_DEVICE_NAME;
|
||||
|
||||
fd = open(device, 0);
|
||||
if (fd < 0)
|
||||
return errno;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t uninit_cm_wrapper(void)
|
||||
{
|
||||
close(fd);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t get_next_device_info(bus_type bus, uint64 *cookie,
|
||||
struct device_info *info, uint32 size)
|
||||
{
|
||||
status_t result;
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_NEXT_DEVICE_INFO;
|
||||
params.bus = bus;
|
||||
params.cookie = *cookie;
|
||||
params.data = (void *)info;
|
||||
params.data_len = size;
|
||||
|
||||
result = ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
|
||||
if (result == B_OK) *cookie = params.cookie;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t get_device_info_for(uint64 id, struct device_info *info,
|
||||
uint32 size)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_DEVICE_INFO_FOR;
|
||||
params.cookie = id;
|
||||
params.data = (void *)info;
|
||||
params.data_len = size;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
status_t get_size_of_current_configuration_for(uint64 id)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_SIZE_OF_CURRENT_CONFIGURATION_FOR;
|
||||
params.cookie = id;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
status_t get_current_configuration_for(uint64 id,
|
||||
struct device_configuration *current, uint32 size)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_CURRENT_CONFIGURATION_FOR;
|
||||
params.cookie = id;
|
||||
params.data = (void *)current;
|
||||
params.data_len = size;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
status_t get_size_of_possible_configurations_for(uint64 id)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_SIZE_OF_POSSIBLE_CONFIGURATIONS_FOR;
|
||||
params.cookie = id;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
status_t get_possible_configurations_for(uint64 id,
|
||||
struct possible_device_configurations *possible, uint32 size)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_POSSIBLE_CONFIGURATIONS_FOR;
|
||||
params.cookie = id;
|
||||
params.data = (void *)possible;
|
||||
params.data_len = size;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
|
||||
status_t count_resource_descriptors_of_type(
|
||||
struct device_configuration *c, resource_type type)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_COUNT_RESOURCE_DESCRIPTORS_OF_TYPE;
|
||||
params.config = c;
|
||||
params.type = type;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
status_t get_nth_resource_descriptor_of_type(
|
||||
struct device_configuration *c, uint32 n,
|
||||
resource_type type, resource_descriptor *d, uint32 size)
|
||||
{
|
||||
struct cm_ioctl_data params;
|
||||
|
||||
params.magic = CM_GET_NTH_RESOURCE_DESCRIPTOR_OF_TYPE;
|
||||
params.config = c;
|
||||
params.n = n;
|
||||
params.type = type;
|
||||
params.data = d;
|
||||
params.data_len = size;
|
||||
|
||||
return ioctl(fd, params.magic, ¶ms, sizeof(params));
|
||||
}
|
||||
|
||||
uchar mask_to_value(uint32 mask)
|
||||
{
|
||||
uchar value;
|
||||
if (!mask) return 0;
|
||||
for (value=0,mask>>=1;mask;value++,mask>>=1)
|
||||
;
|
||||
return value;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#ifndef _CM_WRAPPER_H_
|
||||
#define _CM_WRAPPER_H_
|
||||
|
||||
#include <drivers/config_manager.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
status_t init_cm_wrapper(void);
|
||||
status_t uninit_cm_wrapper(void);
|
||||
|
||||
status_t get_next_device_info(bus_type bus, uint64 *cookie,
|
||||
struct device_info *info, uint32 size);
|
||||
status_t get_device_info_for(uint64 id, struct device_info *info,
|
||||
uint32 size);
|
||||
status_t get_size_of_current_configuration_for(uint64 id);
|
||||
status_t get_current_configuration_for(uint64 id,
|
||||
struct device_configuration *current, uint32 size);
|
||||
status_t get_size_of_possible_configurations_for(uint64 id);
|
||||
status_t get_possible_configurations_for(uint64 id,
|
||||
struct possible_device_configurations *possible, uint32 size);
|
||||
status_t count_resource_descriptors_of_type(
|
||||
struct device_configuration *c, resource_type type);
|
||||
status_t get_nth_resource_descriptor_of_type(
|
||||
struct device_configuration *c, uint32 n, resource_type type,
|
||||
resource_descriptor *d, uint32 size);
|
||||
|
||||
uchar mask_to_value(uint32 mask);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2006 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jerome Duval (listdev)
|
||||
*/
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <drivers/device_manager.h>
|
||||
#include <device_manager_defs.h>
|
||||
#include <generic_syscall_defs.h>
|
||||
#include <string.h>
|
||||
#include <syscalls.h>
|
||||
|
||||
#include "dm_wrapper.h"
|
||||
|
||||
|
||||
status_t
|
||||
init_dm_wrapper(void)
|
||||
{
|
||||
uint32 version = 0;
|
||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, B_SYSCALL_INFO,
|
||||
&version, sizeof(version));
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
uninit_dm_wrapper(void)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_root(device_node_cookie *cookie)
|
||||
{
|
||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_ROOT, cookie,
|
||||
sizeof(device_node_cookie));
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_child(device_node_cookie *device)
|
||||
{
|
||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_CHILD, device,
|
||||
sizeof(device_node_cookie));
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_next_child(device_node_cookie *device)
|
||||
{
|
||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_NEXT_CHILD,
|
||||
device, sizeof(device_node_cookie));
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
dm_get_next_attr(struct device_attr_info *attr)
|
||||
{
|
||||
return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS,
|
||||
DM_GET_NEXT_ATTRIBUTE, attr, sizeof(struct device_attr_info));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2006 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jerome Duval (listdev)
|
||||
*/
|
||||
#ifndef DM_WRAPPER_H
|
||||
#define DM_WRAPPER_H
|
||||
|
||||
|
||||
#include "device_manager_defs.h"
|
||||
|
||||
status_t init_dm_wrapper(void);
|
||||
status_t uninit_dm_wrapper(void);
|
||||
status_t get_root(device_node_cookie *cookie);
|
||||
status_t get_child(device_node_cookie *cookie);
|
||||
status_t get_next_child(device_node_cookie *cookie);
|
||||
status_t dm_get_next_attr(struct device_attr_info *attr);
|
||||
|
||||
#endif /* DM_WRAPPER_H */
|
||||
Reference in New Issue
Block a user