]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Include media-type and media-source in media-col-default 627/head
authorBryan Cain <bryancain@chromium.org>
Wed, 1 Mar 2023 19:54:26 +0000 (12:54 -0700)
committerBryan Cain <bryancain@chromium.org>
Thu, 2 Mar 2023 17:11:22 +0000 (10:11 -0700)
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
scheduler/printers.c

index 3e3040f1a01e5ebbd9d5ee2f3d4b530a725bc44e..11324c791e51c2b8377ec21c6c49c2001c6130f6 100644 (file)
@@ -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 */
 
 
 /*
index 170d6a2faf11a00ce87dfb209b4c6cf0fd428d7c..347fa19c9108b8918557b761ac5e000496beb2df 100644 (file)
@@ -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);
       }