Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alsemyonov/100824 to your computer and use it in GitHub Desktop.
Save alsemyonov/100824 to your computer and use it in GitHub Desktop.
requesting contacts from Telepathy
import telepathy
import telepathy.client
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from telepathy.constants import (
CONNECTION_HANDLE_TYPE_CONTACT, CONNECTION_HANDLE_TYPE_LIST,
CHANNEL_TEXT_MESSAGE_TYPE_NORMAL)
from telepathy.interfaces import (
CHANNEL_INTERFACE_GROUP, CHANNEL_TYPE_CONTACT_LIST,
CHANNEL_TYPE_TEXT,
CONN_INTERFACE)
contacts = []
dbus_loop = DBusGMainLoop()
bus = dbus.SessionBus(mainloop=dbus_loop)
connections = telepathy.client.conn.Connection.get_connections(bus)
for connection in connections:
handle = connection[CONN_INTERFACE].RequestHandles(CONNECTION_HANDLE_TYPE_LIST, ['known'])[0]
channel = connection.request_channel(CHANNEL_TYPE_CONTACT_LIST, CONNECTION_HANDLE_TYPE_LIST, handle, True)
current, local_pending, remote_pending = (
channel[CHANNEL_INTERFACE_GROUP].GetAllMembers())
members = connection[CONN_INTERFACE].InspectHandles(
CONNECTION_HANDLE_TYPE_CONTACT, current)
for member, member_h in zip(members, current):
contacts.append((member, member_h))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment