Index: doc/help/spec-ipp.html =================================================================== --- doc/help/spec-ipp.html (revision 7268) +++ doc/help/spec-ipp.html (working copy) @@ -11,7 +11,7 @@ CUPS IPP specification for the Common UNIX Printing System (CUPS). - Copyright 2007 by Apple Inc. + Copyright 2007-2008 by Apple Inc. Copyright 1997-2007 by Easy Software Products. These coded instructions, statements, and computer programs are the @@ -2459,6 +2459,95 @@

The job-sheets-supported attribute specifies the available banner files. There will always be at least one banner file available called "none". +

marker-colors (1setof name(MAX))

+ +

The marker-colors attribute specifies the color(s) for each supply in the +printer. It is only available when the driver provides supply levels. The +color is either "none" or one or more hex-encoded sRGB colors of the form +"#RRGGBB".

+ +

marker-levels (1setof integer(-1:100))

+ +

The marker-levels attribute specifies the current supply levels for the +printer. It is only available when the driver provides supply levels. A +value of -1 indicates the level is unknown, while values from 0 to 100 +indicate the corresponding percentage.

+ +

marker-names (1setof name(MAX))

+ +

The marker-names attribute specifies the name(s) for each supply in the +printer. It is only available when the driver provides supply levels.

+ +

marker-types (1setof type3 keyword)

+ +

The marker-types attribute specifies the type(s) of each supply in the +printer. It is only available when the driver provides supply levels. The +following (RFC 3805) types are currently supported:

+ + +

port-monitor" (name(127))

The port-monitor attribute specifies the port monitor to use when printing Index: scheduler/printers.c =================================================================== --- scheduler/printers.c (revision 7268) +++ scheduler/printers.c (working copy) @@ -27,6 +27,7 @@ * cupsdSaveAllPrinters() - Save all printer definitions to the * printers.conf file. * cupsdSetAuthInfoRequired() - Set the required authentication info. + * cupsdSetPrinterAttr() - Set a printer attribute. * cupsdSetPrinterAttrs() - Set printer attributes based upon the PPD * file. * cupsdSetPrinterReasons() - Set/update the reasons strings. @@ -1651,6 +1652,120 @@ /* + * 'cupsdSetPrinterAttr()' - Set a printer attribute. + */ + +void +cupsdSetPrinterAttr( + cupsd_printer_t *p, /* I - Printer */ + const char *name, /* I - Attribute name */ + char *value) /* I - Attribute value string */ +{ + ipp_attribute_t *attr; /* Attribute */ + int i, /* Looping var */ + count; /* Number of values */ + char *ptr; /* Pointer into value */ + ipp_tag_t value_tag; /* Value tag for this attribute */ + + + /* + * Count the number of values... + */ + + for (count = 1, ptr = value; + (ptr = strchr(ptr, ',')) != NULL; + ptr ++, count ++); + + /* + * Then add or update the attribute as needed... + */ + + if (!strcmp(name, "marker-levels")) + { + /* + * Integer values... + */ + + if ((attr = ippFindAttribute(p->attrs, name, IPP_TAG_INTEGER)) != NULL && + attr->num_values < count) + { + ippDeleteAttribute(p->attrs, attr); + attr = NULL; + } + + if (attr) + attr->num_values = count; + else + attr = ippAddIntegers(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, name, + count, NULL); + + if (!attr) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to allocate memory for printer attribute " + "(%d values)", count); + return; + } + + for (i = 0; i < count; i ++) + { + if ((ptr = strchr(value, ',')) != NULL) + *ptr++ = '\0'; + + attr->values[i].integer = strtol(value, NULL, 10); + + if (ptr) + value = ptr; + } + } + else + { + /* + * Name or keyword values... + */ + + if (!strcmp(name, "marker-types")) + value_tag = IPP_TAG_KEYWORD; + else + value_tag = IPP_TAG_NAME; + + if ((attr = ippFindAttribute(p->attrs, name, value_tag)) != NULL && + attr->num_values < count) + { + ippDeleteAttribute(p->attrs, attr); + attr = NULL; + } + + if (attr) + attr->num_values = count; + else + attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, value_tag, name, + count, NULL, NULL); + + if (!attr) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to allocate memory for printer attribute " + "(%d values)", count); + return; + } + + for (i = 0; i < count; i ++) + { + if ((ptr = strchr(value, ',')) != NULL) + *ptr++ = '\0'; + + _cupsStrFree(attr->values[i].string.text); + attr->values[i].string.text = _cupsStrAlloc(value); + + if (ptr) + value = ptr; + } + } +} + + +/* * 'cupsdSetPrinterAttrs()' - Set printer attributes based upon the PPD file. */ Index: scheduler/job.c =================================================================== --- scheduler/job.c (revision 7268) +++ scheduler/job.c (working copy) @@ -3673,6 +3673,30 @@ event |= CUPSD_EVENT_PRINTER_STATE; } + if ((attr = cupsGetOption("marker-colors", num_attrs, attrs)) != NULL) + { + cupsdSetPrinterAttr(job->printer, "marker-colors", (char *)attr); + event |= CUPSD_EVENT_PRINTER_STATE; + } + + if ((attr = cupsGetOption("marker-levels", num_attrs, attrs)) != NULL) + { + cupsdSetPrinterAttr(job->printer, "marker-levels", (char *)attr); + event |= CUPSD_EVENT_PRINTER_STATE; + } + + if ((attr = cupsGetOption("marker-names", num_attrs, attrs)) != NULL) + { + cupsdSetPrinterAttr(job->printer, "marker-names", (char *)attr); + event |= CUPSD_EVENT_PRINTER_STATE; + } + + if ((attr = cupsGetOption("marker-types", num_attrs, attrs)) != NULL) + { + cupsdSetPrinterAttr(job->printer, "marker-types", (char *)attr); + event |= CUPSD_EVENT_PRINTER_STATE; + } + cupsFreeOptions(num_attrs, attrs); } #ifdef __APPLE__ Index: scheduler/printers.h =================================================================== --- scheduler/printers.h (revision 7268) +++ scheduler/printers.h (working copy) @@ -150,6 +150,8 @@ extern int cupsdSetAuthInfoRequired(cupsd_printer_t *p, const char *values, ipp_attribute_t *attr); +extern void cupsdSetPrinterAttr(cupsd_printer_t *p, + const char *name, char *value); extern void cupsdSetPrinterAttrs(cupsd_printer_t *p); extern void cupsdSetPrinterReasons(cupsd_printer_t *p, const char *s);