[packagekit] glib2 status update

Richard Hughes hughsient at gmail.com
Fri Sep 4 05:14:03 PDT 2009


As some of you might be watching git and reading the commits, I
thought I would update you all with the progress of the glib2
bindings.

Overall, working with everything asynchronous works really well. The
GUI clients will benefit the most, although it makes the text clients
much simpler too:

[hughsie at hughsie-laptop client]$ wc -l pk-console*.c
  2580 pk-console.c
  1625 pk-console-test.c

One of the main benefits is that the "dance" (the multiple
transactions) can be done asynchronously, and completely hidden from
the client. To do this, I've added the following classes:

PkControl: For getting properties on the main interface, and doing
methods such as GetTid
PkClient: For scheduling a single transaction
PkResults: For storing the completed results of the transaction
(packages, update-details, all the objects)
PkProgress: For storing current progress, for passing to async clients
PkTask: For managing the "dance", for instance, requeuing transaction
for simulate, gpg-keys, eulas and for trusted. It superclasses
PkClient.

Now, PkTask on it's own isn't very interesting, as it fails at every
step of the dance by default. PkTask does however have klass methods
that can be overridden by classes implementing PkTask. There's an
example I made for the "make check" functionality called PkTaskWrapper
which basically accepts each step of the dance without asking the
user.

More interestingly, there's a class called PkTaskText (in client/)
that implements PkTask and handles all the callbacks using console
commands like fgets.

This means that pkcon can create an instance of PkTaskText, and all
the interactions are done for it in the PkTaskText object. The actual
interaction is hidden from pkcon, amd all it gets is the progress
callback as the transactions are scheduled. And because PkTaskText can
be used as a PkTask, it can also be used as a PkClient, so the methods
that are not wrapped can be used with a single object.
It also means that other clients can just use PkTaskText and get all
the complex interaction stuff handled automatically.

Of course, in gnome-packagekit, it will make things much cleaner as
each PkClient can be converted to use the async GpkTask, which will
handle all the interactions. So, instead of having all the scary logic
about what methods to send in response to different signals and return
codes in multiple places, we can just derive from PkTask and do them
all in one place.

It makes things a lot simpler, I can assure you.

Richard.


More information about the PackageKit mailing list