]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
scheduler/ipp.c: Convert incoming ColorModel attribute 451/head
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 2 Aug 2022 08:38:21 +0000 (10:38 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 23 Aug 2022 08:39:58 +0000 (10:39 +0200)
If a client uses PPD option ColorModel (which is converted into
attribute to be sent via IPP) for changing the default color option
(which happens via CUPS-Add-Modify-Printer operation), we have to
convert ColorModel into print-color-mode attribute, so the
print-color-mode-default attribute gets updated.

The change survives reboot because print-color-mode is saved as an
option in printer's entry in /etc/cups/printers.conf.

scheduler/ipp.c

index b722712f638f2e7d906235901ea9dab70caa5cd1..fc575639b5ffe8812fec09389a8e46c6f14b6741 100644 (file)
@@ -2340,6 +2340,18 @@ add_printer(cupsd_client_t  *con,        /* I - Client connection */
 
   set_device_uri = 0;
 
+  if ((attr = ippFindAttribute(con->request, "ColorModel", IPP_TAG_NAME)) != NULL)
+  {
+    const char * keyword = NULL;
+
+    if (!strcmp(attr->values[0].string.text, "FastGray") || !strcmp(attr->values[0].string.text, "Gray") || !strcmp(attr->values[0].string.text, "DeviceGray"))
+      keyword = "monochrome";
+    else
+      keyword = "color";
+
+    printer->num_options = cupsAddOption("print-color-mode", keyword, printer->num_options, &printer->options);
+  }
+
   if ((attr = ippFindAttribute(con->request, "device-uri",
                                IPP_TAG_URI)) != NULL)
   {