1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18  """Generic XMPP stream implementation. 
 19   
 20  Normative reference: 
 21    - `RFC 3920 <http://www.ietf.org/rfc/rfc3920.txt>`__ 
 22  """ 
 23   
 24  __revision__="$Id: stream.py 678 2008-08-08 11:22:14Z jajcus $" 
 25  __docformat__="restructuredtext en" 
 26   
 27  import logging 
 28   
 29  from pyxmpp.streambase import StreamBase 
 30  from pyxmpp.streamtls import StreamTLSMixIn 
 31  from pyxmpp.streamsasl import StreamSASLMixIn 
 32   
 33 -class Stream(StreamTLSMixIn,StreamSASLMixIn,StreamBase): 
  34      """Generic XMPP stream class. 
 35   
 36      Responsible for establishing connection, parsing the stream, 
 37      StartTLS encryption and SASL authentication negotiation 
 38      and usage, dispatching received stanzas to apopriate handlers 
 39      and sending application's stanzas. 
 40   
 41      Whenever we say "stream" here we actually mean two streams 
 42      (incoming and outgoing) of one connections, as defined by the XMPP 
 43      specification. 
 44   
 45      :Ivariables: 
 46          - `lock`: RLock object used to synchronize access to Stream object. 
 47          - `features`: stream features as annouced by the initiator. 
 48          - `me`: local stream endpoint JID. 
 49          - `peer`: remote stream endpoint JID. 
 50          - `process_all_stanzas`: when `True` then all stanzas received are 
 51            considered local. 
 52          - `tls`: TLS connection object. 
 53          - `initiator`: `True` if local stream endpoint is the initiating entity. 
 54          - `_reader`: the stream reader object (push parser) for the stream. 
 55      """ 
 56 -    def __init__(self, default_ns, extra_ns = (), sasl_mechanisms = (), 
 57                      tls_settings = None, keepalive = 0, owner = None): 
  58          """Initialize Stream object 
 59   
 60          :Parameters: 
 61            - `default_ns`: stream's default namespace ("jabber:client" for 
 62              client, "jabber:server" for server, etc.) 
 63            - `extra_ns`: sequence of extra namespace URIs to be defined for 
 64              the stream. 
 65            - `sasl_mechanisms`: sequence of SASL mechanisms allowed for 
 66              authentication. Currently "PLAIN", "DIGEST-MD5" and "GSSAPI" are supported. 
 67            - `tls_settings`: settings for StartTLS -- `TLSSettings` instance. 
 68            - `keepalive`: keepalive output interval. 0 to disable. 
 69            - `owner`: `Client`, `Component` or similar object "owning" this stream. 
 70          """ 
 71          StreamBase.__init__(self, default_ns, extra_ns, keepalive, owner) 
 72          StreamTLSMixIn.__init__(self, tls_settings) 
 73          StreamSASLMixIn.__init__(self, sasl_mechanisms) 
 74          self.__logger = logging.getLogger("pyxmpp.Stream") 
  75   
 82   
 93   
 95          """Process first level element of the stream. 
 96   
 97          The element may be stream error or features, StartTLS 
 98          request/response, SASL request/response or a stanza. 
 99   
100          :Parameters: 
101              - `xmlnode`: XML node describing the element 
102          """ 
103          if self._process_node_tls(xmlnode): 
104              return 
105          if self._process_node_sasl(xmlnode): 
106              return 
107          StreamBase._process_node(self,xmlnode) 
 108   
 121   
122   
123