The following is a minimal example on using Telepathy with Python. It uses Telepathy directly trough DBus. You might want to consider using (not finished) telepathy-python library instead. Note that the example does not use any callbacks, which is required for anything more fancy (like knowing about connection state). Using callbacks however requires mainloop/event loop (probably by using telepathy-glib, qt, gtk, ..). The example should highlight Telepathy's depency on DBus.
See also dbus-python tutorial
import dbus
from time import sleep
# connect to the bus
bus = dbus.SessionBus()
# get (gabble) connection manager from dbus
proxy_obj = bus.get_object('org.freedesktop.Telepathy.ConnectionManager.gabble',
'/org/freedesktop/Telepathy/ConnectionManager/gabble')
dbus_iface = dbus.Interface(proxy_obj,'org.freedesktop.Telepathy.ConnectionManager')
params = {}
params['account'] = ''
params['password'] = ''
# get connection object from connection manager and use it
(a,b) = dbus_iface.RequestConnection('jabber', params)
proxy_obj = bus.get_object(a,b)
dbus_iface = dbus.Interface(proxy_obj, 'org.freedesktop.Telepathy.Connection')
# note that at this point, any listening callback functions should receive "connecting, connected, network error" type signals
dbus_iface.Connect()
sleep (2)
channels = dbus_iface.ListChannels()
for channel in channels:
obj_path, iface_name, handle_type, handle = channel
print 'obj_path ', obj_path
print 'iface_name ', iface_name
print 'handle_type', handle_type
print 'handle ', handle
print '***'
sleep (5)
dbus_iface.Disconnect()
