def _NH_XMPPGotComposingIndication(self, notification): composing_indication = notification.data.composing_indication sender = composing_indication.sender recipient = composing_indication.recipient if not XMPPGatewayConfig.use_msrp_for_chat: state = 'active' if composing_indication.state == 'composing' else 'idle' try: interval = composing_indication.interval except AttributeError: interval = 60 body = IsComposingMessage( state=State(state), refresh=Refresh(interval), last_active=LastActive(ISOTimestamp.now()), content_type=ContentType('text')).toxml() message = NormalMessage(sender, recipient, body) sip_message_sender = SIPMessageSender( message, content_type=IsComposingDocument.content_type, use_cpim=XMPPGatewayConfig.use_cpim) if XMPPGatewayConfig.log_iscomposing: log.info('xmpp:%s to sip:%s chat is %s' % (sender, recipient, composing_indication.state)) try: sip_message_sender.send().wait() except SIPMessageError as e: if XMPPGatewayConfig.log_iscomposing: log.error('SIP Message from %s to %s failed: %s (%s)' % (sender, recipient, e.reason, e.code))
def chatView_becameActive_(self, chatView, last_active): if self.enableIsComposing: content = IsComposingMessage( state=State("active"), refresh=Refresh(60), last_active=LastActive(last_active or datetime.now()), content_type=ContentType('text')).toxml() self.sendMessage(content, IsComposingDocument.content_type)
def _NH_XMPPGotComposingIndication(self, notification): composing_indication = notification.data.composing_indication sender = composing_indication.sender recipient = composing_indication.recipient if not XMPPGatewayConfig.use_msrp_for_chat: state = 'active' if composing_indication.state == 'composing' else 'idle' body = IsComposingMessage(state=state, refresh=composing_indication.interval or 30).toxml() message = NormalMessage(sender, recipient, body, IsComposingDocument.content_type) sip_message_sender = SIPMessageSender(message) try: sip_message_sender.send().wait() except SIPMessageError as e: # TODO report back an error stanza log.error('Error sending SIP Message: %s' % e)