4 import util.misc as misc_utils
7 _moduleLogger = logging.getLogger(__name__)
10 class PresenceMixin(tp.ConnectionInterfacePresence):
12 def __init__(self, torPresence):
13 tp.ConnectionInterfacePresence.__init__(self)
14 self.__torPresence = torPresence
16 @misc_utils.log_exception(_moduleLogger)
17 def GetStatuses(self):
18 # the arguments are in common to all on-line presences
22 (localType, (telepathyType, True, True, arguments))
23 for (localType, telepathyType) in self.__torPresence.TO_PRESENCE_TYPE.iteritems()
26 @misc_utils.log_exception(_moduleLogger)
27 def RequestPresence(self, contactIds):
28 presences = self.__get_presences(contactIds)
29 self.PresenceUpdate(presences)
31 @misc_utils.log_exception(_moduleLogger)
32 def GetPresence(self, contactIds):
33 return self.__get_presences(contactIds)
35 @misc_utils.log_exception(_moduleLogger)
36 def SetStatus(self, statuses):
37 assert len(statuses) == 1
38 status, arguments = statuses.items()[0]
39 assert len(arguments) == 0
40 self.__torPresence.set_presence(status)
42 def __get_presences(self, contacts):
45 (h, (0, {presence: arguments}))
46 for (h, (presenceType, presence)) in self.__torPresence.get_presences(contacts).iteritems()