1
# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
2
# See LICENSE for details.
5
Public Jabber Interfaces.
8
from zope.interface import Attribute, Interface
10
class IInitializer(Interface):
12
Interface for XML stream initializers.
14
Initializers perform a step in getting the XML stream ready to be
15
used for the exchange of XML stanzas.
20
class IInitiatingInitializer(IInitializer):
22
Interface for XML stream initializers for the initiating entity.
25
xmlstream = Attribute("""The associated XML stream""")
29
Initiate the initialization step.
31
May return a deferred when the initialization is done asynchronously.
36
class IIQResponseTracker(Interface):
38
IQ response tracker interface.
40
The XMPP stanza C{iq} has a request-response nature that fits
41
naturally with deferreds. You send out a request and when the response
42
comes back a deferred is fired.
44
The L{IQ} class implements a C{send} method that returns a deferred. This
45
deferred is put in a dictionary that is kept in an L{XmlStream} object,
46
keyed by the request stanzas C{id} attribute.
48
An object providing this interface (usually an instance of L{XmlStream}),
49
keeps the said dictionary and sets observers on the iq stanzas of type
50
C{result} and C{error} and lets the callback fire the associated deferred.
52
iqDeferreds = Attribute("Dictionary of deferreds waiting for an iq "
57
class IXMPPHandler(Interface):
59
Interface for XMPP protocol handlers.
61
Objects that provide this interface can be added to a stream manager to
62
handle of (part of) an XMPP extension protocol.
65
parent = Attribute("""XML stream manager for this handler""")
66
xmlstream = Attribute("""The managed XML stream""")
68
def setHandlerParent(parent):
70
Set the parent of the handler.
72
@type parent: L{IXMPPHandlerCollection}
76
def disownHandlerParent(parent):
78
Remove the parent of the handler.
80
@type parent: L{IXMPPHandlerCollection}
84
def makeConnection(xs):
86
A connection over the underlying transport of the XML stream has been
89
At this point, no traffic has been exchanged over the XML stream
92
This should setup L{xmlstream} and call L{connectionMade}.
94
@type xs: L{XmlStream<twisted.words.protocols.jabber.XmlStream>}
100
Called after a connection has been established.
102
This method can be used to change properties of the XML Stream, its
103
authenticator or the stream manager prior to stream initialization
104
(including authentication).
108
def connectionInitialized():
110
The XML stream has been initialized.
112
At this point, authentication was successful, and XML stanzas can be
113
exchanged over the XML stream L{xmlstream}. This method can be
114
used to setup observers for incoming stanzas.
118
def connectionLost(reason):
120
The XML stream has been closed.
122
Subsequent use of L{parent.send} will result in data being queued
123
until a new connection has been established.
125
@type reason: L{twisted.python.failure.Failure}
130
class IXMPPHandlerCollection(Interface):
132
Collection of handlers.
134
Contain several handlers and manage their connection.
139
Get an iterator over all child handlers.
143
def addHandler(handler):
147
@type handler: L{IXMPPHandler}
151
def removeHandler(handler):
153
Remove a child handler.
155
@type handler: L{IXMPPHandler}
160
class IService(Interface):
162
External server-side component service interface.
164
Services that provide this interface can be added to L{ServiceManager} to
165
implement (part of) the functionality of the server-side component.
168
def componentConnected(xs):
170
Parent component has established a connection.
172
At this point, authentication was succesful, and XML stanzas
173
can be exchanged over the XML stream L{xs}. This method can be used
174
to setup observers for incoming stanzas.
176
@param xs: XML Stream that represents the established connection.
177
@type xs: L{xmlstream.XmlStream}
181
def componentDisconnected():
183
Parent component has lost the connection to the Jabber server.
185
Subsequent use of C{self.parent.send} will result in data being
186
queued until a new connection has been established.
190
def transportConnected(xs):
192
Parent component has established a connection over the underlying
195
At this point, no traffic has been exchanged over the XML stream. This
196
method can be used to change properties of the XML Stream (in L{xs}),
197
the service manager or it's authenticator prior to stream
198
initialization (including authentication).