[Telepathy] Status of Telepathy Python

Danielle Madeley danielle.madeley at collabora.co.uk
Mon Jun 6 21:46:57 PDT 2011


On Tue, 2011-06-07 at 00:15 -0400, Mystilleef wrote:

> > We actually want to move people away from direct use of the D-Bus API
> > and towards using high-level, easier, useful API that calls the D-Bus
> > API for you.
>
> I see. I don't mind using the DBus APIs as long as I know what I'm
> doing.

Like I said, we're now trying to move people away from the low-level
API. If you read the ongoing thread on the list at the moment, there is
a proposal to eventually remove API stability guarantees from the
low-level API and only guarantee stability of the high-level API.

> >> I don't mind going first if I'm nudged in the right
> >> direction. Are there any example code? Can I write a full
> >> blown SIP client using tp-glib via PYGI today? Are there
> >> any limitations?
> >
> > There isn't example code doing this in Python yet. You'd need to use a
> > combination of the javascript code in gnome-shell, the telepathy-glib
> > examples + any notes that exist on how PyGI generates API. People on
> > #telepathy (irc.freenode.net) would gladly give you assistance here;
> > it's our goal that this works, but no one has any time to work on it at
> > the moment.
> >
> > There may be limitations, bugs that need fixing. Again, we haven't ever
> > actually tested this, besides some very initial work I did a long time
> > ago.
> >
> > You may end up having to make fixes to the introspection annotation in
> > tp-glib, and find that pieces of high-level API you need are missing.
> > OTOH, you _should_ be able to write a client at least as complete as
> > gnome-shell.
> >
> 
> I'll look into this. However, I'm nervous about writing an application using
> Gobject Introspection. I've written a small app using it, but I'm not sure,
> I'd use it for a big application, yet.

There is no longer any PyGTK (since gtk3, nor for python3),
gobject-introspection is the future of GNOME/GTK+ in Python.

> > I happily welcome contributed/updated examples. Unfortunately I don't
> > have any time to really invest in the docs at the moment.
> 
> I'd be more qualified to contribute when I _know_ what I'm doing. Newbies like
> myself shouldn't be anywhere near the docs or examples. :-)

Contributions to Telepathy get reviewed. So you'd not be contributing
unseen/unreviewed code :)

> > Telepathy is meant to be used entirely asynchronously. You need to ready
> > the object.
> 
> What object do I need to ready? Dbus Proxy objects, AccountManager, Account,
> Connection objects? Or all of the above?

Generally all proxy objects (AM, Account, Conn, Channel). There might be
some objects that don't have a ready mechanism, which is arguably a bug,
but means there's nothing that object must do to ready itself.

> >> After establishing a connection I can't use the
> >> CONNECTION_INTERFACE_REQUESTS DBus interface at all.
> >>
> >> connection[CONNECTION_INTERFACE_REQUESTS] always raises an
> >> error. I'm I not supposed to call that interface?
> >
> > Well, ideally you should make your requests to the ChannelDispatcher,
> > which will forward them to the appropriate Connection for you. However
> > your problem is not having prepared the object, so it doesn't know what
> > interfaces are available.
> 
> Yeah, I read that in the documentation (developer's manual). If I remember
> correctly I need to use the AccountManager/Accounts and the ChannelDispatcher
> to initialize connections. I couldn't find any example code in Python
> though. I'll
> try to see if I can find examples for tp-glib.

To get a Connection in low-level Telepathy:
 - request and prep the AccountManager object
 - get the ValidAccounts property
 - request and prep the Account object
 - get the Connection property
 - request and prep the Connection object

In high level telepathy it would be similar:

        am = Tp.AccountManager.dup()
        am.prepare_async()
        ~ callback ~
        for account in am.get_valid_accounts():
          conn = account.get_connection()
          conn.prepare_async()

The ChannelDispatcher takes a channel request map, plus an account
object path. There is no ChannelDispatcher object in tp-python (someone
should add them, it really is unmaintained), you can implement them
easily enough:

        import dbus
        
        from telepathy.client.interfacefactory import InterfaceFactory
        from telepathy.interfaces import *
        from telepathy.constants import *
        
        class ChannelDispatcher(InterfaceFactory):
            def __init__(self, bus=None):
                if not bus:
                    bus = dbus.Bus()
        
                self.service_name = CHANNEL_DISPATCHER
                self.object_path = '/' + self.service_name.replace('.', '/')
                object = bus.get_object(self.service_name, self.object_path)
                InterfaceFactory.__init__(self, object, CHANNEL_DISPATCHER)
        
        class ChannelRequest(InterfaceFactory):
            def __init__(self, path, bus=None):
                if not bus:
                    bus = dbus.Bus()
        
                self.service_name = CHANNEL_DISPATCHER
                self.object_path = path
                object = bus.get_object(self.service_name, self.object_path)
                InterfaceFactory.__init__(self, object, CHANNEL_REQUEST)

-- 
Danielle Madeley
Software Developer, Collabora Ltd.                  Melbourne, Australia

www.collabora.co.uk



More information about the telepathy mailing list