From: Bryan Cain Date: Wed, 1 Mar 2023 19:54:26 +0000 (-0700) Subject: Include media-type and media-source in media-col-default X-Git-Tag: v2.4.3~42^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F627%2Fhead;p=thirdparty%2Fcups.git 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. --- 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); }