xref: /haiku/src/apps/devices/DeviceSCSI.cpp (revision c237c4ce593ee823d9867fd997e51e4c447f5623)
1 /*
2  * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Alexander von Gluck, kallisti5@unixzen.com
7  */
8 
9 
10 #include "DeviceSCSI.h"
11 
12 #include <scsi.h>
13 #include <sstream>
14 #include <stdlib.h>
15 
16 #include <Catalog.h>
17 
18 #undef B_TRANSLATION_CONTEXT
19 #define B_TRANSLATION_CONTEXT "DeviceSCSI"
20 
21 
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
42 };
43 
44 
45 DeviceSCSI::DeviceSCSI(Device* parent)
46 	:
47 	Device(parent)
48 {
49 }
50 
51 
52 DeviceSCSI::~DeviceSCSI()
53 {
54 }
55 
56 
57 void
58 DeviceSCSI::InitFromAttributes()
59 {
60 	BString nodeVendor(GetAttribute("scsi/vendor").fValue);
61 	BString nodeProduct(GetAttribute("scsi/product").fValue);
62 
63 	fCategory = (Category)CAT_MASS;
64 
65 	uint32 nodeTypeID = atoi(GetAttribute("scsi/type").fValue);
66 
67 	SetAttribute(B_TRANSLATE("Device name"), nodeProduct.String());
68 	SetAttribute(B_TRANSLATE("Manufacturer"), nodeVendor.String());
69 	SetAttribute(B_TRANSLATE("Device class"), SCSITypeMap[nodeTypeID]);
70 
71 	BString listName;
72 	listName
73 		<< "SCSI " << SCSITypeMap[nodeTypeID] << " (" << nodeProduct << ")";
74 
75 	SetText(listName.String());
76 }
77