]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Update mapping of media-source, media-type, and output-bin to match both PPD
authorMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 21 Sep 2021 13:59:45 +0000 (09:59 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 21 Sep 2021 13:59:45 +0000 (09:59 -0400)
and PWG names (Issue #238)

Add printer-privacy-policy-uri, printer-mandatory-job-attributes, and
printer-requested-job-attributes to PPD file.

CHANGES.md
cups/ppd-cache.c

index b4d7e17a066d7dd516f93343d828dc1e7e64cab0..ab69945bbfd5e94a7ba2f968609c44cade3546c0 100644 (file)
@@ -1,7 +1,7 @@
 Changes in OpenPrinting CUPS
 ============================
 
-CUPS v2.4rc1 (Pending)
+CUPS v2.4-b1 (Pending)
 ----------------------
 
 - Added support for CUPS running in a Snapcraft snap.
@@ -57,6 +57,7 @@ CUPS v2.4rc1 (Pending)
 - Hardened `ippReadIO` to prevent invalid IPP messages from being propagated
   (Issue #195, Issue #196)
 - The scheduler now supports the "everywhere" model directly (Issue #201)
+- Fixed some IPP Everywhere option mapping problems (Issue #238)
 - Fixed support for "job-hold-until" with the Restart-Job operation (Issue #250)
 - Documentation fixes (Issue #92, Issue #163, Issue #177, Issue #184)
 - Localization updates (Issue #123, Issue #129, Issue #134, Issue #146,
index d10e825cb677dcfdf04d13020ba5aa2d4c249c0a..ecce6af72f1734a843e27dbef566f89b937445b3 100644 (file)
@@ -2,7 +2,7 @@
  * PPD cache implementation for CUPS.
  *
  * Copyright © 2021 by OpenPrinting.
- * Copyright © 2010-2019 by Apple Inc.
+ * Copyright © 2010-2021 by Apple Inc.
  *
  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
  * information.
@@ -2083,7 +2083,7 @@ _ppdCacheGetBin(
 
 
   for (i = 0; i < pc->num_bins; i ++)
-    if (!_cups_strcasecmp(output_bin, pc->bins[i].ppd))
+    if (!_cups_strcasecmp(output_bin, pc->bins[i].ppd) || !_cups_strcasecmp(output_bin, pc->bins[i].pwg))
       return (pc->bins[i].pwg);
 
   return (NULL);
@@ -2770,7 +2770,7 @@ _ppdCacheGetSource(
     return (NULL);
 
   for (i = pc->num_sources, source = pc->sources; i > 0; i --, source ++)
-    if (!_cups_strcasecmp(input_slot, source->ppd))
+    if (!_cups_strcasecmp(input_slot, source->ppd) || !_cups_strcasecmp(input_slot, source->pwg))
       return (source->pwg);
 
   return (NULL);
@@ -2799,7 +2799,7 @@ _ppdCacheGetType(
     return (NULL);
 
   for (i = pc->num_types, type = pc->types; i > 0; i --, type ++)
-    if (!_cups_strcasecmp(media_type, type->ppd))
+    if (!_cups_strcasecmp(media_type, type->ppd) || !_cups_strcasecmp(media_type, type->pwg))
       return (type->pwg);
 
   return (NULL);
@@ -3259,6 +3259,45 @@ _ppdCreateFromIPP2(
   if (ippGetBoolean(ippFindAttribute(supported, "job-accounting-user-id-supported", IPP_TAG_BOOLEAN), 0))
     cupsFilePuts(fp, "*cupsJobAccountingUserId: True\n");
 
+  if ((attr = ippFindAttribute(supported, "printer-privacy-policy-uri", IPP_TAG_URI)) != NULL)
+    cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n", ippGetString(attr, 0, NULL));
+
+  if ((attr = ippFindAttribute(supported, "printer-mandatory-job-attributes", IPP_TAG_KEYWORD)) != NULL)
+  {
+    char       prefix = '\"';          // Prefix for string
+
+    cupsFilePuts(fp, "*cupsMandatory: \"");
+    for (i = 0, count = ippGetCount(attr); i < count; i ++)
+    {
+      keyword = ippGetString(attr, i, NULL);
+
+      if (strcmp(keyword, "attributes-charset") && strcmp(keyword, "attributes-natural-language") && strcmp(keyword, "printer-uri"))
+      {
+        cupsFilePrintf(fp, "%c%s", prefix, keyword);
+        prefix = ',';
+      }
+    }
+    cupsFilePuts(fp, "\"\n");
+  }
+
+  if ((attr = ippFindAttribute(supported, "printer-requested-job-attributes", IPP_TAG_KEYWORD)) != NULL)
+  {
+    char       prefix = '\"';          // Prefix for string
+
+    cupsFilePuts(fp, "*cupsRequested: \"");
+    for (i = 0, count = ippGetCount(attr); i < count; i ++)
+    {
+      keyword = ippGetString(attr, i, NULL);
+
+      if (strcmp(keyword, "attributes-charset") && strcmp(keyword, "attributes-natural-language") && strcmp(keyword, "printer-uri"))
+      {
+        cupsFilePrintf(fp, "%c%s", prefix, keyword);
+        prefix = ',';
+      }
+    }
+    cupsFilePuts(fp, "\"\n");
+  }
+
  /*
   * Password/PIN printing...
   */
@@ -4316,7 +4355,7 @@ _ppdCreateFromIPP2(
        "TriplePortrait",
        "TripleLandscape",
        "TripleRevPortrait",
-       "TripleRevLandscape",
+       "TripleRevLandscape"
        "QuadPortrait",
        "QuadLandscape",
        "QuadRevPortrait",