+
+ if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL)
+ {
+ for (i = 0; i < p->pc->num_bins; i ++)
+ if (!strcmp(p->pc->bins[i].ppd, output_bin->defchoice))
+ break;
+
+ if (i >= p->pc->num_bins)
+ i = 0;
+
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, p->pc->bins[i].pwg);
+ }
+ else
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, p->pc->bins[0].pwg);
+ }
+ else if (((ppd_attr = ppdFindAttr(ppd, "DefaultOutputOrder",
+ NULL)) != NULL &&
+ !_cups_strcasecmp(ppd_attr->value, "Reverse")) ||
+ (!ppd_attr && ppd->manufacturer && /* "Compatibility heuristic" */
+ (!_cups_strcasecmp(ppd->manufacturer, "epson") ||
+ !_cups_strcasecmp(ppd->manufacturer, "lexmark"))))
+ {
+ /*
+ * Report that this printer has a single output bin that leaves pages face
+ * up.
+ */
+
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-supported", NULL, "face-up");
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, "face-up");
+ }
+ else
+ {
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-supported", NULL, "face-down");
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, "face-down");
+ }
+
+ /*
+ * print-color-mode...
+ */
+
+ if (ppd->color_device)
+ {
+ static const char * const color_modes[] =
+ {
+ "monochrome",
+ "color"
+ };
+
+ ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-color-mode-supported", 2, NULL, color_modes);
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-color-mode-default", NULL, "color");
+ }
+ else
+ {
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-color-mode-supported", NULL, "monochrome");
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-color-mode-default", NULL, "monochrome");
+ }
+
+ /*
+ * Mandatory job attributes, if any...
+ */
+
+ if (p->pc && cupsArrayCount(p->pc->mandatory) > 0)
+ {
+ int count = cupsArrayCount(p->pc->mandatory);
+ /* Number of mandatory attributes */
+
+ attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "printer-mandatory-job-attributes", count, NULL,
+ NULL);
+
+ for (val = attr->values,
+ mandatory = (char *)cupsArrayFirst(p->pc->mandatory);
+ mandatory;
+ val ++, mandatory = (char *)cupsArrayNext(p->pc->mandatory))
+ val->string.text = _cupsStrAlloc(mandatory);
+ }
+
+ /*
+ * Printer resolutions...
+ */
+
+ if ((resolution = ppdFindOption(ppd, "Resolution")) == NULL)
+ if ((resolution = ppdFindOption(ppd, "JCLResolution")) == NULL)
+ if ((resolution = ppdFindOption(ppd, "SetResolution")) == NULL)
+ resolution = ppdFindOption(ppd, "CNRes_PGP");
+
+ if (resolution)
+ {
+ /*
+ * Report all supported resolutions...
+ */
+
+ attr = ippAddResolutions(p->ppd_attrs, IPP_TAG_PRINTER,
+ "printer-resolution-supported",
+ resolution->num_choices, IPP_RES_PER_INCH,
+ NULL, NULL);
+
+ for (i = 0, choice = resolution->choices;
+ i < resolution->num_choices;
+ i ++, choice ++)
+ {
+ xdpi = ydpi = (int)strtol(choice->choice, (char **)&resptr, 10);
+ if (resptr > choice->choice && xdpi > 0 && *resptr == 'x')
+ ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10);
+
+ if (xdpi <= 0 || ydpi <= 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Bad resolution \"%s\" for printer %s.",
+ choice->choice, p->name);
+ xdpi = ydpi = 300;
+ }
+
+ attr->values[i].resolution.xres = xdpi;
+ attr->values[i].resolution.yres = ydpi;
+ attr->values[i].resolution.units = IPP_RES_PER_INCH;
+
+ if (choice->marked)
+ ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
+ "printer-resolution-default", IPP_RES_PER_INCH,
+ xdpi, ydpi);
+ }
+ }
+ else if ((ppd_attr = ppdFindAttr(ppd, "DefaultResolution", NULL)) != NULL &&
+ ppd_attr->value)
+ {
+ /*
+ * Just the DefaultResolution to report...
+ */
+
+ xdpi = ydpi = (int)strtol(ppd_attr->value, (char **)&resptr, 10);
+ if (resptr > ppd_attr->value && xdpi > 0)
+ {
+ if (*resptr == 'x')
+ ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10);
+ else
+ ydpi = xdpi;
+ }
+
+ if (xdpi <= 0 || ydpi <= 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Bad default resolution \"%s\" for printer %s.",
+ ppd_attr->value, p->name);
+ xdpi = ydpi = 300;
+ }
+
+ ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
+ "printer-resolution-default", IPP_RES_PER_INCH,
+ xdpi, ydpi);
+ ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
+ "printer-resolution-supported", IPP_RES_PER_INCH,
+ xdpi, ydpi);
+ }
+ else
+ {
+ /*
+ * No resolutions in PPD - make one up...
+ */
+
+ ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
+ "printer-resolution-default", IPP_RES_PER_INCH,
+ 300, 300);
+ ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
+ "printer-resolution-supported", IPP_RES_PER_INCH,
+ 300, 300);