X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fcontacts.py;h=41aca943970833b10d7c4081965bfd704fd30f41;hp=fd41265d9c5241475bedb26ef0e6d8022ced8330;hb=707c9235445ddf929457e6bb1850b4af6d4702f6;hpb=1c892d1b9bf14b28eb54ce3590ed2ee29d5e3d25 diff --git a/src/contacts.py b/src/contacts.py index fd41265..41aca94 100644 --- a/src/contacts.py +++ b/src/contacts.py @@ -6,7 +6,7 @@ import telepathy import util.misc as misc_utils -_moduleLogger = logging.getLogger('contacts') +_moduleLogger = logging.getLogger(__name__) class ContactsMixin(telepathy.server.ConnectionInterfaceContacts): @@ -15,7 +15,9 @@ class ContactsMixin(telepathy.server.ConnectionInterfaceContacts): telepathy.CONNECTION : 'contact-id', telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE : 'presence', telepathy.CONNECTION_INTERFACE_ALIASING : 'alias', + telepathy.CONNECTION_INTERFACE_AVATARS : 'token', telepathy.CONNECTION_INTERFACE_CAPABILITIES : 'caps', + telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES : 'capabilities' } def __init__(self): @@ -39,16 +41,17 @@ class ContactsMixin(telepathy.server.ConnectionInterfaceContacts): out_signature='a{ua{sv}}', sender_keyword='sender') def GetContactAttributes(self, handles, interfaces, hold, sender): #InspectHandle already checks we're connected, the handles and handle type. + supportedInterfaces = set() for interface in interfaces: - if interface not in self.ATTRIBUTES: - raise telepathy.errors.InvalidArgument( - 'Interface %s is not supported by GetContactAttributes' % (interface) - ) + if interface in self.ATTRIBUTES: + supportedInterfaces.add(interface) + else: + _moduleLogger.debug("Ignoring unsupported interface %s" % interface) handle_type = telepathy.HANDLE_TYPE_CONTACT - ret = {} + ret = dbus.Dictionary(signature='ua{sv}') for handle in handles: - ret[handle] = {} + ret[handle] = dbus.Dictionary(signature='sv') functions = { telepathy.CONNECTION: @@ -57,8 +60,12 @@ class ContactsMixin(telepathy.server.ConnectionInterfaceContacts): lambda x: self.GetPresences(x).items(), telepathy.CONNECTION_INTERFACE_ALIASING: lambda x: self.GetAliases(x).items(), + telepathy.CONNECTION_INTERFACE_AVATARS : + lambda x: self.GetKnownAvatarTokens(x).items(), telepathy.CONNECTION_INTERFACE_CAPABILITIES: lambda x: self.GetCapabilities(x).items(), + telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES : + lambda x: self.GetContactCapabilities(x).items() } #Hold handles if needed @@ -67,8 +74,9 @@ class ContactsMixin(telepathy.server.ConnectionInterfaceContacts): # Attributes from the interface org.freedesktop.Telepathy.Connection # are always returned, and need not be requested explicitly. - interfaces = set(interfaces + [telepathy.CONNECTION]) - for interface in interfaces: + supportedInterfaces.add(telepathy.CONNECTION) + + for interface in supportedInterfaces: interface_attribute = interface + '/' + self.ATTRIBUTES[interface] results = functions[interface](handles) for handle, value in results: