Created
April 23, 2009 23:08
-
-
Save alsemyonov/100824 to your computer and use it in GitHub Desktop.
requesting contacts from Telepathy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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