Skip to content

Commit

Permalink
Fix auto driver without 1284 device ID (Issue #154)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Apr 15, 2021
1 parent 447bbd1 commit 5d6ccb2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changes in v1.0.3

- The Set-Printer-Attributes operation did not save changes to
"printer-contact-col".
- Fixed using the "auto" driver without an IEEE-1284 device ID string
(Issue #154)
- Fixed some more threading issues (Issue #155, Issue #162)
- Fixed bogus USB error reporting (Issue #156)
- Fixed testpappl on systems without Avahi running (Issue #159)
Expand Down
18 changes: 17 additions & 1 deletion pappl/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,23 @@ papplPrinterCreate(
// If the driver is "auto", figure out the proper driver name...
if (!strcmp(driver_name, "auto") && system->autoadd_cb)
{
if ((driver_name = (system->autoadd_cb)(printer_name, device_uri, device_id, system->driver_cbdata)) == NULL)
// If device_id is NULL, try to look it up...
if (!printer->device_id && strncmp(device_uri, "file://", 7))
{
pappl_device_t *device; // Connection to printer

if ((device = papplDeviceOpen(device_uri, "auto", papplLogDevice, system)) != NULL)
{
char new_id[1024]; // New 1284 device ID

if (papplDeviceGetID(device, new_id, sizeof(new_id)))
printer->device_id = strdup(new_id);

papplDeviceClose(device);
}
}

if ((driver_name = (system->autoadd_cb)(printer_name, device_uri, printer->device_id, system->driver_cbdata)) == NULL)
{
errno = EIO;
_papplPrinterDelete(printer);
Expand Down

0 comments on commit 5d6ccb2

Please sign in to comment.