YaST2 Developers Documentation: printer configuration tool



functions
files
intro

printer configuration tool

modules/Printer.ycp
Module for printer.
Well we all know what modules are for.

Imports

  • Arch
  • CUPS
  • Confirm
  • Crash
  • HTML
  • Label
  • Mode
  • Popup
  • Printerdb
  • Printerlib
  • Progress
  • Report
  • Spooler
  • Summary

Includes

  • printer/misc-cups.ycp
  • printer/misc-lprng.ycp

Global Variables

Global Functions

Local Variables

Local Functions

global version -> integer

Version of YaST2 printer module for updates handling

global write_only -> boolean

Don't run SuSEconfig, don't restart services if true and possible

global detect -> boolean

Shall be printers detected If nil, ask user

global printcap -> list<map<string,any> >

List of print queues. See description of map printer for members structure.

global printcap_backup -> list<map<string,any> >

Backup list of print queues. See description of map printer for members structure.

global default -> string

Default queue name

global save_all -> boolean

Has to be saved all?

global dirty -> boolean

Were settings changed?

global read_done -> boolean

Were settings read?

global printer -> map<string,any>

Print queue we are currently working with.

Example:
 
 $[
 "name" : string, //queue name
 "uri" : string, //printer uri
 "unique_key" : string,  // from libhd  -|
 "ppd" : string // filename of used ppd file, non-raw queues only
 "ppd_info" : map // chached information about PPD file, non-raw only
 "options": map,   // options from printer db -|
 "ff" : boolean, // print formfeed between pages, present only for queues with formfeed
 "raw": boolean, // raw queue, present only for raw queues
 ]

global index -> integer

Index of printer we are working with.

global deleted -> list<map<string,string> >

List of printers that were deleted during this configuration session.

global autodetected -> list<map<string,any> >

List of autodetected printers. For documentation see yast2-lib-printer.

local original_unique_keys -> map<string,boolean>

List of unique keys of the printers read at the beginning. We need this because when writting, we must call Write (.probe.status.configured, "unique_key", `yes | `no) It is map of $[ unique_key : true ]. When saving, unique keys that are still configured are replaced by $[ unique_key : false ]

global detection -> boolean

Type of start, true if autodetection

global tested -> boolean

At least one queue has been tested - because of hw proposal

global skip_autodetection -> boolean

True if autodetection should be skipped

global confmode -> symbol

Current mode of configuration `det for configuring from detected printers dialog `adm for configuring from printer administration dialog

global connection_type_selected -> symbol

Selected item from main connection type dialog

global old_uri -> string

Old URI due to backing it up during edit sequence

global conf_detected -> boolean

Configuring printer, which is result of detection?

global runAutoprobedListDialog__current -> integer

Selected item of the list of detected printers

global testAbort () -> boolean

Test for abort.

Return value:
true if abort was pressed

global fixPrinter (map<string,any> p) -> map<string,any>

Add unpresent entries into a map

Parameters:
p map of printer
Return value:
modified map

global isFile (string file) -> boolean

does file exist?

Parameters:
file string filename to test
Return value:
true if exists

global isPpd (string file) -> boolean

Is file a ppd file?

Parameters:
file string filename to test
Return value:
true if yes

global ppdInfo (string file) -> map

Get PPD file info

Parameters:
file string filename to get info from
Return value:
of informations

global Detect () -> void

Autodetect printers.

global selectPrinter (integer i) -> void

Select printer to edit or something.

Parameters:
i printer to select. Pass nil if you do not want to select printer, e.g. if printer is going to be added.

global selectPrinterByName (string name) -> void

Let print queue named name be currently edited. If printer is not found, then queue will be $[] and index -1

Parameters:
name name of the queue to find

global addToDeleted (string name, string printer_type) -> void

Adds a queue to the deleted list

Parameters:
name string queue name
printer_type string "printer" or "class"

global assignDefault () -> void

Set implicit default queue if no queue is set as default

global deletePrinter () -> void

Delete currently selected printer.

global setDefaultPrinter () -> void

Set current printer as default printer

global getForbiddenNames () -> list<string>

Return list(set) of names that can not be used as printer name. There can be same name for more printers in /etc/printcap. It was impossible to add printer, because all names were invalid because size (union (forbidden_names, new_names)) != size (forbidden_names) + size (new_names).

Return value:
a list of already used names

global assignState (map<string,any> p, boolean changed) -> map<string,any>

Assign states to a printer

Parameters:
p a map printer
changed boolean true if queue was changed (to assign correct state)
Return value:
a map printer with assigned states

global storePrinter () -> void

Save currently edited printer.

global Export () -> map<string, any>

Export module settings to map.

Return value:
Map of module settings.

global Import (map<string, any> settings) -> void

Import module settings.

Parameters:
settings module settings

global Reset () -> void

Reset all settings...

global printcapRead (list<map<string,any> > yast_printcap) -> list<map<string,any> >

read printers from /etc/printcap

Parameters:
yast_printcap list of data read from YaST's configuration file
Return value:
a list of printers

global cupsRead () -> list<map<string,any> >

Read the CUPS settings.

Return value:
a list of printers

global sortPrinters () -> void

Sorts entries of printcap

global checkRootPerm () -> boolean

Check if running with root permission

Return value:
true if yes, or user confirmed he agrees with possible problems

global checkSpooler () -> boolean

Detect spooler currently in use

Return value:
true on success

global checkGhostscript () -> boolean

Check if GhostScript is installed

Return value:
true if is installed

global updateConfig (integer read_version) -> void

Update configuration if cfg. saved by previous version

Parameters:
read_version integere version written in cfg. file

global spoolerInitialize () -> boolean

Initialize current spooler

Return value:
true on success

global doPrinterDetection () -> boolean

Check if it is safe, ask user if needed, and detect local printers

Return value:
true on success TODO error checking

global spoolerSpecQueuesRead () -> list<map<string,any> >

Read queues set for spooler

Return value:
a list of queues

global stateRead () -> boolean

Read the contents of /var/lib/YaST2/printers

Return value:
true on success TODO error handling

global setUniqueKeys () -> void

Set unique keys after configuration reading

global queuesRead () -> boolean

Old read function, called from new Read function TODO: better integrate TODO: error handling

Return value:
true on success

global Read () -> boolean

Read settings from disk or where.

Return value:
success?

global wipePrinter (map printer) -> boolean

deletes printers

Parameters:
printer map of printer to delete (with keys name and type containing "printer" or "class"
Return value:
success state

global deleteDeletedPrinters () -> boolean

Delete printers marked for being deleted

Return value:
true on success

global savePrinters () -> boolean

Save all queues

Return value:
true on success

global saveDefaultQueue () -> boolean

Save default queue to appropriate location

Return value:
true on success

local saveTheConfiguration () -> boolean

Write /var/lib/yast2/printers

Return value:
true if successful

global Write () -> boolean

Write settings.

Return value:
success state

global getArgsOfType (map config, string type) -> map

separates from config map only values of specified type

Parameters:
config Map of configuration
type String specifying type
Return value:
of selected values

global Summary (list style) -> string

Creates summary from autodetected printers and printcap.

Parameters:
style type of summary - list of symbols - flags: `test: add test link
`nonew: do not include new -- unconfigured printers into summary
`short: short summary doesn't contain queue description `state: show printer state
Return value:
summary string

global DeletedNames () -> list

get list of names of deleted printers.

Return value:
List of names.

global getUriType () -> string

Get type of currently selected printer. Just a shortcut to Printerlib::getUriType (...)

Return value:
printer type

global generateQueueName (string name, string uri, string vendor_name, string device_name, list forbidden_names) -> string

TODO: create test case

Parameters:
name printer name
uri string queue uri
vendor_name string name of the printer vendor
device_name string name of the printer device
forbidden_names list of forbidden names
Return value:
new queue name

global editDetected (map det) -> void

Prepare detected printer to be configured.

Parameters:
det map of detected printer

global alreadyConfigured (string uk) -> boolean

Has the printer been already configured?

Parameters:
uk unique key of the printer
Return value:
true or false

global Propose () -> void

Autoconfigure all printers that haven't been configured yet.

global adjustQueueName (string name, list forbidden_names) -> string

Check if queue name is OK. Otherwise adds number at the end.

Parameters:
name printer name
forbidden_names forbidden names
Return value:
new queue name.

global getQueueSuffix (list<map<string,any> > queues) -> string

Get the suffix for the queue name.

Parameters:
queues list of new queues. Keys are the names of the queues.
Return value:
suffix

YaST2 Developers Documentation