|
34 | 34 | * Local functions... |
35 | 35 | */ |
36 | 36 |
|
| 37 | +static void add_ppd_defaults_to_ipp(cupsd_printer_t *p, ppd_file_t *ppd); |
37 | 38 | static void add_printer_defaults(cupsd_printer_t *p); |
38 | 39 | static void add_printer_filter(cupsd_printer_t *p, mime_type_t *type, |
39 | 40 | const char *filter); |
@@ -1381,10 +1382,10 @@ cupsdLoadAllPrinters(void) |
1381 | 1382 | } |
1382 | 1383 |
|
1383 | 1384 | if (found_raw) |
1384 | | - cupsdLogMessage(CUPSD_LOG_WARN, "Raw queues are deprecated and will stop working in a future version of CUPS. See https://github.com/OpenPrinting/cups/issues/103"); |
| 1385 | + cupsdLogMessage(CUPSD_LOG_WARN, "Raw queues are deprecated and will stop working in a future version of CUPS. Use IPP Everywhere drivers (\"-m everywhere\") or Printer Applications instead. See https://github.com/OpenPrinting/cups/issues/103"); |
1385 | 1386 |
|
1386 | 1387 | if (found_driver) |
1387 | | - cupsdLogMessage(CUPSD_LOG_WARN, "Printer drivers are deprecated and will stop working in a future version of CUPS. See https://github.com/OpenPrinting/cups/issues/103"); |
| 1388 | + cupsdLogMessage(CUPSD_LOG_WARN, "Printer drivers are deprecated and will stop working in a future version of CUPS. Use IPP Everywhere drivers (\"-m everywhere\") or Printer Applications instead. See https://github.com/OpenPrinting/cups/issues/103"); |
1388 | 1389 |
|
1389 | 1390 | cupsFileClose(fp); |
1390 | 1391 | } |
@@ -3389,6 +3390,185 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */ |
3389 | 3390 | } |
3390 | 3391 |
|
3391 | 3392 |
|
| 3393 | +/* |
| 3394 | + * 'add_ppd_defaults_to_ipp()' - Map PPD option defaults to IPP "-default" attributes. |
| 3395 | + */ |
| 3396 | + |
| 3397 | +static void |
| 3398 | +add_ppd_defaults_to_ipp(cupsd_printer_t *p, /* I - Printer */ |
| 3399 | + ppd_file_t *ppd) /* I - PPD file */ |
| 3400 | +{ |
| 3401 | + ppd_option_t *option; /* Current PPD option */ |
| 3402 | + ppd_group_t *group; /* Current PPD group */ |
| 3403 | + const char *ipp_name; /* IPP attribute name */ |
| 3404 | + const char *ipp_value; /* IPP attribute value */ |
| 3405 | + const char *mapped_value; /* Mapped IPP attribute value */ |
| 3406 | + char attr_name[256]; /* Attribute name buffer */ |
| 3407 | + int i; /* Looping var */ |
| 3408 | + |
| 3409 | + |
| 3410 | + /* |
| 3411 | + * Skip if no PPD or PPD cache... |
| 3412 | + */ |
| 3413 | + |
| 3414 | + if (!ppd || !p->pc) |
| 3415 | + return; |
| 3416 | + |
| 3417 | + /* |
| 3418 | + * Loop through all PPD options and map their defaults to IPP attributes... |
| 3419 | + */ |
| 3420 | + |
| 3421 | + for (group = ppd->groups; group; group = group->next) |
| 3422 | + { |
| 3423 | + for (option = (ppd_option_t *)cupsArrayFirst(group->options); |
| 3424 | + option; |
| 3425 | + option = (ppd_option_t *)cupsArrayNext(group->options)) |
| 3426 | + { |
| 3427 | + /* |
| 3428 | + * Skip if no default choice... |
| 3429 | + */ |
| 3430 | + |
| 3431 | + if (!option->defchoice || !option->defchoice[0]) |
| 3432 | + continue; |
| 3433 | + |
| 3434 | + /* |
| 3435 | + * Skip options that are already explicitly handled... |
| 3436 | + */ |
| 3437 | + |
| 3438 | + if (!strcmp(option->keyword, "PageSize") || |
| 3439 | + !strcmp(option->keyword, "PageRegion") || |
| 3440 | + !strcmp(option->keyword, "ColorModel") || |
| 3441 | + !strcmp(option->keyword, "HPColorMode") || |
| 3442 | + !strcmp(option->keyword, "BRMonoColor") || |
| 3443 | + !strcmp(option->keyword, "CNIJSGrayScale") || |
| 3444 | + !strcmp(option->keyword, "HPColorAsGray") || |
| 3445 | + !strcmp(option->keyword, "Resolution") || |
| 3446 | + !strcmp(option->keyword, "JCLResolution") || |
| 3447 | + !strcmp(option->keyword, "SetResolution") || |
| 3448 | + !strcmp(option->keyword, "CNRes_PGP") || |
| 3449 | + !strcmp(option->keyword, "Duplex") || |
| 3450 | + !strcmp(option->keyword, "EFDuplex") || |
| 3451 | + !strcmp(option->keyword, "EFDuplexing") || |
| 3452 | + !strcmp(option->keyword, "KD03Duplex") || |
| 3453 | + !strcmp(option->keyword, "JCLDuplex") || |
| 3454 | + !strcmp(option->keyword, "OutputBin") || |
| 3455 | + !strcmp(option->keyword, "InputSlot") || |
| 3456 | + !strcmp(option->keyword, "HPPaperSource") || |
| 3457 | + !strcmp(option->keyword, "MediaType") || |
| 3458 | + !strcmp(option->keyword, "DefaultMediaType") || |
| 3459 | + !strcmp(option->keyword, "DefaultInputSlot")) |
| 3460 | + continue; |
| 3461 | + |
| 3462 | + /* |
| 3463 | + * Map PPD option names to IPP attribute names... |
| 3464 | + */ |
| 3465 | + |
| 3466 | + ipp_name = NULL; |
| 3467 | + ipp_value = option->defchoice; |
| 3468 | + mapped_value = ipp_value; |
| 3469 | + |
| 3470 | + if (!strcmp(option->keyword, "OutputOrder")) |
| 3471 | + ipp_name = "output-order"; |
| 3472 | + else if (!strcmp(option->keyword, "Collate")) |
| 3473 | + { |
| 3474 | + ipp_name = "multiple-document-handling"; |
| 3475 | + /* |
| 3476 | + * Map Collate values to IPP multiple-document-handling values... |
| 3477 | + */ |
| 3478 | + if (!_cups_strcasecmp(ipp_value, "True") || |
| 3479 | + !_cups_strcasecmp(ipp_value, "On") || |
| 3480 | + !_cups_strcasecmp(ipp_value, "Yes")) |
| 3481 | + { |
| 3482 | + mapped_value = "separate-documents-collated-copies"; |
| 3483 | + } |
| 3484 | + else |
| 3485 | + { |
| 3486 | + mapped_value = "separate-documents-uncollated-copies"; |
| 3487 | + } |
| 3488 | + } |
| 3489 | + else if (!strcmp(option->keyword, "cupsPrintQuality") || |
| 3490 | + !strcmp(option->keyword, "OutputMode")) |
| 3491 | + { |
| 3492 | + ipp_name = "print-quality"; |
| 3493 | + /* |
| 3494 | + * Map quality names to IPP enum values... |
| 3495 | + */ |
| 3496 | + if (!_cups_strcasecmp(ipp_value, "draft") || |
| 3497 | + !_cups_strcasecmp(ipp_value, "fast")) |
| 3498 | + { |
| 3499 | + if (!ippFindAttribute(p->attrs, "print-quality-default", IPP_TAG_ZERO)) |
| 3500 | + ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default", IPP_QUALITY_DRAFT); |
| 3501 | + } |
| 3502 | + else if (!_cups_strcasecmp(ipp_value, "best") || |
| 3503 | + !_cups_strcasecmp(ipp_value, "high")) |
| 3504 | + { |
| 3505 | + if (!ippFindAttribute(p->attrs, "print-quality-default", IPP_TAG_ZERO)) |
| 3506 | + ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default", IPP_QUALITY_HIGH); |
| 3507 | + } |
| 3508 | + else |
| 3509 | + { |
| 3510 | + if (!ippFindAttribute(p->attrs, "print-quality-default", IPP_TAG_ZERO)) |
| 3511 | + ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default", IPP_QUALITY_NORMAL); |
| 3512 | + } |
| 3513 | + continue; |
| 3514 | + } |
| 3515 | + else |
| 3516 | + { |
| 3517 | + /* |
| 3518 | + * For other options, convert the option name to lowercase with dashes |
| 3519 | + * and append "-default"... |
| 3520 | + */ |
| 3521 | + |
| 3522 | + snprintf(attr_name, sizeof(attr_name), "%s-default", option->keyword); |
| 3523 | + for (i = 0; attr_name[i]; i ++) |
| 3524 | + { |
| 3525 | + if (attr_name[i] >= 'A' && attr_name[i] <= 'Z') |
| 3526 | + attr_name[i] = (char)(attr_name[i] | 32); /* tolower */ |
| 3527 | + else if (attr_name[i] == '_') |
| 3528 | + attr_name[i] = '-'; |
| 3529 | + } |
| 3530 | + |
| 3531 | + ipp_name = attr_name; |
| 3532 | + } |
| 3533 | + |
| 3534 | + /* |
| 3535 | + * Skip if we already have this attribute... |
| 3536 | + */ |
| 3537 | + |
| 3538 | + if (ippFindAttribute(p->attrs, ipp_name, IPP_TAG_ZERO)) |
| 3539 | + continue; |
| 3540 | + |
| 3541 | + /* |
| 3542 | + * Add the IPP "-default" attribute... |
| 3543 | + */ |
| 3544 | + |
| 3545 | + if (ipp_name && mapped_value) |
| 3546 | + { |
| 3547 | + /* |
| 3548 | + * For boolean options, convert to boolean... |
| 3549 | + */ |
| 3550 | + |
| 3551 | + if (option->ui == PPD_UI_BOOLEAN) |
| 3552 | + { |
| 3553 | + ippAddBoolean(p->attrs, IPP_TAG_PRINTER, ipp_name, |
| 3554 | + !_cups_strcasecmp(mapped_value, "True") || |
| 3555 | + !_cups_strcasecmp(mapped_value, "On") || |
| 3556 | + !_cups_strcasecmp(mapped_value, "Yes")); |
| 3557 | + } |
| 3558 | + else |
| 3559 | + { |
| 3560 | + /* |
| 3561 | + * For other options, add as string/keyword... |
| 3562 | + */ |
| 3563 | + |
| 3564 | + ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, ipp_name, NULL, mapped_value); |
| 3565 | + } |
| 3566 | + } |
| 3567 | + } |
| 3568 | + } |
| 3569 | +} |
| 3570 | + |
| 3571 | + |
3392 | 3572 | /* |
3393 | 3573 | * 'add_printer_filter()' - Add a MIME filter for a printer. |
3394 | 3574 | */ |
@@ -5342,6 +5522,12 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ |
5342 | 5522 | } |
5343 | 5523 | #endif /* HAVE_APPLICATIONSERVICES_H */ |
5344 | 5524 |
|
| 5525 | + /* |
| 5526 | + * Map PPD defaults to IPP "-default" attributes... |
| 5527 | + */ |
| 5528 | + |
| 5529 | + add_ppd_defaults_to_ipp(p, ppd); |
| 5530 | + |
5345 | 5531 | /* |
5346 | 5532 | * Close the PPD and set the type... |
5347 | 5533 | */ |
|
0 commit comments