Skip to content

Commit 3a7209d

Browse files
committed
Move logging of printer attributes to common failure cleanup code.
Update new filetype code to look for application/octet-stream and application/pdf.
1 parent 8fa23b4 commit 3a7209d

2 files changed

Lines changed: 37 additions & 27 deletions

File tree

scheduler/ipp.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5376,8 +5376,6 @@ create_local_bg_thread(
53765376
}
53775377
else
53785378
{
5379-
ipp_tag_t group; /* Current group tag */
5380-
53815379
cupsdLogPrinter(printer, CUPSD_LOG_ERROR, "PPD creation failed: %s", cupsGetErrorString());
53825380

53835381
/* Force printer to timeout and be deleted */
@@ -5387,6 +5385,27 @@ create_local_bg_thread(
53875385
cupsRWUnlock(&printer->lock);
53885386

53895387
send_ipp_status(con, IPP_STATUS_ERROR_DEVICE, _("Unable to create PPD: %s"), cupsGetErrorString());
5388+
goto finish_response;
5389+
}
5390+
5391+
/*
5392+
* Respond to the client...
5393+
*/
5394+
5395+
send_ipp_status(con, IPP_STATUS_OK, _("Local printer created."));
5396+
5397+
ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting);
5398+
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", (int)printer->state);
5399+
add_printer_state_reasons(con, printer);
5400+
5401+
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), httpIsEncrypted(con->http) ? "ipps" : "ipp", NULL, con->clientname, con->clientport, "/printers/%s", printer->name);
5402+
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, uri);
5403+
5404+
finish_response:
5405+
5406+
if (ippGetStatusCode(con->response) >= IPP_STATUS_ERROR_BAD_REQUEST && response)
5407+
{
5408+
ipp_tag_t group; /* Current group tag */
53905409

53915410
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Printer attributes:");
53925411

@@ -5411,25 +5430,8 @@ create_local_bg_thread(
54115430
}
54125431

54135432
cupsdLogClient(con, CUPSD_LOG_DEBUG, "end-of-attributes-tag");
5414-
5415-
goto finish_response;
54165433
}
54175434

5418-
/*
5419-
* Respond to the client...
5420-
*/
5421-
5422-
send_ipp_status(con, IPP_STATUS_OK, _("Local printer created."));
5423-
5424-
ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting);
5425-
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", (int)printer->state);
5426-
add_printer_state_reasons(con, printer);
5427-
5428-
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), httpIsEncrypted(con->http) ? "ipps" : "ipp", NULL, con->clientname, con->clientport, "/printers/%s", printer->name);
5429-
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, uri);
5430-
5431-
finish_response:
5432-
54335435
ippDelete(response);
54345436

54355437
send_response(con);

scheduler/printers.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,30 +3548,38 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */
35483548

35493549
p->filetypes = mimeGetFilterTypes(MimeDatabase, p->filetype, NULL);
35503550

3551-
if ((type = mimeType(MimeDatabase, "application", "pdf")) != NULL && cupsArrayFind(p->filetypes, type))
3552-
preferred = "application/pdf";
3553-
35543551
/*
35553552
* Add the file formats that can be filtered...
35563553
*/
35573554

3558-
cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: %d supported types", cupsArrayCount(p->filetypes) + 1);
3555+
if ((type = mimeType(MimeDatabase, "application", "octet-stream")) != NULL && !cupsArrayFind(p->filetypes, type))
3556+
i = 1;
3557+
else
3558+
i = 0;
3559+
3560+
cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: %d supported types", cupsArrayCount(p->filetypes) + i);
35593561

3560-
if ((attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", cupsArrayCount(p->filetypes) + 1, NULL, NULL)) == NULL)
3562+
if ((attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", cupsArrayCount(p->filetypes) + i, NULL, NULL)) == NULL)
35613563
{
35623564
cupsdLogPrinter(p, CUPSD_LOG_ERROR, "Unable to create document-format-supported attribute.");
35633565
return;
35643566
}
35653567

3566-
attr->values[0].string.text = _cupsStrAlloc("application/octet-stream");
3567-
cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[0]='application/octet-stream'");
3568+
if (i)
3569+
{
3570+
attr->values[0].string.text = _cupsStrAlloc("application/octet-stream");
3571+
cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[0]='application/octet-stream'");
3572+
}
35683573

3569-
for (i = 1, type = (mime_type_t *)cupsArrayFirst(p->filetypes); type; i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes))
3574+
for (type = (mime_type_t *)cupsArrayFirst(p->filetypes); type; i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes))
35703575
{
35713576
snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
35723577

35733578
attr->values[i].string.text = _cupsStrAlloc(mimetype);
35743579
cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "add_printer_formats: document-format-supported[%d]='%s'", i, mimetype);
3580+
3581+
if (!strcmp(mimetype, "application/pdf"))
3582+
preferred = "application/pdf";
35753583
}
35763584

35773585
ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_MIMETYPE), "document-format-preferred", NULL, preferred);

0 commit comments

Comments
 (0)