]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Move logging of printer attributes to common failure cleanup code.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 20 Nov 2025 16:13:42 +0000 (11:13 -0500)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 20 Nov 2025 16:15:13 +0000 (11:15 -0500)
Update new filetype code to look for application/octet-stream and
application/pdf.

scheduler/ipp.c
scheduler/printers.c

index 4ac89cdf41bbe4146ded3676c52e382cdc567d20..d8d1934d033ed2552c3a232c54693319e88e6d7b 100644 (file)
@@ -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);
index 31205ec2ad8fd601abfbe121a4b4519318a84144..12a73008beebe9c33f0002d5d1e1fcd8f53a6640 100644 (file)
@@ -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);