All relevant internal structures are located in module Printconf. There is a list of all printers printcap, default destination default and dirty flag dirty. For printer editation there is a map printer and index of currently edited printer. There is a list of deleted printers - deleted because at the end we must wipe them from system. autodetected contain list of autodetected printers. List sys_forbidden_names contains all the file names present in /etc/lpdfilter/. These names mustn't be used for queue name because directory is created for each queue in /etc/lpdfilter/. For database handling there are variables default_database and current_database. Their meaning will be explained later.
Keys and values: | |
name | Name of the queue |
uri | Printer device uri. See module Printer documentation for the explanation of uri. |
ff | Print formfeed between pages? Default is false |
raw | Skip filtering at all |
ascii | Prints text |
conf | Map of value from /etc/lpdfilter/$QUEUE/conf |
vendor | Name of manufacturer in printer db |
device | Name of model in printer db |
config | Name of configuration in printer db |
options | Map of options for filter. |
vendor_ieee | IEEE ident of vendor in printer db |
device_ieee | IEEE ident of printer in printer db |
database | Path to database or nil for default |
unique_key | Unique key of printer by libhd |
Runtime values: (created in runtime) | |
newer_gs_upp | Was upp file changed externaly later then yast2 file? |
saved | Saved upp and conf file and relevant part of printcap for faster saving |
recreate | Some of crutial properties changed. Forget "saved" and recreate queue using lprsetup |
remote_printer | When creating pre-filter queue, remote queue name is here |
remote_host | When creating pre-filter queue, hostname of the remote printer is here. We don't need to store the name of the forwarding queue sepatately because it is in uri (prefilter://fwd_queue). |
create_remote_queue | Create remote queue for this newly created prefilter queue? |
type | "yast2" for queues created by yast2 |
Printconf is able to cope with more then one printer databases. If you want to make printconf use other database, run it with an argument `db("/usr/lib/YaST2/lib/printerdb/otherdatabasefile")'. Printer will be autodetected and configured using this database. When such a queue will be edited, the proper database will be loaded. It is impossible to switch to other database when editing queue in SuSE Linux 8.0. If you want to choose driver from different database, you must delete the queue and configure it again with the database you want.
Internal implementation is simple. Variable default_database contains filename of the database supplied on the command line (or nil for main suse db). Variable current_database contains database currently loaded. If new queue is created, current_database must be the same as default_database, if queue is edited, current_database must be the same as the database in Queue::database.
Reading the settings is done by agent .etc.printcap. Sources of information:
For printer autodetection module Printer is used. See function Detect. Proposal based on detected printer can be found in function Propose. TODO/FIXME: Proposal needs improvments. Now is only able to scan through all printers and make proposal for the new ones. It should be able to make proposals "on demand", i.e. function MakeProposal (unique_key) or MakeProposal (select (autodetected, i, $[]))
When writting printers, deleted printers are wiped from disk at first, which means that files /etc/lpdfilter/$QUEUE and /var/spool/lpd/$QUEUE are recursively deleted.
Then for each printer following is made:
Printcap entry is created. If printer was already present on disk and
re-creation isn't necessary, printcap part and upp file cached in
printer["saved"] will be saved. Otherwise new upp file is created and
lprsetup is used for printer creation. Note that if queue hadn't been
created by printconf, it is never re-created by lprsetup, it is
always re-created by saving stored settings. Editation of such queues is
disabled by printconf.
If printer is created by yast2, map printer is saved into
/etc/lpdfilter/$QUEUE/yast2.
Finally /etc/lpdfilter/$QUEUE/conf file is saved. If the printer is
Epson connected on USB, a wake-up sequence is written into
reset_before.
At the end /etc/printcap permissions are changed and status of unique
keys is updated (.probe.status.configured, unique_key --> `yes or `no).
Default destination is written into
.sysconfig.printer.DEFAULT_PRINTER and service lpd is
enabled.
Please note that it is necessary to change permission of files although
lprsetup is doing it. We needn't call lprsetup in all cases. Some printers may
be written using printer["saved"].
Common parameters to lprsetup:
In pre-SuSE-linux-8.0 versions, configuration of all queues were saved before testing particular printer. It was very slow.
Now, when testing printer, we only save the printer being tested (when it is prefilter queue we also save relevant forwarding queue). The names of these saved queues are y2test, or y2testNUMBER. The problem may occure when tested printer is somehow connected to other printer that hasn't been saved yet. The situation: You want to test the prefilter queue that forwards jobs to remote queue printforwarder.suse.de:lp. But printforwarder.suse.de:lp forwards the job back to your computer to a queue that hasn't been saved yet.
So our queue is saved and we may send a test page to it. The test pages and the routines for test page preparation are places in yast2-lib-printer. There is nothing interesting about testing ascii printing. A file is just sent to the printer. Postscript printing has more issues to remember: