* Local functions...
*/
+static void adjust_options(int num_options, cups_option_t *options);
static void cancel_job(http_t *http, const char *uri, int id,
const char *resource, const char *user,
int version);
}
+/*
+ * 'adjust_options()' - Adjust options which have the same meaning.
+ *
+ * In case the backend gets PPD option and IPP attribute of the same meaning
+ * among options array, adjust their values to reflect the same choices,
+ * if the values differ (preferring PPD option values).
+ *
+ * Support for each PPD x IPP option pair is added adhoc, based on demand.
+ */
+
+static void
+adjust_options(int num_options, /* I - Number of options */
+ cups_option_t *options) /* I - Array of job options */
+{
+ const char *ppd_option_value = NULL; /* PPD option value */
+ const char *ipp_attr_value = NULL; /* IPP attribute value */
+
+
+ fprintf(stderr, "DEBUG: adjust_options()\n");
+
+ if (options == NULL || num_options < 2)
+ {
+ fprintf(stderr, "DEBUG: adjust_options(): Invalid values.\n");
+ return;
+ }
+
+ /*
+ * PPD option ColorModel and IPP attribute print-color-mode
+ */
+
+ ppd_option_value = cupsGetOption("ColorModel", num_options, options);
+ ipp_attr_value = cupsGetOption("print-color-mode", num_options, options);
+
+ if (!ppd_option_value || !ipp_attr_value)
+ return;
+
+ if (strcmp(ipp_attr_value, "monochrome") && (!strcmp(ppd_option_value, "Gray")
+ || !strcmp(ppd_option_value, "FastGray")
+ || !strcmp(ppd_option_value, "DeviceGray")))
+ {
+ fprintf(stderr, "DEBUG: adjust_options(): Adjusting print-color-mode to monochrome.\n");
+ num_options = cupsAddOption("print-color-mode", "monochrome", num_options, &options);
+ }
+ else if (strcmp(ipp_attr_value, "color") && (!strcmp(ppd_option_value, "CMY")
+ || !strcmp(ppd_option_value, "CMYK")
+ || !strcmp(ppd_option_value, "RGB")))
+ {
+ fprintf(stderr, "DEBUG: adjust_options(): Adjusting print-color-mode to color.\n");
+ num_options = cupsAddOption("print-color-mode", "color", num_options, &options);
+ }
+}
+
+
/*
* 'cancel_job()' - Cancel a print job.
*/
*/
fputs("DEBUG: Adding all operation/job attributes.\n", stderr);
+ adjust_options(num_options, options);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);
}