Closed tillkamppeter closed 3 years ago
Note that ./ps-printer-app autoadd
and also creating a queue with auto-selecting the driver via the web interface work as expected.
This is especially important to get fixed as we need this for simple tools to guide users to set up their printer with a Printer Application. The tool could list printers available (on USB, non-IPP-2.x on network) and if the user selects one to set up he can get a menu of installed Printer Applications, the user chooses one and then the tool has to do PRINTER_APPLICATION -d NAME -v URI -m auto
and in case that the printer is supported by the Printer Application this should result in a print queue with the driver auto-selected within the Printer Application.
see also the discussion about automatic printer setup on the OpenPrinting mailing list, thread "Automatic printer setup with Printer Applications".
@tillkamppeter You're going to have to be patient, I'm in the middle of integrating my IPP-USB gadget code and that trumps any bug fixing at the moment...
@tillkamppeter Can you verify whether your ps_autoadd callback is getting called? Everything appears to be plumbed correctly to allow this to work, so papplPrinterCreate should be calling your callback to get the actual driver name. If it gets NULL
or it doesn't think there is an auto-add callback then things won't work.
I have found what the problem is:
If the driver name "auto" is used, the autoadd_cb is called. The autoadd_cb() of the PostScript Printer Application (and in the future also of many other Printer Applications) requires the device ID to know which make and model the printer is. It immediately exits with NULL if the device ID is NULL.
The server calls the function ipp_create_printer()
as response to the client's IPP request for adding a printer. This function is supposed to get the device ID via the "printer-device-id" IPP attribute:
if ((attr = ippFindAttribute(client->request, "printer-device-id", IPP_TAG_ZERO)) != NULL && (ippGetGroupTag(attr) != IPP_TAG_PRINTER || ippGetValueTag(attr) != IPP_TAG_TEXT || ippGetCount(attr) != 1))
{
papplClientRespondIPPUnsupported(client, attr);
return;
}
else
device_id = ippGetString(attr, 0, NULL);
The client, using the function _papplMainloopAddPrinter()
does not supply this attribute, but the server does not error on this attribute missing. In case attr
being NULL in the code abobe, the else
part is executed setting device_id
to NULL.
The actual bug is that the device ID is nowhere polled from the printer. Polling the device ID is required for auto-determination of the driver. In addition, ipp_create_printer()
should give a decent error message if the driver is "auto" and no device ID is supplied.
An additional hint for the best possible fix:
Let the device ID be polled by the server, as in case of the Printer Application being a Snap, the server runs as root and the client runs as normal user (Issue #148) and with this the chances to obtain the device ID are much higher for the server.
@tillkamppeter I will see about adding a 1284 query, but for 1.0 (at least) that will only work for USB printers because the code to try to query the 1284 ID for a network printer isn't hooked up - SNMP is unreliable at best and not all printers advertise the 1284 keys in the DNS-SD TXT record.
In DNS-SD, if there is no device ID in the TXT record (can there be the complete one at all?) then next step is usb_mfg, usb_mdl, and usb_cmd for an artificial, but good enough device ID (which gives full functionality in the autoadd_cb() of the PostScript Printer Application and will work as well with any future Printer Application). If usb_mfg and or usb_mdl are myssing, needed info can get taken from ty and product, id usb_cmd is missing an artificial CMD: field can be constructed from pdls. So in DNS-SD one should always get enough info to supply a useful device ID.
So both USB and DNS-SD should not be a problem, SNMP will sometimes work sometimes not.
[master b1e9e6e] Fix auto driver without 1284 device ID (Issue #154)
[v1.0.x 5d6ccb2] Fix auto driver without 1284 device ID (Issue #154)
@tillkamppeter Please let me know about this issue and #153 so I can put out the 1.0.3 release. Thanks!
OK, with my printer connected via USB it works now.
It does not work with SNMP or DNS-SD URIs, will probably still need the appropriate device-specific backing for the papplDeviceGetID()
function, in case of DNS-SD as I suggested here.
Issue #153 is a problem of my printer as I have found out. I have no other printer for testing.
So I am fine with 1.0.3 release.
@tillkamppeter WRT DNS-SD, all you have are usb_CMD
, usb_MFG
, and usb_MDL
in the TXT record to build the 1284 device ID. You can also try parsing out the product
(PostScript product string), ty
(make and model), and pdl
(MIME media types) keys - PAPPL does all of these things to generate a 1284 ID when listing devices. The issue is that currently the network schemes do not currently support a later lookup of these values like the USB scheme does. Tracking that with issue #95...
I want to create a queue via command line manually (not "autoadd", so that I can choose the queue name and also create a queue for a network printer) but I want to auto-select the driver, therefore I use
-m auto
:The queue does not get created as "auto" is not accepted as driver name. I get this result also if I use the network connection of the printer, by supplying the SNMP- or DNS-SD-based URI instead of the USB device URI.
The debug logging of the server is