Imitiating buttfly in being explicitly typed
authorEd Page <eopage@byu.net>
Sat, 29 May 2010 00:34:18 +0000 (19:34 -0500)
committerEd Page <eopage@byu.net>
Sat, 29 May 2010 00:34:18 +0000 (19:34 -0500)
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.
"""

src/aliasing.py
src/contacts.py
src/simple_presence.py

index 1ebf4c9..8476e9c 100644 (file)
@@ -1,5 +1,6 @@
 import logging
 
 import logging
 
+import dbus
 import telepathy
 
 import tp
 import telepathy
 
 import tp
@@ -127,9 +128,12 @@ class AliasingMixin(tp.ConnectionInterfaceAliasing):
        def GetAliases(self, contactHandleIds):
                _moduleLogger.debug("Called GetAliases")
 
        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
 
                )
                return idToAlias
 
index 9906a10..d57d1e1 100644 (file)
@@ -46,9 +46,9 @@ class ContactsMixin(telepathy.server.ConnectionInterfaceContacts):
                                )
 
                handle_type = telepathy.HANDLE_TYPE_CONTACT
                                )
 
                handle_type = telepathy.HANDLE_TYPE_CONTACT
-               ret = {}
+               ret = dbus.Dictionary(signature='ua{sv}')
                for handle in handles:
                for handle in handles:
-                       ret[handle] = {}
+                       ret[handle] = dbus.Dictionary(signature='sv')
 
                functions = {
                        telepathy.CONNECTION:
 
                functions = {
                        telepathy.CONNECTION:
index bda9fed..c71a5c2 100644 (file)
@@ -1,5 +1,6 @@
 import logging
 
 import logging
 
+import dbus
 import telepathy
 
 import util.misc as misc_utils
 import telepathy
 
 import util.misc as misc_utils
@@ -20,10 +21,10 @@ class TheOneRingPresence(object):
        OFFLINE = 'offline'
 
        TO_PRESENCE_TYPE = {
        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
        }
 
        @property
@@ -104,9 +105,12 @@ class SimplePresenceMixin(tp.ConnectionInterfaceSimplePresence, TheOneRingPresen
                @return {ContactHandle: (Status, Presence Type, Message)}
                """
                personalMessage = u""
                @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)
                )
 
        @misc_utils.log_exception(_moduleLogger)