From: Ed Page Date: Sat, 29 May 2010 00:34:18 +0000 (-0500) Subject: Imitiating buttfly in being explicitly typed X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=afa4cdb64e451070cf87cc02f257c582fa057f53;p=theonering Imitiating buttfly in being explicitly typed From there commit message """ Be explicit about data types in methods that produce contact attributes Previously, the wrong type was returned for SimplePresence/presence. Until telepathy-glib 0.11.3, this was masked by the fact that TpContact would respond to missing or wrongly-typed information in the result of GetContactAttributes by falling back to a slower path. This is no longer done, meaning that all Butterfly contacts appear to have UNKNOWN presence. """ --- diff --git a/src/aliasing.py b/src/aliasing.py index 1ebf4c9..8476e9c 100644 --- a/src/aliasing.py +++ b/src/aliasing.py @@ -1,5 +1,6 @@ import logging +import dbus import telepathy import tp @@ -127,9 +128,12 @@ class AliasingMixin(tp.ConnectionInterfaceAliasing): def GetAliases(self, contactHandleIds): _moduleLogger.debug("Called GetAliases") - idToAlias = dict( - (handleId, self._get_alias(handleId)) - for handleId in contactHandleIds + idToAlias = dbus.Dictionary( + ( + (handleId, self._get_alias(handleId)) + for handleId in contactHandleIds + ), + signature="us", ) return idToAlias diff --git a/src/contacts.py b/src/contacts.py index 9906a10..d57d1e1 100644 --- a/src/contacts.py +++ b/src/contacts.py @@ -46,9 +46,9 @@ class ContactsMixin(telepathy.server.ConnectionInterfaceContacts): ) 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: diff --git a/src/simple_presence.py b/src/simple_presence.py index bda9fed..c71a5c2 100644 --- a/src/simple_presence.py +++ b/src/simple_presence.py @@ -1,5 +1,6 @@ import logging +import dbus import telepathy import util.misc as misc_utils @@ -20,10 +21,10 @@ class TheOneRingPresence(object): OFFLINE = 'offline' TO_PRESENCE_TYPE = { - ONLINE: telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE, - AWAY: telepathy.constants.CONNECTION_PRESENCE_TYPE_AWAY, - HIDDEN: telepathy.constants.CONNECTION_PRESENCE_TYPE_HIDDEN, - OFFLINE: telepathy.constants.CONNECTION_PRESENCE_TYPE_OFFLINE, + ONLINE: dbus.UInt32(telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE), + AWAY: dbus.UInt32(telepathy.constants.CONNECTION_PRESENCE_TYPE_AWAY), + HIDDEN: dbus.UInt32(telepathy.constants.CONNECTION_PRESENCE_TYPE_HIDDEN), + OFFLINE: dbus.UInt32(telepathy.constants.CONNECTION_PRESENCE_TYPE_OFFLINE), } @property @@ -104,9 +105,12 @@ class SimplePresenceMixin(tp.ConnectionInterfaceSimplePresence, TheOneRingPresen @return {ContactHandle: (Status, Presence Type, Message)} """ personalMessage = u"" - return dict( - (h, (presenceType, presence, personalMessage)) - for (h, (presenceType, presence)) in self.get_presences(contacts).iteritems() + return dbus.Dictionary( + ( + (h, dbus.Struct((presenceType, presence, personalMessage), signature="uss")) + for (h, (presenceType, presence)) in self.get_presences(contacts).iteritems() + ), + signature="u(uss)" ) @misc_utils.log_exception(_moduleLogger)