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 16 const 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 "ACPI controller" // 0x13 (added later) 37 }; 38 39 40 Device::Device(Device* physicalParent, BusType busType, Category category, 41 const BString& name, const BString& manufacturer, 42 const BString& driverUsed, const BString& devPathsPublished) 43 : 44 BStringItem(name.String()), 45 fBusType(busType), 46 fCategory(category), 47 fPhysicalParent(physicalParent) 48 { 49 SetAttribute("Device name", name); 50 SetAttribute("Manufacturer", manufacturer); 51 SetAttribute("Driver used", driverUsed); 52 SetAttribute("Device paths", devPathsPublished); 53 } 54 55 56 Device::~Device() 57 { 58 } 59 60 61 void 62 Device::SetAttribute(const BString& name, const BString& value) 63 { 64 if (name == "Device name") { 65 SetText(value.String()); 66 } 67 fAttributeMap[name] = value; 68 } 69 70 71 Attributes 72 Device::GetBasicAttributes() 73 { 74 Attributes attributes; 75 attributes.push_back(Attribute("Device name:", GetName())); 76 attributes.push_back(Attribute("Manufacturer:", GetManufacturer())); 77 return attributes; 78 } 79 80 81 Attributes 82 Device::GetBusAttributes() 83 { 84 Attributes attributes; 85 attributes.push_back(Attribute("None", "")); 86 return attributes; 87 } 88 89 90 Attributes 91 Device::GetAllAttributes() 92 { 93 Attributes attributes; 94 AttributeMapIterator iter; 95 for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) { 96 attributes.push_back(Attribute(iter->first, iter->second)); 97 } 98 return attributes; 99 } 100 101 102 BString 103 Device::GetBasicStrings() 104 { 105 BString str; 106 str << "Device Name\t\t\t\t: " << GetName() << "\n"; 107 str << "Manufacturer\t\t\t: " << GetManufacturer() << "\n"; 108 str << "Driver used\t\t\t\t: " << GetDriverUsed() << "\n"; 109 str << "Device paths\t: " << GetDevPathsPublished(); 110 return str; 111 } 112 113 BString 114 Device::GetBusStrings() 115 { 116 return "None"; 117 } 118 119 120 BString 121 Device::GetAllStrings() 122 { 123 BString str; 124 AttributeMapIterator iter; 125 for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) { 126 str << iter->first << " : " << iter->second << "\n"; 127 } 128 return str; 129 } 130