PolicyKit and KDE, we are ready
Hey guys, as you see, I’m not dead, just busy as always. But today I found some time to show you what we’ve been working on since some months: PolicyKit support for KDE.
This post is aimed both to users and to developers. So let’s start with the first category.
PolicyKit-KDE sits in extragear now, but will hit kdebase-workspace in time for 4.3. It includes an authorization manager and an authentication agent. But screenshots sometimes are better:
Yes, I forgot to tell you that the Authorization manager can be used both in SystemSettings and as a standalone application. So for everyone who was still trembling on PolicyKit support in KDE: that’s exactly what you were asking for
Now to developers: we created a library, named Polkit-qt, that is also used by our authorization manager. It lets you integrate with a lot of ease your application with PolicyKit. How easy? Just as:
ActionButton *bt = new ActionButton(cryPB, "org.qt.policykit.examples.cry", this);
connect(bt, SIGNAL(triggered(bool)), this, SLOT(activateAction()));
connect(bt, SIGNAL(clicked(QAbstractButton*,bool)), bt, SLOT(activate()));
connect(bt, SIGNAL(activated()), this, SLOT(actionActivated()));
This code associates the QPushButton “cryPB” with the action org.qt.policykit.examples.cry. The library will take also care of editing the properties of your button according to the action’s authorization state. You can also use it as a QAction for inserting it into menus or toolbars. And through some nice signals, you can monitor and activate your actions with ease.
Obviously, the library gives you a lot more: you can manage stand-alone authorizations without GUI elements, informations on PolicyKit context, a special ActionButtons class to associate an infinite number of QAbstractButtons to a single Action, and everything you need to be productive with PolicyKit, but with the ease of Qt.
I keep saying Qt (and you would have noticed this in the code too), because the library is Qt only. We wanted to give the same ease to everyone using Qt, and not only KDE. It sits now in kdesupport, along with an extensive API documentation and a self-explainatory example. You are encouraged to try it out, there are no more reasons for you not to take advantage of PolicyKit in your application now.
Bottom line: we started as second-class citiziens with PolicyKit, but now our support, both for users and developers, is more than complete and is the one that grants most ease of use and less dependencies. A huge step forward.
Forgot to say: you would want to say thanks to Daniel Nicoletti, that is the one who put the majority of the code in there. Without his PolicyKit knowledge it would have been impossible to do all of this.
I will release a tarball for PolicyKit-KDE and Polkit-Qt in the next days. Packagers of distributions using PolicyKit (so most ones) are encouraged to pick up at least the Polkit-Qt tarball and start packaging it, since it will become an optional dependency of kdebase-workspace in 4.3 (and I hope a strong one for more applications in the future).
P.S.: Before you ask it, Solid-Wicd is almost completed, expect a post on it soon.
Enough talk, see you next time