From 5336825ff4d4d2919b07275bb22f7dd2704eeb33 Mon Sep 17 00:00:00 2001 From: Bryan Cain Date: Wed, 1 Mar 2023 12:54:26 -0700 Subject: [PATCH] Include media-type and media-source in media-col-default Otherwise, there's no way for clients to know the default media type or source unless they're using the legacy PPD API. --- cups/ppd-private.h | 2 +- scheduler/printers.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cups/ppd-private.h b/cups/ppd-private.h index 3e3040f1a0..11324c791e 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -36,7 +36,7 @@ extern "C" { * Constants... */ -# define _PPD_CACHE_VERSION 10 /* Version number in cache file */ +# define _PPD_CACHE_VERSION 11 /* Version number in cache file */ /* diff --git a/scheduler/printers.c b/scheduler/printers.c index 170d6a2faf..347fa19c91 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -4221,6 +4221,35 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ipp_t *col; /* Collection value */ col = new_media_col(pwgsize); + + if ((ppd_attr = ppdFindAttr(ppd, "DefaultMediaType", NULL)) != NULL) + { + for (i = p->pc->num_types, pwgtype = p->pc->types; + i > 0; + i --, pwgtype ++) + { + if (!strcmp(pwgtype->ppd, ppd_attr->value)) + { + ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type", NULL, pwgtype->pwg); + break; + } + } + } + + if ((ppd_attr = ppdFindAttr(ppd, "DefaultInputSlot", NULL)) != NULL) + { + for (i = p->pc->num_sources, pwgsource = p->pc->sources; + i > 0; + i --, pwgsource ++) + { + if (!strcmp(pwgsource->ppd, ppd_attr->value)) + { + ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source", NULL, pwgsource->pwg); + break; + } + } + } + ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-default", col); ippDelete(col); } -- 2.47.2