Add marker-* attributes #1307

Closed
michaelrsweet opened this Issue Oct 6, 2005 · 7 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Oct 6, 2005

Version: 1.3-current
CUPS.org User: mike

Add marker-state collection attribute with the following members:

marker-color (type2 keyword)
marker-level (integer (-1:100))

Will also need MARKER: message from filters to set levels.

Collaborator

michaelrsweet commented Feb 23, 2006

CUPS.org User: mike

Pushed to post-1.2.

Collaborator

michaelrsweet commented Aug 24, 2007

CUPS.org User: mike

Considering for 1.4...

Collaborator

michaelrsweet commented Jan 10, 2008

CUPS.org User: mike

These should be set via ATTR: messages, e.g.:

ATTR: marker-names=Cyan,Magenta,Yellow,Black
ATTR: marker-colors=#00ffff,#ff00ff,#ffff00,#000000
ATTR: marker-levels=100,98,97,55

The new definitions should be:

marker-colors (1setOf name(127))
marker-levels (1setOf integer (-1:100))
marker-names (1setOf name(MAX))

For reports of multiple colors (e.g. tri-color ink cartridge), multiple colors can be reported together:

ATTR: marker-names=Tri-Color,Black
ATTR: marker-colors=#00ffff#ff00ff#ffff00,#000000
ATTR: marker-levels=92,34
Collaborator

michaelrsweet commented Jan 10, 2008

CUPS.org User: mike

Possibly also change this to a more general:

supply-colors (1setOf name(127))
supply-levels (1setOf integer (-1:100))
supply-types (1setOf Type2 keyword)
supply-names (1setOf name(MAX))

where "supply-types" would indicate the general type ("ink", "toner", "paper", "fuser", etc.) and "supply-colors" would be "na" for items that should not be graphed.

Collaborator

michaelrsweet commented Jan 30, 2008

CUPS.org User: mike

Back to 1.3...

Collaborator

michaelrsweet commented Jan 30, 2008

CUPS.org User: mike

Fixed in Subversion repository.

Collaborator

michaelrsweet commented Jan 30, 2008

"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 @@

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:


+
+

    +

    • toner
    • wasteToner
    • ink
    • inkCartridge
    • inkRibbon
    • wasteInk
    • opc
    • developer
    • fuserOil
    • solidWax
    • ribbonWax
    • wasteWax
    • fuser
    • coronaWire
    • fuserOilWick
    • cleanerUnit
    • fuserCleaningPad
    • transferUnit
    • tonerCartridge
    • fuserOiler
    • water
    • wasteWater
    • bindingSupply
    • bandingSupply
    • stichingWire
    • shrinkWrap
    • paperWrap
    • staples
    • inserts
    • covers

    +


+

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);

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment