from twisted.python.compat import intern, iteritems, itervalues, unicode from twisted.words.protocols.jabber import error, ijabber, jid from twisted.words.xish import domish, xmlstream from twisted.words.xish.xmlstream import STREAM_CONNECTED_EVENT from twisted.words.xish.xmlstream import STREAM_START_EVENT from twisted.words.xish.xmlstream import STREAM_END_EVENT from twisted.words.xish.xmlstream import STREAM_ERROR_EVENT try: from twisted.internet import ssl except ImportError: ssl = None if ssl and not ssl.supported: ssl = None STREAM_AUTHD_EVENT = intern("//event/stream/authd") INIT_FAILED_EVENT = intern("//event/xmpp/initfailed") NS_STREAMS = 'http://etherx.jabber.org/streams' NS_XMPP_TLS = 'urn:ietf:params:xml:ns:xmpp-tls' Reset = object() def hashPassword(sid, password): """ Create a SHA1-digest string of a session identifier and password. @param sid: The stream session identifier. @type sid: C{unicode}. @param password: The password to be hashed.
@type STREAM_ERROR_EVENT: L{str}. @var STREAM_START_EVENT: This event signals that the root element of the XML Stream has been received. For XMPP, this would be the C{<stream:stream ...>} opening tag. @type STREAM_START_EVENT: L{str}. """ from __future__ import absolute_import, division from twisted.python import failure from twisted.python.compat import intern, unicode from twisted.internet import protocol from twisted.words.xish import domish, utility STREAM_CONNECTED_EVENT = intern("//event/stream/connected") STREAM_START_EVENT = intern("//event/stream/start") STREAM_END_EVENT = intern("//event/stream/end") STREAM_ERROR_EVENT = intern("//event/stream/error") class XmlStream(protocol.Protocol, utility.EventDispatcher): """ Generic Streaming XML protocol handler. This protocol handler will parse incoming data as XML and dispatch events accordingly. Incoming stanzas can be handled by registering observers using XPath-like expressions that are matched against each stanza. See L{utility.EventDispatcher} for details. """ def __init__(self): utility.EventDispatcher.__init__(self) self.stream = None
@type STREAM_ERROR_EVENT: L{str}. @var STREAM_START_EVENT: This event signals that the root element of the XML Stream has been received. For XMPP, this would be the C{<stream:stream ...>} opening tag. @type STREAM_START_EVENT: L{str}. """ from typing import Type from twisted.python import failure from twisted.python.compat import intern, unicode from twisted.internet import protocol from twisted.words.xish import domish, utility STREAM_CONNECTED_EVENT = intern("//event/stream/connected") STREAM_START_EVENT = intern("//event/stream/start") STREAM_END_EVENT = intern("//event/stream/end") STREAM_ERROR_EVENT = intern("//event/stream/error") class XmlStream(protocol.Protocol, utility.EventDispatcher): """ Generic Streaming XML protocol handler. This protocol handler will parse incoming data as XML and dispatch events accordingly. Incoming stanzas can be handled by registering observers using XPath-like expressions that are matched against each stanza. See L{utility.EventDispatcher} for details. """ def __init__(self): utility.EventDispatcher.__init__(self) self.stream = None
from twisted.python.compat import intern, iteritems, itervalues, unicode from twisted.words.protocols.jabber import error, ijabber, jid from twisted.words.xish import domish, xmlstream from twisted.words.xish.xmlstream import STREAM_CONNECTED_EVENT from twisted.words.xish.xmlstream import STREAM_START_EVENT from twisted.words.xish.xmlstream import STREAM_END_EVENT from twisted.words.xish.xmlstream import STREAM_ERROR_EVENT try: from twisted.internet import ssl except ImportError: ssl = None if ssl and not ssl.supported: ssl = None STREAM_AUTHD_EVENT = intern("//event/stream/authd") INIT_FAILED_EVENT = intern("//event/xmpp/initfailed") NS_STREAMS = "http://etherx.jabber.org/streams" NS_XMPP_TLS = "urn:ietf:params:xml:ns:xmpp-tls" Reset = object() def hashPassword(sid, password): """ Create a SHA1-digest string of a session identifier and password. @param sid: The stream session identifier. @type sid: C{unicode}. @param password: The password to be hashed.