* 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;
|
||||
|
||||
|
||||
class IPPPrinter
|
||||
{
|
||||
class IPPPrinter {
|
||||
public:
|
||||
IPPPrinter(const BString& uri, uint32 type)
|
||||
{ fURI=uri; fType=type; }
|
||||
@@ -29,8 +28,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class IPPPrinterRoster
|
||||
{
|
||||
class IPPPrinterRoster {
|
||||
public:
|
||||
IPPPrinterRoster();
|
||||
~IPPPrinterRoster();
|
||||
@@ -38,9 +36,9 @@ public:
|
||||
status_t ListPorts(BMessage *msg);
|
||||
status_t Listen();
|
||||
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;
|
||||
IPPPrinterMap fPrinters;
|
||||
@@ -66,7 +64,7 @@ IPPPrinterRoster::IPPPrinterRoster()
|
||||
return;
|
||||
|
||||
// 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)
|
||||
return;
|
||||
|
||||
@@ -107,11 +105,11 @@ IPPPrinterRoster::Listen()
|
||||
// Check for option parameters
|
||||
if ((pos=strchr(packet, '"')) != NULL) {
|
||||
BString str;
|
||||
if (_parseString(str, pos))
|
||||
if (_ParseString(str, pos))
|
||||
printer->fLocation = str;
|
||||
if (pos && _parseString(str, pos))
|
||||
if (pos && _ParseString(str, pos))
|
||||
printer->fInfo = str;
|
||||
if (pos && _parseString(str, pos))
|
||||
if (pos && _ParseString(str, pos))
|
||||
printer->fMakeModel = str;
|
||||
|
||||
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();
|
||||
while (iterator.HasNext()) {
|
||||
@@ -150,7 +149,7 @@ status_t IPPPrinterRoster::ListPorts(BMessage* msg)
|
||||
|
||||
|
||||
char*
|
||||
IPPPrinterRoster::_parseString(BString& outStr, char*& pos)
|
||||
IPPPrinterRoster::_ParseString(BString& outStr, char*& pos)
|
||||
{
|
||||
outStr = "";
|
||||
|
||||
@@ -174,7 +173,7 @@ IPPPrinterRoster::_parseString(BString& outStr, char*& pos)
|
||||
|
||||
|
||||
status_t
|
||||
IPPPrinterRoster::_ippListeningThread(void *cookie)
|
||||
IPPPrinterRoster::_IPPListeningThread(void *cookie)
|
||||
{
|
||||
return ((IPPPrinterRoster*)cookie)->Listen();
|
||||
}
|
||||
@@ -182,7 +181,8 @@ IPPPrinterRoster::_ippListeningThread(void *cookie)
|
||||
|
||||
// --- general transport hooks
|
||||
|
||||
extern "C" _EXPORT void exit_transport()
|
||||
extern "C" _EXPORT void
|
||||
exit_transport()
|
||||
{
|
||||
DBGMSG(("> exit_transport\n"));
|
||||
if (transport) {
|
||||
@@ -192,13 +192,17 @@ extern "C" _EXPORT void exit_transport()
|
||||
DBGMSG(("< exit_transport\n"));
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
extern "C" _EXPORT BDataIO *init_transport(BMessage *msg)
|
||||
|
||||
extern "C" _EXPORT BDataIO *
|
||||
init_transport(BMessage *msg)
|
||||
{
|
||||
DBGMSG(("> init_transport\n"));
|
||||
|
||||
|
||||
@@ -32,11 +32,10 @@
|
||||
#define PIT_VENDOR_SPECIFIC 0xff
|
||||
|
||||
|
||||
class USBPrinter
|
||||
{
|
||||
class USBPrinter {
|
||||
public:
|
||||
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 Read(void *buf, size_t size);
|
||||
@@ -53,8 +52,8 @@ class USBPrinterRoster : public BUSBRoster {
|
||||
public:
|
||||
USBPrinterRoster();
|
||||
|
||||
status_t DeviceAdded(BUSBDevice* dev);
|
||||
void DeviceRemoved(BUSBDevice* dev);
|
||||
status_t DeviceAdded(BUSBDevice *dev);
|
||||
void DeviceRemoved(BUSBDevice *dev);
|
||||
|
||||
USBPrinter *Printer(const BString& key);
|
||||
|
||||
@@ -65,8 +64,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class USBTransport : public BDataIO
|
||||
{
|
||||
class USBTransport : public BDataIO {
|
||||
public:
|
||||
USBTransport(BDirectory *printer, BMessage *msg);
|
||||
~USBTransport();
|
||||
@@ -93,7 +91,8 @@ USBPrinterRoster::USBPrinterRoster()
|
||||
}
|
||||
|
||||
|
||||
USBPrinter *USBPrinterRoster::Printer(const BString& key)
|
||||
USBPrinter *
|
||||
USBPrinterRoster::Printer(const BString& key)
|
||||
{
|
||||
if (fPrinters.ContainsKey(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 BUSBEndpoint *in = NULL, *out = NULL;
|
||||
@@ -112,11 +112,11 @@ status_t USBPrinterRoster::DeviceAdded(BUSBDevice* dev)
|
||||
if (config) {
|
||||
for (uint32 idx = 0; printer == NULL && idx < config->CountInterfaces(); idx++) {
|
||||
const BUSBInterface *interface = config->InterfaceAt(idx);
|
||||
if (interface->Class() == PRINTER_INTERFACE_CLASS &&
|
||||
interface->Subclass() == PRINTER_INTERFACE_SUBCLASS &&
|
||||
(interface->Protocol() == PIT_UNIDIRECTIONAL ||
|
||||
interface->Protocol() == PIT_BIDIRECTIONAL ||
|
||||
interface->Protocol() == PIT_1284_4_COMPATIBLE)) {
|
||||
if (interface->Class() == PRINTER_INTERFACE_CLASS
|
||||
&& interface->Subclass() == PRINTER_INTERFACE_SUBCLASS
|
||||
&& (interface->Protocol() == PIT_UNIDIRECTIONAL
|
||||
|| interface->Protocol() == PIT_BIDIRECTIONAL
|
||||
|| interface->Protocol() == PIT_1284_4_COMPATIBLE)) {
|
||||
// Found a usable Printer interface!
|
||||
for (uint32 endpointIdx = 0; endpointIdx < interface->CountEndpoints(); 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();
|
||||
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();
|
||||
while (iterator.HasNext()) {
|
||||
@@ -195,14 +197,15 @@ status_t USBPrinterRoster::ListPrinters(BMessage* msg)
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//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)
|
||||
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)
|
||||
return B_BAD_VALUE;
|
||||
@@ -236,7 +240,8 @@ instantiate_transport(BDirectory *printer, BMessage *msg)
|
||||
|
||||
|
||||
// List detected printers
|
||||
status_t list_transport_ports(BMessage* msg)
|
||||
status_t
|
||||
list_transport_ports(BMessage* msg)
|
||||
{
|
||||
return gUSBPrinterRoster.ListPrinters(msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user