Printer Admin tool specifics
TimWaugh
Programming language
The libcups library provides routines for communicating with CUPS using IPP, and they are callable from C. The existing system-config-printer tool provides a very basic pycups Python wrapper for a limited amount of functionality.
For programming the user interface of the new tool, Glade and Python (pygtk) are easiest.
pycups
To bridge the gap between Python and libcups, the pycups Python wrapper should be extended to provide the necessary functionality. Rather than wrap the interface on a function-by-function basis, higher-level methods (such as adding a printer, tweaking a PPD option, etc) will be provided. This allows for cleaner Python code, and easier C.
XML parsing
The foomatic data is XML. The existing code in system-config-printer to parse this uses the 'xml.utils.qp_xml' module. There may be a better module for doing this -- perhaps libxml2 or celementtree?
The existing code writes a pickle (cPickle) of the in-memory structures to /var/cache the first time the foomatic data is parsed. We could use this scheme, or something like it, to make parsing faster.
(NB. The current scheme neglects to stat the timestamps on the XML files to see if any are newer than the cache file.)
Setting PPD defaults
This method for this is straight-forward (although the user interface is fairly involved). The PPD for the printer should be retrieved from the CUPS scheduler using an IPP call. Then libcups provides some routines for manipulating PPD defaults. The PPD can be stored again using IPP.
Modifying cupsd.conf
Some configuration changes will require modifying cupsd.conf. This can be done by requesting the file using IPP, modifying the text file, and sending the modified file back using IPP. The CUPS scheduler will then reload the configuration.
Care should be taken to minimise the window between fetching the file and sending back the modified version, to avoid overwriting any changes made by other (perhaps remote) users.
Modifications should be done in minimal fashion, keeping all of the original configuration in place except for the modified piece. A method for doing this needs to be devised.
The tool will need to parse _and understand_ the cupsd.conf file in order to show the current state adjustable settings in the user interface.
Information which needs to be gleaned from cupsd.conf:
- Whether 'Browsing' is on (if off, no sending or receiving of browse packets will be performed)
- What 'Browse
Address' lines are present, if any
- What 'Browse
Allow' lines are present, if any
- What 'Listen' or 'Port' lines are present
- What the default 'Allow' lines for newly-added printers is; i.e. what the best-match location is ('/' or '/printers') and what it allows
The particular modifications will be:
- Adding/removing 'Browse
Address' lines (controls sending browse packets)
- Adding/removing 'Browse
Allow' lines (controls receiving browse packets)
- Adding/removing 'Listen' lines (controls which network interfaces print jobs can be accepted from, or administration functions performed from)
- Creating a new 'Location /printers/...' section for a printer, if one does not already exist
- Adding/removing 'Allow from' lines to a 'Location /printers/...' section for a printer
SMB browsing
There is existing code in system-config-printer to display a browser in the user interface to search for an SMB printer. This is based on guess-work and parsing the output of the 'smbclient' command. We need to speak to someone who has a better understanding of how SMB networks are formed in order to understand how to re-write this.
User-defined queues
There is more design work to do on this.