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 }; 37 38 39 Device::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 55 Device::~Device() 56 { 57 } 58 59 60 void 61 Device::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 70 Attributes 71 Device::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 80 Attributes 81 Device::GetBusAttributes() 82 { 83 Attributes attributes; 84 attributes.push_back(Attribute("None", "")); 85 return attributes; 86 } 87 88 89 Attributes 90 Device::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 101 BString 102 Device::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 112 BString 113 Device::GetBusStrings() 114 { 115 return "None"; 116 } 117 118 119 BString 120 Device::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 } 129