Ticket #3185: devices.patch

File devices.patch, 46.5 KB (added by PieterPanman, 15 years ago)

new patch with cleaned up sources

  • build/jam/HaikuImage

     
    6262    zdiff zforce zgrep zip zipcloak <bin>zipgrep zipnote zipsplit zmore znew
    6363;
    6464
    65 SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc DiskProbe
    66     DiskUsage DriveSetup CDPlayer Expander Icon-O-Matic Installer LaunchBox
    67     Magnify Mail MediaConverter MediaPlayer MidiPlayer NetworkStatus
     65SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc Devices
     66    DiskProbe DiskUsage DriveSetup CDPlayer Expander Icon-O-Matic Installer
     67    LaunchBox Magnify Mail MediaConverter MediaPlayer MidiPlayer NetworkStatus
    6868    PackageInstaller People PoorMan PowerStatus ProcessController Screenshot
    6969    ShowImage SoundRecorder StyledEdit Terminal TextSearch TV Workspaces
    7070;
     
    302302# Deskbar Application links
    303303AddDirectoryToHaikuImage home config be Applications ;
    304304DESKBAR_APPLICATIONS = ActivityMonitor CharacterMap CodyCam CDPlayer DeskCalc
    305     DiskProbe DriveSetup DiskUsage Expander Icon-O-Matic Installer Magnify
    306     Mail MediaConverter MediaPlayer MidiPlayer People PoorMan Screenshot
     305    Devices DiskProbe DriveSetup DiskUsage Expander Icon-O-Matic Installer
     306    Magnify Mail MediaConverter MediaPlayer MidiPlayer People PoorMan Screenshot
    307307    SoundRecorder StyledEdit Terminal TV
    308308;
    309309local linkTarget ;
  • src/preferences/devices/Jamfile

     
    5656
    5757PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-header.awk ;
    5858
    59 Preference Devices :
     59Preference DevicesOld :
    6060    Devices.cpp
    6161    DevicesWindow.cpp
    6262    ResourceUsageWindow.cpp
  • src/apps/devices/Device.cpp

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8
     9
     10#include "Device.h"
     11
     12#include <iostream>
     13
     14
     15// This list comes from the pciid list, except for the last one
     16const char* kCategoryString[] = {
     17    "Unclassified device",                  // 0x00
     18    "Mass storage controller",              // 0x01
     19    "Network controller",                   // 0x02
     20    "Display controller",                   // 0x03
     21    "Multimedia controller",                // 0x04
     22    "Memory controller",                    // 0x05
     23    "Bridge",                               // 0x06
     24    "Communication controller",             // 0x07
     25    "Generic system peripheral",            // 0x08
     26    "Input device controller",              // 0x09
     27    "Docking station",                      // 0x0a
     28    "Processor",                            // 0x0b
     29    "Serial bus controller",                // 0x0c
     30    "Wireless controller",                  // 0x0d
     31    "Intelligent controller",               // 0x0e
     32    "Satellite communications controller",  // 0x0f
     33    "Encryption controller",                // 0x10
     34    "Signal processing controller",         // 0x11
     35    "Computer"                              // 0x12 (added later)
     36};
     37
     38
     39Device::Device(Device* physicalParent, BusType busType, Category category,
     40            const BString& name, const BString& manufacturer,
     41            const BString& driverUsed, const BString& devPathsPublished)
     42    :
     43    BStringItem(name.String()),
     44    fBusType(busType),
     45    fCategory(category),
     46    fPhysicalParent(physicalParent)
     47{
     48    SetAttribute("Device name", name);
     49    SetAttribute("Manufacturer", manufacturer);
     50    SetAttribute("Driver used", driverUsed);
     51    SetAttribute("Device paths", devPathsPublished);
     52}
     53
     54
     55Device::~Device(void)
     56{
     57}
     58
     59
     60void
     61Device::SetAttribute(const BString& name, const BString& value)
     62{
     63    if (name == "Device name") {
     64        SetText(value.String());
     65    }
     66    fAttributeMap[name] = value;
     67}
     68
     69
     70Attributes
     71Device::GetBasicAttributes()
     72{
     73    Attributes attributes;
     74    attributes.push_back(Attribute("Device name:", GetName()));
     75    attributes.push_back(Attribute("Manufacturer:", GetManufacturer()));
     76    return attributes;
     77}
     78
     79
     80Attributes
     81Device::GetBusAttributes()
     82{
     83    Attributes attributes;
     84    attributes.push_back(Attribute("None", ""));
     85    return attributes;
     86}
     87
     88
     89Attributes
     90Device::GetAllAttributes()
     91{
     92    Attributes attributes;
     93    AttributeMapIterator iter;
     94    for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) {
     95        attributes.push_back(Attribute(iter->first, iter->second));
     96    }
     97    return attributes;
     98}
     99
     100
     101BString
     102Device::GetBasicStrings()
     103{
     104    BString str;
     105    str << "Device Name\t\t\t\t: " << GetName() << "\n";
     106    str << "Manufacturer\t\t\t: " << GetManufacturer() << "\n";
     107    str << "Driver used\t\t\t\t: " << GetDriverUsed() << "\n";
     108    str << "Device paths\t: " << GetDevPathsPublished();
     109    return str;
     110}
     111
     112BString
     113Device::GetBusStrings()
     114{
     115    return "None";
     116}
     117
     118
     119BString
     120Device::GetAllStrings()
     121{
     122    BString str;
     123    AttributeMapIterator iter;
     124    for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) {
     125        str << iter->first << " : " << iter->second << "\n";
     126    }
     127    return str;
     128}
  • src/apps/devices/DevicePCI.h

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8#ifndef DEVICEPCI_H
     9#define DEVICEPCI_H
     10
     11
     12#include "Device.h"
     13
     14
     15class DevicePCI : public Device {
     16public:
     17                        DevicePCI(Device* parent);
     18    virtual             ~DevicePCI();
     19    virtual Attributes  GetBusAttributes();
     20    virtual BString     GetBusStrings();
     21    virtual void        InitFromAttributes();
     22   
     23    virtual BString     GetBusTabName()
     24                            { return "PCI Information"; }
     25
     26private:
     27    uint16              fClassBaseId;
     28    uint16              fClassSubId;
     29    uint16              fClassApiId;
     30    uint16              fVendorId;
     31    uint16              fDeviceId;
     32    uint16              fSubsystemVendorId;
     33    uint16              fSubSystemId;
     34};
     35
     36#endif /* DEVICEPCI_H */
  • src/apps/devices/dm_wrapper.c

     
     1/*
     2 * Copyright 2006 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Jerome Duval (listdev)
     7 */
     8
     9
     10#include <errno.h>
     11#include <fcntl.h>
     12#include <stdio.h>
     13#include <unistd.h>
     14
     15#include <drivers/device_manager.h>
     16#include <device_manager_defs.h>
     17#include <generic_syscall_defs.h>
     18#include <string.h>
     19#include <syscalls.h>
     20
     21#include "dm_wrapper.h"
     22
     23
     24status_t
     25init_dm_wrapper(void)
     26{
     27    uint32 version = 0;
     28    return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, B_SYSCALL_INFO,
     29        &version, sizeof(version));
     30}
     31
     32
     33status_t
     34uninit_dm_wrapper(void)
     35{
     36    return B_OK;
     37}
     38
     39
     40status_t
     41get_root(device_node_cookie *cookie)
     42{
     43    return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_ROOT, cookie,
     44        sizeof(device_node_cookie));
     45}
     46
     47
     48status_t
     49get_child(device_node_cookie *device)
     50{
     51    return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_CHILD, device,
     52        sizeof(device_node_cookie));
     53}
     54
     55
     56status_t
     57get_next_child(device_node_cookie *device)
     58{
     59    return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS, DM_GET_NEXT_CHILD,
     60        device, sizeof(device_node_cookie));
     61}
     62
     63
     64status_t
     65dm_get_next_attr(struct device_attr_info *attr)
     66{
     67    return _kern_generic_syscall(DEVICE_MANAGER_SYSCALLS,
     68        DM_GET_NEXT_ATTRIBUTE, attr, sizeof(struct device_attr_info));
     69}
  • src/apps/devices/Device.h

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8#ifndef DEVICE_H
     9#define DEVICE_H
     10
     11
     12#include <map>
     13#include <vector>
     14
     15#include <String.h>
     16#include <StringItem.h>
     17
     18extern "C" {
     19#include "dm_wrapper.h"
     20}
     21
     22
     23typedef enum {
     24    BUS_ISA = 1,
     25    BUS_PCI,
     26    BUS_SCSI,
     27    BUS_NONE
     28} BusType;
     29
     30
     31struct Attribute {
     32            Attribute(BString name, BString value)
     33                { fName = name; fValue = value; }
     34    BString fName;
     35    BString fValue;
     36};
     37
     38
     39typedef std::map<BString, BString>::const_iterator AttributeMapIterator;
     40typedef std::map<BString, BString> AttributeMap;
     41typedef std::pair<BString, BString> AttributePair;
     42typedef std::vector<Attribute> Attributes;
     43
     44
     45typedef enum {
     46    CAT_NONE = 0,
     47    CAT_BUS = 6,
     48    CAT_COMPUTER = 0x12
     49} Category;
     50
     51
     52extern const char* kCategoryString[];
     53
     54
     55class Device : public BStringItem {
     56public:
     57                            Device(Device* physicalParent,
     58                                BusType busType=BUS_NONE,
     59                                Category category=CAT_NONE,
     60                                const BString& name = "unknown",
     61                                const BString& manufacturer = "unknown",
     62                                const BString& driverUsed = "unknown",
     63                                const BString& devPathsPublished = "unknown");
     64    virtual                 ~Device(void);
     65
     66    virtual BString         GetName()
     67                                { return fAttributeMap["Device name"]; }
     68    virtual BString         GetManufacturer()
     69                                { return fAttributeMap["Manufacturer"]; }
     70    virtual BString         GetDriverUsed()
     71                                { return fAttributeMap["Driver used"]; }
     72    virtual BString         GetDevPathsPublished()
     73                                { return fAttributeMap["Device paths"]; }
     74    virtual Category        GetCategory() const
     75                                { return fCategory; }
     76    virtual Device*         GetPhysicalParent() const
     77                                { return fPhysicalParent; }
     78    virtual BusType         GetBusType() const
     79                                { return fBusType; }
     80
     81    virtual Attributes      GetBasicAttributes();
     82    virtual Attributes      GetBusAttributes();
     83    virtual Attributes      GetAllAttributes();
     84
     85    virtual BString         GetBasicStrings();
     86    virtual BString         GetBusStrings();
     87    virtual BString         GetAllStrings();
     88   
     89    virtual BString         GetBusTabName()
     90                                { return "Bus Information"; }
     91
     92    virtual Attribute       GetAttribute(const BString& name)
     93                                { return Attribute(name.String(),
     94                                     fAttributeMap[name]); }
     95
     96    virtual void            SetAttribute(const BString& name,
     97                                const BString& value);
     98
     99    virtual void            InitFromAttributes() { return; }
     100
     101protected:
     102            AttributeMap    fAttributeMap;
     103            BusType         fBusType;
     104            Category        fCategory;
     105            Device*         fPhysicalParent;
     106};
     107
     108#endif /* DEVICE_H */
     109
  • src/apps/devices/PropertyListPlain.cpp

     
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Author:
     6 *      Artur Wyszynski <harakash@gmail.com>
     7 *      Modified by Pieter Panman
     8 */
     9
     10#include "PropertyListPlain.h"
     11
     12#include <GridLayout.h>
     13#include <GridLayoutBuilder.h>
     14#include <GroupLayout.h>
     15#include <GroupLayoutBuilder.h>
     16#include <Message.h>
     17#include <SpaceLayoutItem.h>
     18#include <String.h>
     19#include <StringView.h>
     20
     21#include "Device.h"
     22
     23
     24PropertyListPlain::PropertyListPlain(const char* name)
     25    :
     26    BView(name, 0, NULL)
     27{
     28    SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
     29    SetLayout(new BGroupLayout(B_VERTICAL));
     30}
     31
     32
     33PropertyListPlain::~PropertyListPlain()
     34{
     35   
     36}
     37
     38
     39void
     40PropertyListPlain::AddAttributes(const Attributes& attributes)
     41{
     42    RemoveAll();
     43    BGridLayoutBuilder builder(5, 5);
     44    unsigned int i;
     45    for (i = 0; i < attributes.size(); i++) {
     46        const char* name = attributes[i].fName;
     47        const char* value = attributes[i].fValue;
     48       
     49        BString tempViewName(name);
     50        BStringView *nameView = new BStringView(tempViewName.String(), name);
     51        tempViewName.Append("Value");
     52        BStringView *valueView = new BStringView(tempViewName.String(), value);
     53
     54        nameView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
     55            B_ALIGN_VERTICAL_UNSET));
     56        valueView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
     57            B_ALIGN_VERTICAL_UNSET));
     58
     59        builder
     60            .Add(nameView, 0, i)
     61            .Add(valueView, 1, i);
     62    }
     63
     64    // make sure that all content is left and top aligned
     65    builder.Add(BSpaceLayoutItem::CreateGlue(), 2, i);
     66
     67    AddChild(BGroupLayoutBuilder(B_VERTICAL,5)
     68        .Add(builder)
     69        .SetInsets(5, 5, 5, 5)
     70    );
     71}
     72
     73
     74void
     75PropertyListPlain::RemoveAll()
     76{
     77    BView *child;
     78    while((child = ChildAt(0))) {
     79        RemoveChild(child);
     80        delete child;
     81    }
     82}
     83
     84
     85void
     86PropertyListPlain::MessageReceived(BMessage* message)
     87{
     88    switch (message->what) {
     89        default:
     90            BView::MessageReceived(message);
     91    }   
     92}
     93
     94
     95void
     96PropertyListPlain::AttachedToWindow()
     97{
     98}
     99
     100
     101void
     102PropertyListPlain::DetachedFromWindow()
     103{
     104}
  • src/apps/devices/dm_wrapper.h

     
     1/*
     2 * Copyright 2006 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Jerome Duval (listdev)
     7 */
     8#ifndef DM_WRAPPER_H
     9#define DM_WRAPPER_H
     10
     11
     12#include "device_manager_defs.h"
     13
     14status_t init_dm_wrapper(void);
     15status_t uninit_dm_wrapper(void);
     16status_t get_root(device_node_cookie *cookie);
     17status_t get_child(device_node_cookie *cookie);
     18status_t get_next_child(device_node_cookie *cookie);
     19status_t dm_get_next_attr(struct device_attr_info *attr);
     20
     21#endif /* DM_WRAPPER_H */
  • src/apps/devices/DevicesApplication.cpp

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT license.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8
     9
     10#include <Alert.h>
     11#include <Application.h>
     12#include <TextView.h>
     13
     14#include "DevicesView.h"
     15
     16
     17class DevicesApplication : public BApplication {
     18public:
     19                    DevicesApplication(void);
     20    virtual void    AboutRequested();
     21    static  void    ShowAbout();
     22};
     23
     24
     25class DevicesWindow : public BWindow {
     26public:
     27            DevicesWindow(void);
     28    bool    QuitRequested(void);
     29    virtual void MessageReceived(BMessage *msg);
     30private:
     31    DevicesView *view;
     32};
     33
     34
     35DevicesApplication::DevicesApplication(void)
     36    : BApplication("application/x-vnd.Haiku-Devices")
     37{
     38    DevicesWindow *window = new DevicesWindow();
     39    window->CenterOnScreen();
     40    window->Show();
     41}
     42
     43
     44void
     45DevicesApplication::AboutRequested()
     46{
     47    ShowAbout();
     48}
     49
     50
     51void
     52DevicesApplication::ShowAbout()
     53{
     54    BAlert *alert = new BAlert("about", "Devices\n"
     55        "\twritten by Pieter Panman\n"
     56        "\n"
     57        "\tBased on listdev by Jérôme Duval\n"
     58        "\tand the previous Devices preference\n"
     59        "\tby Jérôme Duval and Sikosis\n"
     60        "\tCopyright 2009, Haiku Inc.\n", "Ok");
     61    BTextView *view = alert->TextView();
     62    BFont font;
     63
     64    view->SetStylable(true);
     65
     66    view->GetFont(&font);
     67    font.SetSize(18);
     68    font.SetFace(B_BOLD_FACE);
     69    view->SetFontAndColor(0, 7, &font);
     70
     71    alert->Go();
     72}
     73
     74
     75DevicesWindow::DevicesWindow()
     76    : BWindow(BRect(50, 50, 750, 550), "Devices", B_TITLED_WINDOW, 0)
     77{
     78    float minWidth;
     79    float maxWidth;
     80    float minHeight;
     81    float maxHeight;
     82    GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
     83    minWidth = 600;
     84    minHeight = 300;
     85    SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
     86    view = new DevicesView(Bounds());
     87    AddChild(view);
     88}
     89
     90
     91bool
     92DevicesWindow::QuitRequested()
     93{
     94    be_app->PostMessage(B_QUIT_REQUESTED);
     95    return true;
     96}
     97
     98
     99void
     100DevicesWindow::MessageReceived(BMessage *msg)
     101{
     102    switch (msg->what) {
     103        case kMsgRefresh:
     104        case kMsgReportCompatibility:
     105        case kMsgGenerateSysInfo:
     106        case kMsgSelectionChanged:
     107        case kMsgOrderCategory:
     108        case kMsgOrderConnection:
     109        {
     110            view->MessageReceived(msg);
     111            break;
     112        }
     113
     114        default:
     115            BWindow::MessageReceived(msg);
     116            break;
     117    }
     118}
     119
     120
     121int
     122main()
     123{
     124    DevicesApplication app;
     125    app.Run();
     126    return 0;
     127}
  • src/apps/devices/PropertyListPlain.h

     
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Author:
     6 *      Artur Wyszynski <harakash@gmail.com>
     7 *      Modified by Pieter Panman
     8 */
     9#ifndef PROPERTY_LIST_PLAIN_H
     10#define PROPERTY_LIST_PLAIN_H
     11
     12
     13#include <View.h>
     14
     15#include "Device.h"
     16
     17
     18class PropertyListPlain : public BView {
     19public:
     20                    PropertyListPlain(const char* name);
     21    virtual         ~PropertyListPlain();
     22
     23    virtual void    AddAttributes(const Attributes& attributes);
     24    virtual void    RemoveAll();
     25
     26    virtual void    MessageReceived(BMessage* message);
     27    virtual void    AttachedToWindow();
     28    virtual void    DetachedFromWindow();
     29private:
     30    BView*          rootView;
     31};
     32
     33#endif /* PROPERTY_LIST_PLAIN_H */
  • src/apps/devices/DevicesView.cpp

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT license.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8
     9
     10#include <Application.h>
     11#include <MenuBar.h>
     12
     13#include "DevicesView.h"
     14
     15
     16DevicesView::DevicesView(const BRect& rect)
     17    : BView(rect, "DevicesView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS)
     18{
     19    CreateLayout();
     20    RescanDevices();
     21    RebuildDevicesOutline();
     22}
     23
     24
     25void
     26DevicesView::CreateLayout()
     27{
     28    SetLayout(new BGroupLayout(B_VERTICAL));
     29
     30    BMenuBar* menuBar = new BMenuBar("menu");
     31    BMenu* menu = new BMenu("Devices");
     32    BMenuItem* item;
     33    menu->AddItem(new BMenuItem("Refresh Devices", new BMessage(kMsgRefresh), 'R'));
     34    menu->AddItem(item = new BMenuItem("Report Compatibility",
     35        new BMessage(kMsgReportCompatibility)));
     36    item->SetEnabled(false);
     37    menu->AddItem(item = new BMenuItem("Generate System Information",
     38        new BMessage(kMsgGenerateSysInfo)));
     39    item->SetEnabled(false);
     40    menu->AddSeparatorItem();
     41    menu->AddItem(item = new BMenuItem("About Devices" B_UTF8_ELLIPSIS,
     42        new BMessage(B_ABOUT_REQUESTED)));
     43    menu->AddSeparatorItem();
     44    menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
     45    menu->SetTargetForItems(this);
     46    item->SetTarget(be_app);
     47    menuBar->AddItem(menu);
     48
     49    fDevicesOutline = new BOutlineListView("devices_list");
     50    fDevicesOutline->SetTarget(this);
     51    fDevicesOutline->SetSelectionMessage(new BMessage(kMsgSelectionChanged));
     52
     53    BScrollView *scrollView = new BScrollView("devicesScrollView",
     54        fDevicesOutline, B_WILL_DRAW | B_FRAME_EVENTS, true, true);
     55    // Horizontal scrollbar doesn't behave properly like the vertical
     56    // scrollbar... If you make the view bigger (exposing a larger percentage
     57    // of the view), it does not adjust the width of the scroll 'dragger'
     58    // why? Bug? In scrollview or in outlinelistview?
     59
     60    BPopUpMenu* orderByPopupMenu = new BPopUpMenu("orderByMenu");
     61    BMenuItem* byCategory = new BMenuItem("category",
     62        new BMessage(kMsgOrderCategory));
     63    BMenuItem* byConnection = new BMenuItem("connection",
     64        new BMessage(kMsgOrderConnection));
     65    byCategory->SetMarked(true);
     66    fOrderBy = byCategory->IsMarked() ? ORDER_BY_CATEGORY :
     67        ORDER_BY_CONNECTION;
     68    orderByPopupMenu->AddItem(byCategory);
     69    orderByPopupMenu->AddItem(byConnection);
     70    fOrderByMenu = new BMenuField("Order by:", orderByPopupMenu);
     71
     72    fTabView = new BTabView("fTabView", B_WIDTH_FROM_LABEL);
     73
     74    fBasicTab = new BTab();
     75    fBasicView = new PropertyListPlain("basicView");
     76    fTabView->AddTab(fBasicView, fBasicTab);
     77    fBasicTab->SetLabel("Basic Information");
     78
     79    fDeviceTypeTab = new BTab();
     80    fBusView = new PropertyListPlain("busView");
     81    fTabView->AddTab(fBusView, fDeviceTypeTab);
     82    fDeviceTypeTab->SetLabel("Bus");
     83
     84    fDetailedTab = new BTab();
     85    fAttributesView = new PropertyList("attributesView");
     86    fTabView->AddTab(fAttributesView, fDetailedTab);
     87    fDetailedTab->SetLabel("Detailed");
     88
     89    AddChild(BGroupLayoutBuilder(B_VERTICAL,0)
     90                .Add(menuBar)
     91                .Add(BSplitLayoutBuilder(B_HORIZONTAL, 5)
     92                    .Add(BGroupLayoutBuilder(B_VERTICAL, 5)
     93                        .Add(fOrderByMenu, 1)
     94                        .Add(scrollView, 2)
     95                    )
     96                    .Add(fTabView, 2)
     97                    .SetInsets(5, 5, 5, 5)
     98                )
     99            );
     100}
     101
     102
     103void
     104DevicesView::RescanDevices()
     105{
     106    // Empty the outline and delete the devices in the list, incl. categories
     107    fDevicesOutline->MakeEmpty();
     108    DeleteDevices();
     109    DeleteCategoryMap();
     110
     111    // Fill the devices list
     112    status_t error;
     113    device_node_cookie rootCookie;
     114    if ((error = init_dm_wrapper()) < 0) {
     115        std::cerr << "Error initializing device manager: " << strerror(error)
     116            << std::endl;
     117        return;
     118    }
     119
     120    get_root(&rootCookie);
     121    AddDeviceAndChildren(&rootCookie, NULL);
     122
     123    uninit_dm_wrapper();
     124
     125    CreateCategoryMap();
     126}
     127
     128
     129void
     130DevicesView::DeleteDevices()
     131{
     132    while(fDevices.size() > 0) {
     133        delete fDevices.back();
     134        fDevices.pop_back();
     135    }
     136}
     137
     138
     139void
     140DevicesView::CreateCategoryMap()
     141{
     142    CategoryMapIterator iter;
     143    for (unsigned int i = 0; i < fDevices.size(); i++) {
     144        Category category = fDevices[i]->GetCategory();
     145        const char* categoryName = kCategoryString[category];
     146
     147        iter = fCategoryMap.find(category);
     148        if( iter == fCategoryMap.end() ) {
     149            // This category has not yet been added, add it.
     150            fCategoryMap[category] = new Device(NULL, BUS_NONE, CAT_NONE,
     151                categoryName);
     152        }
     153    }
     154}
     155
     156
     157void
     158DevicesView::DeleteCategoryMap()
     159{
     160    CategoryMapIterator iter;
     161    for(iter = fCategoryMap.begin(); iter != fCategoryMap.end(); iter++) {
     162        delete iter->second;
     163    }
     164    fCategoryMap.clear();
     165}
     166
     167
     168int
     169DevicesView::SortItemsCompare(const BListItem *item1,
     170    const BListItem *item2)
     171{
     172    const BStringItem* stringItem1 = dynamic_cast<const BStringItem*>(item1);
     173    const BStringItem* stringItem2 = dynamic_cast<const BStringItem*>(item2);
     174    if (!(stringItem1 && stringItem2)) {
     175        // is this check necessary?
     176        std::cerr << "Could not cast BListItem to BStringItem, file a bug\n";
     177        return 0;
     178    }
     179    return Compare(stringItem1->Text(),stringItem2->Text());
     180}
     181
     182
     183void
     184DevicesView::RebuildDevicesOutline()
     185{
     186    // Rearranges existing Devices into the proper hierarchy
     187    fDevicesOutline->MakeEmpty();
     188
     189    if (fOrderBy == ORDER_BY_CONNECTION) {
     190        for (unsigned int i = 0; i < fDevices.size(); i++) {
     191            if (fDevices[i]->GetPhysicalParent() == NULL) {
     192                // process each parent device and its children
     193                fDevicesOutline->AddItem(fDevices[i]);
     194                AddChildrenToOutlineByConnection(fDevices[i]);
     195            }
     196        }
     197    }
     198    else if (fOrderBy == ORDER_BY_CATEGORY) {
     199        // Add all categories to the outline
     200        CategoryMapIterator iter;
     201        for (iter = fCategoryMap.begin(); iter != fCategoryMap.end(); iter++) {
     202            fDevicesOutline->AddItem(iter->second);
     203        }
     204
     205        // Add all devices under the categories
     206        for (unsigned int i = 0; i < fDevices.size(); i++) {
     207            Category category = fDevices[i]->GetCategory();
     208
     209            iter = fCategoryMap.find(category);
     210            if(iter == fCategoryMap.end()) {
     211                std::cerr << "Tried to add device without category, file a bug\n";
     212                continue;
     213            }
     214            else {
     215                fDevicesOutline->AddUnder(fDevices[i], iter->second);
     216            }
     217        }
     218        fDevicesOutline->SortItemsUnder(NULL, true, SortItemsCompare);
     219    }
     220    // TODO: Implement BY_BUS
     221}
     222
     223
     224void
     225DevicesView::AddChildrenToOutlineByConnection(Device* parent)
     226{
     227    for (unsigned int i = 0; i < fDevices.size(); i++) {
     228        if (fDevices[i]->GetPhysicalParent() == parent) {
     229            fDevicesOutline->AddUnder(fDevices[i], parent);
     230            AddChildrenToOutlineByConnection(fDevices[i]);
     231        }
     232    }
     233}
     234
     235
     236void
     237DevicesView::AddDeviceAndChildren(device_node_cookie *node, Device* parent)
     238{
     239    Attributes attributes;
     240    Device* newDevice = NULL;
     241
     242    // Copy all its attributes,
     243    // necessary because we can only request them once from the device manager
     244    char data[256];
     245    struct device_attr_info attr;
     246    attr.cookie = 0;
     247    attr.node_cookie = *node;
     248    attr.value.raw.data = data;
     249    attr.value.raw.length = sizeof(data);
     250
     251    while (dm_get_next_attr(&attr) == B_OK) {
     252        BString attrString;
     253        switch (attr.type) {
     254            case B_STRING_TYPE:
     255                attrString << attr.value.string;
     256                break;
     257            case B_UINT8_TYPE:
     258                attrString << attr.value.ui8;
     259                break;
     260            case B_UINT16_TYPE:
     261                attrString << attr.value.ui16;
     262                break;
     263            case B_UINT32_TYPE:
     264                attrString << attr.value.ui32;
     265                break;
     266            case B_UINT64_TYPE:
     267                attrString << attr.value.ui64;
     268                break;
     269            default:
     270                attrString << "Raw data";
     271        }
     272        attributes.push_back(Attribute(attr.name, attrString));
     273    }
     274   
     275    // Determine what type of device it is and create it
     276    for (unsigned int i = 0; i < attributes.size(); i++) {
     277        // Devices Root
     278        if (attributes[i].fName == "device/pretty name"
     279                && attributes[i].fValue == "Devices Root") {
     280            newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, "Computer");
     281            break;
     282        }
     283       
     284        // PCI bus
     285        if (attributes[i].fName == "device/pretty name"
     286                && attributes[i].fValue == "PCI") {
     287            newDevice = new Device(parent, BUS_PCI, CAT_BUS, "PCI Bus");
     288            break;
     289        }
     290
     291        // ISA bus
     292        if (attributes[i].fName == "device/bus"
     293                && attributes[i].fValue == "isa") {
     294            newDevice = new Device(parent, BUS_ISA, CAT_BUS, "ISA Bus");
     295            break;
     296        }
     297
     298        // PCI device
     299        if (attributes[i].fName == B_DEVICE_BUS
     300                && attributes[i].fValue == "pci") {
     301            newDevice = new DevicePCI(parent);
     302            break;
     303        }
     304    }
     305   
     306    if (newDevice == NULL) {
     307        newDevice = new Device(parent, BUS_NONE, CAT_NONE, "Unknown Device");
     308    }
     309   
     310    // Add its attributes to the device, initialize it and add to the list.
     311    for (unsigned int i = 0; i < attributes.size(); i++) {
     312        newDevice->SetAttribute(attributes[i].fName, attributes[i].fValue);
     313    }
     314    newDevice->InitFromAttributes();
     315    fDevices.push_back(newDevice);
     316
     317    // Process children
     318    status_t err;
     319    device_node_cookie child = *node;
     320
     321    if (get_child(&child) != B_OK)
     322        return;
     323
     324    do {
     325        AddDeviceAndChildren(&child, newDevice);
     326    } while ((err = get_next_child(&child)) == B_OK);
     327}
     328
     329
     330DevicesView::~DevicesView(void)
     331{
     332    DeleteDevices();
     333}
     334
     335
     336void
     337DevicesView::MessageReceived(BMessage *msg)
     338{
     339    switch (msg->what) {
     340        case kMsgSelectionChanged:
     341        {
     342            int32 selected = fDevicesOutline->CurrentSelection(0);
     343            if (selected >= 0) {
     344                Device* device = (Device*)fDevicesOutline->ItemAt(selected);
     345                fBasicView->AddAttributes(device->GetBasicAttributes());
     346                fBusView->AddAttributes(device->GetBusAttributes());
     347                fAttributesView->AddAttributes(device->GetAllAttributes());
     348                fDeviceTypeTab->SetLabel(device->GetBusTabName());
     349                // hmm the label doesn't automatically refresh
     350                fTabView->Invalidate();
     351            }
     352            break;
     353        }
     354
     355        case kMsgOrderCategory:
     356        {
     357            fOrderBy = ORDER_BY_CATEGORY;
     358            RescanDevices();
     359            RebuildDevicesOutline();
     360            break;
     361        }
     362
     363        case kMsgOrderConnection:
     364        {
     365            fOrderBy = ORDER_BY_CONNECTION;
     366            RescanDevices();
     367            RebuildDevicesOutline();
     368            break;
     369        }
     370
     371        case kMsgRefresh:
     372        {
     373            RescanDevices();
     374            RebuildDevicesOutline();
     375            break;
     376        }
     377
     378        case kMsgReportCompatibility:
     379        {
     380            break;
     381        }
     382
     383        case kMsgGenerateSysInfo:
     384        {
     385            break;
     386        }
     387
     388        default:
     389            BView::MessageReceived(msg);
     390            break;
     391    }
     392}
  • src/apps/devices/Devices.rdef

     
     1
     2resource app_signature "application/x-vnd.Haiku-Devices";
     3
     4resource app_version
     5{
     6    major  = 1,
     7    middle = 0,
     8    minor  = 0,
     9
     10    /* 0 = development  1 = alpha           2 = beta
     11       3 = gamma        4 = golden master   5 = final */
     12    variety = 2,
     13
     14    internal = 0,
     15
     16    short_info = "Devices",
     17    long_info  = "Devices ©2009 Haiku"
     18};
     19
     20resource app_flags B_SINGLE_LAUNCH;
     21
     22resource file_types message;
     23
     24resource vector_icon {
     25    $"6E6369660705010200060239F8173B7914BB791439F8174A3FA149A2B701A3D4"
     26    $"44FF70A804020016053BB7B3BCF33339625B3821E44A58094AD9AF000C5E79A5"
     27    $"C6C9A2FFE80200160236D6EA388279B97B4437F0674A89C84B17E100D3FFA902"
     28    $"001602340AA2385710B9E87A3568D5499E454989E30071FF01020006023887A2"
     29    $"3BCB73BBCB733887A24A60F4493C2E01FFF2ACFFFFD805010100006B0C0A0824"
     30    $"4048525842C6E5BF675041463CC306BD9636320609DADB024258465A584456C1"
     31    $"81C8C144565A405A405A3F5C3C3A5A3A5A3B5A3A425006066E0B42585A405A40"
     32    $"5A3F5D3B395A3A5A3B5A3A42500609DA6E024250465254445544534457465845"
     33    $"5645574555485250424E0607DA26425046525444554453445746585A42580A04"
     34    $"4D4C504950454D480A04373A3F3E3A43323F08053734294037473A45494D0805"
     35    $"3A35333B3E423D434B4B08043D373241364340390807443B413E434240464348"
     36    $"484250460A0D465C4C5C485A6042603D5E3D5B3F57424C3E4D3C363124444655"
     37    $"0B0A06010B000A0001001001178410040A010100000A05040708090A10011782"
     38    $"00040A040106000A040106023F1C710000000000003F1C714771C74731C70A00"
     39    $"01011001178410040A020102000A000103000A030104000A00010500"
     40};
     41
  • src/apps/devices/PropertyList.cpp

     
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT license.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8
     9
     10#include "PropertyList.h"
     11
     12#include <ColumnTypes.h>
     13
     14//#include <stdio.h>
     15
     16
     17PropertyRow::PropertyRow(const char* name, const char* value)
     18    : BRow(),
     19    fName(name), fValue(value)
     20{
     21    SetField(new BStringField(name), kNameColumn);
     22    SetField(new BStringField(value), kValueColumn);
     23}
     24
     25
     26PropertyRow::~PropertyRow()
     27{
     28}
     29
     30
     31void
     32PropertyRow::SetName(const char* name)
     33{
     34    fName = name;
     35    SetField(new BStringField(name), kNameColumn);
     36}
     37
     38
     39void
     40PropertyRow::SetValue(const char* value)
     41{
     42    fValue = value;
     43    SetField(new BStringField(value), kValueColumn);
     44}
     45
     46
     47PropertyList::PropertyList(const char* name)
     48    : BColumnListView(BRect(0.0, 0.0, 1.0, 1.0), name, B_FOLLOW_ALL, 0,
     49        B_NO_BORDER, true)
     50{
     51    BStringColumn* nameColumn;
     52    AddColumn(nameColumn = new BStringColumn("Name", 150, 50, 500,
     53            B_TRUNCATE_MIDDLE),
     54        kNameColumn);
     55    AddColumn(new BStringColumn("Value", 150, 50, 500, B_TRUNCATE_END),
     56        kValueColumn);
     57    SetSortColumn(nameColumn, false, true);
     58}
     59
     60
     61PropertyList::~PropertyList()
     62{
     63    RemoveAll();
     64}
     65
     66
     67void
     68PropertyList::AddAttributes(const Attributes& attributes)
     69{
     70    RemoveAll();
     71    for (unsigned int i = 0; i < attributes.size(); i++) {
     72        AddRow(new PropertyRow(attributes[i].fName, attributes[i].fValue));
     73    }
     74}
     75
     76
     77void
     78PropertyList::RemoveAll()
     79{
     80    BRow *row;
     81    while ((row = RowAt((int32)0, NULL))!=NULL) {
     82        RemoveRow(row);
     83        delete row;
     84    }
     85}
     86
     87
     88void
     89PropertyList::SelectionChanged()
     90{
     91}
  • src/apps/devices/DevicesView.h

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT license.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8#ifndef DEVICESVIEW_H
     9#define DEVICESVIEW_H
     10
     11
     12#include <GroupLayout.h>
     13#include <GroupLayoutBuilder.h>
     14#include <MenuField.h>
     15#include <MenuItem.h>
     16#include <OutlineListView.h>
     17#include <PopUpMenu.h>
     18#include <SplitLayoutBuilder.h>
     19#include <ScrollView.h>
     20#include <String.h>
     21#include <StringView.h>
     22#include <TabView.h>
     23#include <View.h>
     24
     25#include <map>
     26
     27#include "Device.h"
     28#include "DevicePCI.h"
     29#include "PropertyList.h"
     30#include "PropertyListPlain.h"
     31
     32static const uint32 kMsgRefresh             = 'refr';
     33static const uint32 kMsgReportCompatibility = 'repo';
     34static const uint32 kMsgGenerateSysInfo     = 'sysi';
     35static const uint32 kMsgSelectionChanged    = 'selc';
     36static const uint32 kMsgOrderCategory       = 'ocat';
     37static const uint32 kMsgOrderConnection     = 'ocon';
     38
     39typedef enum {
     40    ORDER_BY_CONNECTION,
     41    ORDER_BY_CATEGORY
     42} OrderByType;
     43
     44typedef std::map<Category, Device*> CategoryMap;
     45typedef std::map<Category, Device*>::const_iterator CategoryMapIterator;
     46
     47typedef std::vector<Device*> Devices;
     48
     49
     50class DevicesView : public BView {
     51    public:
     52                DevicesView(const BRect& r);
     53                ~DevicesView(void);
     54
     55        virtual void CreateLayout();
     56
     57        virtual void MessageReceived(BMessage* msg);
     58        virtual void RescanDevices();
     59        virtual void CreateCategoryMap();
     60        virtual void DeleteCategoryMap();
     61
     62        virtual void DeleteDevices();
     63        virtual void RebuildDevicesOutline();
     64        virtual void AddChildrenToOutlineByConnection(Device* parent);
     65        virtual void AddDeviceAndChildren(device_node_cookie* node,
     66                        Device* parent);
     67        static int   SortItemsCompare(const BListItem*, const BListItem*);
     68
     69    private:
     70        BOutlineListView*   fDevicesOutline;
     71        PropertyListPlain*  fBasicView;
     72        PropertyListPlain*  fBusView;
     73        PropertyList*       fAttributesView;
     74        BMenuField*         fOrderByMenu;
     75        BTabView*           fTabView;
     76        Devices             fDevices;
     77        OrderByType         fOrderBy;
     78        CategoryMap         fCategoryMap;
     79        BTab*               fBasicTab;
     80        BTab*               fDeviceTypeTab;
     81        BTab*               fDetailedTab;
     82
     83};
     84
     85#endif /* DEVICESVIEW_H */
  • src/apps/devices/PropertyList.h

     
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT license.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8#ifndef PROPERTYLIST_H
     9#define PROPERTYLIST_H
     10
     11
     12#include <ColumnListView.h>
     13#include <String.h>
     14
     15#include "Device.h"
     16
     17
     18struct Attribute;
     19
     20enum {
     21    kNameColumn,
     22    kValueColumn
     23};
     24
     25
     26class PropertyRow : public BRow {
     27public:
     28                        PropertyRow(const char* name, const char* value);
     29    virtual             ~PropertyRow();
     30       
     31            const char* Name() const { return fName.String(); }
     32            const char* Value() const { return fValue.String(); }
     33            void        SetName(const char* name);
     34            void        SetValue(const char* value);
     35private:
     36    BString     fName;
     37    BString     fValue;
     38};
     39
     40
     41class PropertyList : public BColumnListView {
     42public:
     43                    PropertyList(const char* name = "Properties");
     44    virtual         ~PropertyList();
     45            void    RemoveAll();
     46            void    AddAttributes(const Attributes& attributes);
     47protected:
     48    virtual void    SelectionChanged();
     49};
     50
     51#endif /* PROPERTYLIST_H*/
  • src/apps/devices/Jamfile

     
     1SubDir HAIKU_TOP src apps devices ;
     2
     3SetSubDirSupportedPlatformsBeOSCompatible ;
     4
     5UsePrivateHeaders shared ;
     6UsePrivateHeaders interface ;
     7UsePrivateKernelHeaders ;
     8UsePrivateSystemHeaders ;
     9
     10Application Devices :
     11    DevicesApplication.cpp
     12    DevicesView.cpp
     13    dm_wrapper.c
     14    DevicePCI.cpp
     15    Device.cpp
     16    PropertyList.cpp
     17    PropertyListPlain.cpp
     18    : be libcolumnlistview.a tracker $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++)
     19    : Devices.rdef
     20;
     21
     22# need pcihdr.h so we make its path available and add dependency
     23ObjectHdrs [ FGristFiles devices$(SUFOBJ) ]
     24    : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) preferences devices ] ;
     25Includes [ FGristFiles DevicePCI.cpp ] : <src!preferences!devices>pcihdr.h ;
  • src/apps/devices/Documentation/Todo.txt

     
     1TODO:
     2 * There still is a memory leak somewhere, hunt it down
     3 * Make Get methods of Device const
     4 * Fix view color?
     5 * Fix forwarding of messages to view
     6 * Bottom scrollbar strangeness
     7 * Reduce executable size?
     8 * Find a place for unknown devices (or decypher the names better)
     9 * Reselect currently selected on sort-by change - unique device id (device_node_cookie?)
     10 * Check for keyboard navigation
     11 * Loading and saving settings (sort by, position, size and sizes of views)
     12 * Icons per device type
     13 * Index attributes by enum, not string
  • src/apps/devices/Documentation/Design.txt

     
     1DeviceManager Design
     2====================
     3
     4Requirements
     5------------
     61) Graphically list each device in the system, with all the information available for that specific device type:
     7  - PCI
     8  - USB
     9  - SCSI
     10  - Bluetooth?
     11  - ISA?
     12  - ATAPI?
     13  - AHCI?
     14  - Firewire?
     15
     162) Generate a comprehensive text listing of the devices present to allow users to share detailed information with developers
     17- Generate an email with this information attached
     18
     193) Let the user generate a report on how well Haiku supports the devices in the system.
     20- Present a list of devices and per device a star rating on the support, and provide a space for comments on the device support.
     21- For each device allow comments
     22- Include all available information for the device (including loaded driver)
     23- Perhaps this can go into the Haikuware compatibility database?
     24
     254) Arrange the devices in different orders (by category, by connection, by bus type, by resource assignment?)
     26
     27Graphical Design
     28----------------
     29+=========+
     30| Devices |
     31+=========+======================================================+
     32| Devices | Help |                                               |
     33+----------------------------------------------------------------+
     34| +------------------------+-----------------------------------+ |
     35| | Sort by: [Category v]  | / Basic \/ <Bus> \/ Advanced \    | |
     36| | -------------------    | +        +--------+----------+--+ | |
     37| | v Audio/Video Devices  | | Device Name:  Netlink 5787M   | | |
     38| |     Hauppauge WinTV    | | Manufacturer: Broadcom        | | |
     39| |     Intel HDA Audio    | | Category:     Network Devices | | |
     40| | v Human Interface Dev. | | Driver used:  broadcom570x    | | |
     41| |     USB Mouse          | |                               | | |
     42| |     USB Keyboard       | |                               | | |
     43| | v Network Devices      | |                               | | |
     44| |  -->Broadcom 5787M<--  | |                               | | |
     45| |     Intel 4965 WIFI    | |                               | | |
     46| | v Graphics Card        | |                               | | |
     47| |     NVidia 8600M GT    | |                               | | |
     48| |      ....              | +-------------------------------+ | |
     49| +------------------------+-----------------------------------+ |
     50| +-------------------------+  +------------+   +-----------+    |
     51| | Report hardware support |  | Gen. email |   | Gen. Text |    |
     52| +-------------------------+  +------------+   +-----------+    |
     53+================================================================+
     54
     55Menu:
     56Devices
     57- Refresh devices
     58- Report compatibility
     59- Generate system information
     60- -----
     61- About Devices
     62- -----
     63- Quit
     64
     65Interface details:
     66- The left list is an OutlineListView,
     67  - Is inside a scroll container
     68  - Will contain nice icons per type/device
     69  - Clicking on a device will show the details in the right view
     70
     71- The right view contains 3 tabs:
     72  - Basic tab: Information available for every kind device
     73  - <Bus> tab: Information specific to the bus type of device. (PCI, USB, etc)
     74  - Advanced tab: Has a list of name-value pairs of all available information
     75
     76- Sort by allows the user to arrange the treeview by:
     77  - Category:
     78  - Connection
     79  - Bus type
     80
     81- Report Hardware Support
     82  - List all devices
     83  - For each device
     84
     85When you click Report Hardware Support, this appears:
     86 
     87+=========================+
     88| Report Hardware Support |
     89+=========================+============================+
     90| Report Device                   Supported  Comment   |
     91|  [x]   Broadcom Netlink 5787M    *****     _________ |
     92|  [x]   Hauppauge WinTV           *****     _________ |
     93|  [x]   Intel 4965 WIFI           .....     _________ |
     94|  [x]   Intel HDA Audio           ****.     _________ |
     95|  [x]   NVidia 8600M GT           ***..     _________ |
     96|  [x]   USB Keyboard              *****     _________ |
     97|  [x]   USB Mouse                 *****     _________ |
     98|  [ ]   Intel 82801 PCI Bridge    .....     _________ |
     99|  [ ]   Intel 82801H PCI Express  .....     _________ |
     100|                                                      |
     101|  If you wish, you can leave your contact details so  |
     102|  developers can get in touch with you for questions  |
     103|  about your devices. These will be stored privately. |
     104|                                                      |
     105|  Name: _______________  Email: __________________    |
     106|                                                      |
     107|  Haiku-os.org account: __________________________    |
     108|                                                      |
     109|  +--------------------+  +---------------+           |
     110|  | Preview submission |  | Generate File |           |
     111|  +--------------------+  +---------------+           |
     112+======================================================+
     113
     114Interface details:
     115------------------
     116- All devices are _not_ selected for report by default
     117- As soon as a rating is given, it is selected to be reported
     118- Preview submission will popup the generated list with a submit button
     119- Generate file will generate a file that can be uploaded manually, or emailed to a specific address.
     120- As you mouse over the rating, a popup will appear detailing what each star stands for:
     121  - ..... : No support
     122  - X.... : Crashes Haiku
     123  - **... : Detected but doesn't work with 3rd party driver
     124  - ***.. : Detected but doesn't work out of the box
     125  - ****. : Detected and works with 3rd party driver
     126  - ***** : Detected and works out of the box
     127 
     128 
  • src/apps/devices/Documentation/Specification.txt

     
     1Each device has:
     2- Name (long/short)
     3- Manufacturer (long/short)
     4- Category (one master list, each bus type maps its device types onto the master list)
     5- Driver used
     6- Device paths
     7- Its bus type
     8- Its connection parent, if applicable
     9
     10Each source has: (currently the RescanDevices method does this)
     11- Init function
     12- Scan method that returns the devices.
     13- DevManSource, USBSource, FWSource, ...
     14
     15DeviceManager Specification
     16===========================
     17
     18DeviceManager : BApplication
     19-------------
     20
     21DeviceManagerView : BView
     22-----------------
     23
     24
     25Device : public BStringItem
     26------
     27BString GetName() const;
     28BString GetManufacturer() const;
     29Category GetCategory() const;
     30BString DriverUsed() const;
     31BString DevPathsPublished() const;
     32BView Get
     33private:
     34BString _name;
     35BString _manufacturer;
     36Category _category;
     37BString _driverUsed;
     38BString devPathsPublished;
     39map<BString, BString> _attributes;
     40
     41Bus : public BStringItem
     42---
     43virtual bool IsPresent() const = 0;
     44virtual Scan() = 0;
     45virtual vector<Device *> Devices() = 0;
     46
     47PCIBus : public Bus
     48------
     49
     50PCIDevice: public Device
     51---------
     52
     53ISABus : public Bus
     54-----
     55
     56ISADevice : public Device
     57---------
     58
     59USBBus : public Bus
     60------
     61
     62USBDevice : public Device
     63---------
     64
     65SCSIBus : public Bus
     66-------
     67
     68SCSIDevice : public Device
     69----------
  • src/apps/devices/DevicePCI.cpp

     
     1/*
     2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 */
     8
     9
     10#include <sstream>
     11
     12#include "DevicePCI.h"
     13
     14extern "C" {
     15#include "dm_wrapper.h"
     16#include "pcihdr.h"
     17#include "pci-utils.h"
     18}
     19
     20
     21DevicePCI::DevicePCI(Device* parent)
     22    :
     23    Device(parent),
     24    fClassBaseId(0),
     25    fClassSubId(0),
     26    fClassApiId(0),
     27    fVendorId(0),
     28    fDeviceId(0),
     29    fSubsystemVendorId(0),
     30    fSubSystemId(0)
     31{
     32}
     33
     34
     35DevicePCI::~DevicePCI()
     36{
     37}
     38
     39
     40BString ToHex(uint16 num)
     41{
     42    std::stringstream ss;
     43    ss.flags(std::ios::hex | std::ios::showbase);
     44    ss << num;
     45    return BString(ss.str().c_str());
     46}
     47
     48
     49void
     50DevicePCI::InitFromAttributes()
     51{
     52    // Process the attributes
     53    fClassBaseId = atoi(fAttributeMap[B_DEVICE_TYPE].String());
     54    fClassSubId = atoi(fAttributeMap[B_DEVICE_SUB_TYPE].String());
     55    fClassApiId = atoi(fAttributeMap[B_DEVICE_INTERFACE].String());
     56    fVendorId = atoi(fAttributeMap[B_DEVICE_VENDOR_ID].String());
     57    fDeviceId = atoi(fAttributeMap[B_DEVICE_ID].String());
     58
     59    // Looks better in Hex, so rewrite
     60    fAttributeMap[B_DEVICE_TYPE] = ToHex(fClassBaseId);
     61    fAttributeMap[B_DEVICE_SUB_TYPE] = ToHex(fClassSubId);
     62    fAttributeMap[B_DEVICE_INTERFACE] = ToHex(fClassApiId);
     63    fAttributeMap[B_DEVICE_VENDOR_ID] = ToHex(fVendorId);
     64    fAttributeMap[B_DEVICE_ID] = ToHex(fDeviceId);
     65
     66    // Fetch ClassInfo 
     67    char classInfo[64];
     68    get_class_info(fClassBaseId, fClassSubId, fClassApiId, classInfo, sizeof(classInfo));
     69   
     70    // Fetch ManufacturerName
     71    BString ManufacturerName;
     72    const char *venShort;
     73    const char *venFull;
     74    get_vendor_info(fVendorId, &venShort, &venFull);
     75    if (!venShort && !venFull) {
     76        ManufacturerName << "Unkown";
     77    } else if (venShort && venFull) {
     78        ManufacturerName << venFull << "(" << venShort << ")";
     79    } else {
     80        ManufacturerName << (venShort ? venShort : venFull);
     81    }
     82   
     83    // Fetch DeviceName
     84    BString DeviceName;
     85    const char *devShort;
     86    const char *devFull;
     87    get_device_info(fVendorId, fDeviceId, fSubsystemVendorId, fSubSystemId, &devShort, &devFull);
     88    if (!devShort && !devFull) {
     89        DeviceName << "Unknown";
     90    } else if (devShort && devFull) {
     91        DeviceName << devFull << "(" << devShort << ")";
     92    } else {
     93        DeviceName << (devShort ? devShort : devFull);
     94    }
     95   
     96    SetAttribute("Device name", DeviceName);
     97    SetAttribute("Manufacturer", ManufacturerName);
     98    SetAttribute("Driver used", "Not implemented");
     99    SetAttribute("Device paths", "Not implemented");
     100    SetAttribute("Class Info", classInfo);
     101    fCategory = (Category)fClassBaseId;
     102    BString outlineName;
     103    outlineName << ManufacturerName << " " << DeviceName;
     104    SetText(outlineName.String());
     105}
     106
     107
     108Attributes
     109DevicePCI::GetBusAttributes()
     110{
     111    Attributes attributes;
     112    attributes.push_back(GetAttribute(B_DEVICE_TYPE));
     113    attributes.push_back(GetAttribute(B_DEVICE_SUB_TYPE));
     114    attributes.push_back(GetAttribute(B_DEVICE_INTERFACE));
     115    attributes.push_back(GetAttribute(B_DEVICE_VENDOR_ID));
     116    attributes.push_back(GetAttribute(B_DEVICE_ID));
     117    return attributes;
     118}
     119
     120
     121BString
     122DevicePCI::GetBusStrings()
     123{
     124    BString str;
     125    str << "Class Info:\t\t\t\t: " << fAttributeMap["Class Info"];
     126    return str;
     127}
  • src/apps/Jamfile

     
    1515HaikuSubInclude debugger ;
    1616HaikuSubInclude deskbar ;
    1717HaikuSubInclude deskcalc ;
     18HaikuSubInclude devices ;
    1819HaikuSubInclude diskprobe ;
    1920HaikuSubInclude diskusage ;
    2021HaikuSubInclude drivesetup ;