7 _moduleLogger = logging.getLogger('contacts')
10 class ContactsMixin(telepathy.server.ConnectionInterfaceContacts):
13 telepathy.CONNECTION : 'contact-id',
14 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE : 'presence',
15 telepathy.CONNECTION_INTERFACE_ALIASING : 'alias',
16 telepathy.CONNECTION_INTERFACE_CAPABILITIES : 'caps',
20 telepathy.server.ConnectionInterfaceContacts.__init__(self)
22 dbus_interface = telepathy.CONNECTION_INTERFACE_CONTACTS
23 self._implement_property_get(
25 {'ContactAttributeInterfaces' : self.get_contact_attribute_interfaces}
28 def HoldHandles(self, *args):
32 raise NotImplementedError("Abstract function called")
34 # Overwrite the dbus attribute to get the sender argument
35 @dbus.service.method(telepathy.CONNECTION_INTERFACE_CONTACTS, in_signature='auasb',
36 out_signature='a{ua{sv}}', sender_keyword='sender')
37 def GetContactAttributes(self, handles, interfaces, hold, sender):
38 #InspectHandle already checks we're connected, the handles and handle type.
39 for interface in interfaces:
40 if interface not in self.ATTRIBUTES:
41 raise telepathy.errors.InvalidArgument(
42 'Interface %s is not supported by GetContactAttributes' % (interface)
45 handle_type = telepathy.HANDLE_TYPE_CONTACT
47 for handle in handles:
52 lambda x: zip(x, self.InspectHandles(handle_type, x)),
53 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE:
54 lambda x: self.GetPresences(x).items(),
55 telepathy.CONNECTION_INTERFACE_ALIASING:
56 lambda x: self.GetAliases(x).items(),
57 telepathy.CONNECTION_INTERFACE_CAPABILITIES:
58 lambda x: self.GetCapabilities(x).items(),
61 #Hold handles if needed
63 self.HoldHandles(handle_type, handles, sender)
65 # Attributes from the interface org.freedesktop.Telepathy.Connection
66 # are always returned, and need not be requested explicitly.
67 interfaces = set(interfaces + [telepathy.CONNECTION])
68 for interface in interfaces:
69 interface_attribute = interface + '/' + self.ATTRIBUTES[interface]
70 results = functions[interface](handles)
71 for handle, value in results:
72 ret[int(handle)][interface_attribute] = value
75 def get_contact_attribute_interfaces(self):
76 return self.ATTRIBUTES.keys()