SipMiddlewareApi

Version 146 (Adrian Georgescu, 04/03/2012 02:13 pm)

1 1 Adrian Georgescu
= Middleware API =
2 1 Adrian Georgescu
3 132 Adrian Georgescu
[[TOC(SipMiddlewareApi, SipConfigurationAPI, SipCoreApiDocumentation, SipMSRPApi, ThreadingApi, depth=3)]]
4 104 Adrian Georgescu
5 102 Adrian Georgescu
This chapter describes the ''Middleware API'' for SIP SIMPLE client SDK that can be used for developing a user interface (e.g. Graphical User Interface). The Middleware provides a ''non-blocking'' API  that communicates with the user interface asynchronously by using ''Notifications''. For its configuration, the Middleware uses the [wiki:SipConfigurationAPI Configuration API].
6 1 Adrian Georgescu
7 101 Adrian Georgescu
[[Image(sipsimple-middleware.png, align=center, width=700)]]
8 1 Adrian Georgescu
9 1 Adrian Georgescu
== SIPApplication ==
10 1 Adrian Georgescu
11 62 Luci Stanescu
Implemented in [browser:sipsimple/application.py]
12 1 Adrian Georgescu
13 62 Luci Stanescu
Implements a high-level application responsable for starting and stopping various sub-systems required to implement a fully featured SIP User Agent application. The SIPApplication class is a Singleton and can be instantiated from any part of the code, obtaining a reference to the same object. The SIPApplication takes care of initializing the following components:
14 62 Luci Stanescu
 * the twisted thread
15 93 Adrian Georgescu
 * the configuration system, via the [wiki:SipConfigurationAPI#ConfigurationManager ConfigurationManager]
16 62 Luci Stanescu
 * the core [wiki:SipCoreApiDocumentation#Engine Engine] using the settings in the configuration
17 62 Luci Stanescu
 * the [wiki:SipMiddlewareApi#AccountManager AccountManager], using the accounts in the configuration
18 63 Luci Stanescu
 * the [wiki:SipMiddlewareApi#SessionManager SessionManager], in order to handle incoming sessions
19 62 Luci Stanescu
 * two [wiki:SipMiddlewareApi#AudioBridge AudioBridges], using the settings in the configuration
20 1 Adrian Georgescu
21 62 Luci Stanescu
The attributes in this class can be set and accessed on both this class and its subclasses, as they are implemented using descriptors which keep single value for each attribute, irrespective of the class from which that attribute is set/accessed. Usually, all attributes should be considered read-only.
22 1 Adrian Georgescu
23 95 Adrian Georgescu
==== methods  ====
24 62 Luci Stanescu
25 94 Adrian Georgescu
26 62 Luci Stanescu
 '''!__init!__'''(''self'')::
27 62 Luci Stanescu
  Instantiates a new SIPApplication.
28 94 Adrian Georgescu
29 144 Adrian Georgescu
 '''start'''(''self'', '''storage''')::
30 144 Adrian Georgescu
  Starts the {{{SIPApplication}}} which initializes all the components in the correct order. The {{{storage}}} is saved as an attribute which other entities like the {{{Configuration Manager}}} will use to take the appropriate backend. If any error occurs with loading the configuration, the exception raised by the {{{ConfigurationManager}}} is propagated by this method and {{{SIPApplication}}} can be started again. After this, any fatal errors will result in the SIPApplication being stopped and unusable, which means the whole application will need to stop. This method returns as soon as the twisted thread has been started, which means the application must wait for the {{{SIPApplicationDidStart}}} notification in order to know that the application started.
31 94 Adrian Georgescu
32 62 Luci Stanescu
 '''stop'''(''self'')::
33 62 Luci Stanescu
  Stop all the components started by the SIPApplication. This method returns immediately, but a {{{SIPApplicationDidEnd}}} notification is sent when all the components have been stopped.
34 62 Luci Stanescu
35 95 Adrian Georgescu
==== attributes ====
36 1 Adrian Georgescu
37 94 Adrian Georgescu
38 62 Luci Stanescu
 '''running'''::
39 1 Adrian Georgescu
  {{{True}}} if the SIPApplication is running (it has been started and it has not been told to stop), {{{False}}} otherwise.
40 1 Adrian Georgescu
41 144 Adrian Georgescu
 '''storage'''::
42 144 Adrian Georgescu
  Holds an object which implements the {{{ISIPSimpleStorage}}} interface which will be used to provide a storage facility to other middleware components.
43 144 Adrian Georgescu
44 144 Adrian Georgescu
 '''local_nat_type'''::
45 144 Adrian Georgescu
  String containing the detected local NAT type.
46 94 Adrian Georgescu
47 62 Luci Stanescu
 '''alert_audio_mixer'''::
48 62 Luci Stanescu
  The {{{AudioMixer}}} object created on the alert audio device as defined by the configuration (by SIPSimpleSettings.audio.alert_device).
49 94 Adrian Georgescu
50 62 Luci Stanescu
 '''alert_audio_bridge'''::
51 62 Luci Stanescu
  An {{{AudioBridge}}} where {{{IAudioPort}}} objects can be added to playback sound to the alert device.
52 94 Adrian Georgescu
53 62 Luci Stanescu
 '''alert_audio_device'''::
54 62 Luci Stanescu
  An {{{AudioDevice}}} which corresponds to the alert device as defined by the configuration. This will always be part of the alert_audio_bridge.
55 94 Adrian Georgescu
56 62 Luci Stanescu
 '''voice_audio_mixer'''::
57 62 Luci Stanescu
  The {{{AudioMixer}}} object created on the voice audio device as defined by the configuration (by SIPSimpleSettings.audio.input_device and SIPSimpleSettings.audio.output_device).
58 94 Adrian Georgescu
59 62 Luci Stanescu
 '''voice_audio_bridge'''::
60 62 Luci Stanescu
  An {{{AudioBridge}}} where {{{IAudioPort}}} objects can be added to playback sound to the output device or record sound from the input device.
61 94 Adrian Georgescu
62 62 Luci Stanescu
 '''voice_audio_device'''::
63 62 Luci Stanescu
  An {{{AudioDevice}}} which corresponds to the voice device as defined by the configuration. This will always be part of the voice_audio_bridge.
64 1 Adrian Georgescu
65 95 Adrian Georgescu
==== notifications  ====
66 62 Luci Stanescu
67 94 Adrian Georgescu
68 62 Luci Stanescu
 '''SIPApplicationWillStart'''::
69 62 Luci Stanescu
  This notification is sent just after the configuration has been loaded and the twisted thread started, but before any other components have been initialized.
70 62 Luci Stanescu
  [[BR]]timestamp:[[BR]]
71 62 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
72 94 Adrian Georgescu
73 62 Luci Stanescu
 '''SIPApplicationDidStart'''::
74 62 Luci Stanescu
  This notification is sent when all the components have been initialized. Note: it doesn't mean that all components have succeeded, for example, the account might not have registered by this time, but the registration process will have started.
75 62 Luci Stanescu
  [[BR]]timestamp:[[BR]]
76 62 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
77 94 Adrian Georgescu
78 62 Luci Stanescu
 '''SIPApplicationWillEnd'''::
79 62 Luci Stanescu
  This notification is sent as soon as the {{{stop()}}} method has been called.
80 62 Luci Stanescu
  [[BR]]timestamp:[[BR]]
81 62 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
82 94 Adrian Georgescu
83 62 Luci Stanescu
 '''SIPApplicationDidEnd'''::
84 62 Luci Stanescu
  This notification is sent when all the components have been stopped. All components have been given reasonable time to shutdown gracefully, such as the account unregistering. However, because of factors outside the control of the middleware, such as network problems, some components might not have actually shutdown gracefully; this is needed because otherwise the SIPApplication could hang indefinitely (for example because the system is no longer connected to a network and it cannot be determined when it will be again).
85 62 Luci Stanescu
  [[BR]]timestamp:[[BR]]
86 62 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
87 94 Adrian Georgescu
88 62 Luci Stanescu
 '''SIPApplicationFailedToStartTLS'''::
89 62 Luci Stanescu
  This notification is sent when a problem arises with initializing the TLS transport. In this case, the Engine will be started without TLS support and this notification contains the error which identifies the cause for not being able to start the TLS transport.
90 62 Luci Stanescu
  [[BR]]timestamp:[[BR]]
91 62 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
92 62 Luci Stanescu
  [[BR]]error:[[BR]]
93 62 Luci Stanescu
  The exception raised by the Engine which identifies the cause for not being able to start the TLS transport.
94 50 Adrian Georgescu
95 1 Adrian Georgescu
96 145 Adrian Georgescu
== Storage API ==
97 145 Adrian Georgescu
98 145 Adrian Georgescu
Different middleware components may need to store data, i.e. configuration files or XCAP documents. The {{{Storage API}}} defines a collection of backends which other components will use to store their data.
99 145 Adrian Georgescu
100 145 Adrian Georgescu
=== API Definition ===
101 145 Adrian Georgescu
102 145 Adrian Georgescu
The {{{Storage API}}} currently requires the following attributes to be defined as per the {{{ISIPSimpleStorage}}} interface:
103 145 Adrian Georgescu
104 145 Adrian Georgescu
 '''configuration_backend'''::
105 145 Adrian Georgescu
  The backend used for storing the configuration.
106 145 Adrian Georgescu
107 145 Adrian Georgescu
 '''xcap_storage_factory'''::
108 145 Adrian Georgescu
  Factory used to create XCAP storage backends for each account.
109 145 Adrian Georgescu
110 145 Adrian Georgescu
=== Provided implementations ===
111 145 Adrian Georgescu
112 145 Adrian Georgescu
Two storage implementations are provided: '''FileStorage''' and '''MemoryStorage''' both located in the '''sipsimple.storage''' module.
113 145 Adrian Georgescu
114 63 Luci Stanescu
== SIP Sessions ==
115 1 Adrian Georgescu
116 63 Luci Stanescu
SIP sessions are supported by the {{{sipsimple.session.Session}}} class and independent stream classes, which need to implement the {{{sipsimple.streams.IMediaStream}}} interface. The {{{Session}}} class takes care of the signalling, while the streams offer the actual media support which is negotiated by the {{{Session}}}. The streams which are implemented in the SIP SIMPLE middleware are provided in modules within the {{{sipsimple.streams}}} package, but they are accessible for import directly from {{{sipsimple.streams}}}. Currently, the middleware implements two types of streams, one for RTP data, with a concrete implementation in the {{{AudioStream}}} class, and one for MSRP sessions, with concrete implementations in the {{{ChatStream}}}, {{{FileTransferStream}}} and {{{DesktopSharingStream}}} classes. However, the application can provide its own stream implementation, provided they respect the {{{IMediaStream}}} interface.
117 63 Luci Stanescu
118 74 Luci Stanescu
The {{{sipsimple.streams}}} module also provides a mechanism for automatically registering media streams in order for them to be used for incoming sessions. This is explained in more detail in [wiki:SipMiddlewareApi#MediaStreamRegistry MediaStreamRegistry].
119 65 Luci Stanescu
120 91 Adrian Georgescu
121 91 Adrian Georgescu
=== SessionManager ===
122 91 Adrian Georgescu
123 91 Adrian Georgescu
Implemented in [browser:sipsimple/session.py]
124 91 Adrian Georgescu
125 91 Adrian Georgescu
The {{{sipsimple.session.SessionManager}}} class is a singleton, which acts as the central aggregation point for sessions within the middleware.
126 91 Adrian Georgescu
Although it is mainly used internally, the application can use it to query information about all active sessions.
127 115 Luci Stanescu
The SessionManager is implemented as a singleton, meaning that only one instance of this class exists within the middleware. The SessionManager is started by the SIPApplication and takes care of handling incoming sessions and closing all sessions when SIPApplication is stopped.
128 91 Adrian Georgescu
129 91 Adrian Georgescu
==== attributes ====
130 91 Adrian Georgescu
131 94 Adrian Georgescu
132 91 Adrian Georgescu
 '''sessions'''::
133 91 Adrian Georgescu
  A property providing a copy of the list of all active {{{Sesssion}}} objects within the application, meaning any {{{Session}}} object that exists globally within the application and is not in the {{{NULL}}} or {{{TERMINATED}}} state.
134 91 Adrian Georgescu
135 91 Adrian Georgescu
==== methods ====
136 91 Adrian Georgescu
137 94 Adrian Georgescu
138 91 Adrian Georgescu
 '''!__init!__'''(''self'')::
139 91 Adrian Georgescu
  Instantiate a new {{{SessionManager}}} object.
140 91 Adrian Georgescu
141 94 Adrian Georgescu
142 1 Adrian Georgescu
 '''start'''(''self'')::
143 115 Luci Stanescu
  Start the {{{SessionManager}}} in order to be able to handle incoming sessions. This method is called automatically when SIPApplication is started. The application should not call this method directly.
144 115 Luci Stanescu
145 115 Luci Stanescu
 '''stop'''(''self'')::
146 115 Luci Stanescu
  End all connected sessions. This method is called automatically when SIPApplication is stopped. The application should not call this method directly.
147 91 Adrian Georgescu
148 44 Adrian Georgescu
=== Session ===
149 1 Adrian Georgescu
150 1 Adrian Georgescu
Implemented in [browser:sipsimple/session.py]
151 26 Luci Stanescu
152 1 Adrian Georgescu
A {{{sipsimple.session.Session}}} object represents a complete SIP session between the local and a remote endpoints. Both incoming and outgoing sessions are represented by this class.
153 1 Adrian Georgescu
154 1 Adrian Georgescu
A {{{Session}}} instance is a stateful object, meaning that it has a {{{state}}} attribute and that the lifetime of the session traverses different states, from session creation to termination.
155 2 Adrian Georgescu
State changes are triggered by methods called on the object by the application or by received network events.
156 1 Adrian Georgescu
These states and their transitions are represented in the following diagram:
157 63 Luci Stanescu
158 105 Adrian Georgescu
[[Image(/raw-attachment/wiki/SipCoreApiDocumentation/sipsimple-core-invite-state-machine.png)]]
159 105 Adrian Georgescu
160 1 Adrian Georgescu
Although these states are crucial to the correct operation of the {{{Session}}} object, an application using this object does not need to keep track of these states, as a set of notifications is also emitted, which provide all the necessary information to the application.
161 63 Luci Stanescu
162 63 Luci Stanescu
The {{{Session}}} is completely independent of the streams it contains, which need to be implementations of the {{{sipsimple.streams.IMediaStream}}} interface. This interface provides the API by which the {{{Session}}} communicates with the streams. This API should not be used by the application, unless it also provides stream implementations or a SIP INVITE session implementation.
163 63 Luci Stanescu
164 63 Luci Stanescu
==== methods ====
165 63 Luci Stanescu
166 94 Adrian Georgescu
167 63 Luci Stanescu
 '''!__init!__'''(''self'', '''account''')::
168 63 Luci Stanescu
  Creates a new {{{Session}}} object in the {{{None}}} state.
169 63 Luci Stanescu
  [[BR]]''account'':[[BR]]
170 63 Luci Stanescu
  The local account to be associated with this {{{Session}}}.
171 94 Adrian Georgescu
172 139 Adrian Georgescu
 '''connect'''(''self'', '''to_header''', '''routes''', '''streams''', '''is_focus'''={{{False}}}, '''subject'''={{{None}}})::
173 63 Luci Stanescu
  Will set up the {{{Session}}} as outbound and propose the new session to the specified remote party and move the state machine to the {{{outgoing}}} state.
174 63 Luci Stanescu
  Before contacting the remote party, a {{{SIPSessionNewOutgoing}}} notification will be emitted.
175 63 Luci Stanescu
  If there is a failure or the remote party rejected the offer, a {{{SIPSessionDidFail}}} notification will be sent.
176 63 Luci Stanescu
  Any time a ringing indication is received from the remote party, a {{{SIPSessionGotRingIndication}}} notification is sent.
177 63 Luci Stanescu
  If the remote party accepted the session, a {{{SIPSessionWillStart}}} notification will be sent, followed by a {{{SIPSessionDidStart}}} notification when the session is actually established.
178 63 Luci Stanescu
  This method may only be called while in the {{{None}}} state.
179 63 Luci Stanescu
  [[BR]]''to_header'':[[BR]]
180 63 Luci Stanescu
  A {{{sipsimple.core.ToHeader}}} object representing the remote identity to initiate the session to.
181 63 Luci Stanescu
  [[BR]]''routes'':[[BR]]
182 63 Luci Stanescu
  An iterable of {{{sipsimple.util.Route}}} objects, specifying the IP, port and transport to the outbound proxy.
183 63 Luci Stanescu
  These routes will be tried in order, until one of them succeeds.
184 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
185 1 Adrian Georgescu
  A list of stream objects which will be offered to the remote endpoint.
186 139 Adrian Georgescu
  [[BR]]''is_focus'':[[BR]]
187 139 Adrian Georgescu
  Boolean flag indicating if the {{{isfocus}}} parameter should be added to the {{{Contact}}} header according to RFC 4579.
188 139 Adrian Georgescu
  [[BR]]''subject'':[[BR]]
189 139 Adrian Georgescu
  Session subject. If not None a {{{Subject}}} header will be added with the specified value.
190 94 Adrian Georgescu
191 63 Luci Stanescu
 '''send_ring_indication'''(''self'')::
192 63 Luci Stanescu
  Sends a 180 provisional response in the case of an incoming session.
193 94 Adrian Georgescu
194 63 Luci Stanescu
 '''accept'''(''self'', '''streams''')::
195 63 Luci Stanescu
  Calling this methods will accept an incoming session and move the state machine to the {{{accepting}}} state.
196 63 Luci Stanescu
  When there is a new incoming session, a {{{SIPSessionNewIncoming}}} notification is sent, after which the application can call this method on the sender of the notification.
197 63 Luci Stanescu
  After this method is called, {{{SIPSessionWillStart}}} followed by {{{SIPSessionDidStart}}} will be emitted, or {{{SIPSessionDidFail}}} on an error.
198 63 Luci Stanescu
  This method may only be called while in the {{{incoming}}} state.
199 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
200 63 Luci Stanescu
  A list of streams which needs to be a subset of the proposed streams which indicates which streams are to be accepted. All the other proposed streams will be rejected.
201 94 Adrian Georgescu
202 63 Luci Stanescu
 '''reject'''(''self'', '''code'''={{{603}}}, '''reason'''={{{None}}})::
203 114 Adrian Georgescu
  Reject an incoming session and move it to the {{{terminating}}} state, which eventually leads to the {{{terminated}}} state.
204 63 Luci Stanescu
  Calling this method will cause the {{{Session}}} object to emit a {{{SIPSessionDidFail}}} notification once the session has been rejected.
205 63 Luci Stanescu
  This method may only be called while in the {{{incoming}}} state.
206 63 Luci Stanescu
  [[BR]]''code'':[[BR]]
207 63 Luci Stanescu
  An integer which represents the SIP status code in the response which is to be sent. Usually, this is either 486 (Busy) or 603 (Decline/Busy Everywhere).
208 63 Luci Stanescu
  [[BR]]''reason'':[[BR]]
209 63 Luci Stanescu
  The string which is to be sent as the SIP status reason in the response, or None if PJSIP's default reason for the specified code is to be sent.
210 94 Adrian Georgescu
211 63 Luci Stanescu
 '''accept_proposal'''(''self'', '''streams''')::
212 63 Luci Stanescu
  When the remote party proposes to add some new streams, signaled by the {{{SIPSessionGotProposal}}} notification, the application can use this method to accept the stream(s) being proposed.
213 63 Luci Stanescu
  After calling this method a {{{SIPSessionGotAcceptProposal}}} notification is sent, unless an error occurs while setting up the new stream, in which case a {{{SIPSessionHadProposalFailure}}} notification is sent and a rejection is sent to the remote party. As with any action which causes the streams in the session to change, a {{{SIPSessionDidRenegotiateStreams}}} notification is also sent.
214 63 Luci Stanescu
  This method may only be called while in the {{{received_proposal}}} state.
215 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
216 63 Luci Stanescu
  A list of streams which needs to be a subset of the proposed streams which indicates which streams are to be accepted. All the other proposed streams will be rejected.
217 94 Adrian Georgescu
218 63 Luci Stanescu
 '''reject_proposal'''(''self'', '''code'''={{{488}}}, '''reason'''={{{None}}})::
219 63 Luci Stanescu
  When the remote party proposes new streams that the application does not want to accept, this method can be used to reject the proposal, after which a {{{SIPSessionGotRejectProposal}}} or {{{SIPSessionHadProposalFailure}}} notification is sent.
220 63 Luci Stanescu
  This method may only be called while in the {{{received_proposal}}} state.
221 63 Luci Stanescu
  [[BR]]''code'':[[BR]]
222 63 Luci Stanescu
  An integer which represents the SIP status code in the response which is to be sent. Usually, this is 488 (Not Acceptable Here).
223 63 Luci Stanescu
  [[BR]]''reason'':[[BR]]
224 63 Luci Stanescu
  The string which is to be sent as the SIP status reason in the response, or None if PJSIP's default reason for the specified code is to be sent.
225 94 Adrian Georgescu
226 63 Luci Stanescu
 '''add_stream'''(''self'', '''stream''')::
227 63 Luci Stanescu
  Proposes a new stream to the remote party.
228 63 Luci Stanescu
  Calling this method will cause a {{{SIPSessionGotProposal}}} notification to be emitted.
229 63 Luci Stanescu
  After this, the state machine will move into the {{{sending_proposal}}} state until either a {{{SIPSessionGotAcceptProposal}}}, {{{SIPSessionGotRejectProposal}}} or {{{SIPSessionHadProposalFailure}}} notification is sent, informing the application if the remote party accepted the proposal. As with any action which causes the streams in the session to change, a {{{SIPSessionDidRenegotiateStreams}}} notification is also sent.
230 63 Luci Stanescu
  This method may only be called while in the {{{connected}}} state.
231 94 Adrian Georgescu
232 63 Luci Stanescu
 '''remove_stream'''(''self'', '''stream''')::
233 63 Luci Stanescu
  Stop the stream and remove it from the session, informing the remote party of this. Although technically this is also done via an SDP negotiation which may fail, the stream will always get remove (if the remote party refuses the re-INVITE, the result will be that the remote party will have a different view of the active streams than the local party).
234 63 Luci Stanescu
  This method may only be called while in the {{{connected}}} state.
235 94 Adrian Georgescu
236 63 Luci Stanescu
 '''cancel_proposal'''(''self'')::
237 63 Luci Stanescu
  This method cancels a proposal of adding a stream to the session by sending a CANCEL request. A {{{SIPSessionGotRejectProposal}}} notification will be sent with code 487.
238 94 Adrian Georgescu
239 63 Luci Stanescu
 '''hold'''(''self'')::
240 63 Luci Stanescu
  Put the streams of the session which support the notion of hold on hold.
241 63 Luci Stanescu
  This will cause a {{{SIPSessionDidChangeHoldState}}} notification to be sent.
242 63 Luci Stanescu
  This method may be called in any state and will send the re-INVITE as soon as it is possible.
243 94 Adrian Georgescu
244 63 Luci Stanescu
 '''unhold'''(''self'')::
245 63 Luci Stanescu
  Take the streams of the session which support the notion of hold out of hold.
246 63 Luci Stanescu
  This will cause a {{{SIPSessionDidChangeHoldState}}} notification to be sent.
247 63 Luci Stanescu
  This method may be called in any state and will send teh re-INVITE as soon as it is possible.
248 94 Adrian Georgescu
249 63 Luci Stanescu
 '''end'''(''self'')::
250 63 Luci Stanescu
  This method may be called any time after the {{{Session}}} has started in order to terminate the session by sending a BYE request.
251 1 Adrian Georgescu
  Right before termination a {{{SIPSessionWillEnd}}} notification is sent, after termination {{{SIPSessionDidEnd}}} is sent.
252 1 Adrian Georgescu
253 146 Adrian Georgescu
 '''transfer'''(''self'', '''target_uri''',  '''replaced_session'''={{{None}}})::
254 146 Adrian Georgescu
  Proposes a blind call transfer to a new target URI or assisted transfer to an URI belonging to an already established session. 
255 146 Adrian Georgescu
256 146 Adrian Georgescu
 '''accept_transfer'''(''self'')::
257 146 Adrian Georgescu
  Accepts an incoming call transfer request.
258 146 Adrian Georgescu
259 146 Adrian Georgescu
 '''reject_transfer'''(''self'', '''code'''={{{486}}}, '''reason''={{{None}}})::
260 146 Adrian Georgescu
  Rejects an incoming call transfer request.
261 146 Adrian Georgescu
262 146 Adrian Georgescu
263 64 Luci Stanescu
==== attributes ====
264 1 Adrian Georgescu
265 94 Adrian Georgescu
266 1 Adrian Georgescu
 '''state'''::
267 1 Adrian Georgescu
  The state the object is currently in, being one of the states from the diagram above.
268 94 Adrian Georgescu
269 1 Adrian Georgescu
 '''account'''::
270 19 Ruud Klaver
  The {{{sipsimple.account.Account}}} or {{{sipsimple.account.BonjourAccount}}} object that the {{{Session}}} is associated with.
271 1 Adrian Georgescu
  On an outbound session, this is the account the application specified on object instantiation.
272 94 Adrian Georgescu
273 1 Adrian Georgescu
 '''direction'''::
274 32 Adrian Georgescu
  A string indicating the direction of the initial negotiation of the session.
275 63 Luci Stanescu
  This can be either {{{None}}}, "incoming" or "outgoing".
276 94 Adrian Georgescu
277 63 Luci Stanescu
 '''transport'''::
278 1 Adrian Georgescu
  A string representing the transport this {{{Session}}} is using: {{{"udp"}}}, {{{"tcp"}}} or {{{"tls"}}}.
279 94 Adrian Georgescu
280 1 Adrian Georgescu
 '''start_time'''::
281 1 Adrian Georgescu
  The time the session started as a {{{datetime.datetime}}} object, or {{{None}}} if the session was not yet started.
282 94 Adrian Georgescu
283 1 Adrian Georgescu
 '''stop_time'''::
284 1 Adrian Georgescu
  The time the session stopped as a {{{datetime.datetime}}} object, or {{{None}}} if the session has not yet terminated.
285 94 Adrian Georgescu
286 1 Adrian Georgescu
 '''on_hold'''::
287 1 Adrian Georgescu
  Boolean indicating whether the session was put on hold, either by the local or the remote party.
288 94 Adrian Georgescu
289 1 Adrian Georgescu
 '''remote_user_agent'''::
290 1 Adrian Georgescu
  A string indicating the remote user agent, if it provided one.
291 63 Luci Stanescu
  Initially this will be {{{None}}}, it will be set as soon as this information is received from the remote party (which may be never).
292 94 Adrian Georgescu
293 63 Luci Stanescu
 '''local_identity'''::
294 63 Luci Stanescu
  The {{{sipsimple.core.FrozenFromHeader}}} or {{{sipsimple.core.FrozenToHeader}}} identifying the local party, if the session is active, {{{None}}} otherwise.
295 94 Adrian Georgescu
296 63 Luci Stanescu
 '''remote_identity'''::
297 63 Luci Stanescu
  The {{{sipsimple.core.FrozenFromHeader}}} or {{{sipsimple.core.FrozenToHeader}}} identifying the remote party, if the session is active, {{{None}}} otherwise.
298 94 Adrian Georgescu
299 63 Luci Stanescu
 '''streams'''::
300 63 Luci Stanescu
  A list of the currently active streams in the {{{Session}}}.
301 94 Adrian Georgescu
302 63 Luci Stanescu
 '''proposed_streams'''::
303 1 Adrian Georgescu
  A list of the currently proposed streams in the {{{Session}}}, or {{{None}}} if there is no proposal in progress.
304 1 Adrian Georgescu
305 140 Adrian Georgescu
 '''conference'''::
306 140 Adrian Georgescu
  A {{{ConferenceHandler}}} object instance (or Null). It can be later used to add/remove participants from a remote conference.
307 140 Adrian Georgescu
308 140 Adrian Georgescu
 '''subject'''::
309 140 Adrian Georgescu
  The session subject as a unicode object.
310 140 Adrian Georgescu
311 146 Adrian Georgescu
 '''replaced_session'''::
312 146 Adrian Georgescu
  A {{{Session}}} object instance (or Null). It can be used for assisted call transfer.
313 146 Adrian Georgescu
314 146 Adrian Georgescu
 '''transfer_handler'''::
315 146 Adrian Georgescu
  A {{{TransferHandler}}} object instance (or Null). It is used for managing the call transfer process.
316 146 Adrian Georgescu
317 146 Adrian Georgescu
 '''transfer_info'''::
318 146 Adrian Georgescu
  A {{{TransferInfo}}} object instance (or Null). It is used for describing the details of a call transfer operation.
319 146 Adrian Georgescu
320 64 Luci Stanescu
==== notifications ====
321 1 Adrian Georgescu
322 94 Adrian Georgescu
323 1 Adrian Georgescu
 '''SIPSessionNewIncoming'''::
324 26 Luci Stanescu
  Will be sent when a new incoming {{{Session}}} is received.
325 63 Luci Stanescu
  The application should listen for this notification to get informed of incoming sessions.
326 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
327 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
328 1 Adrian Georgescu
  [[BR]]''streams'':[[BR]]
329 63 Luci Stanescu
  A list of streams that were proposed by the remote party.
330 94 Adrian Georgescu
331 1 Adrian Georgescu
 '''SIPSessionNewOutgoing'''::
332 138 Adrian Georgescu
  Will be sent when the application requests a new outgoing {{{Session}}}.
333 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
334 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
335 1 Adrian Georgescu
  [[BR]]''streams'':[[BR]]
336 63 Luci Stanescu
  A list of streams that were proposed to the remote party.
337 94 Adrian Georgescu
338 1 Adrian Georgescu
 '''SIPSessionGotRingIndication'''::
339 1 Adrian Georgescu
  Will be sent when an outgoing {{{Session}}} receives an indication that a remote device is ringing.
340 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
341 26 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
342 94 Adrian Georgescu
343 63 Luci Stanescu
 '''SIPSessionGotProvisionalResponse'''::
344 63 Luci Stanescu
  Will be sent whenever the {{{Session}}} receives a provisional response as a result of sending a (re-)INVITE.
345 63 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
346 63 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
347 63 Luci Stanescu
  [[BR]]''code'':[[BR]]
348 63 Luci Stanescu
  The SIP status code received.
349 63 Luci Stanescu
  [[BR]]''reason'':[[BR]]
350 63 Luci Stanescu
  The SIP status reason received.
351 94 Adrian Georgescu
352 1 Adrian Georgescu
 '''SIPSessionWillStart'''::
353 1 Adrian Georgescu
  Will be sent just before a {{{Session}}} completes negotiation.
354 1 Adrian Georgescu
  In terms of SIP, this is sent after the final response to the {{{INVITE}}}, but before the {{{ACK}}}.
355 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
356 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
357 94 Adrian Georgescu
358 1 Adrian Georgescu
 '''SIPSessionDidStart'''::
359 63 Luci Stanescu
  Will be sent when a {{{Session}}} completes negotiation and all the streams have started.
360 26 Luci Stanescu
  In terms of SIP this is sent after the {{{ACK}}} was sent or received.
361 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
362 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
363 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
364 63 Luci Stanescu
  The list of streams which now form the active streams of the {{{Session}}}.
365 94 Adrian Georgescu
366 1 Adrian Georgescu
 '''SIPSessionDidFail'''::
367 63 Luci Stanescu
  This notification is sent whenever the session fails before it starts.
368 5 Redmine Admin
  The failure reason is included in the data attributes.
369 63 Luci Stanescu
  This notification is never followed by {{{SIPSessionDidEnd}}}.
370 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
371 26 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
372 1 Adrian Georgescu
  [[BR]]''originator'':[[BR]]
373 63 Luci Stanescu
  A string indicating the originator of the {{{Session}}}. This will either be "local" or "remote".
374 1 Adrian Georgescu
  [[BR]]''code'':[[BR]]
375 1 Adrian Georgescu
  The SIP error code of the failure.
376 1 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
377 63 Luci Stanescu
  A SIP status reason.
378 63 Luci Stanescu
  [[BR]]''failure_reason'':[[BR]]
379 63 Luci Stanescu
  A string which represents the reason for the failure, such as {{{"user_request"}}}, {{{"missing ACK"}}}, {{{"SIP core error..."}}}.
380 94 Adrian Georgescu
381 1 Adrian Georgescu
 '''SIPSessionWillEnd'''::
382 63 Luci Stanescu
  Will be sent just before terminating a {{{Session}}}.
383 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
384 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
385 94 Adrian Georgescu
386 1 Adrian Georgescu
 '''SIPSessionDidEnd'''::
387 63 Luci Stanescu
  Will be sent always when a {{{Session}}} ends as a result of remote or local session termination.
388 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
389 19 Ruud Klaver
  A {{{datetime.datetime}}} object indicating when the notification was sent.
390 19 Ruud Klaver
  [[BR]]''originator'':[[BR]]
391 63 Luci Stanescu
  A string indicating who originated the termination. This will either be "local" or "remote".
392 63 Luci Stanescu
  [[BR]]''end_reason'':[[BR]]
393 63 Luci Stanescu
  A string representing the termination reason, such as {{{"user_request"}}}, {{{"SIP core error..."}}}.
394 94 Adrian Georgescu
395 63 Luci Stanescu
 '''SIPSessionDidChangeHoldState'''::
396 63 Luci Stanescu
  Will be sent when the session got put on hold or removed from hold, either by the local or the remote party.
397 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
398 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
399 1 Adrian Georgescu
  [[BR]]''originator'':[[BR]]
400 1 Adrian Georgescu
  A string indicating who originated the hold request, and consequently in which direction the session got put on hold.
401 63 Luci Stanescu
  [[BR]]''on_hold'':[[BR]]
402 63 Luci Stanescu
  {{{True}}} if there is at least one stream which is on hold and {{{False}}} otherwise.
403 63 Luci Stanescu
  [[BR]]''partial'':[[BR]]
404 63 Luci Stanescu
  {{{True}}} if there is at least one stream which is on hold and one stream which supports hold but is not on hold and {{{False}}} otherwise.
405 94 Adrian Georgescu
406 63 Luci Stanescu
 '''SIPSessionGotProposal'''::
407 63 Luci Stanescu
  Will be sent when either the local or the remote party proposes to add streams to the session.
408 26 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
409 23 Ruud Klaver
  A {{{datetime.datetime}}} object indicating when the notification was sent.
410 23 Ruud Klaver
  [[BR]]''originator'':[[BR]]
411 63 Luci Stanescu
  The party that initiated the stream proposal, can be either "local" or "remote".
412 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
413 63 Luci Stanescu
  A list of streams that were proposed.
414 94 Adrian Georgescu
415 63 Luci Stanescu
 '''SIPSessionGotRejectProposal'''::
416 63 Luci Stanescu
  Will be sent when either the local or the remote party rejects a proposal to have streams added to the session.
417 6 Ruud Klaver
  [[BR]]''timestamp'':[[BR]]
418 6 Ruud Klaver
  A {{{datetime.datetime}}} object indicating when the notification was sent.
419 63 Luci Stanescu
  [[BR]]''originator'':[[BR]]
420 63 Luci Stanescu
  The party that initiated the stream proposal, can be either "local" or "remote".
421 6 Ruud Klaver
  [[BR]]''code'':[[BR]]
422 63 Luci Stanescu
  The code with which the proposal was rejected.
423 1 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
424 63 Luci Stanescu
  The reason for rejecting the stream proposal.
425 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
426 63 Luci Stanescu
  The list of streams which were rejected.
427 94 Adrian Georgescu
428 63 Luci Stanescu
 '''SIPSessionGotAcceptProposal'''::
429 63 Luci Stanescu
  Will be sent when either the local or the remote party accepts a proposal to have stream( added to the session.
430 24 Ruud Klaver
  [[BR]]''timestamp'':[[BR]]
431 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
432 63 Luci Stanescu
  [[BR]]''originator'':[[BR]]
433 63 Luci Stanescu
  The party that initiated the stream proposal, can be either "local" or "remote".
434 1 Adrian Georgescu
  [[BR]]''streams'':[[BR]]
435 63 Luci Stanescu
  The list of streams which were accepted.
436 116 Luci Stanescu
  [[BR]]''proposed_streams'':[[BR]]
437 116 Luci Stanescu
  The list of streams which were originally proposed.
438 94 Adrian Georgescu
439 63 Luci Stanescu
 '''SIPSessionHadProposalFailure'''::
440 24 Ruud Klaver
  Will be sent when a re-INVITE fails because of an internal reason (such as a stream not being able to start).
441 24 Ruud Klaver
  [[BR]]''timestamp'':[[BR]]
442 63 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
443 63 Luci Stanescu
  [[BR]]''failure_reason'':[[BR]]
444 63 Luci Stanescu
  The error which caused the proposal to fail.
445 63 Luci Stanescu
  [[BR]]''streams'':[[BR]]
446 108 Adrian Georgescu
  The streams which were part of this proposal.
447 94 Adrian Georgescu
448 24 Ruud Klaver
 '''SIPSessionDidRenegotiateStreams'''::
449 6 Ruud Klaver
  Will be sent when a media stream is either activated or deactivated.
450 26 Luci Stanescu
  An application should listen to this notification in order to know when a media stream can be used.
451 63 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
452 39 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
453 39 Luci Stanescu
  [[BR]]''action'':[[BR]]
454 39 Luci Stanescu
  A string which is either {{{"add"}}} or {{{"remove"}}} which specifies what happened to the streams the notificaton referes to
455 1 Adrian Georgescu
  [[BR]]''streams'':[[BR]]
456 50 Adrian Georgescu
  A list with the streams which were added or removed.
457 94 Adrian Georgescu
458 39 Luci Stanescu
 '''SIPSessionDidProcessTransaction'''::
459 39 Luci Stanescu
  Will be sent whenever a SIP transaction is complete in order to provide low-level details of the progress of the INVITE dialog.
460 64 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
461 39 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
462 39 Luci Stanescu
  [[BR]]''originator'':[[BR]]
463 39 Luci Stanescu
  The initiator of the transaction, {{{"local"}}} or {{{"remote"}}}.
464 39 Luci Stanescu
  [[BR]]''method'':[[BR]]
465 64 Luci Stanescu
  The method of the request.
466 39 Luci Stanescu
  [[BR]]''code'':[[BR]]
467 39 Luci Stanescu
  The SIP status code of the response.
468 39 Luci Stanescu
  [[BR]]''reason'':[[BR]]
469 39 Luci Stanescu
  The SIP status reason of the response.
470 39 Luci Stanescu
  [[BR]]''ack_received'':[[BR]]
471 39 Luci Stanescu
  This attribute is only present for INVITE transactions and has one of the values {{{True}}}, {{{False}}} or {{{"unknown"}}}. The last value may occur then PJSIP does not let us know whether the ACK was received or not.
472 146 Adrian Georgescu
473 146 Adrian Georgescu
 '''SIPSessionTransferNewOutgoing'''::
474 146 Adrian Georgescu
  Will be sent whenever a SIP session initiates an outgoing call transfer request.
475 146 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
476 146 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
477 146 Adrian Georgescu
  [[BR]]''transfer_destination'':[[BR]]
478 146 Adrian Georgescu
  The destination SIP URI of the call transfer request.
479 146 Adrian Georgescu
  [[BR]]''transfer_source'':[[BR]]
480 146 Adrian Georgescu
  The source SIP URI of the call transfer request.
481 146 Adrian Georgescu
482 146 Adrian Georgescu
 '''SIPSessionTransferDidStart'''::
483 146 Adrian Georgescu
  Will be sent whenever a call transfer has been started.
484 146 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
485 146 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
486 146 Adrian Georgescu
487 146 Adrian Georgescu
 '''SIPSessionTransferDidFail'''::
488 146 Adrian Georgescu
  Will be sent whenever a call transfer request has failed.
489 146 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
490 146 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
491 146 Adrian Georgescu
  [[BR]]''code'':[[BR]]
492 146 Adrian Georgescu
  The SIP failure code reported by the SIP stack.
493 146 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
494 146 Adrian Georgescu
  The reason of the failure as a string.
495 146 Adrian Georgescu
496 1 Adrian Georgescu
497 65 Luci Stanescu
As an example for how to use the {{{Session}}} object, the following provides a basic Python program that initiates an outgoing SIP session request see [wiki:SipSessionExample Minimalist Session Example code].
498 39 Luci Stanescu
499 39 Luci Stanescu
=== IMediaStream ===
500 1 Adrian Georgescu
501 65 Luci Stanescu
Implemented in [browser:sipsimple/streams/__init__.py]
502 1 Adrian Georgescu
503 66 Luci Stanescu
This interface describes the API which the {{{Session}}} uses to communicate with the streams. All streams used by the {{{Session}}} __must__ respect this interface.
504 1 Adrian Georgescu
505 1 Adrian Georgescu
==== methods ====
506 65 Luci Stanescu
507 94 Adrian Georgescu
508 1 Adrian Georgescu
 '''!__init!__'''(''self'', ''account'')::
509 65 Luci Stanescu
  Initializes the generic stream instance.
510 94 Adrian Georgescu
511 65 Luci Stanescu
 '''new_from_sdp'''(''cls'', ''account'', ''remote_sdp'', ''stream_index'')::
512 65 Luci Stanescu
  A classmethod which returns an instance of this stream implementation if the sdp is accepted by the stream or None otherwise.
513 65 Luci Stanescu
  [[BR]]account:[[BR]]
514 65 Luci Stanescu
  The {{{sipsimple.account.Account}}} or {{{sipsimple.account.BonjourAccount}}} object the session which this stream would be part of is associated with.
515 65 Luci Stanescu
  [[BR]]remote_sdp:[[BR]]
516 65 Luci Stanescu
  The {{{FrozenSDPSession}}} which was received by the remote offer.
517 1 Adrian Georgescu
  [[BR]]stream_index:[[BR]]
518 65 Luci Stanescu
  An integer representing the index within the list of media streams within the whole SDP which this stream would be instantiated for. 
519 94 Adrian Georgescu
520 65 Luci Stanescu
 '''get_local_media'''(''self'', ''for_offer'')::
521 65 Luci Stanescu
  Return an {{{SDPMediaStream}}} which represents an offer for using this stream if {{{for_offer}}} is {{{True}}} and a response to an SDP proposal otherwise.
522 1 Adrian Georgescu
  [[BR]]for_offer:[[BR]]
523 65 Luci Stanescu
  {{{True}}} if the {{{SDPMediaStream}}} will be used for an SDP proposal and {{{False}}} if for a response.
524 94 Adrian Georgescu
525 65 Luci Stanescu
 '''initialize'''(''self'', ''session'', ''direction'')::
526 65 Luci Stanescu
  Initializes the stream. This method will get called as soon as the stream is known to be at least offered as part of the {{{Session}}}. If initialization goes fine, the stream must send a {{{MediaStreamDidInitialize}}} notification or a {{{MediaStreamDidFail}}} notification otherwise.
527 65 Luci Stanescu
  [[BR]]session:[[BR]]
528 65 Luci Stanescu
  The {{{Session}}} object this stream will be part of.
529 1 Adrian Georgescu
  [[BR]]direction:[[BR]]
530 65 Luci Stanescu
  {{{"incoming"}}} if the stream was created because of a received proposal and {{{"outgoing"}}} if a proposal was sent. Note that this need not be the same as the initial direction of the {{{Session}}} since streams can be proposed in either way using re-INVITEs.
531 94 Adrian Georgescu
532 65 Luci Stanescu
 '''start'''(''self'', ''local_sdp'', ''remote_sdp'', ''stream_index'')::
533 65 Luci Stanescu
  Starts the stream. This method will be called as soon is known to be used in the {{{Session}}} (eg. only called for an incoming proposal if the local party accepts the proposed stream). If starting succeeds, the stream must send a {{{MediaStreamDidStart}}} notification or a {{{MediaStreamDidFail}}} notification otherwise.
534 65 Luci Stanescu
  [[BR]]local_sdp:[[BR]]
535 65 Luci Stanescu
  The {{{FrozenSDPSession}}} which is used by the local endpoint.
536 65 Luci Stanescu
  [[BR]]remote_sdp:[[BR]]
537 65 Luci Stanescu
  The {{{FrozenSDPSession}}} which is used by the remote endpoint.
538 1 Adrian Georgescu
  [[BR]]stream_index:[[BR]]
539 65 Luci Stanescu
  An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
540 94 Adrian Georgescu
541 65 Luci Stanescu
 '''validate_update'''(''self'', ''remote_sdp'', ''stream_index'')::
542 65 Luci Stanescu
  This method will be called when a re-INVITE is received which changes the parameters of the stream within the SDP. The stream must return {{{True}}} if the changes are acceptable or {{{False}}} otherwise. If any changed streams return {{{False}}} for a re-INVITE, the re-INVITE will be refused with a negative response. This means that streams must not changed any internal data when this method is called as the update is not guaranteed to be applied even if the stream returns {{{True}}}. 
543 65 Luci Stanescu
  [[BR]]remote_sdp:[[BR]]
544 65 Luci Stanescu
  The {{{FrozenSDPSession}}} which is used by the remote endpoint.
545 1 Adrian Georgescu
  [[BR]]stream_index:[[BR]]
546 65 Luci Stanescu
  An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
547 94 Adrian Georgescu
548 65 Luci Stanescu
 '''update'''(''self'', ''local_sdp'', ''remote_sdp'', ''stream_index'')::
549 65 Luci Stanescu
  This method is called when the an SDP negotiation initiated by either the local party or the remote party succeeds. The stream must update its internal state according to the new SDP in use.
550 65 Luci Stanescu
  [[BR]]local_sdp:[[BR]]
551 65 Luci Stanescu
  The {{{FrozenSDPSession}}} which is used by the local endpoint.
552 65 Luci Stanescu
  [[BR]]remote_sdp:[[BR]]
553 65 Luci Stanescu
  The {{{FrozenSDPSession}}} which is used by the remote endpoint.
554 55 Adrian Georgescu
  [[BR]]stream_index:[[BR]]
555 65 Luci Stanescu
  An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
556 94 Adrian Georgescu
557 55 Adrian Georgescu
 '''hold'''(''self'')::
558 65 Luci Stanescu
  Puts the stream on hold if supported by the stream. Typically used by audio and video streams. The stream must immediately stop sending/receiving data and calls to {{{get_local_media()}}} following calls to this method must return an SDP which reflects the new hold state.
559 94 Adrian Georgescu
560 65 Luci Stanescu
 '''unhold'''(''self'')::
561 65 Luci Stanescu
  Takes the stream off hold. Typically used by audio and video streams. Calls to {{{get_local_media()}}} following calls to this method must return an SDP which reflects the new hold state.
562 94 Adrian Georgescu
563 65 Luci Stanescu
 '''deactivate'''(''self'')::
564 65 Luci Stanescu
  This method is called on a stream just before the stream will be removed from the {{{Session}}} (either as a result of a re-INVITE or a BYE). This method is needed because it avoids a race condition with streams using stateful protocols such as TCP: the stream connection might be terminated before the SIP signalling announces this due to network routing inconsistencies and the other endpoint would not be able to distinguish between this case and an error which caused the stream transport to fail. The stream must not take any action, but must consider that the transport being closed by the other endpoint after this method was called as a normal situation rather than an error condition.
565 94 Adrian Georgescu
566 55 Adrian Georgescu
 '''end'''(''self'')::
567 65 Luci Stanescu
  Ends the stream. This must close the underlying transport connection. The stream must send a {{{MediaStreamWillEnd}}} just after this method is called and a {{{MediaStreamDidEnd}}} as soon as the operation is complete. This method is always be called by the {{{Session}}} on the stream if at least the {{{initialize()}}} method has been called. This means that once a stream sends the {{{MediaStreamDidFail}}} notification, the {{{Session}}} will still call this method.
568 55 Adrian Georgescu
569 96 Adrian Georgescu
==== attributes ====
570 65 Luci Stanescu
571 94 Adrian Georgescu
572 65 Luci Stanescu
 '''type''' (class attribute)::
573 65 Luci Stanescu
  A string identifying the stream type (eg: {{{"audio"}}}, {{{"video"}}}).
574 94 Adrian Georgescu
575 65 Luci Stanescu
 '''priority''' (class attribute)::
576 65 Luci Stanescu
  An integer value indicating the stream priority relative to the other streams types (higher numbers have higher priority).
577 94 Adrian Georgescu
578 65 Luci Stanescu
 '''hold_supported'''::
579 65 Luci Stanescu
  True if the stream supports hold
580 94 Adrian Georgescu
581 65 Luci Stanescu
 '''on_hold_by_local'''::
582 65 Luci Stanescu
  True if the stream is on hold by the local party
583 94 Adrian Georgescu
584 65 Luci Stanescu
 '''on_hold_by_remote'''::
585 65 Luci Stanescu
  True if the stream is on hold by the remote
586 94 Adrian Georgescu
587 55 Adrian Georgescu
 '''on_hold'''::
588 65 Luci Stanescu
  True if either on_hold_by_local or on_hold_by_remote is true
589 65 Luci Stanescu
590 65 Luci Stanescu
==== notifications ====
591 65 Luci Stanescu
592 55 Adrian Georgescu
These notifications must be generated by all streams in order for the {{{Session}}} to know the state of the stream.
593 65 Luci Stanescu
594 94 Adrian Georgescu
595 55 Adrian Georgescu
 '''MediaStreamDidInitialize'''::
596 65 Luci Stanescu
  Sent when the stream has been successfully initialized.
597 94 Adrian Georgescu
598 55 Adrian Georgescu
 '''MediaStreamDidStart'''::
599 65 Luci Stanescu
  Sent when the stream has been successfully started.
600 94 Adrian Georgescu
601 55 Adrian Georgescu
 '''MediaStreamDidFail'''::
602 65 Luci Stanescu
  Sent when the stream has failed either as a result of calling one of its methods, or during the normal operation of the stream (such as the transport connection being closed).
603 94 Adrian Georgescu
604 55 Adrian Georgescu
 '''MediaStreamWillEnd'''::
605 65 Luci Stanescu
  Sent immediately after the {{{end()}}} method is called.
606 94 Adrian Georgescu
607 55 Adrian Georgescu
 '''MediaStreamDidEnd'''::
608 66 Luci Stanescu
  Sent when the {{{end()}}} method finished closing the stream.
609 55 Adrian Georgescu
610 66 Luci Stanescu
=== MediaStreamRegistry ===
611 1 Adrian Georgescu
612 66 Luci Stanescu
The MediaStream registry is a collection of classes which implement {{{IMediaStream}}}. This collection is used by the {{{Session}}} to select a stream class for instantiation in the case of an incomming session. The streams are included in the collection in the descending order of their priority. Thus, streams with a higher priority will be tried first by the {{{Session}}}. This object is a Singleton so references to the same object can be obtained by a simple instantiation.
613 66 Luci Stanescu
614 1 Adrian Georgescu
There are several pre-built streams based on the {{{IMediaStream}}} API:
615 1 Adrian Georgescu
 * {{{sipsimple.streams.rtp.AudioStream}}} - Audio stream based on RTP
616 66 Luci Stanescu
 * {{{sipsimple.streams.msrp.ChatStream}}} - Chat stream based on MSRP 
617 1 Adrian Georgescu
 * {{{sipsimple.streams.msrp.FileTransferStream}}} - File Transfer stream based on MSRP 
618 66 Luci Stanescu
 * {{{sipsimple.streams.msrp.DesktopSharingStream}}} -  Desktop Sharing stream based on VNC over MSRP
619 66 Luci Stanescu
620 66 Luci Stanescu
Other streams which are created by the application must be registered in this registry. For a simple way of doing this, see [wiki:SipMiddlewareApi#MediaStreamRegistrar MediaStreamRegistrar].
621 66 Luci Stanescu
622 66 Luci Stanescu
==== methods ====
623 66 Luci Stanescu
624 94 Adrian Georgescu
625 66 Luci Stanescu
 '''!__init!__'''(''self'')::
626 66 Luci Stanescu
  Instantiate the MediaStreamRegistry. This will be called just once when first (and only) instance is created.
627 94 Adrian Georgescu
628 66 Luci Stanescu
 '''!__iter!__'''(''self'')::
629 66 Luci Stanescu
  This method allows the registry to be iterated through and will return classes which were registered to it.
630 94 Adrian Georgescu
631 66 Luci Stanescu
 '''add'''(''self'', '''cls''')::
632 66 Luci Stanescu
  Add {{{cls}}} to the registry of streams. The class must implement the {{{IMediaStream}}} interface.
633 66 Luci Stanescu
634 66 Luci Stanescu
=== MediaStreamRegistrar ===
635 66 Luci Stanescu
636 66 Luci Stanescu
This is a convenience metaclass which automatically registers a defined class with the {{{MediaStreamRegistry}}}. In order to use this class, one simply needs to use it as the metaclass of the new stream.
637 66 Luci Stanescu
638 66 Luci Stanescu
{{{
639 66 Luci Stanescu
from zope.interface import implements
640 66 Luci Stanescu
641 66 Luci Stanescu
from sipsimple.streams import IMediaStream, MediaStreamRegistrar
642 66 Luci Stanescu
643 66 Luci Stanescu
644 66 Luci Stanescu
class MyStream(object):
645 66 Luci Stanescu
  __metaclass__ = MediaStreamRegistrar
646 66 Luci Stanescu
647 66 Luci Stanescu
  implements(IMediaStream)
648 66 Luci Stanescu
  
649 55 Adrian Georgescu
[...] 
650 67 Luci Stanescu
}}}
651 55 Adrian Georgescu
652 55 Adrian Georgescu
=== AudioStream ===
653 55 Adrian Georgescu
654 67 Luci Stanescu
Implemented in [browser:sipsimple/streams/rtp.py]
655 55 Adrian Georgescu
656 55 Adrian Georgescu
The {{{AudioStream}}} is an implementation of {{{IMediaStream}}} which supports audio data using the {{{AudioTransport}}} and {{{RTPTransport}}} of the SIP core. As such, it provides all features of these objects, including ICE negotiation. An example SDP created using the {{{AudioStream}}} is provided below:
657 55 Adrian Georgescu
658 55 Adrian Georgescu
{{{
659 55 Adrian Georgescu
Content-Type: application/sdp
660 55 Adrian Georgescu
Content-Length:  1093
661 55 Adrian Georgescu
662 55 Adrian Georgescu
v=0
663 55 Adrian Georgescu
o=- 3467525278 3467525278 IN IP4 192.168.1.6
664 55 Adrian Georgescu
s=blink-0.10.7-beta
665 57 Adrian Georgescu
c=IN IP4 80.101.96.20
666 57 Adrian Georgescu
t=0 0
667 57 Adrian Georgescu
m=audio 55328 RTP/AVP 104 103 102 3 9 0 8 101
668 57 Adrian Georgescu
a=rtcp:55329 IN IP4 80.101.96.20
669 57 Adrian Georgescu
a=rtpmap:104 speex/32000
670 57 Adrian Georgescu
a=rtpmap:103 speex/16000
671 57 Adrian Georgescu
a=rtpmap:102 speex/8000
672 57 Adrian Georgescu
a=rtpmap:3 GSM/8000
673 57 Adrian Georgescu
a=rtpmap:9 G722/8000
674 57 Adrian Georgescu
a=rtpmap:0 PCMU/8000
675 57 Adrian Georgescu
a=rtpmap:8 PCMA/8000
676 57 Adrian Georgescu
a=rtpmap:101 telephone-event/8000
677 57 Adrian Georgescu
a=fmtp:101 0-15
678 57 Adrian Georgescu
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:esI6DbLY1+Aceu0JNswN9Z10DcFx5cZwqJcu91jb
679 57 Adrian Georgescu
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:SHuEMm1BYJqOF4udKl73EaCwnsI57pO86bYKsg70
680 57 Adrian Georgescu
a=ice-ufrag:2701ed80
681 57 Adrian Georgescu
a=ice-pwd:6f8f8281
682 57 Adrian Georgescu
a=candidate:S 1 UDP 31 80.101.96.20 55328 typ srflx raddr 192.168.1.6 rport 55328
683 57 Adrian Georgescu
a=candidate:H 1 UDP 23 192.168.1.6 55328 typ host
684 57 Adrian Georgescu
a=candidate:H 1 UDP 23 10.211.55.2 55328 typ host
685 57 Adrian Georgescu
a=candidate:H 1 UDP 23 10.37.129.2 55328 typ host
686 57 Adrian Georgescu
a=candidate:S 2 UDP 30 80.101.96.20 55329 typ srflx raddr 192.168.1.6 rport 55329
687 57 Adrian Georgescu
a=candidate:H 2 UDP 22 192.168.1.6 55329 typ host
688 57 Adrian Georgescu
a=candidate:H 2 UDP 22 10.211.55.2 55329 typ host
689 57 Adrian Georgescu
a=candidate:H 2 UDP 22 10.37.129.2 55329 typ host
690 1 Adrian Georgescu
a=sendrecv
691 67 Luci Stanescu
}}}
692 1 Adrian Georgescu
693 67 Luci Stanescu
As an implementation of {{{IAudioPort}}}, an {{{AudioStream}}} can be added to an {{{AudioBridge}}} to send or to read audio data to/from other audio objects. It is connected to the voice {{{AudioMixer}}} ({{{SIPApplication.voice_audio_mixer}}}) so it can only be added to bridges using the same {{{AudioMixer}}}. It also contains an {{{AudioBridge}}} on the {{{bridge}}} attribute which always contains an {{{AudioDevice}}} corresponding to the input and output devices; when the stream is active (started and not on hold), the bridge also contains the stream itself and when recording is active, the stream contains a {{{WaveRecorder}}} which records audio data.
694 67 Luci Stanescu
695 67 Luci Stanescu
==== methods ====
696 67 Luci Stanescu
697 94 Adrian Georgescu
698 67 Luci Stanescu
 '''start_recording'''(''self'', '''filename'''={{{None}}})::
699 67 Luci Stanescu
  If an audio stream is present within this session, calling this method will record the audio to a {{{.wav}}} file.
700 67 Luci Stanescu
  Note that when the session is on hold, nothing will be recorded to the file.
701 67 Luci Stanescu
  Right before starting the recording a {{{SIPSessionWillStartRecordingAudio}}} notification will be emitted, followed by a {{{SIPSessionDidStartRecordingAudio}}}.
702 67 Luci Stanescu
  This method may only be called while the stream is started.
703 67 Luci Stanescu
  [[BR]]''filename'':[[BR]]
704 67 Luci Stanescu
  The name of the {{{.wav}}} file to record to.
705 67 Luci Stanescu
  If this is set to {{{None}}}, a default file name including the session participants and the timestamp will be generated using the directory defined in the configuration.
706 94 Adrian Georgescu
707 67 Luci Stanescu
 '''stop_recording'''(''self'')::
708 67 Luci Stanescu
  This will stop a previously started recording.
709 67 Luci Stanescu
  Before stopping, a {{{SIPSessionWillStopRecordingAudio}}} notification will be sent, followed by a {{{SIPSessionDidStopRecordingAudio}}}.
710 94 Adrian Georgescu
711 67 Luci Stanescu
 '''send_dtmf'''(''self'', '''digit''')::
712 67 Luci Stanescu
  If the audio stream is started, sends a DTMF digit to the remote party.
713 67 Luci Stanescu
  [[BR]]''digit'':[[BR]]
714 67 Luci Stanescu
  This should a string of length 1, containing a valid DTMF digit value (0-9, A-D, * or #).
715 67 Luci Stanescu
716 63 Luci Stanescu
==== attributes ====
717 63 Luci Stanescu
718 94 Adrian Georgescu
719 63 Luci Stanescu
 '''sample_rate'''::
720 1 Adrian Georgescu
  If the audio stream was started, this attribute contains the sample rate of the audio negotiated.
721 94 Adrian Georgescu
722 1 Adrian Georgescu
 '''codec'''::
723 1 Adrian Georgescu
  If the audio stream was started, this attribute contains the name of the audio codec that was negotiated.
724 94 Adrian Georgescu
725 67 Luci Stanescu
 '''srtp_active'''::
726 67 Luci Stanescu
  If the audio stream was started, this boolean attribute indicates if SRTP is currently being used on the stream.
727 94 Adrian Georgescu
728 1 Adrian Georgescu
 '''ice_active'''::
729 1 Adrian Georgescu
  {{{True}}} if the ICE candidates negotiated are being used, {{{False}}} otherwise.
730 94 Adrian Georgescu
731 1 Adrian Georgescu
 '''local_rtp_address'''::
732 1 Adrian Georgescu
  If an audio stream is present within the session, this attribute contains the local IP address used for the audio stream.
733 94 Adrian Georgescu
734 1 Adrian Georgescu
 '''local_rtp_port'''::
735 1 Adrian Georgescu
  If an audio stream is present within the session, this attribute contains the local UDP port used for the audio stream.
736 94 Adrian Georgescu
737 1 Adrian Georgescu
 '''remote_rtp_address_sdp'''::
738 1 Adrian Georgescu
  If the audio stream was started, this attribute contains the IP address that the remote party gave to send audio to.
739 94 Adrian Georgescu
740 1 Adrian Georgescu
 '''remote_rtp_port_sdp'''::
741 1 Adrian Georgescu
  If the audio stream was started, this attribute contains the UDP port that the remote party gave to send audio to.
742 94 Adrian Georgescu
743 1 Adrian Georgescu
 '''remote_rtp_address_received'''::
744 1 Adrian Georgescu
  If the audio stream was started, this attribute contains the remote IP address from which the audio stream is being received.
745 94 Adrian Georgescu
746 67 Luci Stanescu
 '''remote_rtp_port_received'''::
747 67 Luci Stanescu
  If the audio stream was started, this attribute contains the remote UDP port from which the audio stream is being received.
748 94 Adrian Georgescu
749 67 Luci Stanescu
 '''local_rtp_candidate_type'''::
750 67 Luci Stanescu
  The local ICE candidate type which was selected by the ICE negotiation if it succeeded and {{{None}}} otherwise.
751 94 Adrian Georgescu
752 67 Luci Stanescu
 '''remote_rtp_candidate_type'''::
753 63 Luci Stanescu
  The remote ICE candidate type which was selected by the ICE negotiation if it succeeded and {{{None}}} otherwise.
754 94 Adrian Georgescu
755 63 Luci Stanescu
 '''recording_filename'''::
756 67 Luci Stanescu
  If the audio stream is currently being recorded to disk, this property contains the name of the {{{.wav}}} file being recorded to.
757 55 Adrian Georgescu
758 55 Adrian Georgescu
==== notifications ====
759 67 Luci Stanescu
760 94 Adrian Georgescu
761 67 Luci Stanescu
 '''AudioStreamDidChangeHoldState'''::
762 67 Luci Stanescu
  Will be sent when the hold state is changed as a result of either a SIP message received on the network or the application calling the {{{hold()/unhold()}}} methods on the {{{Session}}} this stream is part of.
763 67 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
764 67 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
765 67 Luci Stanescu
  [[BR]]originator:[[BR]]
766 67 Luci Stanescu
  A string representing the party which requested the hold change, {{{"local"}}} or {{{"remote"}}}
767 1 Adrian Georgescu
  [[BR]]on_hold:[[BR]]
768 67 Luci Stanescu
  A boolean indicating the new hold state from the point of view of the originator.
769 94 Adrian Georgescu
770 63 Luci Stanescu
 '''AudioStreamWillStartRecordingAudio''::
771 63 Luci Stanescu
  Will be sent when the application requested that the audio stream be recorded to a {{{.wav}}} file, just before recording starts.
772 67 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
773 67 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
774 55 Adrian Georgescu
  [[BR]]''filename'':[[BR]]
775 67 Luci Stanescu
  The full path to the {{{.wav}}} file being recorded to.
776 94 Adrian Georgescu
777 63 Luci Stanescu
 '''AudioStreamDidStartRecordingAudio'''::
778 63 Luci Stanescu
  Will be sent when the application requested that the audio stream be recorded to a {{{.wav}}} file, just after recording started.
779 67 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
780 67 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
781 63 Luci Stanescu
  [[BR]]''filename'':[[BR]]
782 63 Luci Stanescu
  The full path to the {{{.wav}}} file being recorded to.
783 94 Adrian Georgescu
784 63 Luci Stanescu
 '''AudioStreamWillStopRecordingAudio'''::
785 63 Luci Stanescu
  Will be sent when the application requested ending the recording to a {{{.wav}}} file, just before recording stops.
786 67 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
787 67 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
788 57 Adrian Georgescu
  [[BR]]''filename'':[[BR]]
789 67 Luci Stanescu
  The full path to the {{{.wav}}} file being recorded to.
790 94 Adrian Georgescu
791 63 Luci Stanescu
 '''AudioStreamDidStopRecordingAudio'''::
792 63 Luci Stanescu
  Will be sent when the application requested ending the recording to a {{{.wav}}} file, just after recording stoped.
793 67 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
794 67 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
795 67 Luci Stanescu
  [[BR]]''filename'':[[BR]]
796 67 Luci Stanescu
  The full path to the {{{.wav}}} file being recorded to.
797 94 Adrian Georgescu
798 63 Luci Stanescu
 '''AudioStreamDidChangeRTPParameters'''::
799 1 Adrian Georgescu
  This notification is sent when the RTP parameters are changed, such as codec, sample rate, RTP port etc.
800 63 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
801 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
802 94 Adrian Georgescu
803 57 Adrian Georgescu
 '''AudioStreamGotDTMF'''::
804 1 Adrian Georgescu
  Will be send if there is a DMTF digit received from the remote party on the audio stream. 
805 63 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
806 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
807 67 Luci Stanescu
  [[BR]]''digit'':[[BR]]
808 67 Luci Stanescu
  The DTMF digit that was received, in the form of a string of length 1.
809 94 Adrian Georgescu
810 67 Luci Stanescu
 '''AudioStreamICENegotiationStateDidChange'''::
811 67 Luci Stanescu
  This notification is proxied from the {{{RTPTransport}}} and as such has the same data as the {{{RTPTransportICENegotiationStateDidChange}}}.
812 94 Adrian Georgescu
813 67 Luci Stanescu
 '''AudioStreamICENegotiationDidSucceed'''::
814 67 Luci Stanescu
  This notification is proxied from the {{{RTPTransport}}} and as such has the same data as the {{{RTPTransportICENegotiationDidSucceed}}}.
815 94 Adrian Georgescu
816 1 Adrian Georgescu
 '''AudioStreamICENegotiationDidFail'''::
817 69 Luci Stanescu
  This notification is proxied from the {{{RTPTransport}}} and as such has the same data as the {{{RTPTransportICENegotiationDidFail}}}.
818 136 Adrian Georgescu
819 136 Adrian Georgescu
 '''AudioStreamDidTimeout'''::
820 136 Adrian Georgescu
  This notification is proxied from the {{{RTPTransport}}}. It's sent when the RTP transport did not receive any data after the specified amount of time (rtp.timeout setting in the {{{Account}}}).
821 136 Adrian Georgescu
822 1 Adrian Georgescu
=== MSRPStreamBase ===
823 1 Adrian Georgescu
824 68 Luci Stanescu
Implemented in [browser:sipsimple/streams/msrp.py]
825 1 Adrian Georgescu
826 68 Luci Stanescu
The {{{MSRPStreamBase}}} is used as a base class for streams using the MSRP protocol. Within the SIP SIMPLE middleware, this hold for the {{{ChatStream}}}, {{{FileTransferStream}}} and {{{DesktopSharingStream}}} classes, however the application can also make use of this class to implement some other streams based on the MSRP protocol as a transport.
827 68 Luci Stanescu
828 68 Luci Stanescu
==== methods ====
829 68 Luci Stanescu
 
830 69 Luci Stanescu
Of the methods defined by the {{{IMediaStream}}} interface, only the {{{new_from_sdp}}} method is not implemented in this base class and needs to be provided by the subclasses. Also, the subclasses can defined methods of the form {{{_handle_XXX}}}, where XXX is a MSRP method name in order to handle incoming MSRP requests. Also, since this class registers as an observer for itself, it will receive the notifications it sends so subclasses can define methods having the signature {{{_NH_<notification name>(self, notification)}}} as used throughout the middleware in order to do various things at the different points within the life-cycle of the stream.
831 68 Luci Stanescu
832 96 Adrian Georgescu
==== attributes ====
833 68 Luci Stanescu
834 68 Luci Stanescu
The attributes defined in the {{{IMediaStream}}} interface which are not provided by this class are:
835 68 Luci Stanescu
 * type
836 68 Luci Stanescu
 * priority
837 1 Adrian Georgescu
838 68 Luci Stanescu
In addition, the following attributes need to be defined in the subclass in order for the {{{MSRPStreamBase}}} class to take the correct decisions
839 94 Adrian Georgescu
840 1 Adrian Georgescu
 '''media_type'''::
841 68 Luci Stanescu
  The media type as included in the SDP (eg. {{{"message"}}}, {{{"application"}}}).
842 94 Adrian Georgescu
843 1 Adrian Georgescu
 '''accept_types'''::
844 68 Luci Stanescu
  A list of the MIME types which should be accepted by the stream (this is also sent within the SDP).
845 94 Adrian Georgescu
846 1 Adrian Georgescu
 '''accept_wrapped_types'''::
847 68 Luci Stanescu
  A list of the MIME types which should be accepted by the stream while wrapped in a {{{message/cpim}}} envelope.
848 94 Adrian Georgescu
849 1 Adrian Georgescu
 '''use_msrp_session'''::
850 69 Luci Stanescu
  A boolean indicating whether or not an {{{MSRPSession}}} should be used.
851 1 Adrian Georgescu
852 68 Luci Stanescu
==== notifications ====
853 68 Luci Stanescu
854 1 Adrian Georgescu
While not technically notifications of {{{MSRPStreamBase}}}, these notifications are sent from the middleware on behalf of the {{{MSRPTransport}}} used by a stream in the former case, and anonymously in the latter.
855 68 Luci Stanescu
856 94 Adrian Georgescu
857 68 Luci Stanescu
 '''MSRPTransportTrace'''::
858 68 Luci Stanescu
  This notification is sent when an MSRP message is received for logging purposes.
859 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
860 68 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
861 68 Luci Stanescu
  [[BR]]direction:[[BR]]
862 68 Luci Stanescu
  The direction of the message, {{{"incoming"}}} or {{{"outgoing"}}}.
863 68 Luci Stanescu
  [[BR]]data:[[BR]]
864 68 Luci Stanescu
  The MSRP message as a string.
865 94 Adrian Georgescu
866 68 Luci Stanescu
 '''MSRPLibraryLog'''::
867 68 Luci Stanescu
  This notification is sent anonymously whenever the MSRP library needs to log any information.
868 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
869 68 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
870 68 Luci Stanescu
  [[BR]]message:[[BR]]
871 68 Luci Stanescu
  The log message as a string.
872 1 Adrian Georgescu
  [[BR]]level:[[BR]]
873 68 Luci Stanescu
  The log level at which the message was written. One of the levels {{{DEBUG}}}, {{{INFO}}}, {{{WARNING}}}, {{{ERROR}}}, {{{CRITICAL}}} from the {{{application.log.level}}} object which is part of the {{{python-application}}} library.
874 1 Adrian Georgescu
875 1 Adrian Georgescu
=== ChatStream ===
876 1 Adrian Georgescu
877 68 Luci Stanescu
Implemented in [browser:sipsimple/streams/msrp.py]
878 1 Adrian Georgescu
879 1 Adrian Georgescu
{{{sipsimple.streams.msrp.ChatStream}}} implements session-based Instant Messaging (IM) over MSRP. This class performs the following functions:
880 68 Luci Stanescu
881 68 Luci Stanescu
 * automatically wraps outgoing messages with Message/CPIM if that's necessary according to accept-types
882 1 Adrian Georgescu
 * unwraps incoming Message/CPIM messages; for each incoming message, the {{{ChatStreamGotMessage}}} notification is posted
883 68 Luci Stanescu
 * composes iscomposing payloads and reacts to those received by sending the {{{ChatStreamGotComposingIndication}}} notification
884 1 Adrian Georgescu
885 1 Adrian Georgescu
An example of an SDP created using this class follows:
886 1 Adrian Georgescu
887 1 Adrian Georgescu
{{{
888 1 Adrian Georgescu
Content-Type: application/sdp
889 1 Adrian Georgescu
Content-Length:   283
890 1 Adrian Georgescu
891 1 Adrian Georgescu
v=0
892 1 Adrian Georgescu
o=- 3467525214 3467525214 IN IP4 192.168.1.6
893 1 Adrian Georgescu
s=blink-0.10.7-beta
894 1 Adrian Georgescu
c=IN IP4 192.168.1.6
895 1 Adrian Georgescu
t=0 0
896 1 Adrian Georgescu
m=message 2855 TCP/TLS/MSRP *
897 1 Adrian Georgescu
a=path:msrps://192.168.1.6:2855/ca7940f12ddef14c3c32;tcp
898 1 Adrian Georgescu
a=accept-types:message/cpim text/* application/im-iscomposing+xml
899 1 Adrian Georgescu
a=accept-wrapped-types:*
900 68 Luci Stanescu
}}}
901 1 Adrian Georgescu
902 68 Luci Stanescu
==== methods ====
903 68 Luci Stanescu
904 94 Adrian Georgescu
905 1 Adrian Georgescu
 '''!__init!__'''(''self'', '''account''', '''direction'''={{{'sendrecv'}}})::
906 68 Luci Stanescu
  Initializes the ChatStream instance.
907 68 Luci Stanescu
908 94 Adrian Georgescu
909 68 Luci Stanescu
 '''send_message'''(''self'', '''content''', '''content_type'''={{{'text/plain'}}}, '''recipients'''={{{None}}}, '''courtesy_recipients'''={{{None}}}, '''subject'''={{{None}}}, ''timestamp''={{{None}}}, '''required'''={{{None}}}, '''additional_headers'''={{{None}}})::
910 68 Luci Stanescu
  Sends an IM message. Prefer Message/CPIM wrapper if it is supported. If called before the connection was established, the messages will be
911 68 Luci Stanescu
  queued until the stream starts.
912 68 Luci Stanescu
  Returns the generated MSRP message ID.
913 68 Luci Stanescu
  [[BR]]content:[[BR]]
914 68 Luci Stanescu
  The content of the message.
915 68 Luci Stanescu
  [[BR]]content_type:[[BR]]
916 68 Luci Stanescu
  Content-Type of wrapped message if Message/CPIM is used (Content-Type of MSRP message is always Message/CPIM in that case);
917 68 Luci Stanescu
  otherwise, Content-Type of MSRP message.
918 68 Luci Stanescu
  [[BR]]recipients:[[BR]]
919 68 Luci Stanescu
  The list of {{{CPIMIdentity}}} objects which will be used for the {{{To}}} header of the CPIM wrapper. Used to override the default which depends on the remote identity.
920 68 Luci Stanescu
  May only differ from the default one if the remote party supports private messages. If it does not, a {{{ChatStreamError}}} will be raised.
921 68 Luci Stanescu
  [[BR]]courtesy_recipients:[[BR]]
922 68 Luci Stanescu
  The list of {{{CPIMIdentity}}} objects which will be used for the {{{cc}}} header of the CPIM wrapper.
923 68 Luci Stanescu
  May only be specified if the remote party supports private messages and CPIM is supported. If it does not, a {{{ChatStreamError}}} will be raised.
924 68 Luci Stanescu
  [[BR]]subject:[[BR]]
925 68 Luci Stanescu
  A string or {{{MultilingualText}}} which specifies the subject and its translations to be added to the CPIM message. If CPIM is not supported, a {{{ChatStreamError}}} will be raised.
926 68 Luci Stanescu
  [[BR]]required:[[BR]]
927 68 Luci Stanescu
  A list of strings describing the required capabilities that the other endpoint must support in order to understand this CPIM message. If CPIM is not supported, a {{{ChatStreamError}}} will be raised.
928 68 Luci Stanescu
  [[BR]]additional_headers:[[BR]]
929 1 Adrian Georgescu
  A list of MSRP header objects which will be added to this CPIM message. If CPIM is not supported, a {{{ChatStreamError}}} will be raised.
930 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
931 1 Adrian Georgescu
  A {{{datetime.datetime}}} object representing the timestamp to put on the CPIM wrapper of the message.
932 1 Adrian Georgescu
  When set to {{{None}}}, a default one representing the current moment will be added.
933 1 Adrian Georgescu
934 1 Adrian Georgescu
 These MSRP headers are used to enable end-to-end success reports and to disable hop-to-hop successful responses:
935 1 Adrian Georgescu
{{{
936 1 Adrian Georgescu
Failure-Report: partial
937 1 Adrian Georgescu
Success-Report: yes
938 68 Luci Stanescu
}}}
939 68 Luci Stanescu
940 94 Adrian Georgescu
941 68 Luci Stanescu
 '''send_composing_indication'''(''self'', ''state'', ''refresh'', ''last_active=None'', ''recipients=None'')::
942 68 Luci Stanescu
  Sends an is-composing message to the listed recipients.
943 68 Luci Stanescu
  [[BR]]state:[[BR]]
944 68 Luci Stanescu
  The state of the endpoint, {{{"active"}}} or {{{"idle"}}}.
945 68 Luci Stanescu
  [[BR]]refresh:[[BR]]
946 68 Luci Stanescu
  How often the local endpoint will send is-composing indications to keep the state from being reverted to {{{"idle"}}}.
947 68 Luci Stanescu
  [[BR]]last_active:[[BR]]
948 68 Luci Stanescu
  A {{{datatime.datetime}}} object representing the moment when the local endpoint was last active.
949 68 Luci Stanescu
  [[BR]]recipients:[[BR]]
950 1 Adrian Georgescu
  The list of {{{CPIMIdentity}}} objects which will be used for the {{{To}}} header of the CPIM wrapper. Used to override the default which depends on the remote identity.
951 68 Luci Stanescu
  May only differ from the default one if the remote party supports private messages. If it does not, a {{{ChatStreamError}}} will be raised.
952 1 Adrian Georgescu
953 1 Adrian Georgescu
==== notifications ====
954 68 Luci Stanescu
955 94 Adrian Georgescu
956 68 Luci Stanescu
 '''ChatStreamGotMessage'''::
957 68 Luci Stanescu
  Sent whenever a new incoming message is received,
958 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
959 68 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
960 1 Adrian Georgescu
  [[BR]]message:[[BR]]
961 68 Luci Stanescu
  A {{{ChatMessage}}} or {{{CPIMMessage}}} instance, depending on whether a CPIM message was received or not.
962 94 Adrian Georgescu
963 68 Luci Stanescu
 '''ChatStreamDidDeliverMessage'''::
964 68 Luci Stanescu
  Sent when a successful report is received.
965 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
966 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
967 68 Luci Stanescu
  [[BR]]message_id:[[BR]]
968 68 Luci Stanescu
  Text identifier of the message.
969 68 Luci Stanescu
  [[BR]]code:[[BR]]
970 68 Luci Stanescu
  The status code received. Will always be 200 for this notification.
971 68 Luci Stanescu
  [[BR]]reason:[[BR]]
972 1 Adrian Georgescu
  The status reason received.
973 1 Adrian Georgescu
  [[BR]]chunk:[[BR]]
974 68 Luci Stanescu
  A {{{msrplib.protocol.MSRPData}}} instance providing all the MSRP information about the report.
975 94 Adrian Georgescu
976 68 Luci Stanescu
 '''ChatStreamDidNotDeliverMessage'''::
977 68 Luci Stanescu
  Sent when a failure report is received.
978 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
979 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
980 68 Luci Stanescu
  [[BR]]message_id:[[BR]]
981 68 Luci Stanescu
  Text identifier of the message.
982 68 Luci Stanescu
  [[BR]]code:[[BR]]
983 68 Luci Stanescu
  The status code received.
984 68 Luci Stanescu
  [[BR]]reason:[[BR]]
985 1 Adrian Georgescu
  The status reason received.
986 1 Adrian Georgescu
  [[BR]]chunk:[[BR]]
987 68 Luci Stanescu
  A {{{msrplib.protocol.MSRPData}}} instance providing all the MSRP information about the report.
988 94 Adrian Georgescu
989 68 Luci Stanescu
 '''ChatStreamDidSendMessage'''::
990 68 Luci Stanescu
  Sent when an outgoing message has been sent.
991 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
992 68 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
993 1 Adrian Georgescu
  [[BR]]message:[[BR]]
994 68 Luci Stanescu
  A {{{msrplib.protocol.MSRPData}}} instance providing all the MSRP information about the sent message.
995 94 Adrian Georgescu
996 68 Luci Stanescu
 '''ChatStreamGotComposingIndication'''::
997 68 Luci Stanescu
  Sent when a is-composing payload is received.
998 68 Luci Stanescu
  [[BR]]timestamp:[[BR]]
999 68 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1000 68 Luci Stanescu
  [[BR]]state:[[BR]]
1001 68 Luci Stanescu
  The state of the endpoint, {{{"active"}}} or {{{"idle"}}}.
1002 68 Luci Stanescu
  [[BR]]refresh:[[BR]]
1003 68 Luci Stanescu
  How often the remote endpoint will send is-composing indications to keep the state from being reverted to {{{"idle"}}}. May be {{{None}}}.
1004 68 Luci Stanescu
  [[BR]]last_active:[[BR]]
1005 68 Luci Stanescu
  A {{{datatime.datetime}}} object representing the moment when the remote endpoint was last active. May be {{{None}}}.
1006 68 Luci Stanescu
  [[BR]]content_type:[[BR]]
1007 68 Luci Stanescu
  The MIME type of message being composed. May be {{{None}}}.
1008 55 Adrian Georgescu
  [[BR]]sender:[[BR]]
1009 70 Luci Stanescu
  The {{{ChatIdentity}}} or {{{CPIMIdentity}}} instance which identifies the sender of the is-composing indication.
1010 137 Adrian Georgescu
  [[BR]]recipients:[[BR]]
1011 137 Adrian Georgescu
  The {{{ChatIdentity}}} or {{{CPIMIdentity}}} instances list which identifies the recipients of the is-composing indication.
1012 1 Adrian Georgescu
1013 70 Luci Stanescu
=== FileSelector ===
1014 70 Luci Stanescu
1015 70 Luci Stanescu
The {{{FileSelector}}} is used to contain information about a file tranfer using the {{{FileTransferStream}}} documented below.
1016 70 Luci Stanescu
1017 70 Luci Stanescu
==== methods ====
1018 70 Luci Stanescu
1019 94 Adrian Georgescu
1020 70 Luci Stanescu
 '''!__init!__'''(''self'', '''name'''={{{None}}}, '''type'''={{{None}}}, '''size'''={{{None}}}, '''hash'''={{{None}}}, '''fd'''={{{None}}})::
1021 70 Luci Stanescu
  Instantiate a new {{{FileSelector}}}. All the arguments are also available as attributes.
1022 70 Luci Stanescu
  [[BR]]name:[[BR]]
1023 70 Luci Stanescu
  The filename (should be just the base name).
1024 1 Adrian Georgescu
  [[BR]]type:[[BR]]
1025 1 Adrian Georgescu
  The type of the file.
1026 1 Adrian Georgescu
  [[BR]]size:[[BR]]
1027 1 Adrian Georgescu
  The size of the file in bytes.
1028 1 Adrian Georgescu
  [[BR]]hash:[[BR]]
1029 1 Adrian Georgescu
  The hash of the file in the following format: {{{hash:sha-1:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX}}}, where {{{X}}} is a hexadecimal digit. Currently, only SHA1 hashes are supported according to the RFC.
1030 1 Adrian Georgescu
  [[BR]]fd:[[BR]]
1031 1 Adrian Georgescu
  A file descriptor if the application has already opened the file.
1032 94 Adrian Georgescu
1033 1 Adrian Georgescu
 '''parse'''(''cls'', '''string''')::
1034 1 Adrian Georgescu
  Parses a file selector from the SDP {{{file-selector}}} a attribute and returns a {{{FileSelector}}} instance.
1035 94 Adrian Georgescu
1036 1 Adrian Georgescu
 '''for_file'''(''cls'', '''path''', '''content_type''', '''compute_hash'''={{{True}}})::
1037 1 Adrian Georgescu
  Returns a {{{FileSelector}}} instance for the specified file. The file identified by the path must exist. Note that if {{{compute_hash}}} is {{{True}}} this method will block while the hash is computed, a potentially long operation for large files.
1038 1 Adrian Georgescu
  [[BR]]path:[[BR]]
1039 1 Adrian Georgescu
  The full path to the file.
1040 1 Adrian Georgescu
  [[BR]]content_type:[[BR]]
1041 1 Adrian Georgescu
  An optional MIME type which is to be included in the file-selector.
1042 1 Adrian Georgescu
  [[BR]]compute_hash:[[BR]]
1043 1 Adrian Georgescu
  Whether or not this method should compute the hash of the file.
1044 1 Adrian Georgescu
1045 135 Adrian Georgescu
 '''compute_hash'''(''self'')::
1046 135 Adrian Georgescu
  Compute the hash for this file selector. This method will block while the hash is computed, a potentially long operation for large files. 
1047 135 Adrian Georgescu
1048 1 Adrian Georgescu
==== attributes ====
1049 1 Adrian Georgescu
1050 94 Adrian Georgescu
1051 1 Adrian Georgescu
 '''sdp_repr'''::
1052 1 Adrian Georgescu
  The SDP representation of the file-selector according to the RFC. This should be the value of the {{{file-selector}}} SDP attribute.
1053 1 Adrian Georgescu
1054 1 Adrian Georgescu
=== FileTransferStream ===
1055 1 Adrian Georgescu
1056 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/msrp.py]
1057 1 Adrian Georgescu
1058 1 Adrian Georgescu
The {{{FileTransferStream}}} supports file transfer over MSRP according to RFC5547. An example of SDP constructed using this stream follows:
1059 1 Adrian Georgescu
1060 1 Adrian Georgescu
{{{
1061 1 Adrian Georgescu
Content-Type: application/sdp
1062 1 Adrian Georgescu
Content-Length:   383
1063 1 Adrian Georgescu
1064 1 Adrian Georgescu
v=0
1065 1 Adrian Georgescu
o=- 3467525166 3467525166 IN IP4 192.168.1.6
1066 1 Adrian Georgescu
s=blink-0.10.7-beta
1067 1 Adrian Georgescu
c=IN IP4 192.168.1.6
1068 1 Adrian Georgescu
t=0 0
1069 1 Adrian Georgescu
m=message 2855 TCP/TLS/MSRP *
1070 1 Adrian Georgescu
a=path:msrps://192.168.1.6:2855/e593357dc9abe90754bd;tcp
1071 1 Adrian Georgescu
a=sendonly
1072 1 Adrian Georgescu
a=accept-types:*
1073 1 Adrian Georgescu
a=accept-wrapped-types:*
1074 1 Adrian Georgescu
a=file-selector:name:"reblink.pdf" type:com.adobe.pdf size:268759 hash:sha1:60:A1:BE:8D:71:DB:E3:8E:84:C9:2C:62:9E:F2:99:78:9D:68:79:F6
1075 1 Adrian Georgescu
}}}
1076 1 Adrian Georgescu
1077 1 Adrian Georgescu
==== methods ====
1078 1 Adrian Georgescu
1079 94 Adrian Georgescu
1080 1 Adrian Georgescu
 '''!__init!__'''(''self'', '''account''', '''file_selector'''={{{None}}})::
1081 1 Adrian Georgescu
  Instantiate a new {{{FileTransferStream}}}. If this is constructed by the application for an outgoing file transfer, the {{{file_selector}}} argument must be present.
1082 1 Adrian Georgescu
  [[BR]]account:[[BR]]
1083 1 Adrian Georgescu
  The {{{sipsimple.account.Account}}} or {{{sipsimple.account.BonjourAccount}}} instance which will be associated with the stream.
1084 1 Adrian Georgescu
  [[BR]]file_selector:[[BR]]
1085 1 Adrian Georgescu
  The {{{FileSelector}}} instance which represents the file which is to be transferred.
1086 1 Adrian Georgescu
1087 1 Adrian Georgescu
==== notifications ====
1088 1 Adrian Georgescu
1089 94 Adrian Georgescu
1090 1 Adrian Georgescu
 '''FileTransferStreamDidDeliverChunk'''::
1091 1 Adrian Georgescu
  This notification is sent for an outgoing file transfer when a success report is received about part of the file being transferred.
1092 1 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1093 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1094 1 Adrian Georgescu
  [[BR]]message_id:[[BR]]
1095 1 Adrian Georgescu
  The MSRP message ID of the file transfer session.
1096 1 Adrian Georgescu
  [[BR]]chunk:[[BR]]
1097 1 Adrian Georgescu
  An {{{msrplib.protocol.MSRPData}}} instance represented the received REPORT.
1098 1 Adrian Georgescu
  [[BR]]code:[[BR]]
1099 1 Adrian Georgescu
  The status code received. Will always be 200 for this notification.
1100 1 Adrian Georgescu
  [[BR]]reason:[[BR]]
1101 1 Adrian Georgescu
  The status reason received.
1102 1 Adrian Georgescu
  [[BR]]transferred_bytes:[[BR]]
1103 1 Adrian Georgescu
  The number of bytes which have currently been successfully transferred.
1104 1 Adrian Georgescu
  [[BR]]file_size:[[BR]]
1105 1 Adrian Georgescu
  The size of the file being transferred.
1106 94 Adrian Georgescu
1107 1 Adrian Georgescu
 '''FileTransferStreamDidNotDeliverChunk'''::
1108 1 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1109 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1110 1 Adrian Georgescu
  This notification is sent for an outgoing file transfer when a failure report is received about part of the file being transferred.
1111 1 Adrian Georgescu
  [[BR]]message_id:[[BR]]
1112 1 Adrian Georgescu
  The MSRP message ID of the file transfer session.
1113 1 Adrian Georgescu
  [[BR]]chunk:[[BR]]
1114 1 Adrian Georgescu
  An {{{msrplib.protocol.MSRPData}}} instance represented the received REPORT.
1115 1 Adrian Georgescu
  [[BR]]code:[[BR]]
1116 1 Adrian Georgescu
  The status code received.
1117 1 Adrian Georgescu
  [[BR]]reason:[[BR]]
1118 1 Adrian Georgescu
  The status reason received.
1119 94 Adrian Georgescu
1120 1 Adrian Georgescu
 '''FileTransferStreamDidFinish'''::
1121 1 Adrian Georgescu
  This notification is sent when the incoming or outgoing file transfer is finished.
1122 1 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1123 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1124 94 Adrian Georgescu
1125 1 Adrian Georgescu
 '''FileTransferStreamGotChunk'''::
1126 1 Adrian Georgescu
  This notificaiton is sent for an incoming file transfer when a chunk of file data is received.
1127 1 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1128 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1129 1 Adrian Georgescu
  [[BR]]content:[[BR]]
1130 1 Adrian Georgescu
  The file part which was received, as a {{{str}}}.
1131 1 Adrian Georgescu
  [[BR]]content_type:[[BR]]
1132 1 Adrian Georgescu
  The MIME type of the file which is being transferred.
1133 1 Adrian Georgescu
  [[BR]]transferred_bytes:[[BR]]
1134 1 Adrian Georgescu
  The number of bytes which have currently been successfully transferred.
1135 1 Adrian Georgescu
  [[BR]]file_size:[[BR]]
1136 1 Adrian Georgescu
  The size of the file being transferred.
1137 1 Adrian Georgescu
1138 1 Adrian Georgescu
1139 1 Adrian Georgescu
=== IDesktopSharingHandler ===
1140 1 Adrian Georgescu
1141 1 Adrian Georgescu
This interface is used to describe the interface between a {{{IDesktopSharingHandler}}}, which is responsible for consuming and producing RFB data, and the {{{DesktopSharingStream}}} which is responsible for transporting the RFB data over MSRP. The middleware provides four implementations of this interface:
1142 1 Adrian Georgescu
 * InternalVNCViewerHandler
1143 1 Adrian Georgescu
 * InternalVNCServerHandler
1144 1 Adrian Georgescu
 * ExternalVNCViewerHandler
1145 1 Adrian Georgescu
 * ExternalVNCServerHandler
1146 1 Adrian Georgescu
1147 1 Adrian Georgescu
==== methods ====
1148 1 Adrian Georgescu
 
1149 94 Adrian Georgescu
1150 1 Adrian Georgescu
 '''initialize'''(''self'', '''stream''')::
1151 1 Adrian Georgescu
  This method will be called by the {{{DesktopSharingStream}}} when the stream has been started and RFB data can be transported. The stream has two attributes which are relevant to the {{{IDesktopSharingHandler}}}: incoming_queue and outgoing_queue. These attributes are {{{eventlet.coros.queue}}} instances which are used to transport RFB data between the stream and the handler.
1152 1 Adrian Georgescu
1153 1 Adrian Georgescu
==== attributes ====
1154 1 Adrian Georgescu
1155 94 Adrian Georgescu
1156 1 Adrian Georgescu
 '''type'''::
1157 1 Adrian Georgescu
  {{{"active"}}} or {{{"passive"}}} depending on whether the handler represents a VNC viewer or server respectively.
1158 1 Adrian Georgescu
1159 1 Adrian Georgescu
==== notifications ====
1160 1 Adrian Georgescu
1161 94 Adrian Georgescu
1162 1 Adrian Georgescu
 '''DesktopSharingHandlerDidFail'''::
1163 1 Adrian Georgescu
  This notification must be sent by the handler when an error occurs to notify the stream that it should fail.
1164 1 Adrian Georgescu
  [[BR]]context:[[BR]]
1165 1 Adrian Georgescu
  A string describing when the handler failed, such as {{{"reading"}}}, {{{"sending"}}} or {{{"connecting"}}}.
1166 1 Adrian Georgescu
  [[BR]]failure:[[BR]]
1167 1 Adrian Georgescu
  A {{{twisted.python.failure.Failure}}} instance describing the exception which led to the failure.
1168 1 Adrian Georgescu
  [[BR]]reason:[[BR]]
1169 1 Adrian Georgescu
  A string describing the failure reason.
1170 1 Adrian Georgescu
1171 1 Adrian Georgescu
=== InternalVNCViewerHandler ===
1172 1 Adrian Georgescu
1173 99 Luci Stanescu
This is a concrete implementation of the {{{IDesktopSharingHandler}}} interface which can be used for a VNC viewer implemented within the application.
1174 1 Adrian Georgescu
1175 1 Adrian Georgescu
==== methods ====
1176 1 Adrian Georgescu
1177 94 Adrian Georgescu
1178 1 Adrian Georgescu
 '''send'''(''self'', '''data''')::
1179 1 Adrian Georgescu
  Sends the specified data to the stream in order for it to be transported over MSRP to the remote endpoint.
1180 1 Adrian Georgescu
  [[BR]]data:[[BR]]
1181 1 Adrian Georgescu
  The RFB data to be transported over MSRP, in the form of a {{{str}}}.
1182 1 Adrian Georgescu
1183 1 Adrian Georgescu
==== notifications ====
1184 1 Adrian Georgescu
1185 94 Adrian Georgescu
1186 1 Adrian Georgescu
 '''DesktopSharingStreamGotData'''::
1187 1 Adrian Georgescu
  This notification is sent when data is received over MSRP.
1188 1 Adrian Georgescu
  [[BR]]data:[[BR]]
1189 1 Adrian Georgescu
  The RFB data from the remote endpoint, in the form of a {{{str}}}.
1190 1 Adrian Georgescu
1191 1 Adrian Georgescu
=== InternalVNCServerHandler ===
1192 1 Adrian Georgescu
1193 99 Luci Stanescu
This is a concrete implementation of the {{{IDesktopSharingHandler}}} interface which can be used for a VNC server implemented within the application.
1194 1 Adrian Georgescu
1195 1 Adrian Georgescu
==== methods ====
1196 1 Adrian Georgescu
1197 94 Adrian Georgescu
1198 1 Adrian Georgescu
 '''send'''(''self'', '''data''')::
1199 1 Adrian Georgescu
  Sends the specified data to the stream in order for it to be transported over MSRP to the remote endpoint.
1200 1 Adrian Georgescu
  [[BR]]data:[[BR]]
1201 1 Adrian Georgescu
  The RFB data to be transported over MSRP, in the form of a {{{str}}}.
1202 1 Adrian Georgescu
1203 1 Adrian Georgescu
==== notifications ====
1204 1 Adrian Georgescu
1205 94 Adrian Georgescu
1206 1 Adrian Georgescu
 '''DesktopSharingStreamGotData'''::
1207 1 Adrian Georgescu
  This notification is sent when data is received over MSRP.
1208 1 Adrian Georgescu
  [[BR]]data:[[BR]]
1209 1 Adrian Georgescu
  The RFB data from the remote endpoint, in the form of a {{{str}}}.
1210 1 Adrian Georgescu
1211 1 Adrian Georgescu
=== ExternalVNCViewerHandler ===
1212 1 Adrian Georgescu
1213 1 Adrian Georgescu
This implementation of {{{IDesktopSharingHandler}}} can be used for an external VNC viewer which connects to a VNC server using TCP.
1214 1 Adrian Georgescu
1215 1 Adrian Georgescu
==== methods ====
1216 1 Adrian Georgescu
1217 94 Adrian Georgescu
1218 1 Adrian Georgescu
 '''!__init!__'''(''self'', '''address'''={{{("localhost", 0)}}}, '''connect_timeout'''={{{3}}})::
1219 1 Adrian Georgescu
  This instantiates a new {{{ExternalVNCViewerHandler}}} which is listening on the provided address, ready for the external VNC viewer to connect to it via TCP. After this method returns, the attribute {{{address}}} can be used to find out exactly on what address and port the handler is listening on. The handler will only accept one conenction on this address.
1220 1 Adrian Georgescu
  [[BR]]address:[[BR]]
1221 1 Adrian Georgescu
  A tuple containing an IP address/hostname and a port on which the handler should listen. Any data received on this socket will then be forwarded to the stream and any data received from the stream will be forwarded to this socket.
1222 1 Adrian Georgescu
1223 109 Adrian Georgescu
==== attributes ====
1224 1 Adrian Georgescu
1225 94 Adrian Georgescu
1226 1 Adrian Georgescu
 '''address'''::
1227 1 Adrian Georgescu
  A tuple containing an IP address and a port on which the handler is listening.
1228 1 Adrian Georgescu
1229 1 Adrian Georgescu
=== ExternalVNCServerHandler ===
1230 1 Adrian Georgescu
1231 1 Adrian Georgescu
This implementation of {{{IDesktopSharingHandler}}} can be used for an external VNC server to which handler will connect using TCP.
1232 1 Adrian Georgescu
1233 1 Adrian Georgescu
==== methods ====
1234 1 Adrian Georgescu
1235 94 Adrian Georgescu
1236 1 Adrian Georgescu
 '''!__init!__'''(''self'', '''address''', '''connect_timeout'''={{{3}}})::
1237 1 Adrian Georgescu
  This instantiates a new {{{ExternalVNCServerHandler}}} which will connect to the provided address on which a VNC server must be listening before the stream using this handler starts.
1238 1 Adrian Georgescu
  [[BR]]address:[[BR]]
1239 1 Adrian Georgescu
  A tuple containing an IP address/hostname and a port on which the VNC server will be listening. Any data received on this socket will then be forwared to the stream and any data received form the stream will be forwarded to this socket.
1240 1 Adrian Georgescu
  [[BR]]connect_timeout:[[BR]]
1241 1 Adrian Georgescu
  How long to wait to connect to the VNC server before giving up.
1242 1 Adrian Georgescu
1243 1 Adrian Georgescu
1244 1 Adrian Georgescu
=== DesktopSharingStream ===
1245 1 Adrian Georgescu
1246 1 Adrian Georgescu
Implemented in [browser:sipsimple/streams/msrp.py]
1247 1 Adrian Georgescu
1248 1 Adrian Georgescu
This stream implements desktop sharing using MSRP as a transport protocol for RFB data.
1249 1 Adrian Georgescu
1250 1 Adrian Georgescu
There is no standard defining this usage but is fairly easy to implement in clients that already support MSRP. To traverse a NAT-ed router, a [http://msrprelay.org MSRP relay] configured for the called party domain is needed. Below is an example of the Session Description Protocol used for establishing a Desktop sharing session:
1251 1 Adrian Georgescu
1252 1 Adrian Georgescu
{{{
1253 1 Adrian Georgescu
m=application 2855 TCP/TLS/MSRP *
1254 1 Adrian Georgescu
a=path:msrps://10.0.1.19:2855/b599b22d1b1d6a3324c8;tcp
1255 1 Adrian Georgescu
a=accept-types:application/x-rfb
1256 118 Adrian Georgescu
a=rfbsetup:active
1257 1 Adrian Georgescu
}}}
1258 1 Adrian Georgescu
1259 1 Adrian Georgescu
1260 1 Adrian Georgescu
==== methods ====
1261 1 Adrian Georgescu
1262 94 Adrian Georgescu
1263 1 Adrian Georgescu
 '''!__init!__'''(''self'', '''acount''', '''handler''')::
1264 1 Adrian Georgescu
  Instantiate a new {{{DesktopSharingStream}}}.
1265 1 Adrian Georgescu
  [[BR]]account:[[BR]]
1266 1 Adrian Georgescu
  The {{{sipsimple.account.Account}}} or {{{sipsimple.account.BonjourAccount}}} instance this stream is associated with.
1267 1 Adrian Georgescu
  [[BR]]handler:[[BR]]
1268 1 Adrian Georgescu
  An object implementing the {{{IDesktopSharingHandler}}} interface which will act as the handler for RFB data.
1269 1 Adrian Georgescu
1270 1 Adrian Georgescu
==== attributes ====
1271 1 Adrian Georgescu
1272 94 Adrian Georgescu
1273 1 Adrian Georgescu
 '''handler'''::
1274 1 Adrian Georgescu
  This is a writable property which can be used to get or set the object implementing {{{IDesktopSharingHandler}}} which acts as the handler for RFB data. For incoming {{{DesktopSharingStreams}}}, this must be set by the application before the stream starts.
1275 94 Adrian Georgescu
1276 1 Adrian Georgescu
 '''incoming_queue'''::
1277 1 Adrian Georgescu
  A {{{eventlet.coros.queue}}} instance on which incoming RFB data is written. The handler should wait for data on this queue.
1278 94 Adrian Georgescu
1279 1 Adrian Georgescu
 '''outgoing_queue'''::
1280 1 Adrian Georgescu
  A {{{eventlet.coros.queue}}} instance on which outgoing RFB data is written. The handler should write data on this queue.
1281 84 Adrian Georgescu
1282 141 Adrian Georgescu
=== ConferenceHandler ===
1283 141 Adrian Georgescu
1284 141 Adrian Georgescu
This class is internal to the {{{Session}}} and provied the user with the ability to invite participants to a conference hosted by the remote endpoint.
1285 141 Adrian Georgescu
1286 141 Adrian Georgescu
Adding and removing participants is performed using a {{{REFER}}} request as explained in RFC 4579, section 5.5.
1287 141 Adrian Georgescu
1288 141 Adrian Georgescu
In addition, the {{{ConferenceHandler}}} will subscribe to the {{{conference}}} event in order to get information about participants in the conference.
1289 141 Adrian Georgescu
1290 141 Adrian Georgescu
==== methods ====
1291 141 Adrian Georgescu
1292 141 Adrian Georgescu
 '''add_participant'''(''self'', '''participant_uri''')::
1293 141 Adrian Georgescu
  Send a {{{REFER}}} request telling the server to invite the participant specified in {{{participant_uri}}} to join the ongoing conference.
1294 141 Adrian Georgescu
1295 141 Adrian Georgescu
 '''remove_participant'''(''self'', '''participant_uri''')::
1296 141 Adrian Georgescu
  Send a {{{REFER}}} request telling the server to remove the participant specified in {{{participant_uri}}} from the ongoing conference.
1297 141 Adrian Georgescu
1298 141 Adrian Georgescu
==== notifications ====
1299 141 Adrian Georgescu
1300 141 Adrian Georgescu
 All notifications are sent with the {{{Session}}} object as the sender.
1301 141 Adrian Georgescu
1302 141 Adrian Georgescu
 '''SIPSessionGotConferenceInfo'''::
1303 141 Adrian Georgescu
  This notification is sent when a {{{NOTIFY}}} is received with a valid conferene payload.
1304 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1305 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1306 141 Adrian Georgescu
  [[BR]]conference_info:[[BR]]
1307 141 Adrian Georgescu
  The {{{Conference}}} payload object.
1308 141 Adrian Georgescu
1309 141 Adrian Georgescu
 '''SIPConferenceDidAddParticipant'''::
1310 141 Adrian Georgescu
  This notification is sent when a participant was successfully added to the conference.
1311 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1312 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1313 141 Adrian Georgescu
  [[BR]]participant:[[BR]]
1314 141 Adrian Georgescu
  URI of the participant added to the conference.
1315 141 Adrian Georgescu
1316 141 Adrian Georgescu
 '''SIPConferenceDidNotAddParticipant'''::
1317 141 Adrian Georgescu
  This notification is sent when a participant could not be added to the conference.
1318 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1319 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1320 141 Adrian Georgescu
  [[BR]]participant:[[BR]]
1321 141 Adrian Georgescu
  URI of the participant added to the conference.
1322 141 Adrian Georgescu
  [[BR]]code:[[BR]]
1323 141 Adrian Georgescu
  SIP response code for the failure.
1324 141 Adrian Georgescu
  [[BR]]reason:[[BR]]
1325 141 Adrian Georgescu
  Reason for the failure.
1326 141 Adrian Georgescu
1327 141 Adrian Georgescu
 '''SIPConferenceDidRemoveParticipant'''::
1328 141 Adrian Georgescu
  This notification is sent when a participant was successfully removed from the conference.
1329 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1330 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1331 141 Adrian Georgescu
  [[BR]]participant:[[BR]]
1332 141 Adrian Georgescu
  URI of the participant removed from the conference.
1333 141 Adrian Georgescu
1334 141 Adrian Georgescu
 '''SIPConferenceDidNotRemoveParticipant'''::
1335 141 Adrian Georgescu
  This notification is sent when a participant could not be removed from the conference.
1336 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1337 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1338 141 Adrian Georgescu
  [[BR]]participant:[[BR]]
1339 141 Adrian Georgescu
  URI of the participant removed from the conference.
1340 141 Adrian Georgescu
  [[BR]]code:[[BR]]
1341 141 Adrian Georgescu
  SIP response code for the failure.
1342 141 Adrian Georgescu
  [[BR]]reason:[[BR]]
1343 141 Adrian Georgescu
  Reason for the failure.
1344 141 Adrian Georgescu
1345 141 Adrian Georgescu
 '''SIPConferenceGotAddParticipantProgress'''::
1346 141 Adrian Georgescu
  This notification is sent when a {{{NOTIFY}}} is received indicating the status of the add participant operation.
1347 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1348 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1349 141 Adrian Georgescu
  [[BR]]participant:[[BR]]
1350 141 Adrian Georgescu
  URI of the participant whose operation is in progress.
1351 141 Adrian Georgescu
  [[BR]]code:[[BR]]
1352 141 Adrian Georgescu
  SIP response code for progress.
1353 141 Adrian Georgescu
  [[BR]]reason:[[BR]]
1354 141 Adrian Georgescu
  Reason associated with the response code.
1355 141 Adrian Georgescu
1356 141 Adrian Georgescu
 '''SIPConferenceGotRemoveParticipantProgress'''::
1357 141 Adrian Georgescu
  This notification is sent when a {{{NOTIFY}}} is received indicating the status of the remove participant operation.
1358 141 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1359 141 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1360 141 Adrian Georgescu
  [[BR]]participant:[[BR]]
1361 141 Adrian Georgescu
  URI of the participant whose operation is in progress.
1362 141 Adrian Georgescu
  [[BR]]code:[[BR]]
1363 141 Adrian Georgescu
  SIP response code for progress.
1364 141 Adrian Georgescu
  [[BR]]reason:[[BR]]
1365 141 Adrian Georgescu
  Reason associated with the response code.
1366 141 Adrian Georgescu
1367 85 Adrian Georgescu
== Address Resolution ==
1368 84 Adrian Georgescu
1369 130 Adrian Georgescu
The SIP SIMPLE middleware offers the {{{sipsimple.lookup}}} module which contains an implementation for doing DNS lookups for SIP proxies, MSRP relays, STUN servers and XCAP servers. The interface offers both an asynchronous and synchronous interface. The asynchronous interface is based on notifications, while the synchronous one on green threads. In order to call the methods in a asynchronous manner, you just need to call the method and wait for the notification which is sent on behalf of the DNSLookup instance. The notifications sent by the DNSLookup object are DNSLookupDidSucceed and DNSLookupDidFail. In order to call the methods in a synchronous manner, you need to call the wait method on the object returned by the methods of DNSLookup. This wait method needs to be called from a green thread and will either return the result of the lookup or raise an exception.
1370 1 Adrian Georgescu
1371 130 Adrian Georgescu
The DNSLookup object uses DNSManager, an object that will use the system nameservers and it will fallback to Google's nameservers (8.8.8.8 and 8.8.4.4) in case of failure. 
1372 130 Adrian Georgescu
1373 130 Adrian Georgescu
=== DNS Manager ===
1374 130 Adrian Georgescu
1375 130 Adrian Georgescu
This object provides {{{DNSLookup}}} with the nameserver list that will be used to perform DNS lookups. It will probe the system local nameservers and check if they are able to do proper lookups (by querying sip2sip.info domain). If the local nameservers are not able to do proper lookups Google nameservers will be used and another probing operation will be scheduled. Local nameservers are always preferred.
1376 130 Adrian Georgescu
1377 130 Adrian Georgescu
==== methods ====
1378 130 Adrian Georgescu
1379 130 Adrian Georgescu
 '''!__init!__'''(''self'')::
1380 130 Adrian Georgescu
  Instantiate the DNSManager object (it's a Singleton).
1381 130 Adrian Georgescu
1382 130 Adrian Georgescu
 '''start'''(''self'')::
1383 130 Adrian Georgescu
  Start the DNSManager. It will start the probing process to determine the suitable nameservers to use.
1384 130 Adrian Georgescu
1385 130 Adrian Georgescu
 '''stop'''(''self'')::
1386 131 Adrian Georgescu
  Stop the DNS resolution probing.
1387 130 Adrian Georgescu
1388 130 Adrian Georgescu
1389 130 Adrian Georgescu
==== notifications ====
1390 130 Adrian Georgescu
1391 130 Adrian Georgescu
 '''DNSResolverDidInitialize'''::
1392 130 Adrian Georgescu
  This notification is sent when the nameservers to use for probing (and further DNS lookups) have been set for the first time.
1393 130 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1394 130 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1395 130 Adrian Georgescu
  [[BR]]nameservers:[[BR]]
1396 130 Adrian Georgescu
  The list of nameservers that was set on the DNS Manager.
1397 130 Adrian Georgescu
1398 130 Adrian Georgescu
 '''DNSNameserversDidChange'''::
1399 130 Adrian Georgescu
  This notification is sent when the nameservers to use for probing (and further DNS lookups) have changed as a result of the probing process.
1400 130 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1401 130 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1402 130 Adrian Georgescu
  [[BR]]nameservers:[[BR]]
1403 130 Adrian Georgescu
  The list of nameservers that was set on the DNS Manager.
1404 130 Adrian Georgescu
1405 130 Adrian Georgescu
1406 84 Adrian Georgescu
=== DNS Lookup ===
1407 84 Adrian Georgescu
1408 84 Adrian Georgescu
This object implements DNS lookup support for SIP proxies according to RFC3263 and MSRP relay and STUN server lookup using SRV records. The object initially does NS record queries in order to determine the authoritative nameservers for the domain requested; these authoritative nameservers will then be used for NAPTR, SRV and A record queries. If this fails, the locally configured nameservers are used. The reason for doing this is that some home routers have broken NAPTR and/or SRV query support.
1409 84 Adrian Georgescu
1410 84 Adrian Georgescu
==== methods ====
1411 84 Adrian Georgescu
1412 94 Adrian Georgescu
1413 84 Adrian Georgescu
 '''!__init!__'''(''self'')::
1414 84 Adrian Georgescu
  Instantiate a new DNSLookup object.
1415 94 Adrian Georgescu
1416 84 Adrian Georgescu
 '''lookup_service'''(''self'', '''uri''', '''service''', '''timeout'''={{{3.0}}}, '''lifetime'''={{{15.0}}})::
1417 84 Adrian Georgescu
  Perform an SRV lookup followed by A lookups for MSRP relays or STUN servers depending on the {{{service}}} parameter. If SRV queries on the {{{uri.host}}} domain fail, an A lookup is performed on it and the default port for the service is returned. Only the {{{uri.host}}} attribute is used. The return value is a list of (host, port) tuples.
1418 84 Adrian Georgescu
  [[BR]]uri:[[BR]]
1419 84 Adrian Georgescu
  A {{{(Frozen)SIPURI}}} from which the {{{host}}} attribute is used for the query domain.
1420 84 Adrian Georgescu
  [[BR]]service:[[BR]]
1421 84 Adrian Georgescu
  The service to lookup servers for, {{{"msrprelay"}}} or {{{"stun"}}}.
1422 84 Adrian Georgescu
  [[BR]]timeout:[[BR]]
1423 84 Adrian Georgescu
  How many seconds to wait for a response from a nameserver.
1424 84 Adrian Georgescu
  [[BR]]lifetime:[[BR]]
1425 84 Adrian Georgescu
  How many seconds to wait for a response from all nameservers in total.
1426 94 Adrian Georgescu
1427 84 Adrian Georgescu
 '''lookup_sip_proxy'''(''self'', '''uri''', '''supported_transports''', '''timeout'''={{{3.0}}}, '''lifetime'''={{{15.0}}})::
1428 84 Adrian Georgescu
  Perform a RFC3263 compliant DNS lookup for a SIP proxy using the URI which is considered to point to a host if either the {{{host}}} attribute is an IP address, or the {{{port}}} is present. Otherwise, it is considered a domain for which NAPTR, SRV and A lookups are performed. If NAPTR or SRV queries fail, they fallback to using SRV and A queries. If the transport parameter is present in the URI, this will be used as far as it is part of the supported transports. If the URI has a {{{sips}}} schema, then only the TLS transport will be used as far as it doesn't conflict with the supported transports or the transport parameter. The return value is a list of {{{Route}}} objects containing the IP address, port and transport to use for routing in the order of preference given by the supported_transports argument.
1429 84 Adrian Georgescu
  [[BR]]uri:[[BR]]
1430 84 Adrian Georgescu
  A {{{(Frozen)SIPURI}}} from which the {{{host}}}, {{{port}}}, {{{parameters}}} and {{{secure}}} attributes are used.
1431 84 Adrian Georgescu
  [[BR]]supported_transports:[[BR]]
1432 84 Adrian Georgescu
  A sublist of {{{['udp', 'tcp', 'tls']}}} in the application's order of preference.
1433 84 Adrian Georgescu
  [[BR]]timeout:[[BR]]
1434 84 Adrian Georgescu
  How many seconds to wait for a response from a nameserver.
1435 84 Adrian Georgescu
  [[BR]]lifetime:[[BR]]
1436 84 Adrian Georgescu
  How many seconds to wait for a response from all nameservers in total.
1437 84 Adrian Georgescu
1438 120 Luci Stanescu
 '''lookup_xcap_server'''(''self'', '''uri''', '''timeout'''={{{3.0}}}, '''lifetime'''={{{15.0}}})::
1439 120 Luci Stanescu
  Perform a TXT DNS query on xcap.<uri.host> and return all values of the TXT record which are URIs with a scheme of http or https. Only the {{{uri.host}}} attribute is used. The return value is a list of strings representing HTTP URIs.
1440 120 Luci Stanescu
  [[BR]]uri:[[BR]]
1441 120 Luci Stanescu
  A {{{(Frozen)SIPURI}}} from which the {{{host}}} attribute is used for the query domain.
1442 120 Luci Stanescu
  [[BR]]timeout:[[BR]]
1443 120 Luci Stanescu
  How many seconds to wait for a response from a nameserver.
1444 120 Luci Stanescu
  [[BR]]lifetime:[[BR]]
1445 120 Luci Stanescu
  How many seconds to wait for a response from all nameservers in total.
1446 120 Luci Stanescu
1447 84 Adrian Georgescu
1448 84 Adrian Georgescu
==== notifications ====
1449 94 Adrian Georgescu
1450 84 Adrian Georgescu
1451 84 Adrian Georgescu
 '''DNSLookupDidSucceed'''::
1452 84 Adrian Georgescu
  This notification is sent when one of the lookup methods succeeds in finding a result.
1453 84 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1454 84 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1455 84 Adrian Georgescu
  [[BR]]result:[[BR]]
1456 94 Adrian Georgescu
  The result of the DNS lookup in the format described in each method.
1457 84 Adrian Georgescu
1458 84 Adrian Georgescu
 '''DNSLookupDidFail'''::
1459 84 Adrian Georgescu
  This notification is sent when one of the lookup methods fails in finding a result.
1460 84 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1461 84 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1462 84 Adrian Georgescu
  [[BR]]error:[[BR]]
1463 94 Adrian Georgescu
  A {{{str}}} object describing the error which resulted in the DNS lookup failure.
1464 84 Adrian Georgescu
1465 84 Adrian Georgescu
 '''DNSLookupTrace'''::
1466 84 Adrian Georgescu
  This notification is sent several times during a lookup process for each individual DNS query.
1467 84 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
1468 84 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1469 84 Adrian Georgescu
  [[BR]]query_type:[[BR]]
1470 84 Adrian Georgescu
  The type of the query, {{{"NAPTR"}}}, {{{"SRV"}}}, {{{"A"}}}, {{{"NS"}}} etc.
1471 84 Adrian Georgescu
  [[BR]]query_name:[[BR]]
1472 84 Adrian Georgescu
  The name which was queried.
1473 84 Adrian Georgescu
  [[BR]]answer:[[BR]]
1474 84 Adrian Georgescu
  The answer returned by dnspython, or {{{None}}} if an error occurred.
1475 84 Adrian Georgescu
  [[BR]]error:[[BR]]
1476 84 Adrian Georgescu
  The exception which caused the query to fail, or {{{None}}} if no error occurred.
1477 84 Adrian Georgescu
  [[BR]]context:[[BR]]
1478 84 Adrian Georgescu
  The name of the method which was called on the {{{DNSLookup}}} object.
1479 84 Adrian Georgescu
  [[BR]]service:[[BR]]
1480 1 Adrian Georgescu
  The service which was queried for, only available when context is {{{"lookup_service"}}}.
1481 1 Adrian Georgescu
  [[BR]]uri:[[BR]]
1482 130 Adrian Georgescu
  The uri which was queried for.
1483 130 Adrian Georgescu
  [[BR]]nameservers:[[BR]]
1484 130 Adrian Georgescu
  The list of nameservers that was used to perform the lookup.
1485 130 Adrian Georgescu
1486 84 Adrian Georgescu
1487 84 Adrian Georgescu
=== Route ===
1488 84 Adrian Georgescu
1489 84 Adrian Georgescu
This is a convinience object which contains sufficient information to identify a route to a SIP proxy. This object is returned by {{{DNSLookup.lookup_sip_proxy}}} and can be used with the {{{Session}}} or a {{{(Frozen)RouteHeader}}} can be easily constructed from it to pass to one of the objects in the SIP core handling SIP dialogs/transactions ({{{Invitation}}}, {{{Subscription}}}, {{{Request}}}, {{{Registration}}}, {{{Message}}}, {{{Publication}}}). This object has three attributes which can be set in the constructor or after it was instantiated. They will only be documented as arguments to the constructor.
1490 84 Adrian Georgescu
1491 84 Adrian Georgescu
==== methods ====
1492 84 Adrian Georgescu
1493 94 Adrian Georgescu
1494 1 Adrian Georgescu
 '''!__init!__'''(''self'', '''address''', '''port'''=None, '''transport'''={{{'udp'}}})::
1495 1 Adrian Georgescu
  Creates the Route object with the specified parameters as attributes.
1496 1 Adrian Georgescu
  Each of these attributes can be accessed on the object once instanced.
1497 1 Adrian Georgescu
  [[BR]]''address'':[[BR]]
1498 1 Adrian Georgescu
  The IPv4 address that the request in question should be sent to as a string.
1499 1 Adrian Georgescu
  [[BR]]''port'':[[BR]]
1500 1 Adrian Georgescu
  The port to send the requests to, represented as an int, or None if the default port is to be used.
1501 1 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1502 1 Adrian Georgescu
  The transport to use, this can be a string of either "udp", "tcp" or "tls" (case insensitive).
1503 94 Adrian Georgescu
1504 1 Adrian Georgescu
 '''get_uri'''(''self'')::
1505 1 Adrian Georgescu
  Returns a {{{SIPURI}}} object which contains the adress, port and transport as parameter. This can be used to easily construct a {{{RouteHeader}}}:
1506 1 Adrian Georgescu
  {{{
1507 1 Adrian Georgescu
    route = Route("1.2.3.4", port=1234, transport="tls")
1508 1 Adrian Georgescu
    route_header = RouteHeader(route.get_uri())
1509 1 Adrian Georgescu
  }}}
1510 1 Adrian Georgescu
1511 1 Adrian Georgescu
1512 92 Adrian Georgescu
== SIP Accounts ==
1513 1 Adrian Georgescu
1514 1 Adrian Georgescu
Account Management is implemented in [browser:sipsimple/account.py] ({{{sipsimple.account}}} module) and offers support for SIP accounts registered at SIP providers and SIP bonjour accounts which are discovered using mDNS.
1515 1 Adrian Georgescu
1516 91 Adrian Georgescu
=== AccountManager ===
1517 91 Adrian Georgescu
1518 91 Adrian Georgescu
The {{{sipsimple.account.AccountManager}}} is the entity responsible for loading and keeping track of the existing accounts. It is a singleton and can be instantiated anywhere, obtaining the same instance. It cannot be used until its {{{start}}} method has been called.
1519 91 Adrian Georgescu
1520 91 Adrian Georgescu
==== methods ====
1521 91 Adrian Georgescu
1522 94 Adrian Georgescu
1523 91 Adrian Georgescu
 '''!__init!__'''(''self'')::
1524 91 Adrian Georgescu
  The {{{__init__}}} method allows the {{{AccountManager}}} to be instantiated without passing any parameters. A reference to the {{{AccountManager}}} can be obtained anywhere before it is started.
1525 94 Adrian Georgescu
1526 91 Adrian Georgescu
 '''start'''(''self'')::
1527 91 Adrian Georgescu
  This method will load all the existing accounts from the configuration. If the Engine is running, the accounts will also activate. This method can only be called after the [wiki:SipConfigurationAPI#ConfigurationManager ConfigurationManager] has been started. A '''SIPAccountManagerDidAddAccount''' will be sent for each account loaded. This method is called automatically by the SIPApplication when it initializes all the components of the middleware.
1528 94 Adrian Georgescu
1529 91 Adrian Georgescu
 '''stop'''(''self'')::
1530 91 Adrian Georgescu
  Calling this method will deactivate all accounts managed by the {{{AccountManager}}}. This method is called automatically by the SIPApplication when it stops.
1531 94 Adrian Georgescu
1532 91 Adrian Georgescu
 '''has_account'''(''self'', '''id''')::
1533 91 Adrian Georgescu
  This method returns {{{True}}} if an account which has the specifed SIP ID (must be a string) exists and {{{False}}} otherwise.
1534 94 Adrian Georgescu
1535 91 Adrian Georgescu
 '''get_account'''(''self'', '''id''')::
1536 91 Adrian Georgescu
  Returns the account (either an {{{Account}}} instance or the {{{BonjourAccount}}} instance) with the specified SIP ID. Will raise a {{{KeyError}}} if such an account does not exist.
1537 94 Adrian Georgescu
1538 91 Adrian Georgescu
 '''get_accounts'''(''self'')::
1539 91 Adrian Georgescu
  Returns a list containing all the managed accounts.
1540 94 Adrian Georgescu
1541 91 Adrian Georgescu
 '''iter_accounts'''(''self'')::
1542 91 Adrian Georgescu
  Returns an iterator through all the managed accounts.
1543 94 Adrian Georgescu
1544 91 Adrian Georgescu
 '''find_account'''(''self'', '''contact_uri''')::
1545 91 Adrian Georgescu
  Returns an account with matches the specified {{{contact_uri}}} which must be a {{{sipsimple.core.SIPURI}}} instance. Only the accounts with the enabled flag set will be considered. Returns None if such an account does not exist.
1546 91 Adrian Georgescu
1547 91 Adrian Georgescu
==== notifications ====
1548 91 Adrian Georgescu
1549 94 Adrian Georgescu
1550 91 Adrian Georgescu
 '''SIPAccountManagerDidAddAccount'''::
1551 91 Adrian Georgescu
  This notification is sent when a new account becomes available to the {{{AccountManager}}}. The notification is also sent when the accounts are loaded from the configuration.
1552 91 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1553 91 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1554 91 Adrian Georgescu
  [[BR]]''account'':[[BR]]
1555 91 Adrian Georgescu
  The account object which was added.
1556 94 Adrian Georgescu
1557 91 Adrian Georgescu
 '''SIPAccountManagerDidRemoveAccount'''::
1558 91 Adrian Georgescu
  This notification is sent when an account is deleted using the {{{delete}}} method.
1559 91 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1560 91 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1561 91 Adrian Georgescu
  [[BR]]''account'':[[BR]]
1562 91 Adrian Georgescu
  The account object which was deleted.
1563 94 Adrian Georgescu
1564 91 Adrian Georgescu
 '''SIPAccountManagerDidChangeDefaultAccount'''::
1565 91 Adrian Georgescu
  This notification is sent when the default account changes.
1566 91 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1567 91 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1568 91 Adrian Georgescu
  [[BR]]''old_account'':[[BR]]
1569 91 Adrian Georgescu
   This is the account object which used to be the default account.
1570 91 Adrian Georgescu
  [[BR]]''account'':[[BR]]
1571 91 Adrian Georgescu
   This is the account object which is the new default account.
1572 91 Adrian Georgescu
1573 72 Luci Stanescu
=== Account ===
1574 72 Luci Stanescu
1575 64 Luci Stanescu
The {{{sipsimple.account.Account}}} objects represent the SIP accounts which are registered at SIP providers. It has a dual purpose: it acts as both a container for account-related settings and as a complex object which can be used to interact with various per-account functions, such as presence, registration etc. This page documents the latter case, while the former is explained in the [wiki:SipConfigurationAPI#Account Configuration API].
1576 64 Luci Stanescu
1577 72 Luci Stanescu
There is exactly one instance of {{{Account}}} per SIP account used and it is uniquely identifiable by its SIP ID, in the form ''user@domain''. It is a singleton, in the sense that instantiating {{{Account}}} using an already used SIP ID will return the same object. However, this is not the recommended way of accessing accounts, as this can lead to creation of new ones; the recommended way is by using the [wiki:SipMiddlewareApi#AccountManager AccountManager]. The next sections will use a lowercase, monospaced {{{account}}} to represent an instance of {{{Account}}}.
1578 64 Luci Stanescu
1579 64 Luci Stanescu
==== states ====
1580 64 Luci Stanescu
1581 64 Luci Stanescu
The {{{Account}}} objects have a setting flag called {{{enabled}}} which, if set to {{{False}}} will deactivate it: none of the internal functions will work in this case; in addition, the application using the middleware should not do anything with a disabled account. After changing it's value, the {{{save()}}} method needs to be called, as the flag is a setting and will not be used until this method is called:
1582 64 Luci Stanescu
{{{
1583 64 Luci Stanescu
account.enabled = True
1584 64 Luci Stanescu
account.save()
1585 64 Luci Stanescu
}}}
1586 64 Luci Stanescu
1587 64 Luci Stanescu
The {{{Account}}} objects will activate automatically when they are loaded/created if the {{{enabled}}} flag is set to {{{True}}} and the {{{sipsimple.engine.Engine}}} is running; if it is not running, the accounts will activate after the engine starts.
1588 64 Luci Stanescu
1589 64 Luci Stanescu
In order to create a new account, just create a new instance of {{{Account}}} with an id which doesn't belong to any other account.
1590 64 Luci Stanescu
1591 64 Luci Stanescu
The other functions of {{{Account}}} which run automatically have other enabled flags as well. They will only be activated when both the global enabled flag is set and the function-specific one. These are:
1592 64 Luci Stanescu
1593 94 Adrian Georgescu
1594 64 Luci Stanescu
 '''Account.registration.enabled'''::
1595 64 Luci Stanescu
  This flag controls the automatic registration of the account. The notifications '''SIPAccountRegistrationDidSucceed''', '''SIPAccountRegistrationDidFail''' and '''SIPAccountRegistrationDidEnd''' are used to inform the status of this registration.
1596 94 Adrian Georgescu
1597 64 Luci Stanescu
 '''Account.presence.enabled'''::
1598 64 Luci Stanescu
  This flag controls the automatic subscription to buddies for the ''presence'' event and the publication of data in this event. (Not implemented yet)
1599 94 Adrian Georgescu
1600 1 Adrian Georgescu
 '''Account.dialog_event.enabled'''::
1601 64 Luci Stanescu
  This flag controls the automatic subscription to buddies for the ''dialog-info'' event and the publication of data in this event. (Not implemented yet)
1602 94 Adrian Georgescu
1603 64 Luci Stanescu
 '''Account.message_summary.enabled'''::
1604 64 Luci Stanescu
  This flag controls the automatic subscription to the ''message-summary'' event in order to find out about voicemail messages. (Not implemented yet)
1605 64 Luci Stanescu
1606 72 Luci Stanescu
The {{{save()}}} method needs to be called after changing these flags in order for them to take effect. The methods available on {{{Account}}} objects are inherited from [wiki:SipConfigurationAPI#SettingsObject SettingsObject].
1607 64 Luci Stanescu
1608 64 Luci Stanescu
==== attributes ====
1609 64 Luci Stanescu
1610 64 Luci Stanescu
The following attributes can be used on an Account object and need to be considered read-only.
1611 64 Luci Stanescu
1612 94 Adrian Georgescu
1613 64 Luci Stanescu
 '''id'''::
1614 64 Luci Stanescu
  This attribute is of type {{{sipsimple.configuration.datatypes.SIPAddress}}} (a subclass of {{{str}}}) and contains the SIP id of the account. It can be used as a normal string in the form ''user@domain'', but it also allows access to the components via the attributes {{{username}}} and {{{domain}}}.
1615 64 Luci Stanescu
  {{{
1616 64 Luci Stanescu
  account.id # 'alice@example.com'
1617 64 Luci Stanescu
  account.id.username # 'alice'
1618 64 Luci Stanescu
  account.id.domain # 'example.com'
1619 64 Luci Stanescu
  }}}
1620 94 Adrian Georgescu
1621 64 Luci Stanescu
 '''contact'''::
1622 134 Adrian Georgescu
  This attribute can be used to construct the Contact URI for SIP requests sent on behalf of this account. It's type is {{{sipsimple.account.ContactURIFactory}}}. It can be indexed by a string representing a transport ({{{'udp'}}}, {{{'tcp'}}}, {{{'tls'}}}) or a {{{sipsimple.util.Route}}} object which will return a {{{sipsimple.core.SIPURI}}} object with the appropriate IP, port and transport. The username part is a randomly generated 8 character string consisting of lowercase letters; but it can be chosen by passing it to __init__ when building the {{{ContactURIFactory}}} object.
1623 1 Adrian Georgescu
  {{{
1624 134 Adrian Georgescu
  account.contact # 'ContactURIFactory(username=hnfkybrt)'
1625 1 Adrian Georgescu
  account.contact.username # 'hnfkybrt'
1626 1 Adrian Georgescu
  account.contact['udp'] # <SIPURI "sip:hnfkybrt@10.0.0.1:53024">
1627 1 Adrian Georgescu
  account.contact['tls'] # <SIPURI "sip:hnfkybrt@10.0.0.1:54478;transport=tls">
1628 72 Luci Stanescu
  }}}
1629 94 Adrian Georgescu
1630 1 Adrian Georgescu
 '''credentials'''::
1631 72 Luci Stanescu
  This attribute is of type {{{sipsimple.core.Credentials}}} which is built from the {{{id.username}}} attribute and the {{{password}}} setting of the Account. Whenever this setting is changed, this attribute is updated.
1632 64 Luci Stanescu
  {{{
1633 72 Luci Stanescu
  account.credentials # <Credentials for 'alice'>
1634 72 Luci Stanescu
  }}}
1635 94 Adrian Georgescu
1636 72 Luci Stanescu
 '''uri'''::
1637 72 Luci Stanescu
  This attribute is of type {{{sipsimple.core.SIPURI}}} which can be used to form a {{{FromHeader}}} associated with this account. It contains the SIP ID of the account.
1638 72 Luci Stanescu
  {{{
1639 1 Adrian Georgescu
  account.uri # <SIPURI "sip:alice@example.com">
1640 72 Luci Stanescu
  }}}
1641 1 Adrian Georgescu
1642 1 Adrian Georgescu
==== notifications ====
1643 1 Adrian Georgescu
1644 94 Adrian Georgescu
1645 1 Adrian Georgescu
 '''CFGSettingsObjectDidChange'''::
1646 72 Luci Stanescu
  This notification is sent when the {{{save()}}} method is called on the account after some of the settings were changed. As the notification belongs to the {{{SettingsObject}}} class, it is exaplained in detail in [wiki:SipConfigurationAPI#SettingsObjectNotifications SettingsObject Notifications].
1647 94 Adrian Georgescu
1648 125 Adrian Georgescu
 '''SIPAccountWillActivate'''::
1649 125 Adrian Georgescu
  This notification is sent when the {{{Account}}} is about to be activated, but before actually performing any activation task. See {{{SIPAccountDidActivate}}} for more detail.
1650 125 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1651 125 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1652 125 Adrian Georgescu
1653 72 Luci Stanescu
 '''SIPAccountDidActivate'''::
1654 72 Luci Stanescu
  This notification is sent when the {{{Account}}} activates. This can happen when the {{{Account}}} is loaded if it's enabled flag is set and the Engine is running, and at any later time when the status of the Engine changes or the enabled flag is modified.
1655 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1656 72 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1657 94 Adrian Georgescu
1658 125 Adrian Georgescu
 '''SIPAccountWillDeactivate'''::
1659 125 Adrian Georgescu
  This notification is sent when the {{{Account}}} is about to be deactivated, but before performing any deactivation task. See {{{SIPAccountDidDeactivate}}} for more detail.
1660 125 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1661 125 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1662 125 Adrian Georgescu
1663 72 Luci Stanescu
 '''SIPAccountDidDeactivate'''::
1664 72 Luci Stanescu
  This notification is sent when the {{{Account}}} deactivates. This can happend when the {{{Engine}}} is stopped or when the enabled flag of the account is set to {{{False}}}.
1665 72 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
1666 72 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1667 94 Adrian Georgescu
1668 117 Adrian Georgescu
 '''SIPAccountWillRegister'''::
1669 72 Luci Stanescu
  This notification is sent when the account is about to register for the first time.
1670 72 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
1671 72 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1672 94 Adrian Georgescu
1673 117 Adrian Georgescu
 '''SIPAccountRegistrationWillRefresh'''::
1674 72 Luci Stanescu
  This notification is sent when a registration is about to be refreshed.
1675 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1676 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1677 94 Adrian Georgescu
1678 72 Luci Stanescu
 '''SIPAccountRegistrationDidSucceed'''::
1679 72 Luci Stanescu
  This notification is sent when a REGISTER request sent for the account succeeds (it is also sent for each refresh of the registration). The data contained in this notification is:
1680 72 Luci Stanescu
  [[BR]]''timestamp'':[[BR]]
1681 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1682 1 Adrian Georgescu
  [[BR]]''contact_header'':[[BR]]
1683 1 Adrian Georgescu
   The Contact header which was registered.
1684 1 Adrian Georgescu
  [[BR]]''contact_header_list'':[[BR]]
1685 1 Adrian Georgescu
   A list containing all the contacts registered for this SIP account.
1686 1 Adrian Georgescu
  [[BR]]''expires'':[[BR]]
1687 1 Adrian Georgescu
   The amount in seconds in which this registration will expire.
1688 1 Adrian Georgescu
  [[BR]]''registrar'':[[BR]]
1689 1 Adrian Georgescu
  The {{{sipsimple.util.Route}}} object which was used.
1690 94 Adrian Georgescu
1691 1 Adrian Georgescu
 '''SIPAccountRegistrationDidFail'''::
1692 1 Adrian Georgescu
  This notification is sent when a REGISTER request sent for the account fails. It can fail either because a negative response was returned or because PJSIP considered the request failed (e.g. on timeout). The data contained in this notification is:
1693 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1694 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1695 1 Adrian Georgescu
  [[BR]]''error'':[[BR]]
1696 1 Adrian Georgescu
   The reason for the failure of the REGISTER request.
1697 1 Adrian Georgescu
  [[BR]]''timeout'':[[BR]]
1698 1 Adrian Georgescu
   The amount in seconds as a {{{float}}} after which the registration will be tried again.
1699 94 Adrian Georgescu
1700 1 Adrian Georgescu
 '''SIPAccountRegistrationDidEnd'''::
1701 1 Adrian Georgescu
  This notification is sent when a registration is ended (the account is unregistered). The data contained in this notification is:
1702 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1703 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1704 1 Adrian Georgescu
  [[BR]]''registration'':[[BR]]
1705 1 Adrian Georgescu
   The {{{sipsimple.core.Registration}}} object which ended.
1706 94 Adrian Georgescu
1707 1 Adrian Georgescu
 '''SIPAccountRegistrationDidNotEnd'''::
1708 1 Adrian Georgescu
  This notification is sent when a registration fails to end (the account is not unregistered). The data contained in this notification is:
1709 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1710 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1711 1 Adrian Georgescu
  [[BR]]''code'':[[BR]]
1712 1 Adrian Georgescu
  The SIP status code received.
1713 1 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
1714 1 Adrian Georgescu
  The SIP status reason received.
1715 1 Adrian Georgescu
  [[BR]]''registration'':[[BR]]
1716 1 Adrian Georgescu
  The {{{sipsimple.core.Registration}}} object which ended.
1717 94 Adrian Georgescu
1718 1 Adrian Georgescu
 '''SIPAccountRegistrationGotAnswer'''::
1719 1 Adrian Georgescu
  This notification is sent whenever a response is received to a sent REGISTER request for this account. The data contained in this notification is:
1720 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1721 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1722 1 Adrian Georgescu
  [[BR]]''code'':[[BR]]
1723 1 Adrian Georgescu
  The SIP status code received.
1724 1 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
1725 1 Adrian Georgescu
  The SIP status reason received.
1726 1 Adrian Georgescu
  [[BR]]''registration'':[[BR]]
1727 1 Adrian Georgescu
  The {{{sipsimple.core.Registration}}} object which was used.
1728 1 Adrian Georgescu
  [[BR]]''registrar'':[[BR]]
1729 1 Adrian Georgescu
  The {{{sipsimple.util.Route}}} object which was used.
1730 1 Adrian Georgescu
1731 122 Adrian Georgescu
 '''SIPAccountMWIDidGetSummary'''::
1732 121 Adrian Georgescu
  This notification is sent when a NOTIFY is received with a message-summary payload. The data contained in this notification is:
1733 122 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1734 121 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1735 122 Adrian Georgescu
  [[BR]]''message_summary'':[[BR]]
1736 121 Adrian Georgescu
  A {{{sipsimple.payloads.messagesummary.MessageSummary}}} object with the parsed payload from the NOTIFY request.
1737 121 Adrian Georgescu
1738 1 Adrian Georgescu
=== BonjourAccount ===
1739 1 Adrian Georgescu
1740 1 Adrian Georgescu
The {{{sipsimple.account.BonjourAccount}}} represents the SIP account used for P2P mode; it does not interact with any server. The class is a singleton, as there can only be one such account on a system. Similar to the {{{Account}}}, it is used both as a complex object, which implements the functions for bonjour mode, as well as a container for the related settings.
1741 1 Adrian Georgescu
1742 1 Adrian Georgescu
==== states ====
1743 1 Adrian Georgescu
1744 112 Luci Stanescu
The {{{BonjourAccount}}} has an {{{enabled}}} flag which controls whether this account will be used or not. If it is set to {{{False}}}, none of the internal functions will be activated and, in addition, the account should not be used by the application. The bonjour account can only activated if the Engine is running; once it is started, if the enabled flag is set, the account will activate. When the {{{BonjourAccount}}} is activated, it will broadcast the contact address on the LAN and discover its neighbours sending notifications as this happens.
1745 1 Adrian Georgescu
1746 1 Adrian Georgescu
==== attributes ====
1747 1 Adrian Georgescu
1748 1 Adrian Georgescu
The following attributes can be used on a BonjourAccount object and need to be considered read-only.
1749 1 Adrian Georgescu
1750 94 Adrian Georgescu
1751 1 Adrian Georgescu
 '''id'''::
1752 1 Adrian Georgescu
  This attribute is of type {{{sipsimple.configuration.datatypes.SIPAddress}}} (a subclass of {{{str}}}) and contains the SIP id of the account, which is {{{'bonjour@local'}}}. It can be used as a normal string, but it also allows access to the components via the attributes {{{username}}} and {{{domain}}}.
1753 1 Adrian Georgescu
  {{{
1754 1 Adrian Georgescu
  bonjour_account.id # 'bonjour@local'
1755 1 Adrian Georgescu
  bonjour_account.id.username # 'bonjour'
1756 1 Adrian Georgescu
  bonjour_account.id.domain # 'local'
1757 1 Adrian Georgescu
  }}}
1758 1 Adrian Georgescu
1759 1 Adrian Georgescu
 '''contact'''::
1760 134 Adrian Georgescu
  This attribute can be used to construct the Contact URI for SIP requests sent on behalf of this account. It's type is {{{sipsimple.account.ContactURIFactory}}}. It can be indexed by a string representing a transport ({{{'udp'}}}, {{{'tcp'}}}, {{{'tls'}}}) or a {{{sipsimple.util.Route}}} object which will return a {{{sipsimple.core.SIPURI}}} object with the appropriate IP, port and transport. The username part is a randomly generated 8 character string consisting of lowercase letters; but it can be chosen by passing it to __init__ when building the {{{ContactURIFactory}}} object.
1761 1 Adrian Georgescu
  {{{
1762 134 Adrian Georgescu
  bonjour_account.contact # 'ContactURIFactory(username=lxzvgack)'
1763 1 Adrian Georgescu
  bonjour_account.contact.username # 'lxzvgack'
1764 1 Adrian Georgescu
  bonjour_account.contact['udp'] # <SIPURI "sip:lxzvgack@10.0.0.1:53024">
1765 1 Adrian Georgescu
  bonjour_account.contact['tls'] # <SIPURI "sip:lxzvgack@10.0.0.1:54478;transport=tls">
1766 1 Adrian Georgescu
  }}}
1767 94 Adrian Georgescu
1768 1 Adrian Georgescu
 '''credentials'''::
1769 1 Adrian Georgescu
  This attribute is of type {{{sipsimple.core.Credentials}}} object which is built from the {{{contact.username}}} attribute; the password is set to the empty string.
1770 1 Adrian Georgescu
  {{{
1771 1 Adrian Georgescu
  bonjour_account.credentials # <Credentials for 'alice'>
1772 1 Adrian Georgescu
  }}}
1773 94 Adrian Georgescu
1774 1 Adrian Georgescu
 '''uri'''::
1775 111 Adrian Georgescu
  This attribute is of type {{{sipsimple.core.SIPURI}}} which can be used to form a {{{FromHeader}}} associated with this account. It contains the contact address of the bonjour account:
1776 1 Adrian Georgescu
  {{{
1777 1 Adrian Georgescu
  bonjour_account.uri # <SIPURI "sip:lxzvgack@10.0.0.1">
1778 1 Adrian Georgescu
  }}}
1779 1 Adrian Georgescu
1780 1 Adrian Georgescu
==== notifications ====
1781 1 Adrian Georgescu
1782 127 Adrian Georgescu
 '''BonjourAccountDidAddNeighbour'''::
1783 127 Adrian Georgescu
  This notification is sent when a new Bonjour neighbour is discovered.
1784 129 Adrian Georgescu
  [[BR]]''service_description'':[[BR]]
1785 129 Adrian Georgescu
  BonjourServiceDescription object uniquely identifying this neighbour in the mDNS library.
1786 127 Adrian Georgescu
  [[BR]]''display_name'':[[BR]]
1787 127 Adrian Georgescu
  The name of the neighbour as it is published.
1788 127 Adrian Georgescu
  [[BR]]''host'':[[BR]]
1789 127 Adrian Georgescu
  The hostname of the machine from which the Bonjour neighbour registered its contact address.
1790 127 Adrian Georgescu
  [[BR]]''uri'':[[BR]]
1791 127 Adrian Georgescu
  The contact URI of the Bonjour neighbour, as a {{{FrozenSIPURI}}} object.
1792 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1793 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1794 1 Adrian Georgescu
1795 129 Adrian Georgescu
 '''BonjourAccountDidUpdateNeighbour'''::
1796 129 Adrian Georgescu
  This notification is sent when an existing Bonjour neighbour has updates its published data.
1797 129 Adrian Georgescu
  [[BR]]''service_description'':[[BR]]
1798 129 Adrian Georgescu
  BonjourServiceDescription object uniquely identifying this neighbour in the mDNS library.
1799 129 Adrian Georgescu
  [[BR]]''display_name'':[[BR]]
1800 129 Adrian Georgescu
  The name of the neighbour as it is published.
1801 129 Adrian Georgescu
  [[BR]]''host'':[[BR]]
1802 129 Adrian Georgescu
  The hostname of the machine from which the Bonjour neighbour registered its contact address.
1803 1 Adrian Georgescu
  [[BR]]''uri'':[[BR]]
1804 1 Adrian Georgescu
  The contact URI of the Bonjour neighbour, as a {{{FrozenSIPURI}}} object.
1805 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1806 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1807 1 Adrian Georgescu
1808 129 Adrian Georgescu
 '''BonjourAccountDidRemoveNeighbour'''::
1809 129 Adrian Georgescu
  This notification is sent when a Bonjour neighbour unregisters.
1810 129 Adrian Georgescu
  [[BR]]''service_description'':[[BR]]
1811 129 Adrian Georgescu
  The BonjourServiceDescription object, which uniquely identifies a neighbour, that got unregistered.
1812 129 Adrian Georgescu
1813 1 Adrian Georgescu
 '''BonjourAccountDiscoveryDidFail'''::
1814 129 Adrian Georgescu
  This notification is sent once per transport when the Bonjour account has failed to perform the discovery process for the indicated transport.
1815 129 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
1816 129 Adrian Georgescu
  String defining the reason of the failure.
1817 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1818 129 Adrian Georgescu
  String specifying the transport for which the discovery failed.
1819 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1820 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1821 1 Adrian Georgescu
1822 1 Adrian Georgescu
 '''BonjourAccountDiscoveryFailure'''::
1823 129 Adrian Georgescu
  This notification is sent once per transport when the Bonjour account has encountered a problem while browsing the list of neighbours for the indicated transport.
1824 129 Adrian Georgescu
  [[BR]]''error'':[[BR]]
1825 129 Adrian Georgescu
  String defining the error of the failure.
1826 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1827 129 Adrian Georgescu
  String specifying the transport for which the neighbour resoution failed.
1828 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1829 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1830 124 Adrian Georgescu
1831 1 Adrian Georgescu
 '''BonjourAccountRegistrationDidEnd'''::
1832 129 Adrian Georgescu
  This notification is sent once per transport when the Bonjour account unregisters its contact address for the indicated transport using mDNS.
1833 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1834 129 Adrian Georgescu
  String specifying the transport for which the registration ended.
1835 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1836 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1837 1 Adrian Georgescu
1838 127 Adrian Georgescu
 '''BonjourAccountRegistrationDidFail'''::
1839 129 Adrian Georgescu
  This notification is sent once per transport when the Bonjour account fails to register its contact address for the indicated transport using mDNS.
1840 1 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
1841 1 Adrian Georgescu
  A human readable error message.
1842 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1843 129 Adrian Georgescu
  String specifying the transport for which the registration failed.
1844 129 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1845 129 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1846 1 Adrian Georgescu
1847 129 Adrian Georgescu
 '''BonjourAccountRegistrationUpdateDidFail'''::
1848 129 Adrian Georgescu
  This notification is sent once per transport when the Bonjour account fails to update its data for the indicated transport using mDNS.
1849 129 Adrian Georgescu
  [[BR]]''reason'':[[BR]]
1850 129 Adrian Georgescu
  A human readable error message.
1851 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1852 129 Adrian Georgescu
  String specifying the transport for which the registration update failed.
1853 129 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1854 129 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1855 129 Adrian Georgescu
1856 1 Adrian Georgescu
 '''BonjourAccountRegistrationDidSucceed'''::
1857 129 Adrian Georgescu
  This notification is sent once per transport when the Bonjour account successfully registers its contact address for the indicated transport using mDNS.
1858 1 Adrian Georgescu
  [[BR]]''name'':[[BR]]
1859 127 Adrian Georgescu
  The contact address registered.
1860 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1861 129 Adrian Georgescu
  String specifying the transport for which the registration succeeded.
1862 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1863 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1864 1 Adrian Georgescu
1865 112 Luci Stanescu
 '''BonjourAccountWillInitateDiscovery'''::
1866 129 Adrian Georgescu
  This notification is sent when the Bonjour account is about to start the discovery process for the indicated transport.
1867 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1868 129 Adrian Georgescu
  String specifying the transport for which the discovery will be started.
1869 127 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1870 112 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1871 112 Luci Stanescu
1872 112 Luci Stanescu
  '''BonjourAccountWillRegister'''::
1873 129 Adrian Georgescu
  This notification is sent just before the Bonjour account starts the registering process for the indicated transport.
1874 129 Adrian Georgescu
  [[BR]]''transport'':[[BR]]
1875 129 Adrian Georgescu
  String specifying the transport for which the registration will be started.
1876 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1877 127 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1878 112 Luci Stanescu
1879 112 Luci Stanescu
 '''CFGSettingsObjectDidChange'''::
1880 94 Adrian Georgescu
  This notification is sent when the {{{save()}}} method is called on the account after some of the settings were changed. As the notification belongs to the {{{SettingsObject}}} class, it is exaplained in detail in [wiki:SipConfigurationAPI#SettingsObjectNotifications SettingsObject Notifications].
1881 125 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1882 125 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1883 125 Adrian Georgescu
1884 125 Adrian Georgescu
 '''SIPAccountWillActivate'''::
1885 125 Adrian Georgescu
  This notification is sent when the {{{BonjourAccount}}} is about to be activated, but before actually performing any activation task. See {{{SIPAccountDidActivate}}} for more detail.
1886 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1887 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1888 125 Adrian Georgescu
1889 125 Adrian Georgescu
 '''SIPAccountDidActivate'''::
1890 125 Adrian Georgescu
  This notification is sent when the {{{BonjourAccount}}} activates. This can happen when the {{{BonjourAccount}}} is loaded if it's enabled flag is set and the Engine is running, and at any later time when the status of the Engine changes or the enabled flag is modified.
1891 125 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1892 125 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1893 1 Adrian Georgescu
1894 1 Adrian Georgescu
 '''SIPAccountWillDeactivate'''::
1895 94 Adrian Georgescu
  This notification is sent when the {{{BonjourAccount}}} is about to be deactivated, but before performing any deactivation task. See {{{SIPAccountDidDeactivate}}} for more detail.
1896 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1897 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1898 1 Adrian Georgescu
1899 1 Adrian Georgescu
 '''SIPAccountDidDeactivate'''::
1900 1 Adrian Georgescu
  This notification is sent when the {{{BonjourAccount}}} deactivates. This can happend when the {{{Engine}}} is stopped or when the enabled flag of the account is set to {{{False}}}.
1901 1 Adrian Georgescu
  [[BR]]''timestamp'':[[BR]]
1902 87 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
1903 87 Adrian Georgescu
1904 87 Adrian Georgescu
1905 87 Adrian Georgescu
== Audio ==
1906 87 Adrian Georgescu
1907 87 Adrian Georgescu
The high-level audio API hides the complexity of using the low-level PJMEDIA interface. This is implemented in the {{{sipsimple.audio}}} module and contains the following components:
1908 87 Adrian Georgescu
 * IAudioPort: an interface describing an object capable of producing and/or consuming audio data.
1909 87 Adrian Georgescu
 * AudioDevice: an object conforming to the IAudioPort interface which describes a physical audio device.
1910 87 Adrian Georgescu
 * AudioBridge: a collection of objects conforming to IAudioPort which connects all of them in a full mesh.
1911 87 Adrian Georgescu
 * WavePlayer: an object conforming to the IAudioPort interface which can playback the audio data from a {{{.wav}}} file.
1912 87 Adrian Georgescu
 * WaveRecorder: an object conforming to the IAudioPort interface which can record audio data to a {{{.wav}}} file.
1913 87 Adrian Georgescu
1914 87 Adrian Georgescu
=== IAudioPort ===
1915 87 Adrian Georgescu
1916 87 Adrian Georgescu
The IAudioPort interface describes an object capable of producing and/or consuming audio data. This can be a dynamic object, which changes its role during its lifetime and notifies such changes using a notification, which is part of the interface.
1917 94 Adrian Georgescu
1918 87 Adrian Georgescu
==== attributes ====
1919 87 Adrian Georgescu
1920 94 Adrian Georgescu
1921 87 Adrian Georgescu
 '''mixer'''::
1922 87 Adrian Georgescu
  The {{{AudioMixer}}} this audio object is connected to. Only audio objects connected to the same mixer will be able to send audio data from one to another.
1923 94 Adrian Georgescu
1924 87 Adrian Georgescu
 '''consumer_slot'''::
1925 87 Adrian Georgescu
  An integer representing the slot (see [wiki:SipCoreApiDocumentation#AudioMixer AudioMixer]) which this object uses to consume audio data, or {{{None}}} if this object is not a consumer.
1926 87 Adrian Georgescu
1927 87 Adrian Georgescu
 '''producer_slot'''::
1928 87 Adrian Georgescu
  An integer representing the slot (see [wiki:SipCoreApiDocumentation#AudioMixer AudioMixer]) which this object uses to produce audio data, or {{{None}}} if this object is not a producer.
1929 94 Adrian Georgescu
1930 87 Adrian Georgescu
==== notifications ====
1931 87 Adrian Georgescu
 
1932 87 Adrian Georgescu
1933 87 Adrian Georgescu
 '''AudioPortDidChangeSlots'''::
1934 87 Adrian Georgescu
  This notification needs to be sent by implementations of this interface when the slots it has change, so as to let the {{{AudioBridges}}} it is part of know that reconnections need to be made.
1935 87 Adrian Georgescu
  [[BR]]consumer_slot_changed:[[BR]]
1936 87 Adrian Georgescu
  A bool indicating whether the consumer slot was changed.
1937 87 Adrian Georgescu
  [[BR]]producer_slot_changed:[[BR]]
1938 87 Adrian Georgescu
  A bool indicating whether the producer slot was changed.
1939 87 Adrian Georgescu
  [[BR]]old_consumer_slot:[[BR]]
1940 87 Adrian Georgescu
  The old slot for consuming audio data. Only required if consumer_slot_changed is {{{True}}}.
1941 87 Adrian Georgescu
  [[BR]]new_consumer_slot:[[BR]]
1942 87 Adrian Georgescu
  The new slot for consuming audio data. Only required if consumer_slot_changed is {{{True}}}.
1943 87 Adrian Georgescu
  [[BR]]old_producer_slot:[[BR]]
1944 87 Adrian Georgescu
  The old slot for producing audio data. Only required if producer_slot_changed is {{{True}}}.
1945 87 Adrian Georgescu
  [[BR]]new_producer_slot:[[BR]]
1946 87 Adrian Georgescu
  The new slot for producing audio data. Only required if producer_slot_changed is {{{True}}}.
1947 87 Adrian Georgescu
1948 87 Adrian Georgescu
=== AudioDevice ===
1949 87 Adrian Georgescu
1950 87 Adrian Georgescu
The AudioDevice represents the physical audio device which is part of a {{{AudioMixer}}}, implementing the {{{IAudioPort}}} interface. As such, it can be uniquely identified by the mixer it represents.
1951 94 Adrian Georgescu
1952 87 Adrian Georgescu
==== methods ====
1953 87 Adrian Georgescu
1954 87 Adrian Georgescu
1955 87 Adrian Georgescu
 '''!__init!__'''(''self'', '''mixer''', '''input_muted'''={{{False}}}, '''output_muted'''={{{False}}}):
1956 87 Adrian Georgescu
  Instantiates a new AudioDevice which represents the physical device associated with the specified {{{AudioMixer}}}.
1957 87 Adrian Georgescu
  [[BR]]mixer:[[BR]]
1958 87 Adrian Georgescu
  The {{{AudioMixer}}} whose physical device this object represents.
1959 87 Adrian Georgescu
  [[BR]]input_muted:[[BR]]
1960 87 Adrian Georgescu
  A boolean which indicates whether this object should act as a producer of audio data.
1961 87 Adrian Georgescu
  [[BR]]output_muted:[[BR]]
1962 87 Adrian Georgescu
  A boolean which indicates whether this object should act as a consumer of audio data.
1963 94 Adrian Georgescu
1964 87 Adrian Georgescu
==== attributes ====
1965 87 Adrian Georgescu
1966 94 Adrian Georgescu
1967 87 Adrian Georgescu
 '''input_muted'''::
1968 87 Adrian Georgescu
  A writable property which controls whether this object should act as a producer of audio data. An {{{AudioPortDidChange}}} slots notification is sent when this attribute is changed to force connections to be reconsidered within the {{{AudioBridges}}} this object is part of.
1969 87 Adrian Georgescu
1970 87 Adrian Georgescu
 '''output_muted'''::
1971 87 Adrian Georgescu
  A writable property which controls whether this object should act as a consumer of audio data. An {{{AudioPortDidChange}}} slots notification is sent when this attribute is changed to force connections to be reconsidered within  the {{{AudioBridges}}} this object is part of.
1972 87 Adrian Georgescu
1973 87 Adrian Georgescu
=== AudioBridge ===
1974 87 Adrian Georgescu
1975 87 Adrian Georgescu
The {{{AudioBridge}}} is the basic component which is able to connect {{{IAudioPort}}} implementations. It acts as a container which connects as the producers to all the consumers which are part of it. An object which is both a producer and a consumer of audio data will not be connected to itself. Being an implementation of {{{IAudioPort}}} itself, an {{{AudioBridge}}} can be part of another {{{AudioBridge}}}. The {{{AudioBridge}}} does not keep strong references to the ports it contains and once the port's reference count reaches 0, it is automatically removed from the {{{AudioBridge}}}.
1976 87 Adrian Georgescu
> Note: although this is not enforced, there should never be any cycles when connecting {{{AudioBridges}}}.
1977 94 Adrian Georgescu
1978 87 Adrian Georgescu
==== methods ====
1979 87 Adrian Georgescu
1980 94 Adrian Georgescu
1981 87 Adrian Georgescu
 '''!__init!__'''(''self'', '''mixer''')::
1982 87 Adrian Georgescu
  Instantiate a new {{{AudioBridge}}} which uses the specified {{{AudioMixer}}} for mixing.
1983 94 Adrian Georgescu
1984 87 Adrian Georgescu
 '''add'''(''self'', '''port''')::
1985 87 Adrian Georgescu
  Add an implementation of {{{IAudioPort}}} to this AudioBridge. This will connect the new port to all the existing ports of the bridge. A port cannot be added more than once to an {{{AudioBridge}}}; thus, this object acts like a set.
1986 87 Adrian Georgescu
1987 87 Adrian Georgescu
 '''remove'''(''self'', '''port''')::
1988 87 Adrian Georgescu
  Remove a port from this {{{AudioBridge}}}. The port must have previously been added to the {{{AudioBridge}}}, otherwise a {{{ValueError}}} is raised.
1989 87 Adrian Georgescu
1990 87 Adrian Georgescu
=== WavePlayer ===
1991 87 Adrian Georgescu
1992 87 Adrian Georgescu
A {{{WavePlayer}}} is an implementation of {{{IAudioPort}}} which is capable of producing audio data read from a {{{.wav}}} file. This object is completely reusable, as it can be started and stopped any number of times.
1993 94 Adrian Georgescu
1994 87 Adrian Georgescu
==== methods ====
1995 87 Adrian Georgescu
1996 87 Adrian Georgescu
1997 87 Adrian Georgescu
 '''!__init!__'''(''self'', '''mixer''', '''filename''', '''volume'''={{{100}}}, '''loop_count'''={{{1}}}, '''pause_time'''={{{0}}}, '''initial_play'''={{{True}}})::
1998 87 Adrian Georgescu
  Instantiate a new {{{WavePlayer}}} which is capable of playing a {{{.wav}}} file repeatedly. All the parameters are available as attributes of the object, but should not be changed once the object has been started.
1999 87 Adrian Georgescu
  [[BR]]mixer:[[BR]]
2000 87 Adrian Georgescu
  The {{{AudioMixer}}} this object is connected to.
2001 87 Adrian Georgescu
  [[BR]]filename:[[BR]]
2002 87 Adrian Georgescu
  The full path to the {{{.wav}}} file from which audio data is to be read.
2003 87 Adrian Georgescu
  [[BR]]volume:[[BR]]
2004 87 Adrian Georgescu
  The volume at which the file should be played.
2005 87 Adrian Georgescu
  [[BR]]loop_count:[[BR]]
2006 87 Adrian Georgescu
  The number of times the file should be played, or {{{0}}} for infinity.
2007 87 Adrian Georgescu
  [[BR]]pause_time:[[BR]]
2008 94 Adrian Georgescu
  How many seconds to wait between successive plays of the file. 
2009 87 Adrian Georgescu
  [[BR]]initial_play:[[BR]]
2010 87 Adrian Georgescu
  Whether or not the file to play once the {{{WavePlayer}}} is started, or to wait {{{pause_time}}} seconds before the first play.
2011 94 Adrian Georgescu
2012 87 Adrian Georgescu
 '''start'''(''self'')::
2013 110 Adrian Georgescu
  Start playing the {{{.wav}}} file.
2014 87 Adrian Georgescu
2015 87 Adrian Georgescu
 '''stop'''(''self'')::
2016 87 Adrian Georgescu
  Stop playing the {{{.wav}}} file immediately.
2017 94 Adrian Georgescu
2018 133 Adrian Georgescu
 '''play'''(''self'')::
2019 133 Adrian Georgescu
  Play the {{{.wav}}} file. This method is an alternative to the start/stop methods, it runs on a waitable green thread. One may call {{{play().wait()}}} in order to green-block waiting for the file playback to end.
2020 133 Adrian Georgescu
2021 87 Adrian Georgescu
==== attributes ====
2022 87 Adrian Georgescu
2023 87 Adrian Georgescu
2024 87 Adrian Georgescu
 '''is_active'''::
2025 87 Adrian Georgescu
  A boolean indicating whether or not this {{{WavePlayer}}} is currently playing.
2026 94 Adrian Georgescu
2027 87 Adrian Georgescu
==== notifications ====
2028 87 Adrian Georgescu
2029 87 Adrian Georgescu
2030 87 Adrian Georgescu
 '''WavePlayerDidStart'''::
2031 94 Adrian Georgescu
  This notification is sent when the {{{WavePlayer}}} starts playing the file the first time after the {{{start()}}} method has been called.
2032 87 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
2033 87 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2034 87 Adrian Georgescu
2035 87 Adrian Georgescu
 '''WavePlayerDidEnd'''::
2036 94 Adrian Georgescu
  This notification is sent when the {{{WavePlayer}}} is done playing either as a result of playing the number of times it was told to, or because the {{{stop()}}} method has been called.
2037 87 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
2038 87 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2039 87 Adrian Georgescu
2040 87 Adrian Georgescu
 '''WavePlayerDidFail'''::
2041 87 Adrian Georgescu
  This notification is sent when the {{{WavePlayer}}} is not capable of playing the {{{.wav}}} file.
2042 87 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
2043 87 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2044 87 Adrian Georgescu
  [[BR]]error:[[BR]]
2045 87 Adrian Georgescu
  The exception raised by the {{{WaveFile}}} which identifies the cause for not being able to play the {{{.wav}}} file.
2046 87 Adrian Georgescu
2047 87 Adrian Georgescu
=== WaveRecorder ===
2048 87 Adrian Georgescu
2049 87 Adrian Georgescu
A {{{WaveRecorder}}} is an implementation of {{{IAudioPort}}} is is capable of consuming audio data and writing it to a {{{.wav}}} file. Just like {{{WavePlayer}}}, this object is reusable: once stopped it can be started again, but if the filename attribute is not changed, the previously written file will be overwritten.
2050 94 Adrian Georgescu
2051 87 Adrian Georgescu
==== methods ====
2052 87 Adrian Georgescu
2053 87 Adrian Georgescu
2054 87 Adrian Georgescu
 '''!__init!__'''(''self'', '''mixer''', '''filename''')::
2055 87 Adrian Georgescu
  Instantiate a new {{{WaveRecorder}}}.
2056 87 Adrian Georgescu
  [[BR]]mixer:[[BR]]
2057 94 Adrian Georgescu
  The {{{AudioMixer}}} this {{{WaveRecorder}}} is connected to.
2058 87 Adrian Georgescu
  [[BR]]filename:[[BR]]
2059 87 Adrian Georgescu
  The full path to the {{{.wav}}} file where this object should write the audio data. The file must be writable. The directories up to the file will be created if possible when the {{{start()}}} method is called.
2060 94 Adrian Georgescu
2061 87 Adrian Georgescu
 '''start'''(''self'')::
2062 87 Adrian Georgescu
  Start consuming audio data and writing it to the {{{.wav}}} file. If this object is not part of an {{{AudioBridge}}}, not audio data will be written.
2063 87 Adrian Georgescu
2064 87 Adrian Georgescu
 '''stop'''(''self'')::
2065 87 Adrian Georgescu
  Stop consuming audio data and close the {{{.wav}}} file.
2066 94 Adrian Georgescu
2067 87 Adrian Georgescu
==== attributes ====
2068 87 Adrian Georgescu
2069 87 Adrian Georgescu
2070 73 Luci Stanescu
 '''is_active'''::
2071 86 Adrian Georgescu
  A boolean indicating whether or not this {{{WaveRecorder}}} is currently recording audio data.
2072 73 Luci Stanescu
2073 73 Luci Stanescu
2074 73 Luci Stanescu
== Conference ==
2075 73 Luci Stanescu
2076 73 Luci Stanescu
Conference support is implemented in the {{{sipsimple.conference}}} module. Currently, only audio conferencing is supported.
2077 73 Luci Stanescu
2078 73 Luci Stanescu
=== AudioConference ===
2079 73 Luci Stanescu
2080 73 Luci Stanescu
This class contains the basic implementation for audio conferencing. It acts as a container for {{{AudioStream}}} objects which it will connect in a full mesh, such that all participants can hear all other participants.
2081 94 Adrian Georgescu
2082 73 Luci Stanescu
==== methods ====
2083 73 Luci Stanescu
2084 94 Adrian Georgescu
2085 73 Luci Stanescu
 '''!__init!__'''(''self'')::
2086 73 Luci Stanescu
  Instantiates a new {{{AudioConference}}} which is ready to contain {{{AudioStream}}} objects.
2087 94 Adrian Georgescu
2088 73 Luci Stanescu
 '''add'''(''self'', '''stream''')::
2089 73 Luci Stanescu
  Add the specified {{{AudioStream}}} object to the conference.
2090 94 Adrian Georgescu
2091 73 Luci Stanescu
 '''remove'''(''self'', '''stream''')::
2092 73 Luci Stanescu
  Removes the specified {{{AudioStream}}} object from the conference. Raises a {{{ValueError}}} if the stream is not part of the conference.
2093 94 Adrian Georgescu
2094 73 Luci Stanescu
 '''hold'''(''self'')::
2095 73 Luci Stanescu
  Puts the conference "on hold". This means that the audio device will be disconnected from the conference: all the participants will be able to continue the conference, but the local party will no longer contribute any audio data and will not receive any audio data using the input and output devices respectively. This does not affect the hold state of the streams in any way.
2096 73 Luci Stanescu
2097 73 Luci Stanescu
 '''unhold'''(''self'')::
2098 73 Luci Stanescu
  Removes the conference "from hold". This means that the audio device will be reconnected to the conference: all the participants will start to hear the local party and the local party will start to hear all the participants. This does not affect the hold state of the streams in any way.
2099 94 Adrian Georgescu
2100 73 Luci Stanescu
==== attributes ====
2101 73 Luci Stanescu
2102 94 Adrian Georgescu
2103 73 Luci Stanescu
 '''bridge'''::
2104 73 Luci Stanescu
  An {{{AudioBridge}}} which this conference uses to connect all audio streams. It can be used by the application to play a wav file using a {{{WavePlayer}}} to all the participants or record the whole conference using a {{{WaveRecorder}}}.
2105 94 Adrian Georgescu
2106 1 Adrian Georgescu
 '''on_hold'''::
2107 1 Adrian Georgescu
  A boolean indicating whether or not the conference is "on hold".
2108 119 Luci Stanescu
2109 119 Luci Stanescu
 '''streams'''::
2110 119 Luci Stanescu
  The list of streams which are part of this conference. The application must not manipulate this list in any way.
2111 119 Luci Stanescu
2112 119 Luci Stanescu
2113 119 Luci Stanescu
== XCAP support ==
2114 119 Luci Stanescu
2115 119 Luci Stanescu
The {{{sipsimple.xcap}}} module offers a high level API for managing XCAP resources to other parts of the middleware or to the applications built on top of the middleware. The XCAP resources
2116 119 Luci Stanescu
which can be managed by means of this module are:
2117 119 Luci Stanescu
 * '''contact list''', by means of the {{{resource-lists}}} and {{{rls-services}}} XCAP applications
2118 119 Luci Stanescu
 * '''presence policies''', by means of the {{{org.openmobilealliance.pres-rules}}} or {{{pres-rules}}} XCAP applications
2119 119 Luci Stanescu
 * '''dialoginfo policies''', by means of the {{{org.openxcap.dialog-rules}}} XCAP application
2120 119 Luci Stanescu
 * '''status icon''', by means of the {{{org.openmobilealliance.pres-content}}} XCAP application
2121 119 Luci Stanescu
 * '''offline status''', by means of the {{{pidf-manipulation}}} XCAP application
2122 119 Luci Stanescu
2123 119 Luci Stanescu
The module can work with both OMA or IETF-compliant XCAP servers, preferring the OMA variants of the specification if the server supports them. Not all applications need to be available on the
2124 119 Luci Stanescu
XCAP server, although it is obvious that only those that are will be managed. The central entity for XCAP resource management is the XCAPManager, whose API relies on a series of objects describing
2125 119 Luci Stanescu
the resources stored on the XCAP server.
2126 119 Luci Stanescu
2127 119 Luci Stanescu
=== Contact ===
2128 119 Luci Stanescu
2129 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2130 119 Luci Stanescu
2131 119 Luci Stanescu
A {{{Contact}}} is a URI with additional information stored about it, central to the XCAP contact list management. Information about a contact is stored in the {{{resource-lists}}}, {{{rls-services}}},
2132 119 Luci Stanescu
{{{org.openmobilealliance.pres-rules}}} or {{{pres-rules}}}, and {{{org.openxcap.dialog-rules}}} applications. The URI associated with the contact is considered a unique identifier. Information
2133 119 Luci Stanescu
found in various places about the same URI is aggregated into a single {{{Contact}}} instance. More information about the contact is described within the attributes section.
2134 119 Luci Stanescu
2135 119 Luci Stanescu
==== attributes ====
2136 119 Luci Stanescu
2137 119 Luci Stanescu
 '''name'''::
2138 119 Luci Stanescu
  A human-readable name which can be associated with the contact. This is stored using the {{{display-name}}} standard {{{resource-lists}}} element.
2139 119 Luci Stanescu
2140 119 Luci Stanescu
 '''uri'''::
2141 119 Luci Stanescu
  The uniquely identifying URI.
2142 119 Luci Stanescu
2143 119 Luci Stanescu
 '''group'''::
2144 119 Luci Stanescu
  A human-readable group name which can be used to group contacts together. If this is not {{{None}}}, the contact will be reachable from the {{{oma_buddylist}}} list within the {{{resource-lists}}}
2145 119 Luci Stanescu
  document, as defined by OMA. The group of a contact is the first {{{display-name}}} of an ancestor list which contains the contact information.
2146 119 Luci Stanescu
2147 119 Luci Stanescu
 '''subscribe_to_presence'''::
2148 119 Luci Stanescu
  A boolean flag which indicates whether a subscription to the {{{presence}}} event is desired. If this is {{{True}}}, the contact's URI is referenced from a {{{rls-services}}} service which defines
2149 119 Luci Stanescu
  {{{presence}}} as one of the packages. Thus, a contact with this flag set is guaranteed to be referenced by an RLS service.
2150 119 Luci Stanescu
2151 119 Luci Stanescu
 '''subscribe_to_dialoginfo'''::
2152 119 Luci Stanescu
  A boolean flag which indicates whether a subscription to the {{{dialog}}} event is desired. If this is {{{True}}}, the contact's URI is referenced from a {{{rls-services}}} service which defines
2153 119 Luci Stanescu
  {{{dialog}}} as one of the packages. Thus, a contact with this flag set is guaranteed to be refereneced by an RLS service.
2154 119 Luci Stanescu
2155 119 Luci Stanescu
 '''presence_policies'''::
2156 119 Luci Stanescu
  Either {{{None}}} or a list of {{{PresencePolicy}}} objects which represent {{{org.openmobilealliance.pres-rules}}} or {{{pres-rules}}} rules which reference this contact's URI either directly
2157 119 Luci Stanescu
  (through an identity condition) or indirectly through resource lists (using the OMA external-list common policy extension).
2158 119 Luci Stanescu
2159 119 Luci Stanescu
 '''dialoginfo_policies'''::
2160 119 Luci Stanescu
  Either {{{None}}} or a list of {{{DialoginfoPolicy}}} objects which represent {{{org.openxcap.dialog-rules}}} rules which reference this contact's URI through an identity condition.
2161 119 Luci Stanescu
2162 119 Luci Stanescu
 '''attributes'''::
2163 119 Luci Stanescu
  A dictionary containing additional name, value pairs which the middleware or the application can use to store any information regarding this contact. This is stored through a proprietary AG-Projects
2164 119 Luci Stanescu
  extension to resource-lists.
2165 119 Luci Stanescu
2166 119 Luci Stanescu
==== methods ====
2167 119 Luci Stanescu
2168 119 Luci Stanescu
 '''!__init!__'''(''self'', '''name''', '''uri''', '''group''', '''**attributes''')::
2169 119 Luci Stanescu
  Initializes a new {{{Contact}}} instance. The policies are by default set to {{{None}}} and the {{{subscribe_to_presence}}} and {{{subscribe_to_dialoginfo}}} flags to {{{True}}}.
2170 119 Luci Stanescu
2171 119 Luci Stanescu
2172 119 Luci Stanescu
=== Service ===
2173 119 Luci Stanescu
2174 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2175 119 Luci Stanescu
2176 119 Luci Stanescu
A {{{Service}}} represents a URI managed by a Resource List Server (RLS). Subscriptions to this URI will be handled by the RLS.
2177 119 Luci Stanescu
2178 119 Luci Stanescu
==== attributes ====
2179 119 Luci Stanescu
2180 119 Luci Stanescu
 '''uri'''::
2181 119 Luci Stanescu
  The URI which can be used to access a service provided by the RLS.
2182 119 Luci Stanescu
2183 119 Luci Stanescu
 '''packages'''::
2184 119 Luci Stanescu
  A list of strings containing the SIP events which can be subscribed for to the URI.
2185 119 Luci Stanescu
2186 119 Luci Stanescu
 '''entries'''::
2187 119 Luci Stanescu
  A list of URIs which represent the expanded list of URIs referenced by the service. A subscription to the service's URI for one of packages will result in the RLS subscribing to these URIs.
2188 119 Luci Stanescu
2189 119 Luci Stanescu
==== methods ====
2190 119 Luci Stanescu
2191 119 Luci Stanescu
 '''!__init!__'''(''self'', '''uri''', '''packages''', '''entries'''={{{None}}})::
2192 119 Luci Stanescu
  Initializes a new {{{Service}}} instance.
2193 119 Luci Stanescu
2194 119 Luci Stanescu
2195 119 Luci Stanescu
=== Policy ===
2196 119 Luci Stanescu
2197 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2198 119 Luci Stanescu
2199 119 Luci Stanescu
{{{Policy}}} is the base class for {{{PresencePolicy}}} and {{{DialoginfoPolicy}}}. It describes the attributes common to both.
2200 119 Luci Stanescu
2201 119 Luci Stanescu
==== attributes ====
2202 119 Luci Stanescu
2203 119 Luci Stanescu
 '''id'''::
2204 119 Luci Stanescu
  A string containing the unique identifier of this specific policy. While it should not be considered human readable, OMA does assign specific meanings to some IDs.
2205 119 Luci Stanescu
2206 119 Luci Stanescu
 '''action'''::
2207 119 Luci Stanescu
  A string having one of the values {{{"allow"}}}, {{{"confirm"}}}, {{{"polite-block"}}} or {{{"block"}}}.
2208 119 Luci Stanescu
2209 119 Luci Stanescu
 '''validity'''::
2210 119 Luci Stanescu
  Either {{{None}}}, or a list of {{{datetime}}} instance 2-tuples representing the intervals when this policy applies. Example valid validity list which represents two intervals, each of two hours:
2211 119 Luci Stanescu
  {{{
2212 119 Luci Stanescu
  from datetime import datetime, timedelta
2213 119 Luci Stanescu
  now = datetime.now()
2214 119 Luci Stanescu
  one_hour = timedelta(seconds=3600)
2215 119 Luci Stanescu
  one_day = timedelta(days=1)
2216 119 Luci Stanescu
  validity = [(now-one_hour, now+one_hour), (now+one_day-one_hour, now+one_day+one_hour)]
2217 119 Luci Stanescu
  }}}
2218 119 Luci Stanescu
2219 119 Luci Stanescu
 '''sphere'''::
2220 119 Luci Stanescu
  Either {{{None}}} or a string representing the sphere of presentity when this policy applies.
2221 119 Luci Stanescu
2222 119 Luci Stanescu
 '''multi_identity_conditions'''::
2223 119 Luci Stanescu
  Either {{{None}}} or a list of {{{CatchAllCondition}}} or {{{DomainCondition}}} objects as defined below. This is used to apply this policy to multiple users.
2224 119 Luci Stanescu
2225 119 Luci Stanescu
==== methods ====
2226 119 Luci Stanescu
2227 119 Luci Stanescu
 '''!__init!__'''(''self'', '''id''', '''action''', '''name'''={{{None}}}, '''validity'''={{{None}}}, '''sphere'''={{{None}}}, '''multi_identity_conditions'''={{{None}}})::
2228 119 Luci Stanescu
  Initializes a new {{{Policy}}} instance.
2229 119 Luci Stanescu
2230 119 Luci Stanescu
 '''check_validity'''(''self'', '''timestamp''', '''sphere'''={{{Any}}})::
2231 119 Luci Stanescu
  Returns a boolean indicating whether this policy applies at the specific moment given by timestamp (which must be a {{{datetime}}} instance) in the context of the specific sphere.
2232 119 Luci Stanescu
2233 119 Luci Stanescu
2234 119 Luci Stanescu
=== CatchAllCondition ===
2235 119 Luci Stanescu
2236 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2237 119 Luci Stanescu
2238 119 Luci Stanescu
{{{CatchAllCondition}}} represents a condition which matches any user, but which can have some exceptions.
2239 119 Luci Stanescu
2240 119 Luci Stanescu
==== attributes ====
2241 119 Luci Stanescu
2242 119 Luci Stanescu
 '''exceptions'''::
2243 119 Luci Stanescu
  A list containing {{{DomainException}}} or {{{UserException}}} objects to define when this condition does not apply.
2244 119 Luci Stanescu
2245 119 Luci Stanescu
==== methods ====
2246 119 Luci Stanescu
2247 119 Luci Stanescu
 '''!__init!__'''(''self'', '''exceptions'''={{{None}}})::
2248 119 Luci Stanescu
  Initializes a new {{{CatchAllCondition}}} instance.
2249 119 Luci Stanescu
2250 119 Luci Stanescu
2251 119 Luci Stanescu
=== DomainCondition ===
2252 119 Luci Stanescu
2253 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2254 119 Luci Stanescu
2255 119 Luci Stanescu
{{{DomainCondition}}} represents a condition which matches any user within a specified domain, but which can have some exceptions.
2256 119 Luci Stanescu
2257 119 Luci Stanescu
==== attributes ====
2258 119 Luci Stanescu
2259 119 Luci Stanescu
 '''domain'''::
2260 119 Luci Stanescu
  A string containing the domain for which this condition applies.
2261 119 Luci Stanescu
2262 119 Luci Stanescu
 '''exceptions'''::
2263 119 Luci Stanescu
  A list containing {{{UserEception}}} objects to define when this condition does not apply.
2264 119 Luci Stanescu
2265 119 Luci Stanescu
2266 119 Luci Stanescu
==== methods ====
2267 119 Luci Stanescu
2268 119 Luci Stanescu
 '''!__init!__'''(''self'', '''domain''', '''exceptions'''={{{None}}})::
2269 119 Luci Stanescu
  Initializes a new {{{DomainCondition}}} instance.
2270 119 Luci Stanescu
2271 119 Luci Stanescu
2272 119 Luci Stanescu
=== DomainException ===
2273 119 Luci Stanescu
2274 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2275 119 Luci Stanescu
2276 119 Luci Stanescu
{{{DomainException}}} is used as an exception for a {{{CatchAllCondition}}} which excludes all users within a specified domain.
2277 119 Luci Stanescu
2278 119 Luci Stanescu
==== attributes ====
2279 119 Luci Stanescu
2280 119 Luci Stanescu
 '''domain'''::
2281 119 Luci Stanescu
  A string containing the domain which is to be excluded from the {{{CatchAllCondition}}} containing this object as an exception.
2282 119 Luci Stanescu
2283 119 Luci Stanescu
2284 119 Luci Stanescu
==== methods ====
2285 119 Luci Stanescu
2286 119 Luci Stanescu
 '''!__init!__'''(''self'', '''domain''')::
2287 119 Luci Stanescu
  Initializes a new {{{DomainException}}} instance.
2288 119 Luci Stanescu
2289 119 Luci Stanescu
2290 119 Luci Stanescu
=== UserException ===
2291 119 Luci Stanescu
2292 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2293 119 Luci Stanescu
2294 119 Luci Stanescu
{{{UserException}}} is used as an exception for either a {{{CatchAllCondition}}} or a {{{DomainCondition}}} and excludes a user identified by an URI.
2295 119 Luci Stanescu
2296 119 Luci Stanescu
==== attributes ====
2297 119 Luci Stanescu
2298 119 Luci Stanescu
 '''uri'''::
2299 119 Luci Stanescu
  A string containing the URI which is to be excluded from the {{{CatchAllCondition}}} or {{{DomainCondition}}} containing this object as an exception.
2300 119 Luci Stanescu
2301 119 Luci Stanescu
2302 119 Luci Stanescu
==== methods ====
2303 119 Luci Stanescu
2304 119 Luci Stanescu
 '''!__init!__'''(''self'', '''uri''')::
2305 119 Luci Stanescu
  Initializes a new {{{UserException}}} instance.
2306 119 Luci Stanescu
2307 119 Luci Stanescu
2308 119 Luci Stanescu
=== PresencePolicy ===
2309 119 Luci Stanescu
2310 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2311 119 Luci Stanescu
2312 119 Luci Stanescu
A {{{PresencePolicy}}} represents either a {{{org.openmobilealliance.pres-rules}}} or {{{pres-rules}}} rule. It subclasses {{{Policy}}} and inherits its attributes, but defines additional
2313 119 Luci Stanescu
attributes corresponding to the transformations which can be specified in a rule.
2314 119 Luci Stanescu
2315 119 Luci Stanescu
==== attributes ====
2316 119 Luci Stanescu
2317 119 Luci Stanescu
 All of the following attributes only make sense for a policy having a {{{"allow"}}} action.
2318 119 Luci Stanescu
2319 119 Luci Stanescu
 '''provide_devices'''::
2320 119 Luci Stanescu
  Either {{{sipsimple.util.All}}}, or a list of {{{Class}}}, {{{OccurenceID}}} or {{{DeviceID}}} objects as defined below.
2321 119 Luci Stanescu
2322 119 Luci Stanescu
 '''provide_persons'''::
2323 119 Luci Stanescu
  Either {{{sipsimple.util.All}}}, or a list of {{{Class}}} or {{{OccurenceID}}} objects as defined below.
2324 119 Luci Stanescu
2325 119 Luci Stanescu
 '''provide_services'''::
2326 119 Luci Stanescu
  Either {{{sipsimple.util.All}}}, or a list of {{{Class}}}, {{{OccurenceID}}}, {{{ServiceURI}}} or {{{ServiceURIScheme}}} objects as defined below.
2327 119 Luci Stanescu
2328 119 Luci Stanescu
 '''provide_activities'''::
2329 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2330 119 Luci Stanescu
2331 119 Luci Stanescu
 '''provide_class'''::
2332 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2333 119 Luci Stanescu
2334 119 Luci Stanescu
 '''provide_device_id'''::
2335 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2336 119 Luci Stanescu
2337 119 Luci Stanescu
 '''provide_mood'''::
2338 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2339 119 Luci Stanescu
2340 119 Luci Stanescu
 '''provide_place_is'''::
2341 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2342 119 Luci Stanescu
2343 119 Luci Stanescu
 '''provide_place_type'''::
2344 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2345 119 Luci Stanescu
2346 119 Luci Stanescu
 '''provide_privacy'''::
2347 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2348 119 Luci Stanescu
2349 119 Luci Stanescu
 '''provide_relationship'''::
2350 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2351 119 Luci Stanescu
2352 119 Luci Stanescu
 '''provide_status_icon'''::
2353 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2354 119 Luci Stanescu
2355 119 Luci Stanescu
 '''provide_sphere'''::
2356 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2357 119 Luci Stanescu
2358 119 Luci Stanescu
 '''provide_time_offset'''::
2359 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2360 119 Luci Stanescu
2361 119 Luci Stanescu
 '''provide_user_input'''::
2362 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or one of the strings {{{"false"}}}, {{{"bare"}}}, {{{"thresholds"}}}, {{{"full"}}}.
2363 119 Luci Stanescu
2364 119 Luci Stanescu
 '''provide_unknown_attributes'''::
2365 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean. The name of the attribute is not a typo, although it maps to the transformation named {{{provide-unknown-attribute}}} (singular form).
2366 119 Luci Stanescu
2367 119 Luci Stanescu
 '''provide_all_attributes'''::
2368 119 Luci Stanescu
  Either {{{None}}} (if the transformation is not be specified) or a boolean.
2369 119 Luci Stanescu
2370 119 Luci Stanescu
==== methods ====
2371 119 Luci Stanescu
2372 119 Luci Stanescu
 '''!__init!__'''(''self'', '''id''', '''action''', '''name'''={{{None}}}, '''validity'''={{{None}}}, '''sphere'''={{{None}}}, '''multi_identity_conditions'''={{{None}}})::
2373 119 Luci Stanescu
  Initializes a new {{{PresencePolicy}}} instance. The {{{provide_devices}}}, {{{provide_persons}}} and {{{provide_services}}} are initialized to {{{sipsimple.util.All}}}, {{{provide_all_attributes}}} to {{{True}}} and the rest to {{{None}}}.
2374 119 Luci Stanescu
2375 119 Luci Stanescu
2376 119 Luci Stanescu
=== DialoginfoPolicy ===
2377 119 Luci Stanescu
2378 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2379 119 Luci Stanescu
2380 119 Luci Stanescu
A {{{DialoginfoPolicy}}} represents a {{{org.openxcap.dialog-rules}}} rule. It subclasses {{{Policy}}} and inherits all of its attributes. It does not add any other attributes or methods and thus
2381 119 Luci Stanescu
has an identical API.
2382 119 Luci Stanescu
2383 119 Luci Stanescu
2384 119 Luci Stanescu
=== Icon ===
2385 119 Luci Stanescu
2386 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2387 119 Luci Stanescu
2388 119 Luci Stanescu
An {{{Icon}}} instance represents a status icon stored using the {{{org.openmobilealliance.pres-content}}} application.
2389 119 Luci Stanescu
2390 119 Luci Stanescu
==== attributes ====
2391 119 Luci Stanescu
2392 119 Luci Stanescu
 '''data'''::
2393 119 Luci Stanescu
  The binary data of the image, as  a string.
2394 119 Luci Stanescu
2395 119 Luci Stanescu
 '''mime_type'''::
2396 119 Luci Stanescu
  The MIME type of the image, one of {{{image/jpeg}}}, {{{image/gif}}} or {{{image/png}}}.
2397 119 Luci Stanescu
2398 119 Luci Stanescu
 '''description'''::
2399 119 Luci Stanescu
  An optional description of the icon.
2400 119 Luci Stanescu
2401 119 Luci Stanescu
 '''location'''::
2402 119 Luci Stanescu
  An HTTP(S) URI which can be used by other users to download the status icon of the local user. If the XCAP server returns the proprietary X-AGP-Alternative-Location header in its GET and PUT
2403 119 Luci Stanescu
  responses, that is used otherwise the XCAP URI of the icon is used.
2404 119 Luci Stanescu
2405 119 Luci Stanescu
==== methods ====
2406 119 Luci Stanescu
2407 119 Luci Stanescu
 '''!__init!__'''(''self'', '''data''', '''mime_type''', '''description'''={{{None}}}, '''location'''={{{None}}})::
2408 119 Luci Stanescu
  Initializes a new {{{Icon}}} instance.
2409 119 Luci Stanescu
2410 119 Luci Stanescu
2411 119 Luci Stanescu
=== OfflineStatus ===
2412 119 Luci Stanescu
2413 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2414 119 Luci Stanescu
2415 119 Luci Stanescu
An {{{OfflineStatus}}} instance represents data stored using the {{{pidf-manipulation}}} application.
2416 119 Luci Stanescu
2417 119 Luci Stanescu
==== attributes ====
2418 119 Luci Stanescu
2419 119 Luci Stanescu
 '''activity'''::
2420 119 Luci Stanescu
  A string representing an activity within a {{{person}}} element.
2421 119 Luci Stanescu
2422 119 Luci Stanescu
 '''note'''::
2423 119 Luci Stanescu
  A string stored as a note within a {{{person}}} element.
2424 119 Luci Stanescu
2425 119 Luci Stanescu
==== methods ====
2426 119 Luci Stanescu
2427 119 Luci Stanescu
 '''!__init!__'''(''self'', '''activity'''={{{None}}}, '''note'''={{{Note}}})::
2428 119 Luci Stanescu
  Initializes a new {{{OfflineStatus}}} instance.
2429 119 Luci Stanescu
2430 119 Luci Stanescu
2431 119 Luci Stanescu
=== XCAPManager ===
2432 119 Luci Stanescu
2433 119 Luci Stanescu
Implemented in [browser:sipsimple/xcap/__init__.py]
2434 119 Luci Stanescu
2435 143 Adrian Georgescu
The XCAPManager is the central entity used to manage resource via the XCAP protocol. It uses a storage factory provided by {{{SIPApplication}}} through the {{{Storage API}}}. It has state machine as described in the following diagram:
2436 119 Luci Stanescu
2437 119 Luci Stanescu
[[Image(xcap-manager-state.png, align=center)]]
2438 119 Luci Stanescu
2439 143 Adrian Georgescu
The {{{load}}} method needs to be called just once in order to load the data from the cache. Once this is done, the {{{start}}} and {{{stop}}} methods can be called as needed. Initially in the {{{stopped}}} state,
2440 119 Luci Stanescu
the start method will result in a transition to the {{{initializing}}} state. While in the {{{initializing}}} state, the XCAP manager will try to connect to the XCAP server and retrieve the
2441 119 Luci Stanescu
capabilities ({{{xcap-caps}}} application). It will then initiate a SUBSCRIBE for the {{{xcap-diff}}} event (if configured) and transition to the {{{fetching}}} state. In the {{{fetching}}} state, it
2442 119 Luci Stanescu
will try retrieve all the documents from the XCAP server, also specifying the ETag of the last known version. If none of the documents changed and this is not the first fetch, it transitions to the
2443 119 Luci Stanescu
{{{insync}}} state. Otherwise, it inserts a {{{normalize}}} operation at the beginning of the journal (described below) and transitions to the {{{updating}}} state. In the {{{updating}}} state, it
2444 119 Luci Stanescu
applies the operations from the journal which were not applied yet on the currently known documents and tries to push the documents, specifying the Etag of the last known version. If an operation
2445 119 Luci Stanescu
fails due to a document having been modified, it marks all the operations in the journal as not being applied and transitions to the {{{fetching}}} state; if any other error occurs, the update is
2446 119 Luci Stanescu
retried periodically. If the update succeeds, data is extracted from the documents and the {{{XCAPManagerDidReloadData}}} notification is sent. The XCAPManager then transitions to the {{{insync}}}
2447 119 Luci Stanescu
state. A call to the {{{stop}}} method will result in a transition to the {{{stopping}}} state, termination of any existing SUBSCRIBE dialog and a transition to the {{{stopped}}} state.
2448 119 Luci Stanescu
2449 119 Luci Stanescu
Modifications to the settings which control the XCAPManager can result in either a transition to the {{{initializing}}} state or the termination of any previous SUBSCRIBE dialog and creation of a new
2450 126 Adrian Georgescu
one.
2451 119 Luci Stanescu
2452 119 Luci Stanescu
The subscription to the {{{xcap-diff}}} event allows the XCAPManager to be notified when the documents it manages are modified remotely. If the subscription fails, a fetch of all the documents is
2453 119 Luci Stanescu
tried and the subscription is retried in some time. This allows the XCAPManager to reload the documents when they are modified remotely even if {{{xcap-diff}}} event is not supported by the provider. If subscription for {{{xcap-diff}}} event fails, a fetch of all the documents will be tried every 2 minutes.
2454 119 Luci Stanescu
2455 119 Luci Stanescu
The XCAPManager keeps the documents as they are stored on the XCAP server along with their ETags in an on-disk cache. All operations are made using the conditional {{{If-Match}}} and
2456 119 Luci Stanescu
{{{If-None-Match}}} headers such that remote modifications the XCAPManager does not know about are not overwritten and bandwidth and processing power are not wasted by GET operations when a document
2457 119 Luci Stanescu
is not modified.
2458 119 Luci Stanescu
2459 119 Luci Stanescu
Operations which the XCAPManager can be asked to apply to modify the documents are kept in a journal. This journal is saved to disk, such that operations which cannot be applied when requested due
2460 119 Luci Stanescu
to server problems or lack of connectivity are retried even after application restarts. In addition, the high-level defined operations and the journal allow the modifications to be applied even if the
2461 119 Luci Stanescu
document stored on the XCAP server are modified. Put differently, operations do depend on a specific version of the documents and the XCAPManager will try to apply them irrespective of the format
2462 119 Luci Stanescu
of the document.
2463 119 Luci Stanescu
2464 126 Adrian Georgescu
==== configuration ====
2465 119 Luci Stanescu
2466 119 Luci Stanescu
 '''Account.id''', '''Account.auth.username''', '''Account.auth.password'''::
2467 119 Luci Stanescu
  These are used both for the {{{xcap-diff}}} subscription and the XCAP server connection. 
2468 119 Luci Stanescu
2469 119 Luci Stanescu
 '''Account.sip.subscribe_interval'''::
2470 119 Luci Stanescu
  This controls the Expires header used for the subscription, although a 423 response from the server can result in a larger Expires value being used.
2471 119 Luci Stanescu
2472 119 Luci Stanescu
 '''Account.xcap.xcap_root'''::
2473 119 Luci Stanescu
  This specifies the XCAP root used for contacting the XCAP server and managing the resources. If this setting is {{{None}}}, a TXT DNS query is made for the {{{xcap}}} subdomain of the SIP account's
2474 119 Luci Stanescu
  domain. The result is interpreted as being an XCAP root. Example record for account alice@example.org:
2475 119 Luci Stanescu
  {{{
2476 119 Luci Stanescu
  xcap.example.org.    IN  TXT     "https://xcap.example.org/xcap-root"
2477 119 Luci Stanescu
  }}}
2478 119 Luci Stanescu
2479 119 Luci Stanescu
 '''SIPSimpleSettings.sip.transport_list'''::
2480 119 Luci Stanescu
  This controls the transports which can be used for the subscription.
2481 119 Luci Stanescu
2482 119 Luci Stanescu
==== methods ====
2483 119 Luci Stanescu
2484 119 Luci Stanescu
 '''!__init!__'''(''self'', '''account''')::
2485 142 Adrian Georgescu
  Initializes an XCAPManager for the specified account.
2486 119 Luci Stanescu
2487 142 Adrian Georgescu
 '''load'''(''self'')::
2488 142 Adrian Georgescu
  Allows the XCAPManager to the load its internal data from cache.
2489 119 Luci Stanescu
2490 119 Luci Stanescu
 '''start'''(''self'')::
2491 119 Luci Stanescu
  Starts the XCAPManager. This will result in the subscription being started, the XCAP server being contacted and any operations in the journal being applied. This method must be called in a green
2492 119 Luci Stanescu
  thread.
2493 119 Luci Stanescu
2494 119 Luci Stanescu
 '''stop'''(''self'')::
2495 119 Luci Stanescu
  Stops the XCAPManager from performing any tasks. Waits until the {{{xcap-diff}}} subscription, if any, is terminated. This method must be called in a green thread.
2496 119 Luci Stanescu
2497 119 Luci Stanescu
 '''start_transaction'''(''self'')::
2498 119 Luci Stanescu
  This allows multiple operations to be queued and not applied immediately. All operations queued after a call to this method will not be applied until the {{{commit_transaction}}} method is called.
2499 119 Luci Stanescu
  This does not have the same meaning as a relational database transaction, since there is no {{{rollback}}} operation.
2500 119 Luci Stanescu
2501 119 Luci Stanescu
 '''commit_transaction'''(''self'')::
2502 119 Luci Stanescu
  Applies the modifications queued after a call to {{{start_transaction}}}. This method needs to be called the exact same number of times the {{{start_transaction}}} method was called. Does not have
2503 119 Luci Stanescu
  any effect if {{{start_transaction}}} was not previously called.
2504 119 Luci Stanescu
2505 119 Luci Stanescu
 The following methods results in XCAP operations being queued on the journal:
2506 119 Luci Stanescu
2507 119 Luci Stanescu
 '''add_group'''(''self'', '''group''')::
2508 119 Luci Stanescu
  Add a contact group with the specified name.
2509 119 Luci Stanescu
2510 119 Luci Stanescu
 '''rename_group'''(''self'', '''old_name''', '''new_name''')::
2511 119 Luci Stanescu
  Change the name of the contact group {{{old_name}}} to {{{new_name}}}. If such a contact group does not exist, the operation does not do anything.
2512 119 Luci Stanescu
2513 119 Luci Stanescu
 '''remove_group'''(''self'', '''group''')::
2514 119 Luci Stanescu
  Remove the contact group (and any contacts contained in it) with the specified name. If such a contact group does not exist, the operation does not do anything.
2515 119 Luci Stanescu
2516 119 Luci Stanescu
 '''add_contact'''(''self'', '''contact''')::
2517 119 Luci Stanescu
  Adds a new contact, described by a {{{Contact}}} object. If the contact with the same URI and a not-{{{None}}} group already exists, the operation does not do anything. Otherwise, the contact
2518 119 Luci Stanescu
  is added and any reference to the contact's URI is overwritten. Requests to add a contact to some OMA reserved presence policies ({{{wp_prs_unlisted}}}, {{{wp_prs_allow_unlisted}}},
2519 119 Luci Stanescu
  {{{wp_prs_block_anonymous}}}, {{{wp_prs_allow_own}}}) is ignored.
2520 119 Luci Stanescu
2521 119 Luci Stanescu
 '''update_contact'''(''self'', '''contact''', '''**attributes''')::
2522 119 Luci Stanescu
  Modifies a contact's properties. The keywords can be any of the {{{Contact}}} attributes, with the same meaning. The URI of the contact to be modified is taken from the first argument. If such
2523 119 Luci Stanescu
  a URI does not exist, it is added. Requests to add a contact to some OMA reserved presence policies ({{{wp_prs_unlisted}}}, {{{wp_prs_allow_unlisted}}}, {{{wp_prs_block_anonymous}}},
2524 119 Luci Stanescu
  {{{wp_prs_allow_own}}}) is ignored. The URI of a contact can be changed by specified the keyword argument {{{uri}}} with the new value.
2525 119 Luci Stanescu
2526 119 Luci Stanescu
 '''remove_contact'''(''self'', '''contact''')::
2527 119 Luci Stanescu
  Removes any reference to the contact's URI from all documents. This also means that the operation will make sure there are no policies which match the contact's URI.
2528 119 Luci Stanescu
2529 119 Luci Stanescu
 '''add_presence_policy'''(''self'', '''policy''')::
2530 119 Luci Stanescu
  Adds a new presence policy, described by a {{{PresencePolicy}}} object. If the id is specified and a policy with the same id exists, the operation does not do anything. Otherwise, if the id is not
2531 119 Luci Stanescu
  specified, one will be automatically generated (recommended). If the id is specified, but it is incompatible with the description of the policy (for example if an OMA defined id is used and there
2532 119 Luci Stanescu
  are some multi_identity_conditions), a new one will be automatically generated.
2533 119 Luci Stanescu
2534 119 Luci Stanescu
 '''update_presence_policy'''(''self'', '''policy''', '''**attributes''')::
2535 119 Luci Stanescu
  Modifies a presence policy's properties. The keywords can be any of the {{{PresencePolicy}}} attributes, with the same meaning. The id of the policy to be modified is taken from the first argument.
2536 119 Luci Stanescu
  If such a policy does not exist and there is sufficient information about the policy, it is added. If the policy to be modified uses the OMA extension to reference resource-lists and
2537 119 Luci Stanescu
  multi_identity_conditions are specified in the keywords, a new policy whose properties are the combination of the existing policy and the keywords is created.
2538 119 Luci Stanescu
2539 119 Luci Stanescu
 '''remove_presence_policy'''(''self'', '''policy''')::
2540 119 Luci Stanescu
  Removes the presence policy identified by the id attribute of the {{{PresencePolicy}}} object specified. If the id is {{{None}}} or does not exist in the document, the operation does not do
2541 119 Luci Stanescu
  anything. Some standard OMA policies ({{{wp_prs_unlisted}}}, {{{wp_prs_allow_unlisted}}}, {{{wp_prs_block_anonymous}}}, {{{wp_prs_allow_own}}}, {{{wp_prs_grantedcontacts}}},
2542 119 Luci Stanescu
  {{{wp_prs_blockedcontacts}}}) cannot be removed.
2543 119 Luci Stanescu
2544 119 Luci Stanescu
 '''add_dialoginfo_policy'''(''self'', '''policy''')::
2545 119 Luci Stanescu
  Adds a new dialoginfo policy, described by a {{{DialoginfoPolicy}}} object. If the id is specified and a policy with the same id exists, the operation does not do anything. Otherwise, if the id is
2546 119 Luci Stanescu
  not specified, one will be automatically generated (recommended).
2547 119 Luci Stanescu
2548 119 Luci Stanescu
 '''update_dialoginfo_policy'''(''self'', '''policy''', '''**attributes''')::
2549 119 Luci Stanescu
  Modifies a dialoginfo policy's properties. The keywords can be any of the {{{DialoginfoPolicy}}} attributes, with the same meanining. The id of the policy to be modified is taken from the first
2550 119 Luci Stanescu
  argument. If such a policy does not exist and there is sufficient information about the policy, it is added.
2551 119 Luci Stanescu
2552 119 Luci Stanescu
 '''remove_dialoginfo_policy'''(''self'', '''policy''')::
2553 119 Luci Stanescu
  Removes the dialoginfo policy identified by the id attribute of the {{{DialoginfoPolicy}}} object specified. If the id is {{{None}}} or does not exist in the document, the operation does not do
2554 119 Luci Stanescu
  anything.
2555 119 Luci Stanescu
2556 119 Luci Stanescu
 '''set_status_icon'''(''self'', '''icon''')::
2557 119 Luci Stanescu
  Sets the status icon using the information from the {{{Icon}}} object specified. The {{{location}}} attribute is ignored. The MIME type must be one of {{{image/gif}}}, {{{image/png}}} or
2558 119 Luci Stanescu
  {{{image/jpeg}}}. If the argument is {{{None}}}, the status icon is deleted.
2559 119 Luci Stanescu
2560 119 Luci Stanescu
 '''set_offline_status'''(''self'', '''status''')::
2561 119 Luci Stanescu
  Sets the offline status using the information from the {{{OfflineStatus}}} object specified. If the argument is {{{None}}}, the offline status document is deleted.
2562 119 Luci Stanescu
2563 119 Luci Stanescu
==== notifications ====
2564 119 Luci Stanescu
2565 119 Luci Stanescu
 '''XCAPManagerWillStart'''::
2566 119 Luci Stanescu
  This notification is sent just after calling the {{{start}}} method.
2567 119 Luci Stanescu
  [[BR]]timestamp:[[BR]]
2568 119 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2569 119 Luci Stanescu
2570 119 Luci Stanescu
 '''XCAPManagerDidStart'''::
2571 119 Luci Stanescu
  This notification is sent after the XCAPManager has started doing its tasks (contacting the XCAP server, subscribing to {{{xcap-diff}}} event). This notification does not mean that
2572 119 Luci Stanescu
  any of these operations were successful, as the XCAPManager will retry them continuously should they fail.
2573 119 Luci Stanescu
  [[BR]]timestamp:[[BR]]
2574 119 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2575 119 Luci Stanescu
2576 119 Luci Stanescu
 '''XCAPManagerWillEnd'''::
2577 119 Luci Stanescu
  This notification is sent just after calling the {{{stop}}} method.
2578 119 Luci Stanescu
  [[BR]]timestamp:[[BR]]
2579 119 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2580 119 Luci Stanescu
2581 119 Luci Stanescu
 '''XCAPManagerDidEnd'''::
2582 119 Luci Stanescu
  This notification is sent when the XCAPManager has stopped performing any tasks. This also means that any active {{{xcap-diff}}} subscription has been terminated.
2583 119 Luci Stanescu
  [[BR]]timestamp:[[BR]]
2584 119 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2585 119 Luci Stanescu
2586 119 Luci Stanescu
 '''XCAPManagerDidDiscoverServerCapabilities'''::
2587 119 Luci Stanescu
  This notification is sent when the XCAPManager contacts an XCAP server for the first time or after the connection is reset due to configuration changes. The data of the notification contains
2588 119 Luci Stanescu
  information about the server's capabilities (obtained using the {{{xcap-caps}}} application).
2589 119 Luci Stanescu
  [[BR]]contactlist_supported:[[BR]]
2590 119 Luci Stanescu
  A boolean indicating the support of documents needed for contact management ({{{resource-lists}}} and {{{rls-services}}}).
2591 119 Luci Stanescu
  [[BR]]presence_policies_supported:[[BR]]
2592 119 Luci Stanescu
  A boolean indicating the support of documents needed for presence policy management ({{{org.openmobilealliance.pres-rules}}} or {{{pres-rules}}}).
2593 119 Luci Stanescu
  [[BR]]dialoginfo_policies_supported:[[BR]]
2594 119 Luci Stanescu
  A boolean indicating the support of documents needed for dialoginfo policy management ({{{org.openxcap.dialog-rules}}}).
2595 119 Luci Stanescu
  [[BR]]status_icon_supported:[[BR]]
2596 119 Luci Stanescu
  A boolean indicating the support of documents needed for status icon management ({{{org.openmobilealliance.pres-content}}}).
2597 119 Luci Stanescu
  [[BR]]offline_status_supported:[[BR]]
2598 119 Luci Stanescu
  A boolean indicating the support of documents needed for offline status management ({{{pidf-manipulation}}}).
2599 119 Luci Stanescu
  [[BR]]timestamp:[[BR]]
2600 119 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2601 119 Luci Stanescu
2602 119 Luci Stanescu
 '''XCAPManagerDidReloadData'''::
2603 119 Luci Stanescu
  This notification is sent when the XCAPManager synchronizes with the XCAP server. The data of the notification contains objects representing the data as it is stored on the XCAP server.
2604 119 Luci Stanescu
  [[BR]]contacts:[[BR]]
2605 119 Luci Stanescu
  A list of {{{Contact}}} objects.
2606 119 Luci Stanescu
  [[BR]]groups:[[BR]]
2607 119 Luci Stanescu
  A list of strings.
2608 119 Luci Stanescu
  [[BR]]services:[[BR]]
2609 119 Luci Stanescu
  A list of {{{Service}}} objects.
2610 119 Luci Stanescu
  [[BR]]presence_policies:[[BR]]
2611 119 Luci Stanescu
  A list of {{{PresencePolicy}}} objects.
2612 119 Luci Stanescu
  [[BR]]dialoginfo_policies:[[BR]]
2613 119 Luci Stanescu
  A list of {{{DialoginfoPolicy}}} objects.
2614 119 Luci Stanescu
  [[BR]]status_icon:[[BR]]
2615 119 Luci Stanescu
  A {{{StatusIcon}}} object if one is stored, {{{None}}} otherwise.
2616 119 Luci Stanescu
  [[BR]]offline_status:[[BR]]
2617 119 Luci Stanescu
  A {{{OfflineStatus}}} object if offline status information is stored, {{{None}}} otherwise.
2618 119 Luci Stanescu
  [[BR]]timestamp:[[BR]]
2619 119 Luci Stanescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.
2620 119 Luci Stanescu
2621 119 Luci Stanescu
 '''XCAPManagerDidChangeState'''::
2622 119 Luci Stanescu
  This notification is sent when the XCAPManager transitions from one state to another.
2623 119 Luci Stanescu
  [[BR]]prev_state:[[BR]]
2624 119 Luci Stanescu
  The old state of the XCAPManager, a string.
2625 119 Luci Stanescu
  [[BR]]state:[[BR]]
2626 1 Adrian Georgescu
  The new state of the XCAPManager, a string.
2627 1 Adrian Georgescu
  [[BR]]timestamp:[[BR]]
2628 1 Adrian Georgescu
  A {{{datetime.datetime}}} object indicating when the notification was sent.