]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Ported changes in CUPS' cups/ppd-cache.c file
authorTill Kamppeter <till.kamppeter@gmail.com>
Wed, 22 Sep 2021 14:24:35 +0000 (16:24 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Wed, 22 Sep 2021 14:24:35 +0000 (16:24 +0200)
From original commit to CUPS:

https://github.com/OpenPrinting/cups/commit/a638ae140

Update mapping of media-source, media-type, and output-bin to match both PPD
and PWG names (CUPS Issue #238)

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

cupsfilters/ppdgenerator.c
ppd/ppd-cache.c

index d22316af56015f89b9d898674aab2382614d1bcc..e51582d87bb3d9e53fde8f93e700260e631b148c 100644 (file)
@@ -1726,6 +1726,45 @@ cfCreatePPDFromIPP2(char         *buffer,          /* I - Filename buffer */
                                     IPP_TAG_BOOLEAN), 0))
     cupsFilePuts(fp, "*cupsJobAccountingUserId: True\n");
 
+  if ((attr = ippFindAttribute(response, "printer-privacy-policy-uri", IPP_TAG_URI)) != NULL)
+    cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n", ippGetString(attr, 0, NULL));
+
+  if ((attr = ippFindAttribute(response, "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(response, "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...
   */
@@ -3043,7 +3082,7 @@ cfCreatePPDFromIPP2(char         *buffer,          /* I - Filename buffer */
        "TriplePortrait",
        "TripleLandscape",
        "TripleRevPortrait",
-       "TripleRevLandscape",
+       "TripleRevLandscape"
        "QuadPortrait",
        "QuadLandscape",
        "QuadRevPortrait",
index 6f7f874252c39979eef2147615b59ad31f893f2b..374903bee28beeb05ea2282a048ed79fda98cadf 100644 (file)
@@ -3171,7 +3171,7 @@ ppdCacheGetBin(
 
 
   for (i = 0; i < pc->num_bins; i ++)
-    if (!_ppd_strcasecmp(output_bin, pc->bins[i].ppd))
+    if (!_ppd_strcasecmp(output_bin, pc->bins[i].ppd) || !_ppd_strcasecmp(output_bin, pc->bins[i].pwg))
       return (pc->bins[i].pwg);
 
   return (NULL);
@@ -3907,7 +3907,7 @@ ppdCacheGetSource(
     return (NULL);
 
   for (i = pc->num_sources, source = pc->sources; i > 0; i --, source ++)
-    if (!_ppd_strcasecmp(input_slot, source->ppd))
+    if (!_ppd_strcasecmp(input_slot, source->ppd) || !_ppd_strcasecmp(input_slot, source->pwg))
       return (source->pwg);
 
   return (NULL);
@@ -3936,7 +3936,7 @@ ppdCacheGetType(
     return (NULL);
 
   for (i = pc->num_types, type = pc->types; i > 0; i --, type ++)
-    if (!_ppd_strcasecmp(media_type, type->ppd))
+    if (!_ppd_strcasecmp(media_type, type->ppd) || !_ppd_strcasecmp(media_type, type->pwg))
       return (type->pwg);
 
   return (NULL);