[LOW] STR #1307: Add marker-* attributes
Dmitry Sharov
dsharov at mackiev.com
Wed Jan 30 03:10:59 PST 2008
Greetings,
Should marker-names be already localized by driver or they are going to be localized later by some GUI app/proxy, probably basing on some (new) PPD file attribute(s)?
Thanks, Dima
>
> --PART-BOUNDARY
> Content-Type: text/plain
>
> [STR Closed w/Resolution]
>
> Fixed in Subversion repository.
>
> Link: http://www.cups.org/str.php?L1307
> Version: 1.3-current
> Fix Version: 1.4-current (r7270)
> --PART-BOUNDARY
> Content-Type: text/plain
> Content-Disposition: attachment; filename="str1307.patch"
>
> 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 @@
> <p>The job-sheets-supported attribute specifies the available banner files.
> There will always be at least one banner file available called "none".
>
> +<h4><a name="marker-colors">marker-colors (1setof name(MAX))</a></h4>
> +
> +<p>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".</p>
> +
> +<h4><a name="marker-levels">marker-levels (1setof integer(-1:100))</a></h4>
> +
> +<p>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.</p>
> +
> +<h4><a name="marker-names">marker-names (1setof name(MAX))</a></h4>
> +
> +<p>The marker-names attribute specifies the name(s) for each supply in the
> +printer. It is only available when the driver provides supply levels.</p>
> +
> +<h4><a name="marker-types">marker-types (1setof type3 keyword)</a></h4>
> +
> +<p>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:</p>
> +
> +<ul>
> +
> + <li><tt>toner</tt></li>
> +
> + <li><tt>wasteToner</tt></li>
> +
> + <li><tt>ink</tt></li>
> +
> + <li><tt>inkCartridge</tt></li>
> +
> + <li><tt>inkRibbon</tt></li>
> +
> + <li><tt>wasteInk</tt></li>
> +
> + <li><tt>opc</tt></li>
> +
> + <li><tt>developer</tt></li>
> +
> + <li><tt>fuserOil</tt></li>
> +
> + <li><tt>solidWax</tt></li>
> +
> + <li><tt>ribbonWax</tt></li>
> +
> + <li><tt>wasteWax</tt></li>
> +
> + <li><tt>fuser</tt></li>
> +
> + <li><tt>coronaWire</tt></li>
> +
> + <li><tt>fuserOilWick</tt></li>
> +
> + <li><tt>cleanerUnit</tt></li>
> +
> + <li><tt>fuserCleaningPad</tt></li>
> +
> + <li><tt>transferUnit</tt></li>
> +
> + <li><tt>tonerCartridge</tt></li>
> +
> + <li><tt>fuserOiler</tt></li>
> +
> + <li><tt>water</tt></li>
> +
> + <li><tt>wasteWater</tt></li>
> +
> + <li><tt>bindingSupply</tt></li>
> +
> + <li><tt>bandingSupply</tt></li>
> +
> + <li><tt>stichingWire</tt></li>
> +
> + <li><tt>shrinkWrap</tt></li>
> +
> + <li><tt>paperWrap</tt></li>
> +
> + <li><tt>staples</tt></li>
> +
> + <li><tt>inserts</tt></li>
> +
> + <li><tt>covers</tt></li>
> +
> +</ul>
> +
> <h4><a name="port-monitor">port-monitor" (name(127))</a></h4>
>
> <p>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);
>
> --PART-BOUNDARY--
>
More information about the cups-devel
mailing list