# Path: pyxmpp2/streambase.py
# LANG_SPLIT_RE = re.compile(r"(.*)(?:-[a-zA-Z0-9])?-[a-zA-Z0-9]+$")
# ERROR_TAG = STREAM_QNP + u"error"
# FEATURES_TAG = STREAM_QNP + u"features"
# IP_RE = re.compile(r"^((\d+.){3}\d+)|([0-9a-f]*:[0-9a-f:]*:[0-9a-f]*)$")
# class StreamBase(XMLStreamHandler):
#     def __init__(self, stanza_namespace, stanza_route, handlers,
#                                                             settings = None):
#     def initiate(self, transport, to = None):
#     def _initiate(self):
#     def receive(self, transport, myname):
#     def _setup_stream_element_handlers(self):
#     def disconnect(self):
#     def event(self, event): # pylint: disable-msg=R0201
#     def transport_connected(self):
#     def close(self):
#     def stream_start(self, element):
#     def stream_end(self):
#     def stream_eof(self):
#     def stream_element(self, element):
#     def stream_parse_error(self, descr):
#     def _send_stream_start(self, stream_id = None, stream_to = None):
#     def send_stream_error(self, condition):
#     def _send_stream_error(self, condition):
#     def _restart_stream(self):
#     def _make_stream_features(self):
#     def _send_stream_features(self):
#     def write_element(self, element):
#     def _write_element(self, element):
#     def send(self, stanza):
#     def _send(self, stanza):
#     def _process_element(self, element):
#     def uplink_receive(self, stanza):
#     def process_stream_error(self, error):
#     def check_to(self, to):
#     def generate_id(self):
#     def _got_features(self, features):
#     def is_connected(self):
#     def set_peer_authenticated(self, peer, restart_stream = False):
#     def set_authenticated(self, me, restart_stream = False):
#     def fix_in_stanza(self, stanza):
#     def fix_out_stanza(self, stanza):
#     def auth_properties(self):
# def _languages_factory(settings):
# 
# Path: pyxmpp2/utils.py
# def xml_elements_equal(element1, element2, ignore_level1_cdata = False):
# def datetime_utc_to_local(utc):
# def datetime_local_to_utc(local):
# _MINUTE = datetime.timedelta(minutes = 1)
# _NULLDELTA = datetime.timedelta()
# 
# Path: pyxmpp2/exceptions.py
# class StreamError(Error):
#     """Base class for all stream errors."""
#     pass
# 
# class FatalStreamError(StreamError):
#     """Base class for all fatal Stream exceptions.
# 
#     When `FatalStreamError` is raised the stream is no longer usable."""
#     pass
# 
# class ComponentStreamError(StreamError):
#     """Raised on a component error."""
#     pass
# 
# class FatalComponentStreamError(ComponentStreamError, FatalStreamError):
#     """Raised on a fatal component error."""
#     pass


import hashlib
import logging
from ..stream import Stream
from ..streambase import stanza_factory,HostMismatch
from ..xmlextra import common_doc,common_root
from ..utils import to_utf8
from ..exceptions import StreamError,FatalStreamError,ComponentStreamError,FatalComponentStreamError

        [server only]

        :Parameters:
            - `sock`: a listening socket."""
        Stream.accept(self,sock,None)

    def stream_start(self,doc):
        """Process <stream:stream> (stream start) tag received from peer.

        Call `Stream.stream_start`, but ignore any `HostMismatch` error.

        :Parameters:
            - `doc`: document created by the parser"""
        try:
            Stream.stream_start(self,doc)
        except HostMismatch:
            pass

    def _post_connect(self):
        """Initialize authentication when the connection is established
        and we are the initiator."""
        if self.initiator:
            self._auth()

    def _compute_handshake(self):
        """Compute the authentication handshake value.

        :return: the computed hash value.
        :returntype: `str`"""

# Path: pyxmpp2/streambase.py
# LANG_SPLIT_RE = re.compile(r"(.*)(?:-[a-zA-Z0-9])?-[a-zA-Z0-9]+$")
# ERROR_TAG = STREAM_QNP + u"error"
# FEATURES_TAG = STREAM_QNP + u"features"
# IP_RE = re.compile(r"^((\d+.){3}\d+)|([0-9a-f]*:[0-9a-f:]*:[0-9a-f]*)$")
# class StreamBase(XMLStreamHandler):
#     def __init__(self, stanza_namespace, stanza_route, handlers,
#                                                             settings = None):
#     def initiate(self, transport, to = None):
#     def _initiate(self):
#     def receive(self, transport, myname):
#     def _setup_stream_element_handlers(self):
#     def disconnect(self):
#     def event(self, event): # pylint: disable-msg=R0201
#     def transport_connected(self):
#     def close(self):
#     def stream_start(self, element):
#     def stream_end(self):
#     def stream_eof(self):
#     def stream_element(self, element):
#     def stream_parse_error(self, descr):
#     def _send_stream_start(self, stream_id = None, stream_to = None):
#     def send_stream_error(self, condition):
#     def _send_stream_error(self, condition):
#     def _restart_stream(self):
#     def _make_stream_features(self):
#     def _send_stream_features(self):
#     def write_element(self, element):
#     def _write_element(self, element):
#     def send(self, stanza):
#     def _send(self, stanza):
#     def _process_element(self, element):
#     def uplink_receive(self, stanza):
#     def process_stream_error(self, error):
#     def check_to(self, to):
#     def generate_id(self):
#     def _got_features(self, features):
#     def is_connected(self):
#     def set_peer_authenticated(self, peer, restart_stream = False):
#     def set_authenticated(self, me, restart_stream = False):
#     def fix_in_stanza(self, stanza):
#     def fix_out_stanza(self, stanza):
#     def auth_properties(self):
# def _languages_factory(settings):
# 
# Path: pyxmpp2/utils.py
# def xml_elements_equal(element1, element2, ignore_level1_cdata = False):
# def datetime_utc_to_local(utc):
# def datetime_local_to_utc(local):
# _MINUTE = datetime.timedelta(minutes = 1)
# _NULLDELTA = datetime.timedelta()
# 
# Path: pyxmpp2/exceptions.py
# class StreamError(Error):
#     """Base class for all stream errors."""
#     pass
# 
# class FatalStreamError(StreamError):
#     """Base class for all fatal Stream exceptions.
# 
#     When `FatalStreamError` is raised the stream is no longer usable."""
#     pass
# 
# class ComponentStreamError(StreamError):
#     """Raised on a component error."""
#     pass
# 
# class FatalComponentStreamError(ComponentStreamError, FatalStreamError):
#     """Raised on a fatal component error."""
#     pass


# Path: pyxmpp2/ext/component.py
import hashlib
import logging
from ..stream import Stream
from ..streambase import stanza_factory,HostMismatch
from ..xmlextra import common_doc,common_root
from ..utils import to_utf8
from ..exceptions import StreamError,FatalStreamError,ComponentStreamError,FatalComponentStreamError


        [server only]

        :Parameters:
            - `sock`: a listening socket."""
        Stream.accept(self,sock,None)

    def stream_start(self,doc):
        """Process <stream:stream> (stream start) tag received from peer.

        Call `Stream.stream_start`, but ignore any `HostMismatch` error.

        :Parameters:
            - `doc`: document created by the parser"""
        try:
            Stream.stream_start(self,doc)
        except HostMismatch:
            pass

    def _post_connect(self):
        """Initialize authentication when the connection is established
        and we are the initiator."""
        if self.initiator:
            self._auth()

    def _compute_handshake(self):
        """Compute the authentication handshake value.

        :return: the computed hash value.
        :returntype: `str`"""

        return hashlib.sha1(to_utf8(self.stream_id)+to_utf8(self.secret)).hexdigest()