<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PRINT HEAD &#187; Software</title>
	<atom:link href="http://cyberelk.net/tim/category/techie-stuff/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://cyberelk.net/tim</link>
	<description></description>
	<lastBuildDate>Wed, 23 May 2012 15:57:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Some benefits of printerd</title>
		<link>http://cyberelk.net/tim/2012/05/23/some-benefits-of-printerd/</link>
		<comments>http://cyberelk.net/tim/2012/05/23/some-benefits-of-printerd/#comments</comments>
		<pubDate>Wed, 23 May 2012 15:56:40 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[printerd]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=981</guid>
		<description><![CDATA[Recently I talked about a new print spooler under development, printerd. In that post I mentioned briefly how printerd is structured, but did not go very deeply into why or what the project is for. Firstly, printerd is experimental and is very far from being a functional print spooler. It doesn&#8217;t yet run any filters, [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I <a href="http://cyberelk.net/tim/2012/05/10/announcing-printerd" target="_blank">talked about</a> a new print spooler under development, printerd. In that post I mentioned briefly how printerd is structured, but did not go very deeply into why or what the project is for.</p>
<p>Firstly, printerd is experimental and is very far from being a functional print spooler. It doesn&#8217;t yet run any filters, for instance, and has no backends of its own to transport jobs to devices. So far it is just a test of what a Linux print spooler would look like if it were written today.</p>
<p>There are several problems printerd aims to solve. Some of the solutions come automatically from implementing it as a polkit-enabled D-Bus system service.  I mentioned one of them in the original post about printer: the fact of having an asynchronous client API. All D-Bus services can be used asynchronously thanks to the D-Bus client library. This approach means the print dialog will be able to use printerd without blocking (and without having to start another thread to use it).</p>
<p><span id="more-981"></span></p>
<p>Another benefit is the fact that security/authentication can be made much cleaner and more well integrated into a desktop system if polkit is the basis for policy decisions. Although there is some support for adding polkit support to CUPS in the shape of <a href="http://www.vuntz.net/journal/post/2010/02/19/A-few-words-about-cups-pk-helper..." target="_blank">cups-pk-helper</a>, the way this works is to effectively bypass the standard CUPS policy mechanism. In order to completely limit some operation from users, two different policies must be changed: the built-in CUPS policy in cupsd.conf, and the polkit policy for cups-pk-helper.</p>
<p>In contrast, printerd&#8217;s only interface is D-Bus and it uses polkit to authenticate operations. If extra security policy is added in future that cannot be expressed using polkit (for instance, printer-specific policy rules like CUPS has), that extra policy layer will be in addition to polkit, not an alternative. Currently, for example, cancelling a job requires that the user is permitted to use the org.freedesktop.printerd.job-cancel action (a polkit check), as well as being the user that submitted the job in the first place (an additional check). Both requirements must be fulfilled.</p>
<p>One more benefit of printerd is the idea of splitting the IPP server out from the local spooler. Currently printerd only spools files and does not provide IPP services but the idea is that when it does, this will be implemented out-of-process by a program that acts as a client to printerd. It will use printerd&#8217;s D-Bus interface, just like any other client. That way, users that want to print to local printers but are not interested in sharing those printers on the network don&#8217;t even have to run the IPP server. In fact, as printerd is an activatable system service, the spooler itself won&#8217;t even be running unless there is something for it to do.</p>
<p>By accepting only one format for printing, some complexity can be removed from the spooler. Generally people print from applications that generate PDF for printing. By using PDF as the required format, the task of selecting pages and arranging several pages onto each side (i.e. number-up) is hopefully made a little easier, as the structure of PDF makes this task more straightforward than PostScript does. Increasingly printers are able to understand PDF natively themselves. This means converting between formats can be kept to a minimum.</p>
<p>Finally, printerd is experimental, so ideas can be tested and developed. For example, I hope to get printerd to improve the latency between cancelling a job and having the printer stop feeding paper, by splitting the backend out of the filter pipeline, killing its input, and telling it to discard its send buffer. Another idea related to separating the filter pipeline from the backend is to begin filtering the next job before the backend finishes clearing out the last of its send buffer. I&#8217;m sure there are other areas for improvement that can be played around with in a project like printerd.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2012/05/23/some-benefits-of-printerd/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Announcing printerd</title>
		<link>http://cyberelk.net/tim/2012/05/10/announcing-printerd/</link>
		<comments>http://cyberelk.net/tim/2012/05/10/announcing-printerd/#comments</comments>
		<pubDate>Thu, 10 May 2012 14:50:58 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[printerd]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=976</guid>
		<description><![CDATA[For the last few weeks I&#8217;ve been working on an experimental new print spooler called printerd. It was designed in collaboration with Richard Hughes and it aims to be a modern print spooler for Linux. It is a polkit-enabled D-Bus system service, written using the GLib object system. Although modelled on concepts from IPP (Internet [...]]]></description>
				<content:encoded><![CDATA[<p>For the last few weeks I&#8217;ve been working on an experimental new print spooler called <a href="http://gitorious.org/printerd" target="_blank">printerd</a>. It was designed in collaboration with <a href="http://blogs.gnome.org/hughsie/" target="_blank">Richard Hughes</a> and it aims to be a modern print spooler for Linux.</p>
<p>It is a polkit-enabled D-Bus system service, written using the GLib object system. Although modelled on concepts from IPP (Internet Printing Protocol), printerd is not in itself an IPP server. Its only interface is D-Bus, although the aim is to be able to implement an IPP server on top of the D-Bus API as a separate process. Having a D-Bus interface means that applications wanting to print automatically get to use printerd asynchronously.</p>
<p>As a design decision, the range of input formats accepted by printerd will be very limited: essentially only PDF. The existing CUPS drivers and backends will be compatible with printerd.</p>
<p>There isn&#8217;t much written yet aside from the basic framework and a very simple command line tool.</p>
<p>Feel free to take a look around: <a href="http://gitorious.org/printerd" target="_blank">http://gitorious.org/printerd</a></p>
<p><span id="more-976"></span></p>
<p><a href="http://cyberelk.net/tim/wp-content/uploads/2012/05/dfeet.png"><img class="alignnone size-large wp-image-977" title="dfeet" src="http://cyberelk.net/tim/wp-content/uploads/2012/05/dfeet-451x1024.png" alt="" width="451" height="1024" /></a></p>
<pre>$ pd-client -v print-files myprinter ~/Documents/portrait-a4.pdf
TI:15:09:58    getting printerd manager
TI:15:09:58    Getting printer /org/freedesktop/printerd/printer/myprinter
TI:15:09:58    Job created: /org/freedesktop/printerd/job/1
TI:15:09:58    Document added
TI:15:09:58    Job started
Job path is /org/freedesktop/printerd/job/1

# printerd -v
TI:15:02:46    Entering main event loop
TI:15:02:46    add device usb://HP/DESKJET%20990C?serial=US05N1J00XLG [...]
TI:15:02:46    Connected to the system bus
TI:15:02:46    Acquired the name org.freedesktop.printerd on the system message bus
TI:15:08:52    Handling GetDevices
TI:15:08:57    Handling GetDevices
TI:15:09:12    Checking authorization of :1.642 for org.freedesktop.printerd.printer-add
TI:15:09:12    Authorized
TI:15:09:12    Creating printer from device HEWLETT_PACKARD_DESKJET_990C_US05N1J00XLG
TI:15:09:12    add printer myprinter
TI:15:09:58    Checking authorization of :1.647 for org.freedesktop.printerd.job-add
TI:15:09:58    Authorized
TI:15:09:58    Creating job for printer myprinter
TI:15:09:58    New job path is /org/freedesktop/printerd/job/1
TI:15:09:58    Created job path is /org/freedesktop/printerd/job/1
TI:15:09:58    [Job 1] Adding document
TI:15:09:58    [Job 1] Got file descriptor: 10
TI:15:09:58    [Job 1] Starting job
TI:15:09:58    [Job 1] Spooling
TI:15:09:58    [Job 1]   Created temporary file /tmp/printerd-spool-AHFWDW
TI:15:09:58    [Job 1]   Set job state to pending
TI:15:09:58    Job 1 changed state: pending
TI:15:09:58    Printer for job 1 idle so starting job
TI:15:09:58    [Job 1] Starting to process job
TI:15:09:58    [Job 1] Using device URI usb://HP/DESKJET%20990C?serial=US05N1J00XLG
TI:15:09:58    [Job 1] Executing /usr/lib/cups/backend/usb
TI:15:09:58    [Job 1]  Env: DEVICE_URI=usb://HP/DESKJET%20990C?serial=US05N1J00XLG
TI:15:09:58    [Job 1]  Arg: usb://HP/DESKJET%20990C?serial=US05N1J00XLG
TI:15:09:58    [Job 1]  Arg: 1
TI:15:09:58    [Job 1]  Arg: :1.647
TI:15:09:58    [Job 1]  Arg: job 1
TI:15:09:58    [Job 1]  Arg: 1
TI:15:09:58    [Job 1]  Arg:
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    Job 1 changed state: processing
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 1024 bytes from spool file
TI:15:09:58    [Job 1] Wrote 1024 bytes to backend
TI:15:09:58    [Job 1] Read 564 bytes from spool file
TI:15:09:58    [Job 1] Wrote 564 bytes to backend
TI:15:09:58    [Job 1] Spool finished
TI:15:09:58    [Job 1] backend: STATE: +connecting-to-device
TI:15:09:58    [Job 1] backend: DEBUG: Printer using device file "/dev/usb/lp0"...
TI:15:09:58    [Job 1] backend: STATE: -connecting-to-device
TI:15:09:58    [Job 1] backend: DEBUG: backendRunLoop(print_fd=0, device_fd=3, snmp_fd=-1, addr=(nil), use_bc=1, side_cb=0x7f053adc6c30)
TI:15:09:58    [Job 1] backend: DEBUG: Read 8192 bytes of print data...</pre>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2012/05/10/announcing-printerd/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Session printing</title>
		<link>http://cyberelk.net/tim/2012/03/08/session-printing/</link>
		<comments>http://cyberelk.net/tim/2012/03/08/session-printing/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 17:52:55 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cups]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=956</guid>
		<description><![CDATA[There has been a discussion on the Fedora devel mailing list recently about user session printing: why that might be useful, and in what circumstances it makes sense. Where I can see it can make some sense to have printing entirely in the user session is for PDF printing to smart services hosted elsewhere: e.g. [...]]]></description>
				<content:encoded><![CDATA[<p>There has been <a href="http://lists.fedoraproject.org/pipermail/devel/2012-March/163610.html" target="_blank">a discussion on the Fedora devel mailing list recently</a> about user session printing: why that might be useful, and in what circumstances it makes sense.</p>
<p>Where I can see it can make some sense to have printing entirely in the user session is for PDF printing to smart services hosted elsewhere: e.g. the office CUPS server, or Google Cloud Print.  Applications produce PDF, so for printing to these types of service there is nothing to do but send the PDF (along with any print options).</p>
<p><span id="more-956"></span></p>
<p>A little about Google Cloud Print: this is a service that allows you to register your local printers with their service, and share those printers with other people.  It currently works as part of Chrome: it maintains an XMPP connection to Google so that incoming jobs can be received and passed on to the local CUPS queue.  For printing jobs to it, it is simply an authenticated web service.</p>
<p><a href="http://cyberelk.net/tim/wp-content/uploads/2012/03/session-printing.png"><img class="alignnone size-medium wp-image-957" title="session-printing" src="http://cyberelk.net/tim/wp-content/uploads/2012/03/session-printing-450x318.png" alt="" width="450" height="318" /></a></p>
<p>The GTK print dialog supports multiple print backends, and currently &#8216;cups&#8217; is the one we use for printing.  This communicates with the locally-running cupsd.</p>
<p>Printing is more than simply getting capabilities and submitting jobs though: we also need to monitor the status of submitted jobs, and perform actions on those jobs such as pause, resume, and cancel.</p>
<p>Currently job status monitoring is performed in gsd-printer, which displays notifications when a job has completed etc, and job management actions are implemented in the &#8220;Printers&#8221; panel of the Systems Settings<br />
application.</p>
<p>Adding support for printing to PDF-capable print services directly from the session could be implemented as follows.</p>
<p>A new session service for printing could be created, providing methods for obtaining a list of printers, explicitly adding/removing printers, and with properties for finding out the current state of each printer and whether it is reporting problems.  It could also provide methods for retrieving the list of jobs for each printer, performing actions on those jobs, and have properties for the state of each job.</p>
<p>This service could have plug-ins for dealing with the locally-running cupsd; with CUPS/IPP servers on the network; and with Google Cloud Print.</p>
<p>For the &#8220;network IPP&#8221; plug-in, it could discover available CUPS (and IPP Everywhere) queues using Avahi, and show in the list of printers only those queues that handle PDF.  Additionally, the print dialog could<br />
allow IPP print servers to be added by hostname (for CUPS) or URI (for network printers which speak IPP and handle PDF).</p>
<p>For the &#8220;cloudprint&#8221; plug-in, it could interrogate the Google Cloud Print server to determine the list of available queues. (The &#8220;Online Accounts/Google&#8221; part of System Settings knows how to log in.)</p>
<p>For job status feedback, gsd-printer could instead query the new service. (Or perhaps the service would be implemented in gsd-printer?)</p>
<p>For job management, the printer panel in System Settings could perform actions through the new service.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2012/03/08/session-printing/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>The portreserve problem: is systemd the solution?</title>
		<link>http://cyberelk.net/tim/2012/02/15/portreserve-systemd-solution/</link>
		<comments>http://cyberelk.net/tim/2012/02/15/portreserve-systemd-solution/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 15:52:58 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[portreserve]]></category>
		<category><![CDATA[systemd]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=942</guid>
		<description><![CDATA[Quite a while ago I wrote portreserve, a utility to prevent ports getting stolen at boot time by portmap. This would happen with CUPS, for example: portmap starts first (to allow for NFS-mounted filesystems), and calls bindresvport(). If the privileged (i.e. in the range 512-1023) port it allocates happens to be 631, when CUPS starts [...]]]></description>
				<content:encoded><![CDATA[<p>Quite a while ago I wrote <a href="http://cyberelk.net/tim/software/portreserve/" target="_blank">portreserve</a>, a utility to prevent ports getting stolen at boot time by portmap. This would happen with CUPS, for example: portmap starts first (to allow for NFS-mounted filesystems), and calls bindresvport(). If the privileged (i.e. in the range 512-1023) port it allocates happens to be 631, when CUPS starts and tries to bind that port it fails. This didn&#8217;t just affect CUPS, but any service with a well known port in the privileged range.</p>
<p><span id="more-942"></span></p>
<p>The solution we&#8217;ve been using for a while is portreserve, and it works by having each privileged service (e.g. cupsd, spamd) provide a file in /etc/portreserve saying which ports it uses. At boot portreserve starts before portmap and binds to those ports, to prevent portmap (or anything else) getting them. When each privileged service starts, it calls portrelease first in order to tell portreserve to let go of its ports.</p>
<p>This works well enough from a simplistic point of view, but doesn&#8217;t go far enough. There is a race condition when a privileged service starts: between calling portrelease and the service actually binding to the now-freed port, it could potentially be grabbed by some other service. Also portreserve is a once-per-boot thing: if you stop or restart a protected service after boot there is no protection for its ports.</p>
<p>A really race-proof solution appears to now exist in systemd. It provides port-based socket activation, meaning that it can allocate ports that will later be required during the boot, stopping portmap from getting them. When the relevant service starts, systemd hands the socket file descriptor directly to the service, with no race condition. It even retains the port when the service stops.</p>
<p>What&#8217;s the problem? <strong>Services don&#8217;t always want to be activated on demand.</strong> In the case of CUPS, there are two ports: TCP 631 (for IPP) and UDP 631 (for CUPS Browsing). The UDP port is simple for listening out for periodic announcements of network shared CUPS queues. When a packet arrives, there is no need to start CUPS &#8212; but the port needs to be protected from portmap, or else CUPS Browsing will mysteriously fail from time to time.</p>
<h3>Proposal: separate activation from port reservation</h3>
<p>My proposal to fix this is for systemd to separate this socket activation feature from the more fundamental one of reserving ports for services. One way of doing this would be to add <em>ListenStreamNoActivate</em> and <em>ListenDatagramNoActivate</em> configuration directives.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2012/02/15/portreserve-systemd-solution/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CUPS 1.6 changes ahead</title>
		<link>http://cyberelk.net/tim/2012/02/06/cups-1-6-changes-ahead/</link>
		<comments>http://cyberelk.net/tim/2012/02/06/cups-1-6-changes-ahead/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 11:16:36 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cups]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=940</guid>
		<description><![CDATA[As I mentioned elsewhere, there are some changes ahead in CUPS 1.6. These changes are not imminent but give an indication of the direction the CUPS project is heading. Back in 2007 CUPS became an Apple project.  Now the parts that are not relevant on Mac OS are being dropped, with some of the Linux-relevant [...]]]></description>
				<content:encoded><![CDATA[<p>As I <a href="http://lists.fedoraproject.org/pipermail/devel/2012-January/161306.html" target="_blank">mentioned elsewhere</a>, there are some changes ahead in CUPS 1.6. These changes are not imminent but give an indication of the direction the CUPS project is heading.</p>
<p>Back in 2007 CUPS became an Apple project.  Now the parts that are not relevant on Mac OS are being dropped, with some of the Linux-relevant parts being gathered together in a separate project, cups-filters.</p>
<p><span id="more-940"></span></p>
<p>The main part that is being dropped completely is <strong>CUPS Browsing</strong>. This is currently the primary mechanism for CUPS-to-CUPS printer queue discovery on Linux. It works by having each CUPS server periodically broadcast UDP packets on port 631 announcing its available queues, and listening for broadcasts from other CUPS servers.</p>
<p>This discovery method is being dropped because DNS-SD is preferred upstream. Support for it has been upstream in CUPS for a while, and it is what CUPS uses on Mac OS X, but it uses Apple&#8217;s libdns_sd library and not Avahi. I have added support for this in Fedora, and the patch is <a href="http://cups.org/str.php?L3066" target="_blank">submitted upstream</a>.</p>
<p>So in CUPS 1.6, automatic CUPS queue discovery <strong>will require Avahi to be running</strong> on both the server (i.e. the system hosting the CUPS queue) and the clients (i.e. the systems wanting to print to it).</p>
<p>Of course, you will be able to run CUPS without having Avahi running &#8212; but you won&#8217;t have automatic CUPS queue discovery in that case.  Clients will have to have queues explicitly configured, or else use the BrowsePoll configuration setting to periodically query a particular CUPS server for its queues.</p>
<p>Several other filters will be dropped from CUPS in 1.6, to be picked up by the <strong>new cups-filters package</strong>. Information about this package is on the <a href="http://www.linuxfoundation.org/collaborate/workgroups/openprinting" target="_blank">OpenPrinting web site</a> and a <a href="http://www.openprinting.org/download/cups-filters/" target="_blank">beta release</a> is now available.</p>
<p>This new package restores the filters that will be dropped in CUPS 1.6 and also adds new filters to support PDF as the baseline document format rather than PostScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2012/02/06/cups-1-6-changes-ahead/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CUPS disabled on upgrade to Fedora 16</title>
		<link>http://cyberelk.net/tim/2011/11/14/cups-disabled-on-upgrade-to-fedora-16/</link>
		<comments>http://cyberelk.net/tim/2011/11/14/cups-disabled-on-upgrade-to-fedora-16/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 12:23:31 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=932</guid>
		<description><![CDATA[One common bug that people are running into with Fedora 16 is that CUPS is no longer enabled after upgrade from an earlier version of Fedora (fresh installs are unaffected). This has already been reported in Bugzilla, and a test update is available. There is also an Ask Fedora answer about it.]]></description>
				<content:encoded><![CDATA[<p>One common bug that people are running into with Fedora 16 is that CUPS is no longer enabled after upgrade from an earlier version of Fedora (fresh installs are unaffected).</p>
<p>This has already been <a href="https://bugzilla.redhat.com/show_bug.cgi?id=748841" target="_blank">reported in Bugzilla</a>, and a <a href="https://admin.fedoraproject.org/updates/FEDORA-2011-15223" target="_blank">test update</a> is available.</p>
<p>There is also an <a href="http://ask.fedoraproject.org/question/253/cups-doesnt-start-after-upgrade-from-f15-to-f16?answer=445" target="_blank">Ask Fedora answer</a> about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2011/11/14/cups-disabled-on-upgrade-to-fedora-16/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Printing Test Day</title>
		<link>http://cyberelk.net/tim/2011/10/05/printing-test-day-2/</link>
		<comments>http://cyberelk.net/tim/2011/10/05/printing-test-day-2/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 09:51:18 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=929</guid>
		<description><![CDATA[It&#8217;s that time again.  Fedora 16&#8242;s Printing Test Day is tomorrow, Thursday October 6th.  Come along and help make printing work better on Fedora! The Test Day page has instructions on what you need and how to test.]]></description>
				<content:encoded><![CDATA[<p><a href="http://cyberelk.net/tim/wp-content/uploads/2011/03/test-day-100.png"><img class="alignright size-full wp-image-892" title="test-day-100" src="http://cyberelk.net/tim/wp-content/uploads/2011/03/test-day-100.png" alt="" width="100" height="100" /></a>It&#8217;s that time again.  Fedora 16&#8242;s Printing Test Day is tomorrow, Thursday October 6th.  Come along and help make printing work better on Fedora!</p>
<p>The <a href="https://fedoraproject.org/wiki/Test_Day:2011-10-06_Printing">Test Day page</a> has instructions on what you need and how to test.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2011/10/05/printing-test-day-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>D-Bus and Python: asynchronous method implementation</title>
		<link>http://cyberelk.net/tim/2011/08/16/d-bus-and-python-asynchronous-method-implementation/</link>
		<comments>http://cyberelk.net/tim/2011/08/16/d-bus-and-python-asynchronous-method-implementation/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 16:16:11 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=900</guid>
		<description><![CDATA[This is a quick demonstration of how to implement a D-Bus method in Python using asynchronous callbacks. I recently added support in system-config-printer for determining the best driver to use for a particular printer.  This is an expensive operation, largely because of the time it takes to get a list of available drivers from CUPS, [...]]]></description>
				<content:encoded><![CDATA[<p>This is a quick demonstration of how to implement a D-Bus method in Python using asynchronous callbacks.</p>
<p>I recently <a href="http://cyberelk.net/tim/2011/07/22/more-d-bus-goodness-in-system-config-printer/">added support</a> in system-config-printer for determining the best driver to use for a particular printer.  This is an expensive operation, largely because of the time it takes to get a list of available drivers from CUPS, and the Python program providing the D-Bus service also provides other services.  I wanted the program to be able to deal with other callers while the CUPS operation was in progress.  Here&#8217;s how that was done.</p>
<p><span id="more-900"></span></p>
<p>Firstly, I already had a class for asynchronous communication with CUPS.  When using PolicyKit to talk to CUPS, the calls use D-Bus which provides an asynchronous API for method calls anyway.  For calls not provided that way the fallback is to queue requests for a worker thread to deal with.</p>
<p>Asynchronous D-Bus calls are made in Python by supplying &#8220;reply_handler&#8221; and &#8220;error_handler&#8221; named options in the method call, like this:</p>
<pre>self._cupsconn.getPPDs2 (reply_handler=self._cups_getppds_reply,
                         error_handler=self._cups_error)</pre>
<p>That call returns right away, but the <tt>getPPDs2</tt> operation continues in the background.  When it is done, my reply_handler function is called.  Alternatively, if there is an error, the error_handler function is called.  One or the other will be called, at which point the operation is finished with.</p>
<p>So far so good from the client side, but the question is how to implement a D-Bus <em>service</em> in an asynchronous manner.  Here is a reminder of what a synchronous D-Bus service implementation looks like.</p>
<pre>#!/usr/bin/python
import gobject
import dbus.service
import time

BUS='com.example.Timer'
PATH='/com/example/Timer'
IFACE='com.example.Timer'
START_TIME=time.time ()

class Timer(dbus.service.Object):
    def __init__ (self):
        self.bus = dbus.SessionBus ()
        bus_name = dbus.service.BusName (BUS, bus=self.bus)
        dbus.service.Object.__init__ (self, bus_name, PATH)

    @dbus.service.method(dbus_interface=IFACE,
                         in_signature='i',
                         out_signature='i')
    def Delay (self, seconds):
        print "Sleeping for %ds" % seconds
        time.sleep (seconds)
        return seconds

def heartbeat():
    print "Still alive at", time.time () - START_TIME
    return True

from dbus.glib import DBusGMainLoop
DBusGMainLoop (set_as_default=True)
loop = gobject.MainLoop ()
# Start the heartbeat
handle = gobject.timeout_add_seconds (1, heartbeat)
# Start the D-Bus service
timer = Timer ()
loop.run ()</pre>
<p>The Timer class is the D-Bus service.  It has a single method, Delay, which delays for a number of seconds and returns that same number.  The program sets a repeating 1-second timer to print &#8220;Still alive&#8221;, and the D-Bus calls into the Timer service are handled by the D-Bus main loop.</p>
<p>How does this program behave?  Here is its output.  While it was running I used <a href="http://live.gnome.org/DFeet/">D-Feet</a> to call Delay(3).</p>
<pre>Still alive at 1.02512407303
Still alive at 2.0262401104
Still alive at 3.02633500099
Still alive at 4.02575397491
Sleeping for 3s
Still alive at 7.0756611824
Still alive at 8.02573609352
Still alive at 9.02583909035
Still alive at 10.0259339809
^CTraceback (most recent call last):
  File "/tmp/demo.py", line 36, in &lt;module&gt;
    loop.run ()
KeyboardInterrupt</pre>
<p>As you can see, while it was handling the call to the Delay method it could not do anything else.  Here is a new version of the Delay function, this time implemented using asynchronous callbacks.</p>
<pre>    @dbus.service.method(dbus_interface=IFACE,
                         in_signature='i',
                         out_signature='i',
                         async_callbacks=('reply_handler',
                                          'error_handler'))
    def Delay (self, seconds, reply_handler, error_handler):
        print "Sleeping for %ds" % seconds
        gobject.timeout_add_seconds (seconds,
                                     lambda: reply_handler (seconds))</pre>
<p>You&#8217;ll notice that the D-Bus function decorator now contains an async_callbacks keyword.  This keyword declares the method keywords that the function uses for reply and error handlers.  Here, I&#8217;ve stuck with the usual &#8220;reply_handler&#8221; and &#8220;error_handler&#8221; names, and added those same names to the definition of the Delay function on the next line.</p>
<p>This time, when the D-Bus main loop calls the Delay method it will also provide the reply and error callbacks.  When the Delay method returns, its return value is ignored.  The D-Bus call is only ended by calling one of the callbacks.  In this very simple implementation, I&#8217;ve arranged for that to happen by setting a timeout.</p>
<p>How does the program behave now?</p>
<pre>Still alive at 1.07246303558
Still alive at 2.07272696495
Still alive at 3.07237696648
Still alive at 4.07276511192
Sleeping for 3s
Still alive at 5.07263112068
Still alive at 6.07277011871
Still alive at 7.07274699211
Still alive at 8.07311701775
Still alive at 9.07332015038
Still alive at 10.0734181404
Still alive at 11.0735199451
^CTraceback (most recent call last):
  File "/tmp/demo-async.py", line 38, in &lt;module&gt;
    loop.run ()
KeyboardInterrupt</pre>
<p>Much better.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2011/08/16/d-bus-and-python-asynchronous-method-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avahi support for CUPS 1.5.0</title>
		<link>http://cyberelk.net/tim/2011/08/09/avahi-support-for-cups-1-5-0/</link>
		<comments>http://cyberelk.net/tim/2011/08/09/avahi-support-for-cups-1-5-0/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 15:06:11 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Avahi]]></category>
		<category><![CDATA[cups]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=915</guid>
		<description><![CDATA[The Avahi support for CUPS has been ported to 1.5.0 now.  I&#8217;ve updated the git repository (tracking upstream CUPS, as well as having feature branches for Avahi): git://fedorapeople.org/home/fedora/twaugh/public_html/cups-avahi.git Fedora packages for F-16 and rawhide have been built.]]></description>
				<content:encoded><![CDATA[<p>The Avahi support for CUPS has been ported to 1.5.0 now.  I&#8217;ve updated the git repository (tracking upstream CUPS, as well as having feature branches for Avahi):<br />
<tt>git://fedorapeople.org/home/fedora/twaugh/public_html/cups-avahi.git</tt></p>
<p>Fedora packages for F-16 and rawhide have been built.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2011/08/09/avahi-support-for-cups-1-5-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More D-Bus goodness in system-config-printer</title>
		<link>http://cyberelk.net/tim/2011/07/22/more-d-bus-goodness-in-system-config-printer/</link>
		<comments>http://cyberelk.net/tim/2011/07/22/more-d-bus-goodness-in-system-config-printer/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 16:02:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cups]]></category>
		<category><![CDATA[printing]]></category>
		<category><![CDATA[system-config-printer]]></category>

		<guid isPermaLink="false">http://cyberelk.net/tim/?p=902</guid>
		<description><![CDATA[Previously I&#8217;ve described the D-Bus activation of dialogs in system-config-printer-1.3.  That D-Bus interface has been extended to help improve GNOME. Fedora 15 has been released for a little while now, including GNOME 3.  One of the great new features in this release of GNOME is the System Settings window.  It is easily accessed from the [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://cyberelk.net/tim/2011/04/13/using-system-config-printer-from-d-bus/">Previously</a> I&#8217;ve described the D-Bus activation of dialogs in system-config-printer-1.3.  That D-Bus interface has been extended to help improve GNOME.</p>
<p>Fedora 15 has been released for a little while now, including GNOME 3.  One of the great new features in this release of GNOME is the System Settings window.  It is easily accessed from the system menu in the top right corner of the desktop.</p>
<p><img class="size-full wp-image-903 alignnone" title="menu" src="http://cyberelk.net/tim/wp-content/uploads/2011/07/menu.png" alt="" width="160" height="284" /></p>
<p>This shows a System Settings window containing an overview of all the various tweakable settings for the system, including personal preferences.  They are shown as icons, such as &#8220;Keyboard&#8221;, &#8220;Background&#8221;, &#8220;Printers&#8221; etc, organised into groups: Personal, Hardware, System, and Other.  Clicking on one of them changes the window so it shows the settings relating to that topic.  So if you click on Printers, you get this:</p>
<p><a href="http://cyberelk.net/tim/wp-content/uploads/2011/07/Screenshot-Printers1.png"><img class="alignnone size-full wp-image-908" title="Screenshot-Printers" src="http://cyberelk.net/tim/wp-content/uploads/2011/07/Screenshot-Printers1.png" alt="" width="450" height="332" /></a></p>
<p>It&#8217;s great to have printer configuration in GNOME, and this interface is nice and simple.  There are a couple of things that it needs to learn to do though.</p>
<p><span id="more-902"></span></p>
<p>One of them is choosing a good driver when adding a printer.  This is something that is <a href="http://cyberelk.net/tim/2011/02/23/adding-a-printer-to-cups/">not easy</a>, and system-config-printer has a fair amount of logic to deal with it.  Now that logic is exposed via D-Bus, so the GNOME System Settings program will be able to use it in future.</p>
<pre>node "/org/fedoraproject/Config/Printing" {
  interface "org.fedoraproject.Config.Printing" {
    method "GetBestDrivers"      (
      in s device_id
      in s device_make_and_model
      in s device_uri
      out a(ss) drivers
    )
  }
}</pre>
<p>Given the IEEE 1284 Device ID of the printer, and/or a string describing the make and model, and the CUPS device URI to be used, this method returns a list of drivers that should work.  They are ordered with the &#8220;best&#8221; choice first, and with descriptions of how good a fit each driver is for this model (e.g. <tt>exact</tt>, <tt>close</tt>, etc).</p>
<p>Two other methods have been exposed using D-Bus.  The first is a method for examining a PPD and deciding whether it has unmet requirements.  Often a PPD will containing information about what commands to run to convert from various different formats into the format required for the printer.  This method parses those and returns a list of executables that are missing.</p>
<pre>node "/org/fedoraproject/Config/Printing" {
  interface "org.fedoraproject.Config.Printing" {
    method "MissingExecutables"      (
      in s ppd_filename
      out as missing_executables
    )
  }
}</pre>
<p>The final method is for grouping together CUPS device URIs that address the same physical device.  It is often the case that there is a choice of backends to use for a printer, and this method helps to sort out which devices are just different choices for the same printer.</p>
<pre>node "/org/fedoraproject/Config/Printing" {
  interface "org.fedoraproject.Config.Printing" {
    method "GroupPhysicalDevices"      (
      in a{sa{ss}} devices
      out aas grouped_devices
    )
  }
}</pre>
<p>It takes a dictionary (keyed by device URI) of IPP attribute dictionaries describing devices, and returns a list of physical devices, each one represented by a list of device URIs that refer to it.</p>
<p>These methods will be in system-config-printer 1.3.5.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberelk.net/tim/2011/07/22/more-d-bus-goodness-in-system-config-printer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
