diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-02-20 10:44:08 -0500 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-02-20 10:44:08 -0500 |
commit | 7d26bf7d6cb1474e981655819adff91f883346ac (patch) | |
tree | 025e12f369a96b3adc3d7521a349d596407d8a6e /scheduler/ipp.c | |
parent | d6ddd199f43ef2de187a646de572e6aa1c477756 (diff) | |
download | cups-7d26bf7d6cb1474e981655819adff91f883346ac.tar.gz |
Support IPP/1.1 printers with CUPS-Create-Local-Printer operation (Issue #5241)
Diffstat (limited to 'scheduler/ipp.c')
-rw-r--r-- | scheduler/ipp.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/scheduler/ipp.c b/scheduler/ipp.c index b8a9f35d8..649995bb5 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -5259,6 +5259,7 @@ create_local_bg_thread( ipp_t *request, /* Request to printer */ *response; /* Response from printer */ ipp_attribute_t *attr; /* Attribute in response */ + ipp_status_t status; /* Status code */ /* @@ -5291,12 +5292,35 @@ create_local_bg_thread( cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Connected to %s:%d, sending Get-Printer-Attributes request...", printer->name, host, port); request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); + ippSetVersion(request, 2, 0); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer->device_uri); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "all"); response = cupsDoRequest(http, request, resource); + status = cupsLastError(); - cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Get-Printer-Attributes returned %s", printer->name, ippErrorString(cupsLastError())); + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsLastError()), cupsLastErrorString()); + + if (status == IPP_STATUS_ERROR_BAD_REQUEST || status == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) + { + /* + * Try request using IPP/1.1, in case we are talking to an old CUPS server or + * printer... + */ + + ippDelete(response); + + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Re-sending Get-Printer-Attributes request using IPP/1.1...", printer->name); + + request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); + ippSetVersion(request, 1, 1); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer->device_uri); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "all"); + + response = cupsDoRequest(http, request, resource); + + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: IPP/1.1 Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsLastError()), cupsLastErrorString()); + } // TODO: Grab printer icon file... httpClose(http); |