3 * Copyright 1999-2000 Y.Takagi All Rights Reserved.
7 #include <FindDirectory.h>
9 #include <StorageDefs.h>
11 #include "PrinterData.h"
13 const char *PD_DRIVER_NAME
= "Driver Name";
14 const char *PD_PRINTER_NAME
= "Printer Name";
15 const char *PD_COMMENTS
= "Comments";
16 const char *PD_TRANSPORT
= "transport";
17 const char *PD_PROTOCOL_CLASS
= "libprint:protocolClass";
20 PrinterData::PrinterData(BNode
*node
)
28 PrinterData::~PrinterData()
36 if (fNode
== NULL
) return;
40 fNode
->ReadAttr(PD_DRIVER_NAME
, B_STRING_TYPE
, 0, buffer
, sizeof(buffer
));
41 // TODO fix possible buffer overrun (not terminated string).
43 fNode
->ReadAttr(PD_PRINTER_NAME
, B_STRING_TYPE
, 0, buffer
, sizeof(buffer
));
44 fPrinterName
= buffer
;
45 fNode
->ReadAttr(PD_COMMENTS
, B_STRING_TYPE
, 0, buffer
, sizeof(buffer
));
47 fNode
->ReadAttr(PD_TRANSPORT
, B_STRING_TYPE
, 0, buffer
, sizeof(buffer
));
51 fNode
->ReadAttr(PD_PROTOCOL_CLASS
, B_INT32_TYPE
, 0, &valueI32
, sizeof(valueI32
));
52 fProtocolClass
= (int)valueI32
;
62 int32 valueI32
= (int32
)fProtocolClass
;
63 fNode
->WriteAttr(PD_PROTOCOL_CLASS
, B_INT32_TYPE
, 0, &valueI32
,
69 PrinterData::GetPath(string
&path
) const
75 if (fNode
->GetNodeRef(&nref
) != B_OK
)
78 BDirectory
dir(&nref
);
79 if (dir
.InitCheck() != B_OK
)
82 BPath
path0(&dir
, ".");
83 if (path0
.InitCheck() != B_OK
)