- for handleId in contacts:
- handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
+ for handleId in contactIds:
+ h = self.get_handle_by_id(telepathy.HANDLE_TYPE_CONTACT, handleId)
+ if isinstance(h, handle.ConnectionHandle):
+ isDnd = self.session.is_dnd()
+ if isDnd:
+ presence = TheOneRingPresence.HIDDEN
+ else:
+ state = self.session.stateMachine.state
+ if state == state_machine.StateMachine.STATE_ACTIVE:
+ presence = TheOneRingPresence.ONLINE
+ elif state == state_machine.StateMachine.STATE_IDLE:
+ presence = TheOneRingPresence.AWAY
+ else:
+ raise telepathy.errors.InvalidArgument("Unsupported state on the state machine: %s" % state)
+ presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
+ else:
+ presence = TheOneRingPresence.AWAY
+ presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
+
+ presences[h] = (presenceType, presence)
+ return presences