Ticket #7245: devices-fix.patch

File devices-fix.patch, 28.3 KB (added by Karvjorm, 13 years ago)

An enhancement and fix for the Devices application.

  • src/apps/devices/Device.cpp

     
    3737    B_TRANSLATE("Encryption controller"),               // 0x10
    3838    B_TRANSLATE("Signal processing controller"),        // 0x11
    3939    B_TRANSLATE("Computer"),                            // 0x12 (added later)
    40     B_TRANSLATE("ACPI controller")                      // 0x13 (added later)
     40    B_TRANSLATE("ACPI controller"),                     // 0x13 (added later)
     41    B_TRANSLATE("USB controller"),                      // 0x14 (added later)
     42    B_TRANSLATE("SCSI controller")                      // 0x15 (added later)
    4143};
    4244
    4345
     
    5052    fCategory(category),
    5153    fPhysicalParent(physicalParent)
    5254{
    53     SetAttribute(B_TRANSLATE("Device name"), name);
    54     SetAttribute(B_TRANSLATE("Manufacturer"), manufacturer);
    55     SetAttribute(B_TRANSLATE("Driver used"), driverUsed);
    56     SetAttribute(B_TRANSLATE("Device paths"), devPathsPublished);
     55    SetAttribute("Device name", name);
     56    SetAttribute("Manufacturer", manufacturer);
     57    SetAttribute("Driver used", driverUsed);
     58    SetAttribute("Device paths", devPathsPublished);
    5759}
    5860
    5961
     
    6567void
    6668Device::SetAttribute(const BString& name, const BString& value)
    6769{
    68     if (name == B_TRANSLATE("Device name")) {
     70    if (name == "Device name") {
    6971        SetText(value.String());
    7072    }
    7173    fAttributeMap[name] = value;
     
    132134{
    133135    BString str;
    134136    AttributeMapIterator iter;
     137    AttributeMapIterator another;
     138    bool getaway = false;
     139    const BString deviceName = B_TRANSLATE_MARK("Device name");
     140    int32 laskuri = 0;
    135141    for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) {
     142        getaway = false;
     143        laskuri++;
     144        if (iter->first == "Device name" && iter->second == "Unknown device") {
     145            for (another = fAttributeMap.begin(); another != fAttributeMap.end(); another++) {
     146                if ((another->first == "Device name") &&
     147                    ((another->second != "unknown") ||
     148                    (another->second != "Unknown") ||
     149                    (another->second != "Unknown device"))) {
     150                        str << deviceName << " : " << another->second << "\n";
     151                        getaway = true;
     152                        continue;
     153                }
     154                if (another->first == "controller_name" &&
     155                    ((another->second != "unknown") ||
     156                    (another->second != "Unknown"))) {
     157                    str << deviceName << " : " << another->second << "\n";
     158                    getaway = true;
     159                    continue;
     160                }
     161                if (another->first == "ide/controller_name" &&
     162                    ((another->second != "unknown") ||
     163                    (another->second != "Unknown"))) {
     164                    str << deviceName << " : " << another->second << "\n";
     165                    getaway = true;
     166                    continue;
     167                }
     168                if (another->first == "isa/controller_name" &&
     169                    ((another->second != "unknown") ||
     170                    (another->second != "Unknown"))) {
     171                    str << deviceName << " : " << another->second << "\n";
     172                    getaway = true;
     173                    continue;
     174                }
     175                if (another->first == "pci/controller_name" &&
     176                    ((another->second != "unknown") ||
     177                    (another->second != "Unknown"))) {
     178                    str << deviceName << " : " << another->second << "\n";
     179                    getaway = true;
     180                    continue;
     181                }
     182                if (another->first == "acpi/controller_name" &&
     183                    ((another->second != "unknown") ||
     184                    (another->second != "Unknown"))) {
     185                    str << deviceName << " : " << another->second << "\n";
     186                    getaway = true;
     187                    continue;
     188                }
     189                if (another->first == "scsi/controller_name" &&
     190                    ((another->second != "unknown") ||
     191                    (another->second != "Unknown"))) {
     192                    str << deviceName << " : " << another->second << "\n";
     193                    getaway = true;
     194                    continue;
     195                }
     196                if (another->first == "usb/controller_name" &&
     197                    ((another->second != "unknown") ||
     198                    (another->second != "Unknown"))) {
     199                    str << deviceName << " : " << another->second << "\n";
     200                    getaway = true;
     201                    continue;
     202                }
     203
     204                if (another->first == "device/pretty name" &&
     205                    ((another->second != "unknown") ||
     206                    (another->second != "Unknown"))) {
     207                    str << deviceName << " : " << another->second << "\n";
     208                    getaway = true;
     209                    continue;
     210                }
     211            }
     212        } else if (iter->first == "Device name" &&
     213            ((iter->second != "unknown") ||
     214            (iter->second != "Unknown"))) {
     215            for (another = fAttributeMap.begin();
     216                another != fAttributeMap.end(); another++) {
     217                if ((another->first == "Device name") &&
     218                    ((another->second != "unknown") ||
     219                    (another->second != "Unknown") ||
     220                    (another->second != "Unknown device"))) {
     221                        str << deviceName << " : " << another->second << "\n";
     222                        getaway = true;
     223                        continue;
     224                }
     225                if (another->first == "controller_name" &&
     226                    ((another->second != "unknown") ||
     227                    (another->second != "Unknown"))) {
     228                    str << deviceName << " : " << another->second << "\n";
     229                    getaway = true;
     230                    continue;
     231                }
     232                if (another->first == "ide/controller_name" &&
     233                    ((another->second != "unknown") ||
     234                    (another->second != "Unknown"))) {
     235                    str << deviceName << " : " << another->second << "\n";
     236                    getaway = true;
     237                    continue;
     238                }
     239                if (another->first == "isa/controller_name" &&
     240                    ((another->second != "unknown") ||
     241                    (another->second != "Unknown"))) {
     242                    str << deviceName << " : " << another->second << "\n";
     243                    getaway = true;
     244                    continue;
     245                }
     246                if (another->first == "pci/controller_name" &&
     247                    ((another->second != "unknown") ||
     248                    (another->second != "Unknown"))) {
     249                    str << deviceName << " : " << another->second << "\n";
     250                    getaway = true;
     251                    continue;
     252                }
     253                if (another->first == "acpi/controller_name" &&
     254                    ((another->second != "unknown") ||
     255                    (another->second != "Unknown"))) {
     256                    str << deviceName << " : " << another->second << "\n";
     257                    getaway = true;
     258                    continue;
     259                }
     260                if (another->first == "scsi/controller_name" &&
     261                    ((another->second != "unknown") ||
     262                    (another->second != "Unknown"))) {
     263                    str << deviceName << " : " << another->second << "\n";
     264                    getaway = true;
     265                    continue;
     266                }
     267                if (another->first == "usb/controller_name" &&
     268                    ((another->second != "unknown") ||
     269                    (another->second != "Unknown"))) {
     270                    str << deviceName << " : " << another->second << "\n";
     271                    getaway = true;
     272                    continue;
     273                }
     274                if (another->first == "device/pretty name" &&
     275                    ((another->second != "unknown") ||
     276                    (another->second != "Unknown"))) {
     277                    str << deviceName << " : " << another->second << "\n";
     278                    getaway = true;
     279                    continue;
     280                }
     281            }
     282        }
     283        if (iter->first == "Manufacturer" && (iter->second == "Unknown" ||
     284            iter->second == "unknown")) {
     285            for (another = fAttributeMap.begin();
     286                another != fAttributeMap.end(); another++) {
     287                if ((another->first == "Manufacturer") &&
     288                    ((another->second != "unknown") ||
     289                    (another->second != "Unknown"))) {
     290                        str << another->first << " : ";
     291                        str << another->second << "\n";
     292                        getaway = true;
     293                        continue;
     294                }
     295            }
     296        }
     297        if (iter->first == "controller_name") {
     298            for (another = fAttributeMap.begin();
     299                another != fAttributeMap.end(); another++) {
     300                if ((another->first == "Device name") &&
     301                    ((another->second == "unknown") ||
     302                    (another->second == "Unknown"))) {
     303                        fAttributeMap["Device name"] = iter->second;
     304                        str << another->first << " : ";
     305                        str << iter->second << "\n";
     306                        getaway = true;
     307                        continue;
     308                }
     309            }
     310        }
     311        if (getaway) continue;
    136312        str << iter->first << " : " << iter->second << "\n";
    137313    }
    138314    return str;
  • src/apps/devices/DevicePCI.h

     
    1313#include <Catalog.h>
    1414
    1515#undef B_TRANSLATE_CONTEXT
    16 #define B_TRANSLATE_CONTEXT "DevicePCI"
     16#define B_TRANSLATE_CONTEXT "DevicePCI_H"
    1717
     18BString ToHex(uint16 num);
     19BString GetClassinfo(uint16 fClassBaseId, uint16 fClassSubId, uint16 fClassApiId);
     20BString GetVendorInfo(uint16 vendor_id);
     21BString GetDeviceinfo(uint16 VendorId, uint16 DeviceId,
     22    uint16 SubsystemVendorId, uint16 SubSystemId,
     23    const char* devShort, const char* devFull);
     24
     25
    1826class DevicePCI : public Device {
    1927public:
    2028                        DevicePCI(Device* parent);
  • src/apps/devices/DeviceACPI.h

     
    1313#include <Catalog.h>
    1414
    1515#undef B_TRANSLATE_CONTEXT
    16 #define B_TRANSLATE_CONTEXT "DeviceACPI"
     16#define B_TRANSLATE_CONTEXT "DeviceACPI_H"
    1717
    1818class DeviceACPI : public Device {
    1919public:
  • src/apps/devices/Device.h

     
    1212#include <map>
    1313#include <vector>
    1414
     15#include <Catalog.h>
    1516#include <String.h>
    1617#include <StringItem.h>
    1718
     19#undef B_TRANSLATE_CONTEXT
     20#define B_TRANSLATE_CONTEXT "Device_H"
     21
    1822extern "C" {
    1923#include "dm_wrapper.h"
    2024}
     
    2529    BUS_PCI,
    2630    BUS_SCSI,
    2731    BUS_ACPI,
     32    BUS_USB,
    2833    BUS_NONE
    2934} BusType;
    3035
     
    4752    CAT_NONE = 0,
    4853    CAT_BUS = 6,
    4954    CAT_COMPUTER = 0x12,
    50     CAT_ACPI = 0x13
     55    CAT_ACPI = 0x13,
     56    CAT_USB = 0x14
    5157} Category;
    5258
    5359
     
    8995    virtual BString         GetAllStrings();
    9096   
    9197    virtual BString         GetBusTabName()
    92                                 { return "Bus Information"; }
     98                                { return B_TRANSLATE("Bus Information"); }
    9399
    94100    virtual Attribute       GetAttribute(const BString& name)
    95101                                { return Attribute(name.String(),
  • src/apps/devices/DevicesApplication.cpp

     
    5353void
    5454DevicesApplication::ShowAbout()
    5555{
    56     BAlert* alert = new BAlert("about", B_TRANSLATE("Devices\n"
    57         "\twritten by Pieter Panman\n"
    58         "\n"
    59         "\tBased on listdev by Jérôme Duval\n"
    60         "\tand the previous Devices preference\n"
    61         "\tby Jérôme Duval and Sikosis\n"
    62         "\tCopyright 2009, Haiku, Inc.\n"), B_TRANSLATE("OK"));
     56    BString aboutStr("%1\n%2\n\n%3\nCopyright 2009, Haiku, Inc.\n");
     57    aboutStr.ReplaceFirst("%1", B_TRANSLATE("Devices"));
     58    aboutStr.ReplaceFirst("%2", B_TRANSLATE("written by Pieter Panman"));
     59    aboutStr.ReplaceFirst("%3", B_TRANSLATE("Based on listdev by Jérôme "
     60    "Duval\nand the previous Devices preference\nby Jérôme Duval and "
     61    "Sikosis"));
     62    BAlert* alert = new BAlert("about", aboutStr.String(), B_TRANSLATE("OK"));
    6363    BTextView* view = alert->TextView();
    6464    BFont font;
    6565
     
    6868    view->GetFont(&font);
    6969    font.SetSize(18);
    7070    font.SetFace(B_BOLD_FACE);
    71     view->SetFontAndColor(0, 7, &font);
     71    view->SetFontAndColor(0, strlen(B_TRANSLATE("Devices")), &font);
    7272
    7373    alert->Go();
    7474}
  • src/apps/devices/DeviceUSB.cpp

     
     1/*
     2 * Copyright 2008-2011 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 *      Jorma Karvonen
     8 */
     9
     10
     11#include <sstream>
     12#include <stdlib.h>
     13
     14#include "DeviceUSB.h"
     15
     16extern BString ToHex(uint16);
     17extern BString GetClassinfo(uint16, uint16,uint16);
     18extern BString GetVendorInfo(uint16);
     19extern BString GetDeviceinfo(uint16, uint16, uint16, uint16);
     20
     21
     22DeviceUSB::DeviceUSB(Device* parent)
     23    :
     24    Device(parent),
     25    fClassBaseId(0),
     26    fClassSubId(0),
     27    fClassApiId(0),
     28    fVendorId(0),
     29    fDeviceId(0),
     30    fSubsystemVendorId(0),
     31    fSubSystemId(0)
     32{
     33}
     34
     35
     36DeviceUSB::~DeviceUSB()
     37{
     38}
     39
     40
     41void
     42DeviceUSB::InitFromAttributes()
     43{
     44    // Process the attributes
     45    fClassBaseId = atoi(fAttributeMap[B_DEVICE_TYPE].String());
     46    fClassSubId = atoi(fAttributeMap[B_DEVICE_SUB_TYPE].String());
     47    fClassApiId = atoi(fAttributeMap[B_DEVICE_INTERFACE].String());
     48    fVendorId = atoi(fAttributeMap[B_DEVICE_VENDOR_ID].String());
     49    fDeviceId = atoi(fAttributeMap[B_DEVICE_ID].String());
     50
     51    // Looks better in Hex, so rewrite
     52    fAttributeMap[B_DEVICE_TYPE] = ToHex(fClassBaseId);
     53    fAttributeMap[B_DEVICE_SUB_TYPE] = ToHex(fClassSubId);
     54    fAttributeMap[B_DEVICE_INTERFACE] = ToHex(fClassApiId);
     55    fAttributeMap[B_DEVICE_VENDOR_ID] = ToHex(fVendorId);
     56    fAttributeMap[B_DEVICE_ID] = ToHex(fDeviceId);
     57
     58    // Fetch ClassInfo
     59    BString classInfo = GetClassinfo(fClassBaseId, fClassSubId, fClassApiId);
     60   
     61    // Fetch ManufacturerName
     62    BString ManufacturerName = GetVendorInfo(fVendorId);
     63       
     64    // Fetch DeviceName
     65    BString DeviceName = GetDeviceinfo(fVendorId, fDeviceId,
     66                            fSubsystemVendorId, fSubSystemId);
     67   
     68    SetAttribute("Device name", DeviceName);
     69    SetAttribute("Manufacturer", ManufacturerName);
     70    SetAttribute("Driver used", "Not implemented");
     71    SetAttribute("Device paths", "Not implemented");
     72    SetAttribute("Class info", classInfo.String());
     73    //fCategory = (Category)fClassBaseId;
     74    fCategory = (Category)CAT_USB;
     75    BString outlineName;
     76    outlineName << ManufacturerName << " " << DeviceName;
     77    SetText(outlineName.String());
     78}
     79
     80
     81Attributes
     82DeviceUSB::GetBusAttributes()
     83{
     84    Attributes attributes;
     85    attributes.push_back(GetAttribute(B_DEVICE_TYPE));
     86    attributes.push_back(GetAttribute(B_DEVICE_SUB_TYPE));
     87    attributes.push_back(GetAttribute(B_DEVICE_INTERFACE));
     88    attributes.push_back(GetAttribute(B_DEVICE_VENDOR_ID));
     89    attributes.push_back(GetAttribute(B_DEVICE_ID));
     90    attributes.push_back(GetAttribute("device/bus"));
     91    attributes.push_back(GetAttribute("usb/path"));
     92    attributes.push_back(GetAttribute("usb/type"));
     93    return attributes;
     94}
     95
     96
     97BString
     98DeviceUSB::GetBusStrings()
     99{
     100    BString str(B_TRANSLATE("Class Info:\t\t\t\t: %classInfo%"));
     101    str.ReplaceFirst("%classInfo%", fAttributeMap["Class Info"]);
     102    return str;
     103}
  • src/apps/devices/DevicesView.cpp

     
    275275                attrString << attr.value.ui64;
    276276                break;
    277277            default:
    278                 attrString << "Raw data";
     278                attrString << B_TRANSLATE("Raw data");
    279279        }
    280280        attributes.push_back(Attribute(attr.name, attrString));
    281281    }
     
    285285        // Devices Root
    286286        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
    287287                && attributes[i].fValue == "Devices Root") {
    288             newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, "Computer");
     288            newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, B_TRANSLATE("Computer"));
    289289            break;
    290290        }
    291291
    292292        // ACPI Controller
    293293        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
    294294                && attributes[i].fValue == "ACPI") {
    295             newDevice = new Device(parent, BUS_ACPI, CAT_BUS, "ACPI bus");
     295            newDevice = new Device(parent, BUS_ACPI, CAT_BUS, B_TRANSLATE("ACPI bus"));
    296296            break;
    297297        }
     298       
     299        // SCSI Controller
     300        /* if (attributes[i].fName == B_DEVICE_PRETTY_NAME
     301                && attributes[i].fValue == "SCSI") {
     302            newDevice = new Device(parent, BUS_SCSI, CAT_BUS, "SCSI bus");
     303            break;
     304        } */
    298305
    299306        // PCI bus
    300307        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
    301308                && attributes[i].fValue == "PCI") {
    302             newDevice = new Device(parent, BUS_PCI, CAT_BUS, "PCI bus");
     309            newDevice = new Device(parent, BUS_PCI, CAT_BUS, B_TRANSLATE("PCI bus"));
    303310            break;
    304311        }
    305312
     313        // USB bus
     314        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
     315                && attributes[i].fValue == "USB") {
     316            newDevice = new Device(parent, BUS_USB, CAT_BUS, "USB bus");
     317            break;
     318        }
     319
    306320        // ISA bus
    307321        if (attributes[i].fName == B_DEVICE_BUS
    308322                && attributes[i].fValue == "isa") {
    309             newDevice = new Device(parent, BUS_ISA, CAT_BUS, "ISA bus");
     323            newDevice = new Device(parent, BUS_ISA, CAT_BUS, B_TRANSLATE("ISA bus"));
    310324            break;
    311325        }
     326       
     327        // SCSI bus
     328        /* if (attributes[i].fName == B_DEVICE_BUS
     329                && attributes[i].fValue == "scsi") {
     330            newDevice = new DeviceSCSI(parent);
     331            break;
     332        } */
    312333
    313334        // PCI device
    314335        if (attributes[i].fName == B_DEVICE_BUS
     
    323344            newDevice = new DeviceACPI(parent);
    324345            break;
    325346        }
     347       
     348        // USB device
     349        if (attributes[i].fName == B_DEVICE_BUS
     350                && attributes[i].fValue == "usb") {
     351            newDevice = new DeviceUSB(parent);
     352            break;
     353        }   
    326354    }
    327355
    328356    if (newDevice == NULL) {
  • src/apps/devices/DeviceUSB.h

     
     1/*
     2 * Copyright 2008-2011 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 *      Jorma Karvonen
     8 */
     9#ifndef DEVICEUSB_H
     10#define DEVICEUSB_H
     11
     12
     13#include "Device.h"
     14#include <Catalog.h>
     15
     16#undef B_TRANSLATE_CONTEXT
     17#define B_TRANSLATE_CONTEXT "DeviceUSB_H"
     18
     19class DeviceUSB : public Device {
     20public:
     21                        DeviceUSB(Device* parent);
     22    virtual             ~DeviceUSB();
     23    virtual Attributes  GetBusAttributes();
     24    virtual BString     GetBusStrings();
     25    virtual void        InitFromAttributes();
     26   
     27    virtual BString     GetBusTabName()
     28                            { return B_TRANSLATE("USB Information"); }
     29
     30private:
     31    uint16              fClassBaseId;
     32    uint16              fClassSubId;
     33    uint16              fClassApiId;
     34    uint16              fVendorId;
     35    uint16              fDeviceId;
     36    uint16              fSubsystemVendorId;
     37    uint16              fSubSystemId;
     38};
     39
     40#endif /* DEVICEUSB_H */
  • src/apps/devices/PropertyList.cpp

     
    88
    99
    1010#include "PropertyList.h"
     11
     12#include <Catalog.h>
    1113#include <ColumnTypes.h>
    1214
    1315//#include <stdio.h>
    1416
     17#undef B_TRANSLATE_CONTEXT
     18#define B_TRANSLATE_CONTEXT "PropertyList"
     19
    1520PropertyRow::PropertyRow(const char* name, const char* value)
    1621    : BRow(),
    1722    fName(name), fValue(value)
  • src/apps/devices/DeviceSCSI.cpp

     
     1/*
     2 * Copyright 2008-2011 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Pieter Panman
     7 *      Jorma Karvonen
     8 */
     9
     10
     11#include <sstream>
     12#include <stdlib.h>
     13
     14#include "DeviceSCSI.h"
     15
     16extern BString ToHex(uint16);
     17extern BString GetClassinfo(uint16 fClassBaseId, uint16 fClassSubId,
     18    uint16 fClassApiId);
     19extern BString GetVendorInfo(uint16);
     20extern BString GetDeviceinfo(uint16, uint16, uint16, uint16);
     21
     22
     23DeviceSCSI::DeviceSCSI(Device* parent)
     24    :
     25    Device(parent),
     26    fClassBaseId(0),
     27    fClassSubId(0),
     28    fClassApiId(0),
     29    fVendorId(0),
     30    fDeviceId(0),
     31    fSubsystemVendorId(0),
     32    fSubSystemId(0)
     33{
     34}
     35
     36
     37DeviceSCSI::~DeviceSCSI()
     38{
     39}
     40
     41
     42void
     43DeviceSCSI::InitFromAttributes()
     44{
     45    // Process the attributes
     46    fClassBaseId = atoi(fAttributeMap[B_DEVICE_TYPE].String());
     47    fClassSubId = atoi(fAttributeMap[B_DEVICE_SUB_TYPE].String());
     48    fClassApiId = atoi(fAttributeMap[B_DEVICE_INTERFACE].String());
     49    fVendorId = atoi(fAttributeMap[B_DEVICE_VENDOR_ID].String());
     50    fDeviceId = atoi(fAttributeMap[B_DEVICE_ID].String());
     51
     52    // Looks better in Hex, so rewrite
     53    fAttributeMap[B_DEVICE_TYPE] = ToHex(fClassBaseId);
     54    fAttributeMap[B_DEVICE_SUB_TYPE] = ToHex(fClassSubId);
     55    fAttributeMap[B_DEVICE_INTERFACE] = ToHex(fClassApiId);
     56    fAttributeMap[B_DEVICE_VENDOR_ID] = ToHex(fVendorId);
     57    fAttributeMap[B_DEVICE_ID] = ToHex(fDeviceId);
     58
     59    // Fetch ClassInfo 
     60    BString classInfo = GetClassinfo(fClassBaseId, fClassSubId, fClassApiId);
     61   
     62    // Fetch ManufacturerName
     63    BString ManufacturerName;
     64    ManufacturerName << GetVendorInfo(fVendorId);
     65   
     66    // Fetch DeviceName
     67    BString DeviceName;
     68    DeviceName << GetDeviceinfo(fVendorId, fDeviceId, fSubsystemVendorId,
     69        fSubSystemId);
     70
     71    SetAttribute("Device name", DeviceName);
     72    SetAttribute("Manufacturer", ManufacturerName);
     73    SetAttribute("Driver used", "Not implemented");
     74    SetAttribute("Device paths", "Not implemented");
     75    SetAttribute("Class info", classInfo.String());
     76    fCategory = (Category)fClassBaseId;
     77    BString outlineName;
     78    outlineName << ManufacturerName << " " << DeviceName;
     79    SetText(outlineName.String());
     80}
     81
     82
     83Attributes
     84DeviceSCSI::GetBusAttributes()
     85{
     86    Attributes attributes;
     87    attributes.push_back(GetAttribute(B_DEVICE_TYPE));
     88    attributes.push_back(GetAttribute(B_DEVICE_SUB_TYPE));
     89    attributes.push_back(GetAttribute(B_DEVICE_INTERFACE));
     90    attributes.push_back(GetAttribute(B_DEVICE_VENDOR_ID));
     91    attributes.push_back(GetAttribute(B_DEVICE_ID));
     92    return attributes;
     93}
     94
     95
     96BString
     97DeviceSCSI::GetBusStrings()
     98{
     99    BString str(B_TRANSLATE("Class Info:\t\t\t\t: %classInfo%"));
     100    str.ReplaceFirst("%classInfo%", fAttributeMap["Class Info"]);
     101    return str;
     102}
  • src/apps/devices/DevicesView.h

     
    2525#include <map>
    2626
    2727#include "Device.h"
     28#include "DeviceSCSI.h"
    2829#include "DevicePCI.h"
    2930#include "DeviceACPI.h"
     31#include "DeviceUSB.h"
    3032#include "PropertyList.h"
    3133#include "PropertyListPlain.h"
    3234
  • src/apps/devices/PropertyList.h

     
    1616#include <Catalog.h>
    1717
    1818#undef B_TRANSLATE_CONTEXT
    19 #define B_TRANSLATE_CONTEXT "PropertyList"
     19#define B_TRANSLATE_CONTEXT "PropertyList_H"
    2020
    2121struct Attribute;
    2222
  • src/apps/devices/Jamfile

     
    7272    Device.cpp
    7373    PropertyList.cpp
    7474    PropertyListPlain.cpp
     75    DeviceUSB.cpp
     76#   DeviceSCSI.cpp
    7577    : be libcolumnlistview.a tracker $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS)
    7678    : Devices.rdef
    7779;
     
    7981DoCatalogs Devices :
    8082    x-vnd.Haiku-Devices
    8183    :
     84    Device.h
     85    Device.cpp
    8286    DevicesApplication.cpp
    8387    DevicesView.cpp
     88    DeviceACPI.h
     89    DeviceACPI.cpp
     90    DevicePCI.h
    8491    DevicePCI.cpp
     92    PropertyList.h
    8593    PropertyList.cpp
    86     PropertyListPlain.cpp
     94    DeviceUSB.h
     95    ResourceUsageWindow.cpp
     96#   DeviceSCSI.h
    8797;
    8898
    8999Includes [ FGristFiles DevicesInfo.cpp ] : [ FGristFiles isapnpids.h usbdevs.h
  • src/apps/devices/DeviceSCSI.h

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

     
    1616#include "dm_wrapper.h"
    1717#include "pcihdr.h"
    1818#include "pci-utils.h"
     19};
     20
     21BString
     22ToHex(uint16 num)
     23{
     24    std::stringstream ss;
     25    ss.flags(std::ios::hex | std::ios::showbase);
     26    ss << num;
     27    return BString(ss.str().c_str());
    1928}
    2029
    2130
     31BString
     32GetClassinfo(uint16 fClassBaseId, uint16 fClassSubId, uint16 fClassApiId)
     33{
     34    // Fetch ClassInfo
     35    BString ret;   
     36    char classInfo[128];
     37    memset(classInfo, 0x00, sizeof(classInfo));
     38    get_class_info(fClassBaseId, fClassSubId, fClassApiId, classInfo,
     39        sizeof(classInfo));
     40    ret << classInfo;
     41    return ret;
     42}
     43
     44
     45BString
     46GetVendorInfo(uint16 vendor_id)
     47{
     48    BString ret;
     49    const char* venShort;
     50    const char* venFull;
     51    get_vendor_info(vendor_id, &venShort, &venFull);
     52    if (!venShort && !venFull) {
     53        ret << "Unknown";
     54    } else if (venShort && venFull) {
     55        ret << venFull << "(" << venShort << ")";
     56    } else {
     57        ret << (venShort ? venShort : venFull);
     58    }
     59    return ret;
     60}
     61
     62
     63BString
     64GetDeviceinfo(uint16 VendorId, uint16 DeviceId,
     65    uint16 SubsystemVendorId, uint16 SubSystemId)
     66{
     67    BString ret;
     68    const char* devShort;
     69    const char* devFull;
     70    get_device_info(VendorId, DeviceId, SubsystemVendorId, SubSystemId,
     71        &devShort, &devFull);
     72    if (!devShort && !devFull) {
     73        ret << "Unknown";
     74    } else if (devShort && devFull) {
     75        ret << devFull << "(" << devShort << ")";
     76    } else {
     77        ret << (devShort ? devShort : devFull);
     78    }
     79    return ret;
     80}
     81
     82
    2283DevicePCI::DevicePCI(Device* parent)
    2384    :
    2485    Device(parent),
     
    3899}
    39100
    40101
    41 BString ToHex(uint16 num)
    42 {
    43     std::stringstream ss;
    44     ss.flags(std::ios::hex | std::ios::showbase);
    45     ss << num;
    46     return BString(ss.str().c_str());
    47 }
    48 
    49 
    50102void
    51103DevicePCI::InitFromAttributes()
    52104{
     
    71123   
    72124    // Fetch ManufacturerName
    73125    BString ManufacturerName;
    74     const char *venShort;
    75     const char *venFull;
    76     get_vendor_info(fVendorId, &venShort, &venFull);
    77     if (!venShort && !venFull) {
    78         ManufacturerName << B_TRANSLATE("Unknown");
    79     } else if (venShort && venFull) {
    80         ManufacturerName << venFull << "(" << venShort << ")";
    81     } else {
    82         ManufacturerName << (venShort ? venShort : venFull);
    83     }
     126    ManufacturerName << GetVendorInfo(fVendorId);
    84127   
    85128    // Fetch DeviceName
    86129    BString DeviceName;
    87     const char *devShort;
    88     const char *devFull;
    89     get_device_info(fVendorId, fDeviceId, fSubsystemVendorId, fSubSystemId,
    90         &devShort, &devFull);
    91     if (!devShort && !devFull) {
    92         DeviceName << B_TRANSLATE("Unknown");
    93     } else if (devShort && devFull) {
    94         DeviceName << devFull << "(" << devShort << ")";
    95     } else {
    96         DeviceName << (devShort ? devShort : devFull);
    97     }
     130    DeviceName << GetDeviceinfo(fVendorId, fDeviceId, fSubsystemVendorId,
     131                        fSubSystemId);
    98132   
    99     SetAttribute(B_TRANSLATE("Device name"), DeviceName);
    100     SetAttribute(B_TRANSLATE("Manufacturer"), ManufacturerName);
    101     SetAttribute(B_TRANSLATE("Driver used"), B_TRANSLATE("Not implemented"));
    102     SetAttribute(B_TRANSLATE("Device paths"), B_TRANSLATE("Not implemented"));
    103     SetAttribute(B_TRANSLATE("Class info"), classInfo);
     133    SetAttribute("Device name", DeviceName);
     134    SetAttribute("Manufacturer", ManufacturerName);
     135    SetAttribute("Driver used", "Not implemented");
     136    SetAttribute("Device paths", "Not implemented");
     137    SetAttribute("Class info", classInfo);
    104138    fCategory = (Category)fClassBaseId;
    105139    BString outlineName;
    106140    outlineName << ManufacturerName << " " << DeviceName;
     
    124158BString
    125159DevicePCI::GetBusStrings()
    126160{
    127     BString str("Class Info:\t\t\t\t: %classInfo%");
     161    BString str(B_TRANSLATE("Class Info:\t\t\t\t: %classInfo%"));
    128162    str.ReplaceFirst("%classInfo%", fAttributeMap["Class Info"]);
    129163    return str;
    130164}
  • src/apps/devices/DeviceACPI.cpp

     
    1212
    1313#include "DeviceACPI.h"
    1414
     15#include <Catalog.h>
    1516
     17#undef B_TRANSLATE_CONTEXT
     18#define B_TRANSLATE_CONTEXT "DeviceACPI"
     19
     20
    1621DeviceACPI::DeviceACPI(Device* parent)
    1722    :
    1823    Device(parent)
     
    5560        outlineName << string.String();
    5661    } else if (rootACPIPath == "\\_SI_") {
    5762        outlineName = B_TRANSLATE("ACPI System Indicator");
     63    } else if ((rootACPIPath == "\\_BAT1_") || (rootACPIPath == "\\_BAT2_")){
     64        outlineName = B_TRANSLATE("ACPI Battery");
    5865    } else {
    5966        // This allows to localize apostrophes, too
    6067        BString string(B_TRANSLATE("ACPI node '%1'"));
     
    6269        outlineName << string.String();
    6370    }
    6471
    65     SetAttribute(B_TRANSLATE("Device name"), outlineName.String());
    66     SetAttribute(B_TRANSLATE("Manufacturer"), B_TRANSLATE("Not implemented"));
     72    SetAttribute("Device name", outlineName.String());
     73    SetAttribute("Manufacturer", "Not implemented");
    6774
    6875    SetText(outlineName.String());
    6976}
     
    8491BString
    8592DeviceACPI::GetBusStrings()
    8693{
    87     BString str("Class Info:\t\t\t\t: %classInfo%");
     94    BString str(B_TRANSLATE("Class Info:\t\t\t\t: %classInfo%"));
    8895    str.ReplaceFirst("%classInfo%", fAttributeMap["Class Info"]);
    8996   
    9097    return str;