Skip to content

Commit 8db2f27

Browse files
Merge pull request #1424 from Swastik092/#1357
Improve deprecation warnings with IPP Everywhere guidance (#1357)
2 parents 9e22bf0 + acb474d commit 8db2f27

3 files changed

Lines changed: 191 additions & 5 deletions

File tree

scheduler/printers.c

Lines changed: 188 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* Local functions...
3535
*/
3636

37+
static void add_ppd_defaults_to_ipp(cupsd_printer_t *p, ppd_file_t *ppd);
3738
static void add_printer_defaults(cupsd_printer_t *p);
3839
static void add_printer_filter(cupsd_printer_t *p, mime_type_t *type,
3940
const char *filter);
@@ -1381,10 +1382,10 @@ cupsdLoadAllPrinters(void)
13811382
}
13821383

13831384
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");
13851386

13861387
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");
13881389

13891390
cupsFileClose(fp);
13901391
}
@@ -3389,6 +3390,185 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */
33893390
}
33903391

33913392

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+
33923572
/*
33933573
* 'add_printer_filter()' - Add a MIME filter for a printer.
33943574
*/
@@ -5342,6 +5522,12 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
53425522
}
53435523
#endif /* HAVE_APPLICATIONSERVICES_H */
53445524

5525+
/*
5526+
* Map PPD defaults to IPP "-default" attributes...
5527+
*/
5528+
5529+
add_ppd_defaults_to_ipp(p, ppd);
5530+
53455531
/*
53465532
* Close the PPD and set the type...
53475533
*/

systemv/lpadmin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ main(int argc, /* I - Number of command-line arguments */
611611
#ifdef __APPLE__
612612
_cupsLangPuts(stderr, _("lpadmin: Raw queues are no longer supported on macOS."));
613613
#else
614-
_cupsLangPuts(stderr, _("lpadmin: Raw queues are deprecated and will stop working in a future version of CUPS."));
614+
_cupsLangPuts(stderr, _("lpadmin: Raw queues are deprecated and will stop working in a future version of CUPS. Use IPP Everywhere drivers (\"-m everywhere\") or Printer Applications instead."));
615615
#endif /* __APPLE__ */
616616

617617
if (device_uri && (!strncmp(device_uri, "ipp://", 6) || !strncmp(device_uri, "ipps://", 7)) && strstr(device_uri, "/printers/"))
@@ -623,7 +623,7 @@ main(int argc, /* I - Number of command-line arguments */
623623
}
624624
else if ((ppd_name && strcmp(ppd_name, "everywhere") && strncmp(ppd_name, "driverless:", 11)) || file)
625625
{
626-
_cupsLangPuts(stderr, _("lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS."));
626+
_cupsLangPuts(stderr, _("lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS. Use IPP Everywhere drivers (\"-m everywhere\") or Printer Applications instead."));
627627
}
628628

629629
if (num_options || file)

templates/printer-added.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
successfully.
55

66
<blockquote>
7-
<b>Note:</b> Printer drivers and raw queues are deprecated and will stop working in a future version of CUPS.
7+
<b>Note:</b> Printer drivers and raw queues are deprecated and will stop working in a future version of CUPS. Use IPP Everywhere drivers (select "everywhere" as the model) or Printer Applications instead. See <a href="https://github.com/OpenPrinting/cups/issues/103">issue #103</a> for more information.
88
</blockquote>
99

1010
<FORM ACTION="admin/" METHOD="POST">

0 commit comments

Comments
 (0)