danielle.madeley at collabora.co.uk
Mon Nov 23 15:40:00 PST 2009
Based on a suggestion from Sjoerd, I have put together TpHandler, a
GObject class that handles practically all of the heavy-lifting required
to implement a Handler.
It's designed so that no subclassing is required (but is possible), an
example Handler looks like this:
Obviously a TpObserver and TpApprover class could also exist, however
it's not possible using this pattern to design a class that can be any
combination of the three (unless someone can think of a way to
optionally publish methods on the bus, based on what callbacks are
supplied, in which case.. neat).
The only thing I'm a bit dubious about is the automatic tracking of
channels for HandleChannels (all channels passed to HandleChannels are
automatically added to the HandledChannels list, and are removed when
the channel is closed). In turn, disposing the GObject closes all of the
still open channels. This is not going to fly in the case where you are
registering a temporary client with some special filter. It might be
possible to have a "close-channels-on-dispose" property that can be set
to FALSE, combined with a tp_handler_track_channel() method call so that
a temporary Handler can pass a channel off to the real Handler, but in
general things will work correctly.
I'm planning on extending this today to support
Client.Interface.Requests using GSignals (since implementing these
callbacks is neither here nor there, and you should be able to implement
as many of them as you want, unlike the main HandleChannels callback).
Everyone should feel free to jump on and bikeshed now.
Collabora Ltd., Melbourne, Australia
More information about the telepathy