Documentation
¶
Overview ¶
Package ipp is the slice of the Internet Printing Protocol (RFC 8010 and 8011) the print dialog needs from CUPS: list the printers (CUPS-Get-Printers) and send a job (Print-Job), over the CUPS domain socket or CUPS_SERVER. Pure Go; no libcups.
Index ¶
- Constants
- func DefaultServer() string
- func IsNotFound(err error) bool
- func PrinterURI(name string) string
- func StatusOK(code uint16) bool
- type Attr
- type Client
- func (c *Client) Attributes(ctx context.Context, printerURI string) (Printer, error)
- func (c *Client) CreateLocalPrinter(ctx context.Context, deviceURI, name string) (string, error)
- func (c *Client) Default(ctx context.Context) (string, error)
- func (c *Client) Print(ctx context.Context, j Job) (int32, error)
- func (c *Client) Printer(ctx context.Context, name string) (Printer, error)
- func (c *Client) Printers(ctx context.Context) ([]Printer, error)
- type Group
- type Job
- type Marker
- type Message
- type Printer
- type StatusError
- type Value
Constants ¶
const ( StateIdle int32 = 3 StateProcessing int32 = 4 StateStopped int32 = 5 )
The printer-state values.
const ( OpPrintJob uint16 = 0x0002 OpGetPrinterAttributes uint16 = 0x000B OpCUPSGetDefault uint16 = 0x4001 OpCUPSGetPrinters uint16 = 0x4002 OpCUPSCreateLocalPrinter uint16 = 0x4028 )
Operations.
const ( GroupOperation byte = 0x01 GroupJob byte = 0x02 GroupPrinter byte = 0x04 )
Attribute group delimiters.
const ( TagInteger byte = 0x21 TagBoolean byte = 0x22 TagEnum byte = 0x23 TagRange byte = 0x33 // TagCollection opens a collection value, whose members follow as // memberAttrName values each before its own values, up to // tagEndCollection. TagCollection byte = 0x34 TagText byte = 0x41 TagName byte = 0x42 TagKeyword byte = 0x44 TagURI byte = 0x45 TagCharset byte = 0x47 TagLanguage byte = 0x48 TagMimeMedia byte = 0x49 )
Value tags.
Variables ¶
This section is empty.
Functions ¶
func DefaultServer ¶
func DefaultServer() string
DefaultServer is libcups' server choice: $CUPS_SERVER (a socket path or host[:port]), else the scheduler's domain socket, else localhost:631.
func IsNotFound ¶
IsNotFound reports client-error-not-found (no such printer, or no printers at all for CUPS-Get-Printers).
func PrinterURI ¶
PrinterURI is the queue's URI as CUPS names it.
Types ¶
type Attr ¶
Attr is one named attribute with its values.
func Collection ¶
Collection is a collection attribute of one value, its members.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks IPP to one CUPS server.
func (*Client) Attributes ¶
Attributes reads the attributes of the printer at printerURI, posted to its path (Get-Printer-Attributes).
func (*Client) CreateLocalPrinter ¶
CreateLocalPrinter has CUPS make a temporary IPP Everywhere queue for the printer at deviceURI, which it removes once idle (CUPS-Create-Local-Printer), and reports its name.
func (*Client) Default ¶
Default is the scheduler's default destination (CUPS-Get-Default), "" when it has none.
type Group ¶
Group is one attribute group.
type Job ¶
type Job struct {
Printer, Title, User string
// Format is the document's MIME type.
Format string
// Attrs are the job template attributes (copies, sides, media...).
Attrs []Attr
Document io.Reader
}
Job is one document to spool.
type Marker ¶
Marker is one supply (marker-names, marker-colors, marker-levels): its level in percent, negative when the printer cannot tell.
type Message ¶
Message is a request (Code is the operation) or a response (Code is the status).
type Printer ¶
type Printer struct {
Name, Location, StateMessage string
// State is printer-state: 3 idle, 4 processing, 5 stopped.
State int32
Accepting bool
// UUID is its printer-uuid ("urn:uuid:…"), DeviceURI where CUPS
// sends its jobs.
UUID, DeviceURI string
// StateReasons are its printer-state-reasons keywords ("none" left
// out), Markers its supplies.
StateReasons []string
Markers []Marker
// Media are its PWG media names, Sides its sides keywords,
// ColorModes its print-color-mode keywords, Qualities its
// print-quality enums; each with its default.
Media, Sides, ColorModes []string
MediaDefault, SidesDefault string
ColorModeDefault string
Qualities []int32
QualityDefault int32
// NumberUp are the pages per sheet it can print (number-up-
// supported, its ranges spelled out up to maxNumberUp), Scalings its
// print-scaling keywords, MediaSources its trays, MediaTypes its
// media types and OutputBins its output trays; each with its default
// where IPP has one.
NumberUp []int32
Scalings []string
ScalingDefault string
MediaSources, MediaTypes []string
OutputBins []string
OutputBinDefault string
}
Printer is one queue as the dialog lists it, with what it supports (empty when it does not say).
func DeviceAttributes ¶
DeviceAttributes reads the attributes of a network printer at its own ipp:// or ipps:// URI, as the dialog does for one found over DNS-SD before CUPS has a queue for it. An ipps printer's certificate is self-signed as a rule, and only its capabilities are read, so it is not verified; the job itself goes through CUPS.
type StatusError ¶
StatusError is an unsuccessful IPP status.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type Value ¶
type Value struct {
Tag byte
Int int32
Low int32 // range lower bound; Int is the upper
Text string
Members []Attr
}
Value is one attribute value: an int for integer, enum and boolean (0 or 1), a [2]int32 for a range, a string for the text kinds, the members of a collection.
func CollectionValue ¶
CollectionValue is a collection value, a member of another one.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ipptest is a fake CUPS scheduler on loopback for tests: the queues a test sets answer CUPS-Get-Printers, Get-Printer-Attributes and CUPS-Get-Default, CUPS-Create-Local-Printer adds one, and Print-Job records what it is sent.
|
Package ipptest is a fake CUPS scheduler on loopback for tests: the queues a test sets answer CUPS-Get-Printers, Get-Printer-Attributes and CUPS-Get-Default, CUPS-Create-Local-Printer adds one, and Print-Job records what it is sent. |