BPicture: Fix archive constructor.
[haiku.git] / src / apps / devices / DeviceSCSI.cpp
blob84145f4cced46c42f4fa28cb7bf987a5196f08d8
1 /*
2 * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Alexander von Gluck, kallisti5@unixzen.com
7 */
10 #include "DeviceSCSI.h"
12 #include <scsi.h>
13 #include <sstream>
14 #include <stdlib.h>
16 #include <Catalog.h>
18 #undef B_TRANSLATION_CONTEXT
19 #define B_TRANSLATION_CONTEXT "DeviceSCSI"
22 // standard SCSI device types
23 const char* SCSITypeMap[] = {
24 B_TRANSLATE("Disk Drive"), // 0x00
25 B_TRANSLATE("Tape Drive"), // 0x01
26 B_TRANSLATE("Printer"), // 0x02
27 B_TRANSLATE("Processor"), // 0x03
28 B_TRANSLATE("Worm"), // 0x04
29 B_TRANSLATE("CD-ROM"), // 0x05
30 B_TRANSLATE("Scanner"), // 0x06
31 B_TRANSLATE("Optical Drive"), // 0x07
32 B_TRANSLATE("Changer"), // 0x08
33 B_TRANSLATE("Communications"), // 0x09
34 B_TRANSLATE("Graphics Peripheral"), // 0x0A
35 B_TRANSLATE("Graphics Peripheral"), // 0x0B
36 B_TRANSLATE("Array"), // 0x0C
37 B_TRANSLATE("Enclosure"), // 0x0D
38 B_TRANSLATE("RBC"), // 0x0E
39 B_TRANSLATE("Card Reader"), // 0x0F
40 B_TRANSLATE("Bridge"), // 0x10
41 B_TRANSLATE("Other") // 0x11
45 DeviceSCSI::DeviceSCSI(Device* parent)
47 Device(parent)
52 DeviceSCSI::~DeviceSCSI()
57 void
58 DeviceSCSI::InitFromAttributes()
60 BString nodeVendor(GetAttribute("scsi/vendor").fValue);
61 BString nodeProduct(GetAttribute("scsi/product").fValue);
63 fCategory = (Category)CAT_MASS;
65 uint32 nodeTypeID = atoi(GetAttribute("scsi/type").fValue);
67 SetAttribute(B_TRANSLATE("Device name"), nodeProduct.String());
68 SetAttribute(B_TRANSLATE("Manufacturer"), nodeVendor.String());
69 SetAttribute(B_TRANSLATE("Device class"), SCSITypeMap[nodeTypeID]);
71 BString listName;
72 listName
73 << "SCSI " << SCSITypeMap[nodeTypeID] << " (" << nodeProduct << ")";
75 SetText(listName.String());
79 Attributes
80 DeviceSCSI::GetBusAttributes()
82 // Push back things that matter for SCSI devices
83 Attributes attributes;
84 attributes.push_back(GetAttribute(B_TRANSLATE("Device class")));
85 attributes.push_back(GetAttribute(B_TRANSLATE("Device name")));
86 attributes.push_back(GetAttribute(B_TRANSLATE("Manufacturer")));
87 attributes.push_back(GetAttribute("scsi/revision"));
88 attributes.push_back(GetAttribute("scsi/target_id"));
89 attributes.push_back(GetAttribute("scsi/target_lun"));
90 return attributes;
94 BString
95 DeviceSCSI::GetBusStrings()
97 BString str(B_TRANSLATE("Class Info:\t\t\t\t: %classInfo%"));
98 str.ReplaceFirst("%classInfo%", fAttributeMap["Class Info"]);
100 return str;
104 BString
105 DeviceSCSI::GetBusTabName()
107 return B_TRANSLATE("SCSI Information");