]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Don't use "unknown" default InputSlot value for IPP Everywhere PPDs
authorMichael R Sweet <msweet@msweet.org>
Sat, 14 Nov 2020 14:24:51 +0000 (09:24 -0500)
committerMichael R Sweet <msweet@msweet.org>
Sat, 14 Nov 2020 14:27:44 +0000 (09:27 -0500)
(Issue #44)

CHANGES-OPENPRINTING.md
cups/ppd-cache.c

index a8743728ece33f50f6b4cea113e93d8f177ae176..0bf85e23638286cf7fd6209a8e256c3ee68637d9 100644 (file)
@@ -25,6 +25,7 @@ Changes in CUPS v2.3.3op1
   (Issue #30, Issue #31)
 - The scheduler no longer adds the local hostname to the ServerAlias list
   (Issue #32)
+- IPP Everywhere PPDs could have an "unknown" default InputSlot (Issue #44)
 - The `httpAddrListen` function now uses a listen backlog of 128.
 - Added USB quirks (Apple issue #5789, #5823, #5831)
 - Fixed IPP Everywhere v1.1 conformance issues in ippeveprinter.
index 11a4479fb9c9e6ae8f768cd787c692273ade0709..e27b05bab4f349f82d32348246a7d0ad2e69d40f 100644 (file)
@@ -3620,10 +3620,12 @@ _ppdCreateFromIPP(char   *buffer,       /* I - Filename buffer */
   if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_ZERO)) != NULL)
     pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
   else
-    strlcpy(ppdname, "Unknown", sizeof(ppdname));
+    ppdname[0] = '\0';
 
   if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
   {
+    int have_default = ppdname[0] != '\0';
+                                       /* Do we have a default InputSlot? */
     static const char * const sources[] =
     {                                  /* Standard "media-source" strings */
       "auto",
@@ -3678,15 +3680,20 @@ _ppdCreateFromIPP(char   *buffer,       /* I - Filename buffer */
       "roll-10"
     };
 
-    cupsFilePrintf(fp, "*OpenUI *InputSlot: PickOne\n"
-                       "*OrderDependency: 10 AnySetup *InputSlot\n"
-                       "*DefaultInputSlot: %s\n", ppdname);
+    cupsFilePuts(fp, "*OpenUI *InputSlot: PickOne\n"
+                     "*OrderDependency: 10 AnySetup *InputSlot\n");
+    if (have_default)
+      cupsFilePrintf(fp, "*DefaultInputSlot: %s\n", ppdname);
+
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
       keyword = ippGetString(attr, i, NULL);
 
       pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
 
+      if (i == 0 && !have_default)
+       cupsFilePrintf(fp, "*DefaultInputSlot: %s\n", ppdname);
+
       for (j = 0; j < (int)(sizeof(sources) / sizeof(sources[0])); j ++)
         if (!strcmp(sources[j], keyword))
        {