Esempio n. 1
0
 def handle_response(self, message, addr):
     headers = {}
     for key, values in message.headers.items():
         headers[key.replace('-', '_')] = values[0]
     self.event_func(servicetest.Event('sip-response',
         code=message.code, headers=message.headers, body=message.body,
         sip_message=message, **headers))
Esempio n. 2
0
 def register(self, message, host, port):
     if hasattr(self, 'registrar_handler'):
         self.event_func(servicetest.Event('sip-register',
             uri=str(message.uri), headers=message.headers, body=message.body,
             sip_message=message, host=host, port=port))
         if self.registrar_handler(message, host, port):
             sip.RegisterProxy.register(self, message, host, port)
         else:
             self.unauthorized(message, host, port)
    def _cb_authd(self, _):
        # called when stream is authenticated
        assert self.authenticator.full_jid is not None
        assert self.authenticator.bare_jid is not None

        self.addObserver(
            "/iq[@to='%s']/query[@xmlns='http://jabber.org/protocol/disco#info']"
            % self.domain, self._cb_disco_iq)
        self.addObserver(
            "/iq[@to='%s']/query[@xmlns='http://jabber.org/protocol/disco#info']"
            % self.authenticator.bare_jid, self._cb_bare_jid_disco_iq)
        self.event_func(servicetest.Event('stream-authenticated'))
Esempio n. 4
0
 def handle_request(self, message, addr):
     if message.method == 'REGISTER':
         return sip.RegisterProxy.handle_REGISTER_request(self, message, addr)
     elif message.method == 'OPTIONS' and \
             'REGISTRATION PROBE' == message.headers.get('subject','')[0]:
         self.deliverResponse(self.responseFromRequest(200, message))
     else:
         headers = {}
         for key, values in message.headers.items():
             headers[key.replace('-', '_')] = values[0]
         self.event_func(servicetest.Event('sip-%s' % message.method.lower(),
             uri=str(message.uri), headers=message.headers, body=message.body,
             sip_message=message, **headers))
Esempio n. 5
0
def make_stream_event(type, stanza):
    event = servicetest.Event(type, stanza=stanza)
    if stanza.hasAttribute("to"):
        event.to = stanza.getAttribute("to")
    else:
        event.to = None

    if stanza.hasAttribute("from"):
        event.from_ = stanza.getAttribute("from")
    else:
        event.from_ = None

    event.name = event.to
    event.remote_name = event.from_

    return event
Esempio n. 6
0
def make_irc_event(type, data):
    if data:
        data[-1] = data[-1].rstrip('\r\n')
    event = servicetest.Event(type, data=data)
    return event
 def connectionLost(self, reason):
     self.event_func(servicetest.Event('stream-connection-lost'))
     xmlstream.XmlStream.connectionLost(self, reason)
 def onDocumentEnd(self):
     self.event_func(servicetest.Event('stream-closed'))