[Telepathy] how to use empathy's TubeHandler in python?

Will Thompson will.thompson at collabora.co.uk
Wed Feb 18 02:40:30 PST 2009


Hi,

Jiri Baum wrote:
> As far as I can tell, this should be the EmpathyTubeHandler, which appears in 
> the python-empathy library as empathy.TubeHandler; however, when I try to 
> instantiate that class, I get: NotImplementedError: empathy.TubeHandler is an 
> abstract widget

The EmpathyTubeHandler abstract class helps you implement the D-Bus
interface I describe below, but in Python it's easiest to just do it
directly.

> I also tried requesting the name "org.gnome.Empathy.DTubeHandler.%s"%SERVICE 
> from D-Bus; that looks like it's close to the right thing, because when the 
> tube arrives, Empathy falls over (mostly because I don't have any real object 
> attached there).
> 
> Google finds very little in the way of either documentation or code...
> 
> What am I doing wrong, please? Is there a function in python-empathy that I 
> should be calling? Example code that I should be copying? Documentation that 
> I should be reading?

This is not at all obvious or documented. Sorry. :)

There's a D-Bus interface defined in Empathy named
'org.gnome.Empathy.TubeHandler', which (as of my git checkout of
Empathy; this has changed recently to move to new-style tubes) has a
single method, named HandleTube. It takes five arguments:

* Bus_Name (type s): the bus name of the connection and the tube channel
* Connection (type o): the connection's object path.
* Channel (type o): the tube channel's object path.
* Handle_Type (type u): the tube channel's target handle type, if there
is one, or Handle_Type_None (== 0) if there is not.
* Handle (type u): if Handle_Type is not None, the target handle of the
channel.

(In older Empathies which spoke old-style tubes, there was an extra
parameter for the tube id, and possibly another one for the type of tube.)

When Empathy sees a new stream tube with Service='foo', it looks for a
service named org.gnome.Empathy.StreamTubeHandler.foo; if that exists,
it calls org.gnome.Empathy.TubeHandler.HandleTube(...) on its object
/org/gnome/Empathy/StreamTubeHandler/foo .

In principle, the handler for Channel.Type.DBusTube with
Service='bar.baz' should take the bus name
org.gnome.Empathy.DTubeHandler.bar.baz and have an object at
/org/gnome/Empathy/DTubeHandler/bar/baz with the HandleTube() method,
and then everything should work. However:

* in old, pre-new-style-tubes Empathy, there was a bug in this code so
that the service name was not escaped, and thus Empathy would construct
an illegal object path and make libdbus assert. :D I'm not sure this was
fixed before...
* in the glorious future where Empathy only understands new-style tubes,
I don't think DBus tubes have been hooked up yet. This shouldn't be that
hard to do; Sjoerd said he might have time, but if you want to rummage
around in Empathy's dispatcher I'm sure #telepathy would be happy to
help. :-)

-- 
Will

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.freedesktop.org/archives/telepathy/attachments/20090218/4536afc3/attachment.pgp 


More information about the telepathy mailing list