]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Generated PPDs could have an "Unknown" default InputSlot
authorTill Kamppeter <till.kamppeter@gmail.com>
Tue, 1 Dec 2020 22:37:15 +0000 (23:37 +0100)
committerTill Kamppeter <till.kamppeter@gmail.com>
Wed, 2 Dec 2020 11:07:50 +0000 (12:07 +0100)
(cherry picked from commit accfbb110692b7356cbb5a1c17a840ca2954698a)

NEWS
cupsfilters/ppdgenerator.c

diff --git a/NEWS b/NEWS
index c044aa39bd148ff0f4f2c5889d7071339ff47972..5658f1cda4215b9d94644c557c70826a75a6ac45 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ NEWS - OpenPrinting CUPS Filters v1.28.5 - 2020-10-13
 
 CHANGES IN V1.28.6
 
+       - libcupsfilters: Generated PPDs could have an "Unknown"
+         default InputSlot (OpenPrinting CUPS issue #44).
        - cups-browsed: Removed unneeded IPP attribute additions
          preventing the created local queues from preserving a
          location or description the user assigns to them (Issue
index 5f34f57682a3c4f0132a89245c171e4a6ab036b0..9ec7c63eeb67bb9c68e9fd543b03dd145b009efd 100644 (file)
@@ -2463,11 +2463,13 @@ ppdCreateFromIPP2(char         *buffer,          /* I - Filename buffer */
                               IPP_TAG_KEYWORD)) != 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_KEYWORD)) != NULL &&
       (count = ippGetCount(attr)) > 1) {
+    int have_default = ppdname[0] != '\0';
+                                       /* Do we have a default InputSlot? */
     static const char * const sources[][2] =
     {                                  /* "media-source" strings */
       { "Auto", _("Automatic") },
@@ -2525,15 +2527,18 @@ ppdCreateFromIPP2(char         *buffer,          /* I - Filename buffer */
     human_readable = lookup_option("media-source", opt_strings_catalog,
                                   printer_opt_strings_catalog);
     cupsFilePrintf(fp, "*OpenUI *InputSlot/%s: PickOne\n"
-                  "*OrderDependency: 10 AnySetup *InputSlot\n"
-                  "*DefaultInputSlot: %s\n",
-                  (human_readable ? human_readable : "Media Source"),
-                  ppdname);
+                  "*OrderDependency: 10 AnySetup *InputSlot\n",
+                  (human_readable ? human_readable : "Media Source"));
+    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);
+
       human_readable = lookup_choice((char *)keyword, "media-source",
                                     opt_strings_catalog,
                                     printer_opt_strings_catalog);