~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/words/protocols/jabber/ijabber.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2001-2006 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
"""
 
5
Public Jabber Interfaces.
 
6
"""
 
7
 
 
8
from zope.interface import Attribute, Interface
 
9
 
 
10
class IInitializer(Interface):
 
11
    """
 
12
    Interface for XML stream initializers.
 
13
 
 
14
    Initializers perform a step in getting the XML stream ready to be
 
15
    used for the exchange of XML stanzas.
 
16
    """
 
17
 
 
18
class IInitiatingInitializer(IInitializer):
 
19
    """
 
20
    Interface for XML stream initializers for the initiating entity.
 
21
    """
 
22
 
 
23
    xmlstream = Attribute("""The associated XML stream""")
 
24
 
 
25
    def initialize():
 
26
        """
 
27
        Initiate the initialization step.
 
28
 
 
29
        May return a deferred when the initialization is done asynchronously.
 
30
        """
 
31
 
 
32
class IIQResponseTracker(Interface):
 
33
    """
 
34
    IQ response tracker interface.
 
35
 
 
36
    The XMPP stanza C{iq} has a request-response nature that fits
 
37
    naturally with deferreds. You send out a request and when the response
 
38
    comes back a deferred is fired.
 
39
 
 
40
    The L{IQ} class implements a C{send} method that returns a deferred. This
 
41
    deferred is put in a dictionary that is kept in an L{XmlStream} object,
 
42
    keyed by the request stanzas C{id} attribute.
 
43
 
 
44
    An object providing this interface (usually an instance of L{XmlStream}),
 
45
    keeps the said dictionary and sets observers on the iq stanzas of type
 
46
    C{result} and C{error} and lets the callback fire the associated deferred.
 
47
    """
 
48
    iqDeferreds = Attribute("Dictionary of deferreds waiting for an iq "
 
49
                             "response")
 
50
 
 
51
class IService(Interface):
 
52
    """
 
53
    External server-side component service interface.
 
54
 
 
55
    Services that provide this interface can be added to L{ServiceManager} to
 
56
    implement (part of) the functionality of the server-side component.
 
57
    """
 
58
 
 
59
    def componentConnected(xs):
 
60
        """
 
61
        Parent component has established a connection.
 
62
 
 
63
        At this point, authentication was succesful, and XML stanzas
 
64
        can be exchanged over the XML stream L{xs}. This method can be used
 
65
        to setup observers for incoming stanzas.
 
66
 
 
67
        @param xs: XML Stream that represents the established connection.
 
68
        @type xs: L{xmlstream.XmlStream}
 
69
        """
 
70
 
 
71
    def componentDisconnected():
 
72
        """
 
73
        Parent component has lost the connection to the Jabber server.
 
74
 
 
75
        Subsequent use of C{self.parent.send} will result in data being
 
76
        queued until a new connection has been established.
 
77
        """
 
78
 
 
79
    def transportConnected(xs):
 
80
        """
 
81
        Parent component has established a connection over the underlying
 
82
        transport.
 
83
 
 
84
        At this point, no traffic has been exchanged over the XML stream. This
 
85
        method can be used to change properties of the XML Stream (in L{xs}),
 
86
        the service manager or it's authenticator prior to stream
 
87
        initialization (including authentication).
 
88
        """
 
89