From: Michael R Sweet Date: Thu, 20 Nov 2025 16:13:42 +0000 (-0500) Subject: Move logging of printer attributes to common failure cleanup code. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a7209d47bb7123786454332b2afecf03c7bdc59;p=thirdparty%2Fcups.git Move logging of printer attributes to common failure cleanup code. Update new filetype code to look for application/octet-stream and application/pdf. --- diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 4ac89cdf41..d8d1934d03 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -5376,8 +5376,6 @@ create_local_bg_thread( } else { - ipp_tag_t group; /* Current group tag */ - cupsdLogPrinter(printer, CUPSD_LOG_ERROR, "PPD creation failed: %s", cupsGetErrorString()); /* Force printer to timeout and be deleted */ @@ -5387,6 +5385,27 @@ create_local_bg_thread( cupsRWUnlock(&printer->lock); send_ipp_status(con, IPP_STATUS_ERROR_DEVICE, _("Unable to create PPD: %s"), cupsGetErrorString()); + goto finish_response; + } + + /* + * Respond to the client... + */ + + send_ipp_status(con, IPP_STATUS_OK, _("Local printer created.")); + + ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting); + ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", (int)printer->state); + add_printer_state_reasons(con, printer); + + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), httpIsEncrypted(con->http) ? "ipps" : "ipp", NULL, con->clientname, con->clientport, "/printers/%s", printer->name); + ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, uri); + + finish_response: + + if (ippGetStatusCode(con->response) >= IPP_STATUS_ERROR_BAD_REQUEST && response) + { + ipp_tag_t group; /* Current group tag */ cupsdLogClient(con, CUPSD_LOG_DEBUG, "Printer attributes:"); @@ -5411,25 +5430,8 @@ create_local_bg_thread( } cupsdLogClient(con, CUPSD_LOG_DEBUG, "end-of-attributes-tag"); - - goto finish_response; } - /* - * Respond to the client... - */ - - send_ipp_status(con, IPP_STATUS_OK, _("Local printer created.")); - - ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting); - ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", (int)printer->state); - add_printer_state_reasons(con, printer); - - httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), httpIsEncrypted(con->http) ? "ipps" : "ipp", NULL, con->clientname, con->clientport, "/printers/%s", printer->name); - ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, uri); - - finish_response: - ippDelete(response); send_response(con); diff --git a/scheduler/printers.c b/scheduler/printers.c index 31205ec2ad..12a73008be 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -3548,30 +3548,38 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */ p->filetypes = mimeGetFilterTypes(MimeDatabase, p->filetype, NULL); - if ((type = mimeType(MimeDatabase, "application", "pdf")) != NULL && cupsArrayFind(p->filetypes, type)) - preferred = "application/pdf"; - /* * Add the file formats that can be filtered... */ - cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: %d supported types", cupsArrayCount(p->filetypes) + 1); + if ((type = mimeType(MimeDatabase, "application", "octet-stream")) != NULL && !cupsArrayFind(p->filetypes, type)) + i = 1; + else + i = 0; + + cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: %d supported types", cupsArrayCount(p->filetypes) + i); - if ((attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", cupsArrayCount(p->filetypes) + 1, NULL, NULL)) == NULL) + if ((attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", cupsArrayCount(p->filetypes) + i, NULL, NULL)) == NULL) { cupsdLogPrinter(p, CUPSD_LOG_ERROR, "Unable to create document-format-supported attribute."); return; } - attr->values[0].string.text = _cupsStrAlloc("application/octet-stream"); - cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[0]='application/octet-stream'"); + if (i) + { + attr->values[0].string.text = _cupsStrAlloc("application/octet-stream"); + cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[0]='application/octet-stream'"); + } - for (i = 1, type = (mime_type_t *)cupsArrayFirst(p->filetypes); type; i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes)) + for (type = (mime_type_t *)cupsArrayFirst(p->filetypes); type; i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes)) { snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type); attr->values[i].string.text = _cupsStrAlloc(mimetype); cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[%d]='%s'", i, mimetype); + + if (!strcmp(mimetype, "application/pdf")) + preferred = "application/pdf"; } ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_MIMETYPE), "document-format-preferred", NULL, preferred);