* More style fixes ;)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36160 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -18,8 +18,7 @@ IppTransport *transport = NULL;
|
|||||||
uint32 transport_features = B_TRANSPORT_IS_HOTPLUG | B_TRANSPORT_IS_NETWORK;
|
uint32 transport_features = B_TRANSPORT_IS_HOTPLUG | B_TRANSPORT_IS_NETWORK;
|
||||||
|
|
||||||
|
|
||||||
class IPPPrinter
|
class IPPPrinter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
IPPPrinter(const BString& uri, uint32 type)
|
IPPPrinter(const BString& uri, uint32 type)
|
||||||
{ fURI=uri; fType=type; }
|
{ fURI=uri; fType=type; }
|
||||||
@@ -29,8 +28,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class IPPPrinterRoster
|
class IPPPrinterRoster {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
IPPPrinterRoster();
|
IPPPrinterRoster();
|
||||||
~IPPPrinterRoster();
|
~IPPPrinterRoster();
|
||||||
@@ -38,9 +36,9 @@ public:
|
|||||||
status_t ListPorts(BMessage *msg);
|
status_t ListPorts(BMessage *msg);
|
||||||
status_t Listen();
|
status_t Listen();
|
||||||
private:
|
private:
|
||||||
char *_parseString(BString& outStr, char*& pos);
|
char *_ParseString(BString& outStr, char*& pos);
|
||||||
|
|
||||||
static status_t _ippListeningThread(void *cookie);
|
static status_t _IPPListeningThread(void *cookie);
|
||||||
|
|
||||||
typedef HashMap<HashString,IPPPrinter*> IPPPrinterMap;
|
typedef HashMap<HashString,IPPPrinter*> IPPPrinterMap;
|
||||||
IPPPrinterMap fPrinters;
|
IPPPrinterMap fPrinters;
|
||||||
@@ -66,7 +64,7 @@ IPPPrinterRoster::IPPPrinterRoster()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Now create thread for listening
|
// Now create thread for listening
|
||||||
fListenThreadID = spawn_thread(_ippListeningThread, "IPPListener", B_LOW_PRIORITY, this);
|
fListenThreadID = spawn_thread(_IPPListeningThread, "IPPListener", B_LOW_PRIORITY, this);
|
||||||
if (fListenThreadID <= 0)
|
if (fListenThreadID <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -107,11 +105,11 @@ IPPPrinterRoster::Listen()
|
|||||||
// Check for option parameters
|
// Check for option parameters
|
||||||
if ((pos=strchr(packet, '"')) != NULL) {
|
if ((pos=strchr(packet, '"')) != NULL) {
|
||||||
BString str;
|
BString str;
|
||||||
if (_parseString(str, pos))
|
if (_ParseString(str, pos))
|
||||||
printer->fLocation = str;
|
printer->fLocation = str;
|
||||||
if (pos && _parseString(str, pos))
|
if (pos && _ParseString(str, pos))
|
||||||
printer->fInfo = str;
|
printer->fInfo = str;
|
||||||
if (pos && _parseString(str, pos))
|
if (pos && _ParseString(str, pos))
|
||||||
printer->fMakeModel = str;
|
printer->fMakeModel = str;
|
||||||
|
|
||||||
if (pos)
|
if (pos)
|
||||||
@@ -128,7 +126,8 @@ IPPPrinterRoster::Listen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t IPPPrinterRoster::ListPorts(BMessage* msg)
|
status_t
|
||||||
|
IPPPrinterRoster::ListPorts(BMessage* msg)
|
||||||
{
|
{
|
||||||
IPPPrinterMap::Iterator iterator = fPrinters.GetIterator();
|
IPPPrinterMap::Iterator iterator = fPrinters.GetIterator();
|
||||||
while (iterator.HasNext()) {
|
while (iterator.HasNext()) {
|
||||||
@@ -150,7 +149,7 @@ status_t IPPPrinterRoster::ListPorts(BMessage* msg)
|
|||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
IPPPrinterRoster::_parseString(BString& outStr, char*& pos)
|
IPPPrinterRoster::_ParseString(BString& outStr, char*& pos)
|
||||||
{
|
{
|
||||||
outStr = "";
|
outStr = "";
|
||||||
|
|
||||||
@@ -174,7 +173,7 @@ IPPPrinterRoster::_parseString(BString& outStr, char*& pos)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
IPPPrinterRoster::_ippListeningThread(void *cookie)
|
IPPPrinterRoster::_IPPListeningThread(void *cookie)
|
||||||
{
|
{
|
||||||
return ((IPPPrinterRoster*)cookie)->Listen();
|
return ((IPPPrinterRoster*)cookie)->Listen();
|
||||||
}
|
}
|
||||||
@@ -182,7 +181,8 @@ IPPPrinterRoster::_ippListeningThread(void *cookie)
|
|||||||
|
|
||||||
// --- general transport hooks
|
// --- general transport hooks
|
||||||
|
|
||||||
extern "C" _EXPORT void exit_transport()
|
extern "C" _EXPORT void
|
||||||
|
exit_transport()
|
||||||
{
|
{
|
||||||
DBGMSG(("> exit_transport\n"));
|
DBGMSG(("> exit_transport\n"));
|
||||||
if (transport) {
|
if (transport) {
|
||||||
@@ -192,13 +192,17 @@ extern "C" _EXPORT void exit_transport()
|
|||||||
DBGMSG(("< exit_transport\n"));
|
DBGMSG(("< exit_transport\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// List detected printers
|
// List detected printers
|
||||||
extern "C" _EXPORT status_t list_transport_ports(BMessage* msg)
|
extern "C" _EXPORT status_t
|
||||||
|
list_transport_ports(BMessage* msg)
|
||||||
{
|
{
|
||||||
return gRoster.ListPorts(msg);
|
return gRoster.ListPorts(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" _EXPORT BDataIO *init_transport(BMessage *msg)
|
|
||||||
|
extern "C" _EXPORT BDataIO *
|
||||||
|
init_transport(BMessage *msg)
|
||||||
{
|
{
|
||||||
DBGMSG(("> init_transport\n"));
|
DBGMSG(("> init_transport\n"));
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,10 @@
|
|||||||
#define PIT_VENDOR_SPECIFIC 0xff
|
#define PIT_VENDOR_SPECIFIC 0xff
|
||||||
|
|
||||||
|
|
||||||
class USBPrinter
|
class USBPrinter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
USBPrinter(const BString& id, const BString& name,
|
USBPrinter(const BString& id, const BString& name,
|
||||||
const BUSBInterface *interface, const BUSBEndpoint* in, const BUSBEndpoint* out);
|
const BUSBInterface *interface, const BUSBEndpoint *in, const BUSBEndpoint *out);
|
||||||
|
|
||||||
ssize_t Write(const void *buf, size_t size);
|
ssize_t Write(const void *buf, size_t size);
|
||||||
ssize_t Read(void *buf, size_t size);
|
ssize_t Read(void *buf, size_t size);
|
||||||
@@ -53,8 +52,8 @@ class USBPrinterRoster : public BUSBRoster {
|
|||||||
public:
|
public:
|
||||||
USBPrinterRoster();
|
USBPrinterRoster();
|
||||||
|
|
||||||
status_t DeviceAdded(BUSBDevice* dev);
|
status_t DeviceAdded(BUSBDevice *dev);
|
||||||
void DeviceRemoved(BUSBDevice* dev);
|
void DeviceRemoved(BUSBDevice *dev);
|
||||||
|
|
||||||
USBPrinter *Printer(const BString& key);
|
USBPrinter *Printer(const BString& key);
|
||||||
|
|
||||||
@@ -65,8 +64,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class USBTransport : public BDataIO
|
class USBTransport : public BDataIO {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
USBTransport(BDirectory *printer, BMessage *msg);
|
USBTransport(BDirectory *printer, BMessage *msg);
|
||||||
~USBTransport();
|
~USBTransport();
|
||||||
@@ -93,7 +91,8 @@ USBPrinterRoster::USBPrinterRoster()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
USBPrinter *USBPrinterRoster::Printer(const BString& key)
|
USBPrinter *
|
||||||
|
USBPrinterRoster::Printer(const BString& key)
|
||||||
{
|
{
|
||||||
if (fPrinters.ContainsKey(key.String()))
|
if (fPrinters.ContainsKey(key.String()))
|
||||||
return fPrinters.Get(key.String());
|
return fPrinters.Get(key.String());
|
||||||
@@ -102,7 +101,8 @@ USBPrinter *USBPrinterRoster::Printer(const BString& key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t USBPrinterRoster::DeviceAdded(BUSBDevice* dev)
|
status_t
|
||||||
|
USBPrinterRoster::DeviceAdded(BUSBDevice *dev)
|
||||||
{
|
{
|
||||||
const BUSBConfiguration *config = dev->ActiveConfiguration();
|
const BUSBConfiguration *config = dev->ActiveConfiguration();
|
||||||
const BUSBEndpoint *in = NULL, *out = NULL;
|
const BUSBEndpoint *in = NULL, *out = NULL;
|
||||||
@@ -112,11 +112,11 @@ status_t USBPrinterRoster::DeviceAdded(BUSBDevice* dev)
|
|||||||
if (config) {
|
if (config) {
|
||||||
for (uint32 idx = 0; printer == NULL && idx < config->CountInterfaces(); idx++) {
|
for (uint32 idx = 0; printer == NULL && idx < config->CountInterfaces(); idx++) {
|
||||||
const BUSBInterface *interface = config->InterfaceAt(idx);
|
const BUSBInterface *interface = config->InterfaceAt(idx);
|
||||||
if (interface->Class() == PRINTER_INTERFACE_CLASS &&
|
if (interface->Class() == PRINTER_INTERFACE_CLASS
|
||||||
interface->Subclass() == PRINTER_INTERFACE_SUBCLASS &&
|
&& interface->Subclass() == PRINTER_INTERFACE_SUBCLASS
|
||||||
(interface->Protocol() == PIT_UNIDIRECTIONAL ||
|
&& (interface->Protocol() == PIT_UNIDIRECTIONAL
|
||||||
interface->Protocol() == PIT_BIDIRECTIONAL ||
|
|| interface->Protocol() == PIT_BIDIRECTIONAL
|
||||||
interface->Protocol() == PIT_1284_4_COMPATIBLE)) {
|
|| interface->Protocol() == PIT_1284_4_COMPATIBLE)) {
|
||||||
// Found a usable Printer interface!
|
// Found a usable Printer interface!
|
||||||
for (uint32 endpointIdx = 0; endpointIdx < interface->CountEndpoints(); endpointIdx++) {
|
for (uint32 endpointIdx = 0; endpointIdx < interface->CountEndpoints(); endpointIdx++) {
|
||||||
const BUSBEndpoint *endpoint = interface->EndpointAt(endpointIdx);
|
const BUSBEndpoint *endpoint = interface->EndpointAt(endpointIdx);
|
||||||
@@ -166,7 +166,8 @@ status_t USBPrinterRoster::DeviceAdded(BUSBDevice* dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void USBPrinterRoster::DeviceRemoved(BUSBDevice* dev)
|
void
|
||||||
|
USBPrinterRoster::DeviceRemoved(BUSBDevice* dev)
|
||||||
{
|
{
|
||||||
PrinterMap::Iterator iterator = fPrinters.GetIterator();
|
PrinterMap::Iterator iterator = fPrinters.GetIterator();
|
||||||
while (iterator.HasNext()) {
|
while (iterator.HasNext()) {
|
||||||
@@ -181,7 +182,8 @@ void USBPrinterRoster::DeviceRemoved(BUSBDevice* dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t USBPrinterRoster::ListPrinters(BMessage* msg)
|
status_t
|
||||||
|
USBPrinterRoster::ListPrinters(BMessage* msg)
|
||||||
{
|
{
|
||||||
PrinterMap::Iterator iterator = fPrinters.GetIterator();
|
PrinterMap::Iterator iterator = fPrinters.GetIterator();
|
||||||
while (iterator.HasNext()) {
|
while (iterator.HasNext()) {
|
||||||
@@ -195,14 +197,15 @@ status_t USBPrinterRoster::ListPrinters(BMessage* msg)
|
|||||||
|
|
||||||
|
|
||||||
USBPrinter::USBPrinter(const BString& id, const BString& name,
|
USBPrinter::USBPrinter(const BString& id, const BString& name,
|
||||||
const BUSBInterface *intf, const BUSBEndpoint* in, const BUSBEndpoint* out)
|
const BUSBInterface *intf, const BUSBEndpoint *in, const BUSBEndpoint *out)
|
||||||
: fInterface(intf), fOut(out), fIn(in), fName(name), fID(id)
|
: fInterface(intf), fOut(out), fIn(in), fName(name), fID(id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: see usb_printer.cpp for error handling during read/write!
|
//TODO: see usb_printer.cpp for error handling during read/write!
|
||||||
ssize_t USBPrinter::Write(const void *buf, size_t size)
|
ssize_t
|
||||||
|
USBPrinter::Write(const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (!buf || size <= 0)
|
if (!buf || size <= 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -212,7 +215,8 @@ ssize_t USBPrinter::Write(const void *buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t USBPrinter::Read(void *buf, size_t size)
|
ssize_t
|
||||||
|
USBPrinter::Read(void *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (!buf || size <= 0)
|
if (!buf || size <= 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -236,7 +240,8 @@ instantiate_transport(BDirectory *printer, BMessage *msg)
|
|||||||
|
|
||||||
|
|
||||||
// List detected printers
|
// List detected printers
|
||||||
status_t list_transport_ports(BMessage* msg)
|
status_t
|
||||||
|
list_transport_ports(BMessage* msg)
|
||||||
{
|
{
|
||||||
return gUSBPrinterRoster.ListPrinters(msg);
|
return gUSBPrinterRoster.ListPrinters(msg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user